hermetechnics / cellulare

A journey into the Network
GNU General Public License v3.0
0 stars 0 forks source link

Schedule base rhythm client-side #11

Closed jakubfiala closed 4 years ago

imunita21 commented 4 years ago

pocuj, po tom refaktore sa moc nevyznam v tom js syntaxte, vedel by si tam pls hodit do mainu background thread ktory spusti tu drum funkciu vo while(true) loope? Nechcem ti tam zaserkat ten kod volakym mojim dirty fixom (sorry that i suck so bad in js)

len volaco ako:

function drumBeat(){ while(true){ const sample = chooseRandomlyFrom(kicks); await audioEngine.playSample(sample, playbackConfig.STEPS_PER_SECOND + randomSwing()); } }

jakubfiala commented 4 years ago

oukej, hodim to tam. v JS vacsinou nerobime while(true) loopy (teda nie v samotnej web appke), ale nieco vymyslim :)

jakubfiala commented 4 years ago

@imunita21 pozri si kod okolo tejto lajny - vyzera to trochu komplikovane, ale v podstate raz za sekundu vzdy schedulujeme dalsie beaty, dokym najneskorsi schedulovany beat nie je viac ako sekundu po current time :)

na tom istom mieste mozme schedulnut aj ine veci ak chceme, napr. vieme tie extra zvuky prichadzajuce cez socket zladit rytmicky so zakladnym beatom.