def snare(amp, length): if amp == 0: return dsp.pad('', 0, length) # Two layers of noise: lowmid and high out = dsp.mix([ dsp.bln(int(length * 0.2), 700, 3200, 'impulse'), dsp.bln(int(length * 0.01), 7000, 9000) ]) out = dsp.env(out, 'phasor') out = dsp.pad(out, 0, length - dsp.flen(out)) out = dsp.amp(out, amp) return out
def hat(length): lowf = dsp.rand(600, 7000) highf = dsp.rand(7000, 19000) if dsp.randint(0, 6) == 0: out = dsp.bln(length, lowf, highf) out = dsp.env(out, 'line') else: out = dsp.bln(int(length * 0.05), lowf, highf) out = dsp.env(out, 'phasor') out = dsp.pad(out, 0, length - dsp.flen(out)) return out
def clap(amp, length): if amp == 0: return dsp.pad('', 0, length) # Two layers of noise: lowmid and high lowlow, lowhigh = dsp.rand(300, 600), dsp.rand(700, 1200) highlow, highhigh = dsp.rand(3000, 7000), dsp.rand(7000, 9000) out = dsp.mix([ dsp.bln(int(length * 0.2), lowlow, lowhigh), dsp.bln(int(length * 0.2), 7000, 9000) ]) out = dsp.env(out, 'phasor') out = dsp.pad(out, 0, length - dsp.flen(out)) out = dsp.amp(out, amp) return out
def makeHat(length, i): h = dsp.bln(length / 4, dsp.rand(6000, 8000), dsp.rand(9000, 16000)) h = dsp.amp(h, dsp.rand(0.5, 1)) h = dsp.env(h, 'phasor') h = dsp.fill(h, length, silence=True) return h
def rhodes(total_time, freq=220.0, ampscale=0.5): partials = [ # Multiple, amplitude, duration [1, 0.6, 1.0], [2, 0.25, 0.35], [3, 0.08, 0.15], [4, 0.005, 0.04], ] layers = [] for plist in partials: partial = dsp.tone(freq=plist[0] * freq, length=total_time, amp=plist[1] * ampscale) env_length = (total_time * plist[2] * 2) / 32 wtable = dsp.wavetable('hann', int(env_length)) wtable = wtable[int(env_length / 2):] wtable.extend([0 for i in range(total_time - len(wtable))]) print env_length, len(wtable), dsp.flen(partial) partial = dsp.split(partial, 32) partial = [dsp.amp(partial[i], wtable[i]) for i in range(len(partial))] layer = ''.join(partial) layers += [layer] out = dsp.mix(layers) noise = dsp.amp(dsp.bln(dsp.flen(out) * 2, 2000, 20000), 0.005) noise = dsp.fill(noise, dsp.flen(out)) out = dsp.mix([out, noise]) return out
def rhodes(total_time, freq=220.0, ampscale=0.5): partials = [ # Multiple, amplitude, duration [1, 0.6, 1.0], [2, 0.25, 0.35], [3, 0.08, 0.15], [4, 0.005, 0.04], ] layers = [] for plist in partials: partial = dsp.tone(freq=plist[0] * freq, length=total_time, amp=plist[1] * ampscale) env_length = (total_time * plist[2] * 2) / 32 wtable = dsp.wavetable('hann', int(env_length)) wtable = wtable[int(env_length / 2):] wtable.extend([0 for i in range(total_time - len(wtable))]) print env_length, len(wtable), dsp.flen(partial) partial = dsp.split(partial, 32) partial = [ dsp.amp(partial[i], wtable[i]) for i in range(len(partial)) ] layer = ''.join(partial) layers += [ layer ] out = dsp.mix(layers) noise = dsp.amp(dsp.bln(dsp.flen(out) * 2, 2000, 20000), 0.005) noise = dsp.fill(noise, dsp.flen(out)) out = dsp.mix([out, noise]) return out
def rhodes(length=22050, freq=220.0, amp=0.5, wavetype='sine'): partials = [ # Multiple, amplitude, duration [1, 0.6, 1.0], [2, 0.25, 0.35], [3, 0.08, 0.15], [4, 0.005, 0.04], ] layers = [] for plist in partials: partial = dsp.tone(freq=plist[0] * freq, length=length, amp=plist[1], wavetype=wavetype) env_length = (length * plist[2] * 2) / 32 if env_length <= 2: env_length = 4 wtable = dsp.wavetable('hann', int(env_length)) wtable = wtable[int(env_length / 2):] wtable.extend([0 for i in range(length - len(wtable))]) partial = dsp.split(partial, 32) partial = [ dsp.amp(partial[i], wtable[i]) for i in range(len(partial)) ] layer = ''.join(partial) layers += [ layer ] out = dsp.mix(layers) noise = dsp.amp(dsp.bln(dsp.flen(out) * 2, 2000, 20000), 0.005) noise = dsp.fill(noise, dsp.flen(out)) out = dsp.mix([out, noise]) out = dsp.amp(out, amp) return out
def makeSnare(length, i): burst = dsp.bln(length, dsp.rand(400, 800), dsp.rand(8000, 10000)) burst = dsp.env(burst, 'phasor') s = dsp.mix([snare, burst]) s = dsp.transpose(s, dsp.rand(0.9, 1.1)) s = dsp.fill(s, length, silence=True) return dsp.taper(s, 40)
def brass(length=22050, freq=220, amp=0.5): pw = dsp.rand(0.25, 0.5) note = pulsar(length=length, freq=freq, pulsewidth=pw, amp=amp) noise = dsp.bln(length, dsp.rand(1000, 2000), dsp.rand(2000, 3000)) noise = dsp.fill(noise, length) noise = fx.bend(noise, [ dsp.rand() for _ in range(dsp.randint(5, 10)) ], dsp.rand(0.01, 0.3)) noise = dsp.amp(noise, dsp.rand(0.001, 0.002)) noise = dsp.env(noise, 'tri') note = dsp.mix([ note, noise ]) return note
def play(ctl): param = ctl.get('param') lpd = ctl.get('midi').get('lpd') freqs = [ (10000, 15000), (5000, 15000), (5000, 10000), ] low = dsp.rand(50, 100) high = dsp.rand(80, 120) low = 80 high = 120 wform = 'sine2pi' amp = lpd.get(5, low=0, high=1, default=0) low = dsp.rand(low * 0.9, low) high = dsp.rand(high, high * 1.1) length = dsp.mstf(lpd.get(1, low=10, high=900)) if dsp.rand() > 10.5: length = length / 2 pulselength = lpd.geti(2, low=dsp.mstf(10), high=length, default=length) out = dsp.bln(pulselength, low, high, wform) out = dsp.env(out, 'phasor') if dsp.rand() > 10.1: beep = dsp.tone(dsp.flen(out), dsp.rand(12000, 12000), amp=dsp.rand(0.5, 1)) out = dsp.mix([out, beep]) out = dsp.drift(out, dsp.rand(0, 1)) out = dsp.pad(out, 0, length - dsp.flen(out)) out = dsp.pan(out, dsp.rand()) out = dsp.amp(out, amp) return out
def play(ctl): grains = dsp.randint(1, 100) o = "" for g in range(grains): length = dsp.stf(dsp.rand(0.001, 0.1)) numpoints = dsp.randint(10, 30) points = [0] + [dsp.rand(-1, 1) for _ in range(numpoints)] + [0] out = dsp.bln(length, 330, 330, "tri") # out = dsp.am(out, dsp.tone(length, dsp.rand(10, 100))) out = dsp.env(out, "random") out = dsp.pan(out, dsp.rand()) out = dsp.amp(out, dsp.rand(0.1, 0.9)) o += out out = dsp.env(o, "random") out = dsp.pad(out, 0, dsp.stf(dsp.rand(0.1, 1))) return out
def play(ctl): param = ctl.get('param') lpd = ctl.get('midi').get('lpd') pc = ctl.get('midi').get('pc') #pc.setOffset(111) gamut = { 'high': [ (10000, 15000), (5000, 15000), (5000, 10000), ], 'mid': [ (1000, 5000), (1000, 2000), ], 'pitch': [ tuple([ dsp.rand(500, 2000) for p in range(2) ]), tuple([ dsp.rand(100, 1000) for p in range(2) ]), tuple([ dsp.rand(1000, 5000) for p in range(2) ]), ], 'low': [ (20, 5000), (30, 10000), (40, 10000), ] } area = param.get('wash-area', default='high') area = dsp.randchoose(['high', 'mid', 'pitch', 'low']) area = 'pitch' dsp.log(area) freqs = dsp.randchoose(gamut[area]) freqscale = pc.get(16, low=0.125, high=2, default=1) #freqscale = dsp.rand(0.125, 2) low = freqs[0] * freqscale high = freqs[1] * freqscale wform = dsp.randchoose(['sine2pi', 'tri', 'vary', 'square']) timescale = pc.get(17, low=1, high=4, default=1) #timescale = dsp.rand(1, 4) lengthscale = pc.get(18, low=0.125, high=2.5) #lengthscale = dsp.rand(0.125, 2.5) amp = pc.get(0, low=0, high=0.5, default=0.5) #amp = dsp.rand(0, 0.5) if area == 'high': low = dsp.rand(low * 0.9, low) high = dsp.rand(high, high * 1.1) length = dsp.stf(dsp.rand(0.01, 0.3) * lengthscale) out = dsp.bln(length, low, high, wform) out = dsp.env(out, 'phasor') if dsp.rand() > 10.5: beep = dsp.tone(dsp.flen(out), high * 2, amp=dsp.rand(0.5, 1)) out = dsp.mix([out, beep]) out = dsp.pad(out, 0, dsp.mstf(dsp.rand(1, 400) * timescale)) out = out * dsp.randint(1, 3) out = dsp.drift(out, dsp.rand(0, 1)) elif area == 'mid': low = dsp.rand(low * 0.9, low) high = dsp.rand(high, high * 1.1) length = dsp.stf(dsp.rand(0.01, 0.5) * lengthscale) out = dsp.bln(length, low, high, wform) out = dsp.env(out, 'random') if timescale > 1: out = dsp.pad(out, 0, dsp.mstf(500 * timescale * dsp.rand(0.5, 1.5))) elif area == 'pitch': low = dsp.rand(low * 0.9, low) high = dsp.rand(high, high * 1.1) length = dsp.stf(dsp.rand(0.01, 0.5) * lengthscale) out = dsp.bln(length, low, high, wform) out = dsp.env(out, 'random') if timescale > 1: out = dsp.pad(out, 0, dsp.mstf(500 * timescale * dsp.rand(0.5, 1.5))) elif area == 'low': low = dsp.rand(low * 0.9, low) high = dsp.rand(high, high * 1.1) length = dsp.stf(dsp.rand(0.2, 2) * lengthscale) out = dsp.bln(length, low, high, wform) out = dsp.env(out, 'random') out = dsp.mix([out, dsp.tone(length, low)]) if dsp.rand() > 0.5: beep = dsp.tone(dsp.flen(out), high, amp=dsp.rand(0.015, 0.1), wavetype=dsp.randchoose(['hann', 'impulse', 'square', 'vary', 'sine'])) out = dsp.mix([out, beep]) if timescale > 1: out = dsp.pad(out, 0, dsp.mstf(500 * timescale * dsp.rand(0.5, 1.5))) if dsp.rand() > pc.get(19, low=0, high=1, default=0.75): plength = length * dsp.randint(2, 6) freq = tune.ntf(param.get('key', default='c'), octave=dsp.randint(0, 4)) out = dsp.mix([ dsp.pine(out, plength, freq), dsp.pine(out, plength, freq * 1.25) ]) out = dsp.fill(out, length) out = dsp.pan(out, dsp.rand()) out = dsp.amp(out, amp) return out
highs = dsp.breakpoint( [dsp.rand(60, 15000) for _ in range(npulses / 50)], npulses) lows = [dsp.rand(20, freq) for freq in highs] amps = dsp.breakpoint( [dsp.rand(0.1, 0.3) for _ in range(npulses / 50)], npulses) pans = dsp.breakpoint([dsp.rand(0, 1) for _ in range(npulses / 10)], npulses) lengths = [ dsp.mstf(l) for l in dsp.breakpoint( [dsp.rand(1, 30) for _ in range(npulses / 10)], npulses) ] for high, low, amp, pan, length in zip(highs, lows, amps, pans, lengths): p = dsp.bln(length, low, high, wform=dsp.randchoose(['hann', 'sine2pi', 'tri'])) p = dsp.env(p, 'hann') p = dsp.taper(p, 20) p = dsp.amp(p, amp) p = dsp.pan(p, pan) layer += p layers += [layer] freqs = tune.fromdegrees([dsp.randint(1, 9) for _ in range(nlayers)], octave=1, root='a') for i, freq in enumerate(freqs):
nlayers = 3 sectionlength = dsp.stf(dsp.rand(10, 12)) for _ in range(nchords): layers = [] for _ in range(nlayers): layer = '' highs = dsp.breakpoint([ dsp.rand(60, 15000) for _ in range(npulses / 50) ], npulses) lows = [ dsp.rand(20, freq) for freq in highs ] amps = dsp.breakpoint([ dsp.rand(0.1, 0.3) for _ in range(npulses / 50) ], npulses) pans = dsp.breakpoint([ dsp.rand(0, 1) for _ in range(npulses / 10) ], npulses) lengths = [ dsp.mstf(l) for l in dsp.breakpoint([ dsp.rand(1, 30) for _ in range(npulses / 10) ], npulses) ] for high, low, amp, pan, length in zip(highs, lows, amps, pans, lengths): p = dsp.bln(length, low, high, wform=dsp.randchoose(['hann', 'sine2pi', 'tri'])) p = dsp.env(p, 'hann') p = dsp.taper(p, 20) p = dsp.amp(p, amp) p = dsp.pan(p, pan) layer += p layers += [ layer ] freqs = tune.fromdegrees([dsp.randint(1, 9) for _ in range(nlayers)], octave=1, root='a') for i, freq in enumerate(freqs): layers[i] = dsp.pine(layer, dsp.flen(layer) * 10, freq) section = dsp.fill(dsp.mix(layers), sectionlength)