def play_patches(wait=0.500, patch_total = 100, **kwargs): once = True patch_count = 0 while True: for i in range(24): patch = patch_count % patch_total patch_count = patch_count + 1 note_on(osc=i % ALLES_OSCS, note=i+50, wave=FM, patch=patch, **kwargs) time.sleep(wait) note_off(osc=i % ALLES_OSCS)
def polyphony(max_voices=ALLES_OSCS,**kwargs): note = 0 oscs = [] for i in range(int(max_voices/2)): oscs.append(int(i)) oscs.append(int(i+(ALLES_OSCS/2))) print(str(oscs)) while(1): osc = oscs[note % max_voices] print("osc %d note %d filter %f " % (osc, 30+note, note*50)) note_on(osc=osc, **kwargs, patch=note, filter_type=FILTER_NONE, filter_freq=note*50, note=30+(note), client = -1) time.sleep(0.5) note =(note + 1) % 64
def complex(speed=0.250, loops=-1, **kwargs): while(loops != 0): # -1 means forever for i in [0,2,4,5, 0, 4, 0, 2]: note_on(osc=0, wave=FM, vel=0.8, note=50+i, patch=15, **kwargs) time.sleep(speed) note_on(osc=1, wave=FM, vel=0.6, note=50+i, patch=8, **kwargs) time.sleep(speed) note_on(osc=2, wave=SINE, vel=0.5, note=62+i, patch=2, **kwargs) time.sleep(speed) note_on(osc=2, wave=SINE, vel=1, freq = 20, **kwargs) time.sleep(speed) loops = loops - 1
def sweep(speed=0.100, res=0.5, loops = -1): end = 2000 cur = 0 while(loops != 0): for i in [0, 1, 4, 5, 1, 3, 4, 5]: cur = (cur + 100) % end note_on(osc=0,filter_type=FILTER_LPF, filter_freq=cur+250, resonance=res, wave=PULSE, note=50+i, duty=0.50) note_on(osc=1,filter_type=FILTER_LPF, filter_freq=cur+500, resonance=res, wave=PULSE, note=50+12+i, duty=0.25) note_on(osc=2,filter_type=FILTER_LPF, filter_freq=cur, resonance=res, wave=PULSE, note=50+6+i, duty=0.90) time.sleep(speed)
def test(): while True: for wave in [SINE, SAW, PULSE, TRIANGLE, FM, NOISE]: for i in range(12): note_on(osc=0, wave=wave, note=40+i, patch=i) time.sleep(0.5)
def c_major(octave=2,wave=SINE, **kwargs): note_on(osc=0, freq=220.5*octave, wave=wave, **kwargs) note_on(osc=1, freq=138.5*octave, wave=wave, **kwargs) note_on(osc=2, freq=164.5*octave, wave=wave, **kwargs)
def drums(bpm=120, loops=-1, **kwargs): preset(5, osc=0, **kwargs) # sine bass drum preset(8, osc=3, **kwargs) # sample hat preset(9, osc=4, **kwargs) # sample cow preset(10, osc=5, **kwargs) # sample hi cow preset(11, osc=2, **kwargs) # sample snare preset(12, osc=7, **kwargs) # FM bass [bass, snare, hat, cow, hicow, silent] = [1, 2, 4, 8, 16, 32] pattern = [bass+hat, hat+hicow, bass+hat+snare, hat+cow, hat, hat+bass, snare+hat, hat] bassline = [50, 0, 0, 0, 50, 52, 51, 0] while (loops != 0): loops = loops - 1 for i,x in enumerate(pattern): if(x & bass): note_on(osc=0, note=50, vel=1.5, **kwargs) if(x & snare): note_on(osc=2, vel=1.5) if(x & hat): note_on(osc=3, vel=1) if(x & cow): note_on(osc=4, vel=1) if(x & hicow): note_on(osc=5, vel=1) if(bassline[i]>0): note_on(osc=7, vel=0.25, note=bassline[i], **kwargs) else: note_off(osc=7, **kwargs) time.sleep(1.0/(bpm*2/60))