def play(voice_id): volume = P(voice_id, 'volume', 100.0) volume = volume / 100.0 # TODO: move into param filter volume = volume * 0.65 length = P(voice_id, 'length', 40) env = False wii = False # wii = True speed = False numcycles = dsp.randint(1, 200) # Make breakpoint env with 2-10 vals between 0.1 and 1.0 curve_a = dsp.breakpoint([1.0] + [dsp.rand(0.1, 1.0) for r in range(dsp.randint(2, 10))] + [0], numcycles) # Make wavetable with single cycle from given wave types curve_types = ['vary', 'phasor', 'sine', 'cos', 'impulse'] curve_b = dsp.wavetable(dsp.randchoose(curve_types), numcycles) # Make pan curve - always cosine pan = dsp.breakpoint([ dsp.rand() for i in range(dsp.randint(5, 50)) ], numcycles) amps = dsp.breakpoint([ dsp.rand(0.1, 0.75) for i in range(dsp.randint(5, 30)) ], numcycles) # Multiply breakpoint curve with simple wavetable wtable = [ curve_a[i] * curve_b[i] for i in range(numcycles) ] # Scale to max frequency wtable = [ (f * 20000) + length for f in wtable ] # Possible osc wavetypes wtypes = ['sine2pi'] # wtypes = ['tri', 'sine2pi', 'impulse'] # wtypes = ['impulse', 'tri', 'cos', 'sine2pi', 'vary'] if wii is True: out = [ dsp.pan(dsp.cycle(wtable[i], dsp.randchoose(wtypes)), pan[i]) for i in range(numcycles) ] else: wtype = dsp.randchoose(wtypes) out = [ dsp.pan(dsp.cycle(wtable[i], wtype), pan[i]) for i in range(numcycles) ] out = [ dsp.amp(oo, amps[i]) for i, oo in enumerate(out) ] out = dsp.amp(''.join(out), volume) if speed != False and speed > 0.0: out = dsp.transpose(out, speed) if env != False: out = dsp.env(out, env) return out
def play(params={}): volume = params.get('volume', 100.0) volume = volume / 100.0 # TODO: move into param filter volume = volume * 0.25 length = params.get('length', 40) env = params.get('envelope', False) wii = params.get('wii', False) speed = params.get('speed', False) numcycles = dsp.randint(10, 524) # Make breakpoint env with 2-10 vals between 0.1 and 1.0 curve_a = dsp.breakpoint([1.0] + [dsp.rand(0.1, 1.0) for r in range(dsp.randint(2, 10))] + [0], numcycles) # Make wavetable with single cycle from given wave types curve_types = ['vary', 'phasor', 'sine', 'cos', 'impulse'] curve_b = dsp.wavetable(dsp.randchoose(curve_types), numcycles) # Make pan curve - always cosine pan = dsp.wavetable('cos', numcycles) # Multiply breakpoint curve with simple wavetable wtable = [ curve_a[i] * curve_b[i] for i in range(numcycles) ] # Scale to max frequency wtable = [ (f * 19000) + length for f in wtable ] # Possible osc wavetypes wtypes = ['impulse', 'tri', 'cos', 'sine2pi', 'vary'] if wii is True: out = [ dsp.pan(dsp.cycle(wtable[i], dsp.randchoose(wtypes)), pan[i]) for i in range(numcycles) ] else: wtype = dsp.randchoose(wtypes) out = [ dsp.pan(dsp.cycle(wtable[i], wtype), pan[i]) for i in range(numcycles) ] out = dsp.amp(''.join(out), volume) if speed != False and speed > 0.0: out = dsp.transpose(out, speed) if env != False: out = dsp.env(out, env) return out
def dosweep(wtype, start_freq, freq_range, numgrains, cycle_type): out = '' pitch_curve = dsp.curve(wtype, numgrains, math.pi * 0.5, freq_range, 0.0, start_freq) pan_curve = dsp.curve(1, numgrains, math.pi * dsp.rand(1, 80)) for i, freq in enumerate(pitch_curve): grain = dsp.cycle(freq, cycle_type, 0.01) grain = dsp.pan(grain, pan_curve[i]) out += grain return out
def bln(length, low=3000.0, high=7100.0, wform="sine2pi"): wforms = ["tri", "sine2pi", "impulse", "cos2pi"] outlen = 0 cycles = "" while outlen < length: cycle = dsp.cycle(dsp.rand(low, high), dsp.randchoose(wforms)) outlen += len(cycle) cycles += cycle return cycles
def bln(length, low=3000.0, high=7100.0, wform='sine2pi'): """ Time-domain band-limited noise generator """ outlen = 0 cycles = '' while outlen < length: cycle = dsp.cycle(dsp.rand(low, high), wform) outlen += len(cycle) cycles += cycle return cycles
def kick(amp, length): fhigh = 160.0 flow = 60.0 fdelta = fhigh - flow target = length pos = 0 fpos = fhigh out = '' while pos < target: # Add single cycle # Decrease pitch by amount relative to cycle len cycle = dsp.cycle(fpos) #cycle = ''.join([ str(v) for v in dsp.curve(0, dsp.htf(fpos), math.pi * 2) ]) pos += dsp.flen(cycle) #fpos = fpos - (fhigh * (length / dsp.htf(fpos))) fpos = fpos - 30.0 out += cycle return dsp.env(out, 'phasor')
def kick(amp, length): if amp == 0: return dsp.pad('', 0, length) fhigh = 160.0 flow = 60.0 fdelta = fhigh - flow target = length pos = 0 fpos = fhigh out = '' while pos < target: # Add single cycle # Decrease pitch by amount relative to cycle len cycle = dsp.cycle(fpos) pos += dsp.flen(cycle) fpos = fpos - 30.0 out += cycle out = dsp.amp(out, amp) return dsp.env(out, 'phasor')
def kick(amp, length): if amp == 0: return dsp.pad('', 0, length) fhigh = 160.0 flow = 60.0 fdelta = fhigh - flow target = length pos = 0 fpos = fhigh out = '' while pos < target: # Add single cycle # Decrease pitch by amount relative to cycle len cycle = dsp.cycle(fpos) #cycle = ''.join([ str(v) for v in dsp.curve(0, dsp.htf(fpos), math.pi * 2) ]) pos += dsp.flen(cycle) #fpos = fpos - (fhigh * (length / dsp.htf(fpos))) fpos = fpos - 30.0 out += cycle return dsp.env(out, 'phasor')
def play(voice_id): volume = P(voice_id, 'volume', 100.0) volume = volume / 100.0 # TODO: move into param filter volume = volume * 0.65 length = P(voice_id, 'length', 40) env = False wii = False # wii = True speed = False numcycles = dsp.randint(1, 200) # Make breakpoint env with 2-10 vals between 0.1 and 1.0 curve_a = dsp.breakpoint( [1.0] + [dsp.rand(0.1, 1.0) for r in range(dsp.randint(2, 10))] + [0], numcycles) # Make wavetable with single cycle from given wave types curve_types = ['vary', 'phasor', 'sine', 'cos', 'impulse'] curve_b = dsp.wavetable(dsp.randchoose(curve_types), numcycles) # Make pan curve - always cosine pan = dsp.breakpoint([dsp.rand() for i in range(dsp.randint(5, 50))], numcycles) amps = dsp.breakpoint( [dsp.rand(0.1, 0.75) for i in range(dsp.randint(5, 30))], numcycles) # Multiply breakpoint curve with simple wavetable wtable = [curve_a[i] * curve_b[i] for i in range(numcycles)] # Scale to max frequency wtable = [(f * 20000) + length for f in wtable] # Possible osc wavetypes wtypes = ['sine2pi'] # wtypes = ['tri', 'sine2pi', 'impulse'] # wtypes = ['impulse', 'tri', 'cos', 'sine2pi', 'vary'] if wii is True: out = [ dsp.pan(dsp.cycle(wtable[i], dsp.randchoose(wtypes)), pan[i]) for i in range(numcycles) ] else: wtype = dsp.randchoose(wtypes) out = [ dsp.pan(dsp.cycle(wtable[i], wtype), pan[i]) for i in range(numcycles) ] out = [dsp.amp(oo, amps[i]) for i, oo in enumerate(out)] out = dsp.amp(''.join(out), volume) if speed != False and speed > 0.0: out = dsp.transpose(out, speed) if env != False: out = dsp.env(out, env) return out