def play(ctl): freq = tune.ntf(dsp.randchoose(['eb']), octave=dsp.randint(0,2)) synth = keys.rhodes(dsp.stf(4), freq) s = dsp.vsplit(synth, dsp.mstf(50), dsp.mstf(2000)) s = dsp.randshuffle(s) #s = [ dsp.alias(ss) for ss in s ] s = [ dsp.amp(ss, dsp.rand(0.5, 0.75)) for ss in s ] s = [ dsp.pan(ss, dsp.rand(0, 1)) for ss in s ] s = ''.join(s) s = dsp.fill(s, dsp.flen(synth)) s2 = dsp.vsplit(synth, dsp.mstf(150), dsp.mstf(1500)) s2 = dsp.randshuffle(s2) s2 = [ dsp.transpose(ss, dsp.randchoose([1,1.5,2,3,4,8])) for ss in s2 ] s2 = [ dsp.env(ss, 'phasor') for ss in s2 ] s2 = ''.join(s2) out = dsp.mix([ s, s2 ]) out = dsp.amp(out, 1.5) out = dsp.transpose(out, 1.01) #synth = dsp.fill(synth, dsp.flen(main)) #out = synth return out
def smear(input, mingrain=2205, maxgrain=4410, waveform='hann', spread=0.1, drift=0.05, minpan=0.0, maxpan=1.0, minamp=0.0, maxamp=1.0): out = dsp.vsplit(input, mingrain, maxgrain) out = [ dsp.amp(grain, dsp.rand(minamp, maxamp)) for grain in out ] out = [ dsp.env(grain, waveform) for grain in out ] out = [ dsp.pan(grain, dsp.rand(minpan, maxpan)) for grain in out ] drift_delta = drift / 2.0 minspeed = 1.0 - drift_delta maxspeed = 1.0 + drift_delta out = [ dsp.transpose(grain, dsp.rand(minspeed, maxspeed)) for grain in out ] num_shuffled_grains = int(len(out) * spread) # Pull a random set of grains shuffled_grains = [] for i in range(num_shuffled_grains): index = dsp.randint(0, len(out) - 1) shuffled_grains += [ out.pop(index) ] # Insert them back into random positions for grain in shuffled_grains: index = dsp.randint(0, len(out) - 1) out.insert(index, grain) out = ''.join(out) return out
def wild(snd, factor=1): snd = dsp.vsplit(snd, 41, 441) #snd = [ dsp.fnoise(l, dsp.rand(0, factor * 0.05)) for l in snd ] snd = [ dsp.amp(dsp.amp(l, dsp.rand(10, factor * 30 + 20)), 0.5) for l in snd ] snd = ''.join(snd) return snd
def play(voice_id): bpm = C('bpm') beat = dsp.bpm2frames(bpm) volume = P(voice_id, 'volume', default=1.0) crinkle = dsp.read('sounds/s/crinkle.wav').data glass1 = dsp.read('sounds/s/glass1.wav').data glass2 = dsp.read('sounds/s/glass2.wav').data toys = dsp.read('sounds/s/rolling.wav').data c = dsp.vsplit(crinkle, dsp.mstf(10), dsp.stf(3)) c = dsp.randshuffle(c) c = c[:40] c = [dsp.pan(cc, dsp.rand()) for cc in c] c = [dsp.env(cc, 'sine') for cc in c] c = [dsp.transpose(cc, dsp.rand(0.25, 0.5)) for cc in c] t = dsp.vsplit(toys, dsp.mstf(10), dsp.stf(1)) t = dsp.randshuffle(t) t = t[:40] t = [dsp.amp(tt, dsp.rand(0.1, 0.8)) for tt in t] t = [dsp.pan(tt, dsp.rand(0, 1)) for tt in t] t = [dsp.env(tt, 'sine') for tt in t] t = [dsp.transpose(tt, 0.5) for tt in t] g = dsp.vsplit(glass2, dsp.mstf(1), dsp.mstf(100)) g = dsp.randshuffle(g) g = g[:40] g = [dsp.amp(gg, dsp.rand(0.35, 0.95)) for gg in g] g = [dsp.transpose(gg, dsp.rand(0.5, 1.75)) for gg in g] g = [gg * dsp.randint(1, 8) for gg in g] things = [c, t, g] out = [ dsp.mix([ dsp.randchoose(dsp.randchoose(things)) for l in range(dsp.randint(2, 4)) ]) for i in range(4) ] out = ''.join(out) dsp.log('voice %s length: %.2f' % (voice_id, dsp.fts(dsp.flen(out)))) return out
def makeGrains(out, length=None, env=None): envs = ['tri', 'line', 'flat', 'sine', 'hann'] out = dsp.vsplit(out, dsp.mstf(20), dsp.mstf(90)) out = [ dsp.env(grain, 'hann') for grain in out ] out = [ dsp.pan(grain, dsp.rand()) for grain in out ] out = dsp.randshuffle(out) out = ''.join(out) out = dsp.env(out, dsp.randchoose(envs)) return out
def makeGrains(out, length=None, env=None): envs = ['tri', 'line', 'flat', 'sine', 'hann'] out = dsp.vsplit(out, dsp.mstf(20), dsp.mstf(90)) out = [dsp.env(grain, 'hann') for grain in out] out = [dsp.pan(grain, dsp.rand()) for grain in out] out = dsp.randshuffle(out) out = ''.join(out) out = dsp.env(out, dsp.randchoose(envs)) return out
def play(voice_id): bpm = C('bpm') beat = dsp.bpm2frames(bpm) volume = P(voice_id, 'volume', default=1.0) crinkle = dsp.read('sounds/s/crinkle.wav').data glass1 = dsp.read('sounds/s/glass1.wav').data glass2 = dsp.read('sounds/s/glass2.wav').data toys = dsp.read('sounds/s/rolling.wav').data c = dsp.vsplit(crinkle, dsp.mstf(10), dsp.stf(3)) c = dsp.randshuffle(c) c = c[:40] c = [ dsp.pan(cc, dsp.rand()) for cc in c ] c = [ dsp.env(cc, 'sine') for cc in c ] c = [ dsp.transpose(cc, dsp.rand(0.25, 0.5)) for cc in c ] t = dsp.vsplit(toys, dsp.mstf(10), dsp.stf(1)) t = dsp.randshuffle(t) t = t[:40] t = [ dsp.amp(tt, dsp.rand(0.1, 0.8)) for tt in t ] t = [ dsp.pan(tt, dsp.rand(0, 1)) for tt in t ] t = [ dsp.env(tt, 'sine') for tt in t ] t = [ dsp.transpose(tt, 0.5) for tt in t ] g = dsp.vsplit(glass2, dsp.mstf(1), dsp.mstf(100)) g = dsp.randshuffle(g) g = g[:40] g = [ dsp.amp(gg, dsp.rand(0.35, 0.95)) for gg in g ] g = [ dsp.transpose(gg, dsp.rand(0.5, 1.75)) for gg in g ] g = [ gg * dsp.randint(1, 8) for gg in g ] things = [c,t,g] out = [ dsp.mix([ dsp.randchoose(dsp.randchoose(things)) for l in range(dsp.randint(2, 4)) ]) for i in range(4) ] out = ''.join(out) dsp.log('voice %s length: %.2f' % (voice_id, dsp.fts(dsp.flen(out)))) return out
def make_layer(freq): out = dsp.tone(length, freq, amp=0.2) out = dsp.vsplit(out, dsp.mstf(10), dsp.mstf(2500)) for i, o in enumerate(out): if dsp.randint(0, 100) > 50: out[i] = make_pulse(o) else: out[i] = make_vary(o) out = [ dsp.amp(o, dsp.rand(0, 1)) for o in out ] out = ''.join(out) return out
def glitchStutter(snd): """ Basically a random gate """ snd = dsp.vsplit(snd, dsp.mstf(1, 50), dsp.mstf(50, 200)) for i, s in enumerate(snd): if dsp.rand() > dsp.rand(0.5, 0.9): s = dsp.amp(s, dsp.rand(0, 0.15)) s = dsp.taper(s, 20) snd[i] = s else: s = dsp.amp(s, dsp.rand(0.85, 1)) snd[i] = dsp.taper(s, 20) snd = ''.join(snd) return snd
def play(voice_id): bpm = config('bpm') key = config('key') quality = getattr(tune, config('quality')) ratios = getattr(tune, config('tune')) beat = dsp.bpm2frames(bpm) beat = beat / 4 glitch = False alias = False nbeats = P(voice_id, 'multiple', dsp.randchoose([8, 16])) gs = ['gC1', 'gC2'] g = dsp.randchoose(gs) n = dsp.read('sounds/%s.wav' % g).data # speeds = [1, 1.25, 1.5, 1.666, 2, 4] speeds = [1, 1.25, 1.5, 2, 3, 4, 6, 8, 16] root = tune.ntf('c') target = tune.ntf(key) n = dsp.transpose(n, target / root) n = dsp.fill(n, dsp.stf(20)) n = dsp.transpose(n, dsp.randchoose(speeds)) n = dsp.split(n, beat) n = dsp.randshuffle(n) n = n[:nbeats + 1] if alias: n = [dsp.alias(nn) for nn in n] n = [dsp.amp(nn, dsp.rand(0.1, 0.75)) for nn in n] n = [dsp.pan(nn, dsp.rand()) for nn in n] n = ''.join(n) out = n if glitch: out = dsp.vsplit(out, dsp.mstf(dsp.rand(80, 140)), dsp.mstf(500)) out = dsp.randshuffle(out) out = ''.join(out) return out
def play(voice_id): bpm = config('bpm') key = config('key') quality = getattr(tune, config('quality')) ratios = getattr(tune, config('tune')) beat = dsp.bpm2frames(bpm) beat = beat / 4 glitch = False alias = False nbeats = P(voice_id, 'multiple', dsp.randchoose([8, 16])) gs = ['gC1', 'gC2'] g = dsp.randchoose(gs) n = dsp.read('sounds/%s.wav' % g).data # speeds = [1, 1.25, 1.5, 1.666, 2, 4] speeds = [1, 1.25, 1.5, 2, 3, 4, 6, 8, 16] root = tune.ntf('c') target = tune.ntf(key) n = dsp.transpose(n, target / root) n = dsp.fill(n, dsp.stf(20)) n = dsp.transpose(n, dsp.randchoose(speeds)) n = dsp.split(n, beat) n = dsp.randshuffle(n) n = n[:nbeats + 1] if alias: n = [ dsp.alias(nn) for nn in n ] n = [ dsp.amp(nn, dsp.rand(0.1, 0.75)) for nn in n ] n = [ dsp.pan(nn, dsp.rand()) for nn in n ] n = ''.join(n) out = n if glitch: out = dsp.vsplit(out, dsp.mstf(dsp.rand(80, 140)), dsp.mstf(500)) out = dsp.randshuffle(out) out = ''.join(out) return out
def play(voice_id): bpm = config('bpm') root = config('key') quality = getattr(tune, config('quality')) ratios = getattr(tune, config('tune')) beat = dsp.bpm2frames(bpm) length = dsp.randint(dsp.stf(1), dsp.stf(3)) wav = dsp.breakpoint([0] + [dsp.rand(-1, 1) for w in range(10)] + [0], 512) win = dsp.wavetable('sine', 512) mod = dsp.wavetable('vary', 512) root = dsp.randchoose(tune.fromdegrees([1, 3, 5, 8], octave=0, root='a')) pw = dsp.rand(0.1, 1) amp = dsp.rand(0.5, 1.2) mFreq = 0.01 / dsp.fts(length) out = dsp.pulsar(root, length, pw, wav, win, mod, 0.05, mFreq, amp) # out = dsp.env(out, 'vary') out = dsp.vsplit(out, dsp.mstf(1), dsp.mstf(500)) out = dsp.randshuffle(out) out = [dsp.pad(o, 0, dsp.randint(0, 4410)) for o in out] out = [dsp.pan(o, dsp.rand()) for o in out] out = [dsp.alias(o) for o in out] out = [o * dsp.randint(1, 30) for o in out] out = [dsp.env(o, 'random') for o in out] out = [dsp.amp(o, dsp.rand(0.9, 1.5)) for o in out] out = ''.join(out) return out
def play(voice_id): bpm = config('bpm') root = config('key') quality = getattr(tune, config('quality')) ratios = getattr(tune, config('tune')) beat = dsp.bpm2frames(bpm) length = dsp.randint(dsp.stf(1), dsp.stf(3)) wav = dsp.breakpoint([0] + [ dsp.rand(-1,1) for w in range(10) ] + [0], 512) win = dsp.wavetable('sine', 512) mod = dsp.wavetable('vary', 512) root = dsp.randchoose(tune.fromdegrees([1,3,5,8], octave=0, root='a')) pw = dsp.rand(0.1, 1) amp = dsp.rand(0.5, 1.2) mFreq = 0.01 / dsp.fts(length) out = dsp.pulsar(root, length, pw, wav, win, mod, 0.05, mFreq, amp) # out = dsp.env(out, 'vary') out = dsp.vsplit(out, dsp.mstf(1), dsp.mstf(500)) out = dsp.randshuffle(out) out = [ dsp.pad(o, 0, dsp.randint(0, 4410)) for o in out ] out = [ dsp.pan(o, dsp.rand()) for o in out ] out = [ dsp.alias(o) for o in out ] out = [ o * dsp.randint(1, 30) for o in out ] out = [ dsp.env(o, 'random') for o in out ] out = [ dsp.amp(o, dsp.rand(0.9, 1.5)) for o in out ] out = ''.join(out) return out
def play(ctl): pianos = ['sawvib', 'piano', 'pianooct1', 'harp', 'saw'] pianos = ['sawvib', 'piano'] piano = snds.load('genie/%s.wav' % dsp.randchoose(pianos)) notes = [1,3,5] chord = tune.fromdegrees([ dsp.randchoose(notes) + (dsp.randchoose([0, 1]) * 8) for _ in range(dsp.randint(1, 3)) ], octave=0) length = dsp.stf(dsp.rand(1, 4)) layers = [] for freq in chord: p = dsp.transpose(piano, freq / 220.0) p = dsp.amp(p, 0.35) #p = dsp.pan(p, dsp.rand()) p = dsp.fill(p, length) if dsp.rand() > 0.25: p = dsp.vsplit(p, dsp.mstf(100), dsp.mstf(500)) p = [ dsp.pan(pp, dsp.rand()) for pp in p ] p = [ dsp.amp(pp, dsp.rand(0,2)) for pp in p ] p = [ dsp.transpose(pp, dsp.randchoose([1,2,4,8])) for pp in p ] p = [ dsp.taper(pp, 20) for pp in p ] p = [ dsp.pad(pp, 0, dsp.mstf(dsp.rand(0, 100))) for pp in p ] p = dsp.randshuffle(p) p = ''.join(p) if dsp.rand() > 0.75: p = dsp.alias(p) #p = dsp.env(p, 'phasor') layers += [ p ] out = dsp.mix(layers) return out
def play(params): """ Usage: shine.py [length] [volume] """ length = params.get('length', dsp.stf(dsp.rand(0.1, 1))) volume = params.get('volume', 100.0) volume = volume / 100.0 # TODO: move into param filter octave = params.get('octave', 2) + 1 # Add one to compensate for an old error for now note = params.get('note', ['c']) note = note[0] quality = params.get('quality', tune.major) glitch = params.get('glitch', False) superglitch = params.get('superglitch', False) pinecone = params.get('pinecone', False) glitchpad = params.get('glitch-padding', 0) glitchenv = params.get('glitch-envelope', False) env = params.get('envelope', False) ratios = params.get('ratios', tune.terry) pad = params.get('padding', False) bend = params.get('bend', False) bpm = params.get('bpm', 75.0) width = params.get('width', False) wform = params.get('waveform', False) instrument = params.get('instrument', 'r') scale = params.get('scale', [1,6,5,4,8]) shuffle = params.get('shuffle', False) # Reorganize input scale reps = params.get('repeats', len(scale)) alias = params.get('alias', False) phase = params.get('phase', False) pi = params.get('pi', False) wild = params.get('wii', False) root = params.get('root', 27.5) trigger_id = params.get('trigger_id', 0) tune.a0 = float(root) try: # Available input samples if instrument == 'r': instrument = 'rhodes' tone = dsp.read('sounds/synthrhodes.wav').data elif instrument == 's': instrument = 'synthrhodes' tone = dsp.read('sounds/220rhodes.wav').data elif instrument == 'c': instrument = 'clarinet' tone = dsp.read('sounds/clarinet.wav').data elif instrument == 'v': instrument = 'vibes' tone = dsp.read('sounds/glock220.wav').data elif instrument == 't': instrument = 'tape triangle' tone = dsp.read('sounds/tape220.wav').data elif instrument == 'g': instrument = 'glade' tone = dsp.read('sounds/glade.wav').data elif instrument == 'p': instrument = 'paperclips' tone = dsp.read('sounds/paperclips.wav').data elif instrument == 'i': instrument = 'input' tone = dsp.capture(dsp.stf(1)) except: instrument = None tone = None out = '' # Shuffle the order of pitches if shuffle is not False: scale = dsp.randshuffle(scale) # Translate the list of scale degrees into a list of frequencies freqs = tune.fromdegrees(scale, octave, note, quality, ratios) freqs = [ freq / 4.0 for freq in freqs ] # Format is: [ [ path, offset, id, value ] ] # Offset for video osc_messages = [ ['/dac', float(dsp.fts(length)), 1, tune.fts(osc_freq)] for osc_freq in freqs ] # Phase randomly chooses note lengths from a # set of ratios derived from the current bpm if phase is not False: ldivs = [0.5, 0.75, 2, 3, 4] ldiv = dsp.randchoose(ldivs) length = dsp.bpm2ms(bpm) / ldiv length = dsp.mstf(length) reps = ldiv if ldiv > 1 else 4 # Construct a sequence of notes for i in range(reps): # Get the freqency freq = freqs[i % len(freqs)] # Transpose the input sample or # synthesize tone if wform is False and tone is not None: # Determine the pitch shift required # to arrive at target frequency based on # the pitch of the original samples. if instrument == 'clarinet': diff = freq / 293.7 elif instrument == 'vibes': diff = freq / 740.0 else: diff = freq / 440.0 clang = dsp.transpose(tone, diff) elif wform == 'super': clang = dsp.tone(length, freq, 'phasor', 0.5) clang = [ dsp.drift(clang, dsp.rand(0, 0.02)) for s in range(7) ] clang = dsp.mix(clang) elif wform is False and tone is None: clang = dsp.tone(length, freq, 'sine2pi', 0.75) clang = dsp.amp(clang, 0.6) else: clang = dsp.tone(length, freq, wform, 0.75) clang = dsp.amp(clang, 0.6) # Stupidly copy the note enough or # trim it to meet the target length clang = dsp.fill(clang, length) # Give synth tones simple env (can override) if wform is not False and env is False: clang = dsp.env(clang, 'phasor') # Apply an optional amplitude envelope if env is not False: clang = dsp.env(clang, env) # Add optional padding between notes if pad != False: clang = dsp.pad(clang, 0, pad) # Add to the final note sequence out += clang # Add optional aliasing (crude bitcrushing) if alias is not False: out = dsp.alias(out) # Cut sound into chunks of variable length (between 5 & 300 ms) # Pan each chunk to a random position # Apply a sine amplitude envelope to each chunk # Finally, add variable silence between each chunk and shuffle the # order of the chunks before joining. if glitch is not False: out = dsp.vsplit(out, dsp.mstf(5), dsp.mstf(300)) out = [dsp.pan(o, dsp.rand()) for o in out] out = [dsp.env(o, 'sine') for o in out] out = [dsp.pad(o, 0, dsp.mstf(dsp.rand(0, glitchpad))) for o in out] out = ''.join(dsp.randshuffle(out)) # Detune between 1.01 and 0.99 times original speed # as a sine curve whose length equals the total output length if bend is not False: out = dsp.split(out, 441) freqs = dsp.wavetable('sine', len(out), 1.01, 0.99) out = [ dsp.transpose(out[i], freqs[i]) for i in range(len(out)) ] out = ''.join(out) if wild is not False: #out = dsp.vsplit(out, 400, 10000) out = dsp.split(out, 3000) out = [ dsp.amp(dsp.amp(o, dsp.rand(10, 50)), 0.5) for o in out ] #out = [ o * dsp.randint(1, 5) for o in out ] for index, o in enumerate(out): if dsp.randint(0, 1) == 0: out[index] = dsp.env(dsp.cut(o, 0, dsp.flen(o) / 4), 'gauss') * 4 if dsp.randint(0, 6) == 0: out[index] = dsp.transpose(o, 8) out = [ dsp.env(o, 'gauss') for o in out ] freqs = dsp.wavetable('sine', len(out), 1.02, 0.98) out = [ dsp.transpose(out[i], freqs[i]) for i in range(len(out)) ] out = ''.join(out) if pinecone == True: out = dsp.pine(out, int(length * dsp.rand(0.5, 8.0)), dsp.randchoose(freqs) * dsp.rand(0.5, 4.0)) # Adjust output amplitude as needed and return audio + OSC if pi: return (dsp.amp(out, volume), {'osc': osc_messages}) else: return dsp.amp(out, volume)
def play(voice_id): tel = bot.getTel() bpm = s.config('bpm') #if 'gentle' in tel['name'] or 'upbeat' in tel['name'] or 'full' in tel['name']: #dsp.log('') #dsp.log(voice_id + ' chirps silent') #return dsp.pad('', 0, dsp.stf(dsp.rand(1, 10))) length = int((1.0 / (tel['pace'] / 10.0)) * dsp.stf(3)) def makecurve(length): # freq, length, pulsewidth, waveform, window, mod, modRange, modFreq, amp wf = dsp.breakpoint([0] + [ dsp.rand(-1, 1) for i in range(int(dsp.rand(5, 30))) ] + [0], 1024) win = dsp.breakpoint([0] + [ dsp.rand(0, 1) for i in range(4) ] + [0], 1024) mod = dsp.breakpoint([ dsp.rand(0, 1) for i in range(int(dsp.rand(4, 8))) ], 1024) smaxamp = dsp.rand(0.65, 0.95) amp = dsp.rand(0.01, smaxamp) pw = dsp.rand(0.1, 1.0) if 'upbeat' in tel['name']: wf = dsp.breakpoint([0] + [ dsp.rand(-1, 1) for i in range(int(dsp.rand(5, 30))) ] + [0], 1024) win = dsp.breakpoint([0] + [ dsp.rand(0, 1) for i in range(4) ] + [0], 1024) mod = dsp.breakpoint([ dsp.rand(0, 1) for i in range(int(dsp.rand(5, 80))) ], 1024) pw = 1.0 if 'ballsout' in tel['name']: wf = dsp.breakpoint([0] + [ dsp.rand(-1, 1) for i in range(int(dsp.rand(10, 40))) ] + [0], 1024) win = dsp.breakpoint([0] + [ dsp.rand(0, 1) for i in range(10) ] + [0], 1024) mod = dsp.breakpoint([ dsp.rand(0, 1) for i in range(int(dsp.rand(20, 100))) ], 1024) if 'sparse' in tel['name']: amp = dsp.rand(0.7, 3) freq = tel['register'] * tel['roughness'] * (tel['density'] * tel['pace'] * 0.25) #if dsp.rand(0, 100) > 50: #freq = dsp.rand(2, 20) modR = tel['harmonicity'] modF= tel['pace'] / 10.0 c = dsp.pulsar(freq, length, pw, wf, win, mod, modR, modF, amp) ngrains = len(c) pans = dsp.breakpoint([ dsp.rand(0,1) for i in range(100) ], ngrains) maxPad = dsp.randint(2000, 4000) if 'sparse' in tel['name']: c = dsp.vsplit(c, dsp.mstf(0.5), dsp.mstf(tel['density'] * tel['harmonicity'] * tel['roughness'] * tel['pace'])) c = [ dsp.randchoose(c) for i in range(int(dsp.rand(3, 10))) ] elif 'ballsout' in tel['name']: c = dsp.vsplit(c, dsp.mstf(0.1), dsp.mstf(400)) c = dsp.packet_shuffle(c, dsp.randint(5, 10)) speeds = dsp.breakpoint([ dsp.rand(tel['register'] * 0.1 + 0.2, tel['register'] + 0.2) for i in range(100) ], ngrains) #c = [ dsp.transpose(cg, speeds[i]) for i, cg in enumerate(c) ] #c = [ dsp.amp(cg, dsp.rand(0.25, 1.25)) for i, cg in enumerate(c) ] for ic, cc in enumerate(c): if dsp.rand(0, 100) > 70: c[ic] = dsp.tone(dsp.flen(cc), 11000, amp=0.5) elif 'upbeat' in tel['name']: beat = dsp.bpm2frames(bpm) c = dsp.split(c, beat) maxPad = 0 c = [ dsp.pad(cg, 0, dsp.mstf(dsp.rand(10, beat / 4))) for i, cg in enumerate(c) ] else: c = dsp.vsplit(c, dsp.mstf(10), dsp.mstf(tel['density'] * tel['harmonicity'] * tel['roughness'] * tel['pace'] * dsp.rand(1, 10))) c = [ dsp.pan(cg, pans[i]) for i, cg in enumerate(c) ] c = [ dsp.env(cg, 'sine') for i, cg in enumerate(c) ] if 'sparse' in tel['name'] or 'ballsout' in tel['name']: speeds = dsp.breakpoint([ dsp.rand(0.5, 1.99) for i in range(100) ], ngrains) for ic, cc in enumerate(c): if dsp.flen(cc) < dsp.mstf(100): c[ic] = cc + ''.join([ dsp.amp(cc, dsp.rand(0.1, 1.0)) for buh in range(dsp.randint(1, int(tel['density']))) ]) #c = [ dsp.transpose(cg, speeds[i]) for i, cg in enumerate(c) ] c = [ dsp.pan(cg, dsp.rand(0.0, 1.0)) for i, cg in enumerate(c) ] if 'ballsout' not in tel['name']: c = [ dsp.pad(cg, 0, dsp.mstf(dsp.rand(10, maxPad))) for i, cg in enumerate(c) ] out = ''.join(c) return out out = makecurve(length) if dsp.flen(out) > dsp.mstf(100) and dsp.rand(0, 100) > 30: out = dsp.drift(out, (tel['harmonicity'] - 10.0) * -1 * 0.5, dsp.randint(41, 441)) if dsp.flen(out) > dsp.stf(10): out = dsp.fill(out, dsp.stf(10)) if dsp.rand(0, 100) > 50: out = dsp.vsplit(out, 41, 441) for ii, o in enumerate(out): if dsp.rand(0, 100) > 50: out[ii] = dsp.pad('', 0, dsp.flen(o)) elif dsp.rand(0, 100) > 50: out[ii] = dsp.amp(o, dsp.rand(0.75, 3)) out = [ dsp.pan(o, dsp.rand()) for o in out ] out = ''.join(out) dsp.log('') dsp.log('chirp') dsp.log('%s length: %.2f' % (voice_id, dsp.fts(dsp.flen(out)))) bot.show_telemetry(tel) return out
def makecurve(length): # freq, length, pulsewidth, waveform, window, mod, modRange, modFreq, amp wf = dsp.breakpoint([0] + [ dsp.rand(-1, 1) for i in range(int(dsp.rand(5, 30))) ] + [0], 1024) win = dsp.breakpoint([0] + [ dsp.rand(0, 1) for i in range(4) ] + [0], 1024) mod = dsp.breakpoint([ dsp.rand(0, 1) for i in range(int(dsp.rand(4, 8))) ], 1024) smaxamp = dsp.rand(0.65, 0.95) amp = dsp.rand(0.01, smaxamp) pw = dsp.rand(0.1, 1.0) if 'upbeat' in tel['name']: wf = dsp.breakpoint([0] + [ dsp.rand(-1, 1) for i in range(int(dsp.rand(5, 30))) ] + [0], 1024) win = dsp.breakpoint([0] + [ dsp.rand(0, 1) for i in range(4) ] + [0], 1024) mod = dsp.breakpoint([ dsp.rand(0, 1) for i in range(int(dsp.rand(5, 80))) ], 1024) pw = 1.0 if 'ballsout' in tel['name']: wf = dsp.breakpoint([0] + [ dsp.rand(-1, 1) for i in range(int(dsp.rand(10, 40))) ] + [0], 1024) win = dsp.breakpoint([0] + [ dsp.rand(0, 1) for i in range(10) ] + [0], 1024) mod = dsp.breakpoint([ dsp.rand(0, 1) for i in range(int(dsp.rand(20, 100))) ], 1024) if 'sparse' in tel['name']: amp = dsp.rand(0.7, 3) freq = tel['register'] * tel['roughness'] * (tel['density'] * tel['pace'] * 0.25) #if dsp.rand(0, 100) > 50: #freq = dsp.rand(2, 20) modR = tel['harmonicity'] modF= tel['pace'] / 10.0 c = dsp.pulsar(freq, length, pw, wf, win, mod, modR, modF, amp) ngrains = len(c) pans = dsp.breakpoint([ dsp.rand(0,1) for i in range(100) ], ngrains) maxPad = dsp.randint(2000, 4000) if 'sparse' in tel['name']: c = dsp.vsplit(c, dsp.mstf(0.5), dsp.mstf(tel['density'] * tel['harmonicity'] * tel['roughness'] * tel['pace'])) c = [ dsp.randchoose(c) for i in range(int(dsp.rand(3, 10))) ] elif 'ballsout' in tel['name']: c = dsp.vsplit(c, dsp.mstf(0.1), dsp.mstf(400)) c = dsp.packet_shuffle(c, dsp.randint(5, 10)) speeds = dsp.breakpoint([ dsp.rand(tel['register'] * 0.1 + 0.2, tel['register'] + 0.2) for i in range(100) ], ngrains) #c = [ dsp.transpose(cg, speeds[i]) for i, cg in enumerate(c) ] #c = [ dsp.amp(cg, dsp.rand(0.25, 1.25)) for i, cg in enumerate(c) ] for ic, cc in enumerate(c): if dsp.rand(0, 100) > 70: c[ic] = dsp.tone(dsp.flen(cc), 11000, amp=0.5) elif 'upbeat' in tel['name']: beat = dsp.bpm2frames(bpm) c = dsp.split(c, beat) maxPad = 0 c = [ dsp.pad(cg, 0, dsp.mstf(dsp.rand(10, beat / 4))) for i, cg in enumerate(c) ] else: c = dsp.vsplit(c, dsp.mstf(10), dsp.mstf(tel['density'] * tel['harmonicity'] * tel['roughness'] * tel['pace'] * dsp.rand(1, 10))) c = [ dsp.pan(cg, pans[i]) for i, cg in enumerate(c) ] c = [ dsp.env(cg, 'sine') for i, cg in enumerate(c) ] if 'sparse' in tel['name'] or 'ballsout' in tel['name']: speeds = dsp.breakpoint([ dsp.rand(0.5, 1.99) for i in range(100) ], ngrains) for ic, cc in enumerate(c): if dsp.flen(cc) < dsp.mstf(100): c[ic] = cc + ''.join([ dsp.amp(cc, dsp.rand(0.1, 1.0)) for buh in range(dsp.randint(1, int(tel['density']))) ]) #c = [ dsp.transpose(cg, speeds[i]) for i, cg in enumerate(c) ] c = [ dsp.pan(cg, dsp.rand(0.0, 1.0)) for i, cg in enumerate(c) ] if 'ballsout' not in tel['name']: c = [ dsp.pad(cg, 0, dsp.mstf(dsp.rand(10, maxPad))) for i, cg in enumerate(c) ] out = ''.join(c) return out
def play(voice_id): bpm = config('bpm') beat = dsp.bpm2frames(bpm) dsl = P(voice_id, 'drum', '["c","k","h"]') dsp.log(dsl) dsl = json.loads(dsl) def hat(beat): length = beat * 4 nbeats = 16 blen = length / nbeats out = '' for b in range(nbeats): h = dsp.transpose(tape1, 9) h = dsp.fill(h, dsp.mstf(dsp.rand(1, 20))) h = dsp.env(h, 'phasor') h = dsp.amp(h, dsp.rand(0, 0.8)) h = dsp.pad(h, 0, blen - dsp.flen(h)) out += h out *= 8 return out def kick(beat): out = drums.sinekick(length=beat, amp=dsp.rand(0.8, 1)) out = dsp.pad(out, 0, beat * dsp.randint(1, 2)) out *= 2 return out def clap1(beat): c = dsp.read('sounds/mikeclap.wav').data c = dsp.transpose(c, dsp.rand(1, 2.5)) c = dsp.fill(c, dsp.mstf(dsp.rand(10, 100))) c = dsp.env(c, 'phasor') c = dsp.amp(c, dsp.rand(1, 3)) c = dsp.pad(c, 0, beat - dsp.flen(c)) blen = beat / dsp.randchoose([1, 2]) c = dsp.pad(c, blen, 0) c *= 4 return c def clap2(beat): nlens = [ beat * 2, beat, beat / 2, ] # length of pattern (in beats) nbeats = dsp.randint(10, 15) # beat lengths (from a set of bpm-derived note lengths defined in the nlens list) blens = [dsp.randchoose(nlens) for b in range(nbeats)] out = '' # synthesize the tones for i in range(nbeats): beat = dsp.transpose(dsp.randchoose([c1, c2]), dsp.rand(0.25, 40.0)) beat = dsp.pad(beat, 0, blens[i] - dsp.flen(beat)) beat = dsp.amp(beat, dsp.rand(1, 4)) # add it to the output out += beat return out all = [] if 'c' in dsl: clapper = dsp.randchoose([clap1, clap2]) all += [clapper(beat)] if 'k' in dsl: all += [kick(beat)] if 'h' in dsl: all += [hat(beat)] out = dsp.mix(all) # out = dsp.vsplit(out, dsp.mstf(dsp.rand(8, 140)), dsp.mstf(500)) # out = dsp.randshuffle(out) # out = ''.join(out) out = dsp.vsplit(out, 10, 1000) out = [dsp.amp(o, dsp.rand(0, 4)) for o in out] out = [dsp.env(o, 'random') for o in out] out = [dsp.transpose(o, dsp.rand(0.25, 1)) for o in out] out = dsp.randshuffle(out) out = ''.join(out) out = dsp.pine(out, int(dsp.flen(out) * dsp.rand(1.5, 4)), dsp.rand(10, 2000), dsp.randint(0, 2), dsp.rand(1, 3), dsp.randint(0, 2), dsp.rand(1, 3)) out = dsp.amp(out, 0.65) glass = dsp.read('sounds/s/glass2.wav').data glass = dsp.vsplit(glass, dsp.mstf(1), dsp.mstf(100)) glass = dsp.randshuffle(glass) # glass = [ dsp.pad(g, 0, dsp.randint(10, 1000)) for g in glass ] # glass = [ dsp.transpose(g, dsp.rand(0.5, 1.5)) * dsp.randint(1, 3) for g in glass ] glass = ''.join(glass) glass = dsp.fill(glass, dsp.flen(out)) out = dsp.mix([out, glass]) return out
def play(params): length = params.get("length", dsp.mstf(10000)) buffer_index = params.get("buffer_index", False) sample_index = params.get("sample_index", False) buffer_length = params.get("buffer_length", dsp.stf(5)) volume = params.get("volume", 100.0) / 100.0 scale = params.get("scale", [25, 50, 100, 200]) octave = params.get("octave", 0) envelope = params.get("envelope", False) glitch = params.get("glitch", True) overdub = params.get("dub", False) pad = params.get("padding", False) pan = params.get("pan", False) if sample_index != False: out = dsp.read("samps/pre/buf-%s.wav" % str(sample_index)).data elif buffer_index != False: fname = "samps/buf-%s" % str(buffer_index) if not os.path.exists(fname + ".wav") or overdub == True: out = rt.capture(buffer_length, "T6_pair1", 1) out = sox("sox %s %s silence 1 0.1 1%% -1 0.1 1%%", out) out = dsp.transpose(out, 0.5) else: out = dsp.read("samps/buf-%s.wav" % str(buffer_index)).data else: out = rt.capture(buffer_length, "T6_pair1", 1) out = sox("sox %s %s silence 1 0.1 1%% -1 0.1 1%%", out) out = dsp.transpose(out, 0.5) speeds = [s / 100.0 for s in scale] # speeds = [ 0.25, 0.5, 1.0, 2.0 ] if glitch == True: grain_length = dsp.flen(out) / 4 out = dsp.vsplit(out, int(grain_length * 0.5), grain_length) numgrains = (length / grain_length) * 2 if len(out) < numgrains: for i in range(numgrains - len(out)): out += [dsp.randchoose(out)] layers = [] for index in range(1, 20): layer = dsp.randshuffle(out) if pad is not False: layer = [dsp.pad(grain, 0, pad) for grain in layer] layer = [dsp.env(grain, "sine") for grain in layer] layer = [dsp.transpose(grain, dsp.randchoose(speeds) * 2 ** octave * 0.25) for grain in layer] layer = "".join(layer) layer = dsp.pad(layer, grain_length / index, 0) layers += [layer] out = dsp.mix(layers, True, 10) if envelope == True: out = dsp.env(out, envelope) if buffer_index: fname = "samps/buf-%s" % str(buffer_index) if os.path.exists(fname + ".wav") and overdub == False: pass else: dsp.write(out, fname) if pan: out = dsp.pan(out, dsp.rand()) return out
grains = [makeGrains(gnote) for g in range(dsp.randint(4, 10))] for gi, grain in enumerate(grains): if dsp.randint(0, 1) == 0: grains[gi] = dsp.transpose(grain, 2) * 2 grains = dsp.mix(grains) grains = dsp.amp(grains, dsp.rand(0.25, 0.55)) grains = mixdrift(grains) layers += [grains] sounds = dsp.fill(dsp.mix(layers), tlen) if canPlay('ending', bigoldsection): sounds = dsp.vsplit(sounds, dsp.mstf(1), dsp.mstf(200)) sounds = [ dsp.pad(s, 0, dsp.mstf(dsp.rand(50, 250))) for s in sounds ] sounds = ''.join(sounds) subsection_length = dsp.flen(sounds) print 'subsection length:', dsp.fts(subsection_length), seg_index section += sounds section_length = dsp.flen(section) print 'section length:', dsp.fts(section_length) sections += [section] print
def play(params): volume = params.get('volume', dsp.rand(70.0, 100.0)) / 100.0 notes = params.get('note', [ dsp.randchoose(['c', 'f', 'e', 'a', 'd']) for i in range(2) ]) octave = params.get('octave', dsp.randint(1, 5)) root = params.get('root', 27.5) bpm = params.get('bpm', 75.0) if dsp.randint(0, 1) == 0: length = params.get('length', dsp.mstf(dsp.rand(10, 2000))) else: length = params.get('length', int(dsp.randint(1, 4) * dsp.bpm2frames(bpm) * 0.25)) env = params.get('envelope', 'random') env = params.get('envelope', 'tri') mod = params.get('mod', 'random') modFreq = params.get('modfreq', dsp.rand(1.0, 1.5) / dsp.fts(length)) modRange = params.get('speed', 0.01) modRange = dsp.rand(0, modRange) pulsewidth = params.get('pulsewidth', dsp.rand(0.01, 0.8)) window = params.get('window', 'gauss') #waveform = params.get('waveform', 'random') waveform = params.get('waveform', 'tri') glitch = params.get('glitch', True) pulsewidth = 1.0 freqs = [ tune.ntf(note, octave) for note in notes ] tune.a0 = float(root) mod = dsp.wavetable(mod, 512) window = dsp.wavetable(window, 512) waveform = dsp.wavetable(waveform, 512) layers = [] for freq in freqs: layers += [ dsp.pulsar(freq, length, pulsewidth, waveform, window, mod, modRange, modFreq, volume) ] out = dsp.mix(layers) try: out = dsp.env(out, env) except TypeError: out = dsp.env(out, 'sine') if glitch: bitlen = dsp.randint(dsp.mstf(10), dsp.mstf(500)) bit = dsp.cut(out, dsp.randint(0, len(out) - bitlen), bitlen) out = dsp.vsplit(out, dsp.mstf(10), dsp.mstf(500)) out.insert(dsp.randint(0, len(out) - 2), bit) out = ''.join(out) out = dsp.pan(out, dsp.rand()) return out
freq = dsp.rand(0.1, 5000) length = dsp.stf(slen) pulsewidth = dsp.rand(0.15, 1) waveform = [0] + dsp.breakpoint([ dsp.rand(-1, 1) for _ in range(dsp.randint(6, dsp.randint(10, 300))) ], 512) + [0] window = dsp.wavetable(dsp.randchoose(['tri', 'hann', 'sine']), 512) mod = dsp.breakpoint([ dsp.rand() for _ in range(dsp.randint(5, 2000)) ], 1024*4) modrange = dsp.rand(0.01, 10) modfreq = 1.0 / slen amp = dsp.rand(0.05, 0.25) layer = dsp.pulsar(freq, length, pulsewidth, waveform, window, mod, modrange, modfreq, amp) layer = fx.penv(layer) bits = [] layer = dsp.vsplit(layer, dsp.mstf(1), dsp.stf(0.2)) for bit in layer: if dsp.rand() > 0.75: bit = ''.join([ dsp.pan(dsp.amp(bit, dsp.rand(0.1, 10)), dsp.rand()) for _ in range(dsp.randint(2, 10)) ]) bits += [ bit ] layer = ''.join(bits) layers += [ layer ] out = dsp.mix(layers) now = datetime.now() filename = 'fart-%s-%s-%s-%s' % (now.year, now.month, now.day, now.hour)
def play(voice_id): bpm = config('bpm') beat = dsp.bpm2frames(bpm) dsl = P(voice_id, 'drum', 'h.c') length = int(P(voice_id, 'length', dsp.stf(dsp.rand(5, 12)))) volume = P(voice_id, 'volume', 70.0) volume = volume / 100.0 # TODO move into param filter octave = P(voice_id, 'octave', 3) notes = P(voice_id, 'note', '["%s"]' % config('key')) notes = json.loads(notes) hertz = P(voice_id, 'hertz', False) alias = P(voice_id, 'alias', False) alias = True bend = P(voice_id, 'bend', False) env = P(voice_id, 'envelope', 'gauss') harmonics = P(voice_id, 'harmonic', '[1,2,3,4]') harmonics = json.loads(harmonics) reps = P(voice_id, 'repeats', 1) waveform = P(voice_id, 'waveform', 'sine2pi') quality = getattr(tune, config('quality')) ratios = getattr(tune, config('tune')) glitch = False #glitch = True root = 27.5 pinecone = False bbend = False wild = False if bbend == True: bend = True tune.a0 = float(root) # These are amplitude envelopes for each partial, # randomly selected for each. Not to be confused with # the master 'env' param which is the amplit wtypes = ['sine', 'phasor', 'line', 'saw'] layers = [] if hertz is not False: notes = hertz for note in notes: tones = [] for i in range(dsp.randint(2, 4)): if hertz is not False: freq = float(note) if octave > 1: freq *= octave else: freq = tune.ntf(note, octave) snds = [ dsp.tone(length, freq * h, waveform, 0.05) for h in harmonics ] snds = [ dsp.env(s, dsp.randchoose(wtypes), highval=dsp.rand(0.3, 0.6)) for s in snds ] snds = [dsp.pan(s, dsp.rand()) for s in snds] if bend is not False: def bendit(out=''): if bbend == True: bendtable = dsp.randchoose([ 'impulse', 'sine', 'line', 'phasor', 'cos', 'impulse' ]) lowbend = dsp.rand(0.8, 0.99) highbend = dsp.rand(1.0, 1.25) else: bendtable = 'sine' lowbend = 0.99 # lowbend = 0.75 highbend = 1.01 # highbend = 1.5 out = dsp.split(out, 441) freqs = dsp.wavetable(bendtable, len(out)) freqs = [ math.fabs(f) * (highbend - lowbend) + lowbend for f in freqs ] out = [ dsp.transpose(out[i], freqs[i]) for i in range(len(out)) ] return ''.join(out) snds = [bendit(snd) for snd in snds] tones += [dsp.mix(snds)] layer = dsp.mix(tones) if wild != False: layer = dsp.vsplit(layer, 41, 4410) layer = [dsp.amp(dsp.amp(l, dsp.rand(10, 20)), 0.5) for l in layer] layer = ''.join(layer) if pinecone != False: layer = dsp.pine(layer, length, freq, 4) if glitch == True: layer = dsp.vsplit(layer, dsp.mstf(10), dsp.flen(layer) / 4) layer = dsp.randshuffle(layer) layer = ''.join(layer) layer = dsp.env(layer, env) layers += [layer] out = dsp.mix(layers) * reps return dsp.amp(out, volume)
def play(params): length = params.get('length', dsp.stf(20)) volume = params.get('volume', 0.3) octave = params.get('octave', 6) note = params.get('note', 'c') quality = params.get('quality', tune.major) multiple = params.get('multiple', 1) width = params.get('width', 0) waveform = params.get('waveform', 'vary') chirp = params.get('chirp', False) harmonics = params.get('harmonics', [1, 2]) scale = params.get('scale', [1, 4, 6, 5, 8]) wavetypes = params.get('wavetypes', ['sine', 'phasor', 'line', 'saw']) ratios = params.get('ratios', tune.terry) glitch = params.get('glitch', False) def chirp(s): length = dsp.flen(s) #chirps = [ dsp.chirp(dsp.randint(10, 10000), 60, 5000, dsp.randint(1,100)) for c in range(100) ] chirps = [ dsp.chirp( numcycles=dsp.randint(50, 1000), lfreq=dsp.rand(9000, 12000), hfreq=dsp.rand(14000, 20000), length=441 + (i * 41), etype=dsp.randchoose(['gauss', 'sine', 'line', 'phasor']), wform=dsp.randchoose(['sine', 'tri', 'phasor', 'line'])) for i in range(100) ] chirps = [ dsp.pan(c, dsp.rand()) for c in chirps ] chirps = ''.join(chirps) return dsp.fill(chirps, length) tones = [] multiple *= 1.0 freqs = tune.fromdegrees(dsp.randshuffle(scale), octave, note[0]) for i in range(dsp.randint(2,4)): #freq = tune.step(i, note, octave, dsp.randshuffle(scale), quality, ratios) freq = freqs[i % len(freqs)] snds = [ dsp.tone(length, freq * h, waveform) for h in harmonics ] for snd in snds: snd = dsp.vsplit(snd, dsp.mstf(10 * multiple), dsp.mstf(100 * multiple)) if width != 0: for ii, s in enumerate(snd): if width > dsp.mstf(5): owidth = int(width * dsp.rand(0.5, 2.0)) else: owidth = width olen = dsp.flen(s) s = dsp.cut(s, 0, owidth) s = dsp.pad(s, 0, olen - dsp.flen(s)) snd[ii] = s snd = [ dsp.env(s, dsp.randchoose(wavetypes)) for s in snd ] snd = [ dsp.pan(s, dsp.rand()) for s in snd ] snd = [ dsp.amp(s, dsp.rand()) for s in snd ] if chirp == True: snd = [ chirp(s) for s in snd ] snd = ''.join(snd) tones += [ snd ] out = dsp.mix(tones) out = dsp.pan(out, dsp.rand()) return dsp.amp(out, volume)
[dsp.rand(-1, 1) for _ in range(dsp.randint(6, dsp.randint(10, 300)))], 512) + [0] window = dsp.wavetable(dsp.randchoose(['tri', 'hann', 'sine']), 512) mod = dsp.breakpoint([dsp.rand() for _ in range(dsp.randint(5, 2000))], 1024 * 4) modrange = dsp.rand(0.01, 10) modfreq = 1.0 / slen amp = dsp.rand(0.05, 0.25) layer = dsp.pulsar(freq, length, pulsewidth, waveform, window, mod, modrange, modfreq, amp) layer = fx.penv(layer) bits = [] layer = dsp.vsplit(layer, dsp.mstf(1), dsp.stf(0.2)) for bit in layer: if dsp.rand() > 0.75: bit = ''.join([ dsp.pan(dsp.amp(bit, dsp.rand(0.1, 10)), dsp.rand()) for _ in range(dsp.randint(2, 10)) ]) bits += [bit] layer = ''.join(bits) layers += [layer] out = dsp.mix(layers)
grains = [ makeGrains(gnote) for g in range(dsp.randint(4, 10)) ] for gi, grain in enumerate(grains): if dsp.randint(0,1) == 0: grains[gi] = dsp.transpose(grain, 2) * 2 grains = dsp.mix(grains) grains = dsp.amp(grains, dsp.rand(0.25, 0.55)) grains = mixdrift(grains) layers += [ grains ] sounds = dsp.fill(dsp.mix(layers), tlen) if canPlay('ending', bigoldsection): sounds = dsp.vsplit(sounds, dsp.mstf(1), dsp.mstf(200)) sounds = [ dsp.pad(s, 0, dsp.mstf(dsp.rand(50, 250))) for s in sounds ] sounds = ''.join(sounds) subsection_length = dsp.flen(sounds) print 'subsection length:', dsp.fts(subsection_length), seg_index section += sounds section_length = dsp.flen(section) print 'section length:', dsp.fts(section_length) sections += [ section ] print
def play(voice_id): bpm = config('bpm') beat = dsp.bpm2frames(bpm) dsl = P(voice_id, 'drum', 'h.c') length = int(P(voice_id, 'length', dsp.stf(dsp.rand(5, 12)))) volume = P(voice_id, 'volume', 70.0) volume = volume / 100.0 # TODO move into param filter octave = P(voice_id, 'octave', 3) notes = P(voice_id, 'note', '["%s"]' % config('key')) notes = json.loads(notes) hertz = P(voice_id, 'hertz', False) alias = P(voice_id, 'alias', False) alias = True bend = P(voice_id, 'bend', False) env = P(voice_id, 'envelope', 'gauss') harmonics = P(voice_id, 'harmonic', '[1,2,3,4]') harmonics = json.loads(harmonics) reps = P(voice_id, 'repeats', 1) waveform = P(voice_id, 'waveform', 'sine2pi') quality = getattr(tune, config('quality')) ratios = getattr(tune, config('tune')) glitch = False #glitch = True root = 27.5 pinecone = False bbend = False wild = False if bbend == True: bend = True tune.a0 = float(root) # These are amplitude envelopes for each partial, # randomly selected for each. Not to be confused with # the master 'env' param which is the amplit wtypes = ['sine', 'phasor', 'line', 'saw'] layers = [] if hertz is not False: notes = hertz for note in notes: tones = [] for i in range(dsp.randint(2,4)): if hertz is not False: freq = float(note) if octave > 1: freq *= octave else: freq = tune.ntf(note, octave) snds = [ dsp.tone(length, freq * h, waveform, 0.05) for h in harmonics ] snds = [ dsp.env(s, dsp.randchoose(wtypes), highval=dsp.rand(0.3, 0.6)) for s in snds ] snds = [ dsp.pan(s, dsp.rand()) for s in snds ] if bend is not False: def bendit(out=''): if bbend == True: bendtable = dsp.randchoose(['impulse', 'sine', 'line', 'phasor', 'cos', 'impulse']) lowbend = dsp.rand(0.8, 0.99) highbend = dsp.rand(1.0, 1.25) else: bendtable = 'sine' lowbend = 0.99 # lowbend = 0.75 highbend = 1.01 # highbend = 1.5 out = dsp.split(out, 441) freqs = dsp.wavetable(bendtable, len(out)) freqs = [ math.fabs(f) * (highbend - lowbend) + lowbend for f in freqs ] out = [ dsp.transpose(out[i], freqs[i]) for i in range(len(out)) ] return ''.join(out) snds = [ bendit(snd) for snd in snds ] tones += [ dsp.mix(snds) ] layer = dsp.mix(tones) if wild != False: layer = dsp.vsplit(layer, 41, 4410) layer = [ dsp.amp(dsp.amp(l, dsp.rand(10, 20)), 0.5) for l in layer ] layer = ''.join(layer) if pinecone != False: layer = dsp.pine(layer, length, freq, 4) if glitch == True: layer = dsp.vsplit(layer, dsp.mstf(10), dsp.flen(layer) / 4) layer = dsp.randshuffle(layer) layer = ''.join(layer) layer = dsp.env(layer, env) layers += [ layer ] out = dsp.mix(layers) * reps return dsp.amp(out, volume)
def play(params=None): params = params or {} length = params.get('length', dsp.stf(dsp.rand(5, 12))) volume = params.get('volume', 20.0) volume = volume / 100.0 # TODO move into param filter octave = params.get('octave', 1) notes = params.get('note', ['c', 'g']) hertz = params.get('hertz', False) quality = params.get('quality', tune.major) glitch = params.get('glitch', False) waveform = params.get('waveform', 'sine') ratios = params.get('ratios', tune.terry) alias = params.get('alias', False) wild = params.get('wii', False) bend = params.get('bend', False) bbend = params.get('bbend', False) env = params.get('envelope', 'gauss') harmonics = params.get('harmonic', [1,2]) reps = params.get('repeats', 1) root = params.get('root', 27.5) pinecone = params.get('pinecone', False) if bbend == True: bend = True tune.a0 = float(root) # These are amplitude envelopes for each partial, # randomly selected for each. Not to be confused with # the master 'env' param which is the amplit wtypes = ['sine', 'phasor', 'line', 'saw'] layers = [] if hertz is not False: notes = hertz for note in notes: tones = [] for i in range(dsp.randint(2,4)): if hertz is not False: freq = float(note) if octave > 1: freq *= octave else: freq = tune.ntf(note, octave) snds = [ dsp.tone(length, freq * h, waveform, 0.05) for h in harmonics ] snds = [ dsp.env(s, dsp.randchoose(wtypes), highval=dsp.rand(0.2, 0.4)) for s in snds ] snds = [ dsp.pan(s, dsp.rand()) for s in snds ] if bend is not False: def bendit(out=''): if bbend == True: bendtable = dsp.randchoose(['impulse', 'sine', 'line', 'phasor', 'cos', 'impulse']) lowbend = dsp.rand(0.8, 0.99) highbend = dsp.rand(1.0, 1.25) else: bendtable = 'sine' lowbend = 0.99 highbend = 1.01 out = dsp.split(out, 441) freqs = dsp.wavetable(bendtable, len(out)) freqs = [ math.fabs(f) * (highbend - lowbend) + lowbend for f in freqs ] out = [ dsp.transpose(out[i], freqs[i]) for i in range(len(out)) ] return ''.join(out) snds = [ bendit(snd) for snd in snds ] tones += [ dsp.mix(snds) ] layer = dsp.mix(tones) if wild != False: layer = dsp.vsplit(layer, 41, 4410) layer = [ dsp.amp(dsp.amp(l, dsp.rand(10, 20)), 0.5) for l in layer ] layer = ''.join(layer) if pinecone != False: layer = dsp.pine(layer, length, freq, 4) layer = dsp.env(layer, env) layers += [ layer ] out = dsp.mix(layers) * reps # Format is: [ path, offset, id, value ] if hertz is not False: osc_message = ['/dac', 0.0, 0, tune.fts(notes[0])] else: osc_message = ['/dac', 0.0, 0, tune.nts(notes[0], octave - 1)] #return (dsp.amp(out, volume), {'osc': [ osc_message ]}) return dsp.amp(out, volume)
def play(ctl): param = ctl.get('param') lpd = ctl.get('midi').get('lpd') scale = [ dsp.randchoose([1, 3, 5, 6, 8]) for s in range(dsp.randint(2, 4)) ] #scale = [ dsp.randchoose([1, 2, 4, 6, 8]) for s in range(dsp.randint(2, 4)) ] freqs = tune.fromdegrees(scale, root='a', octave=dsp.randint(2,3), scale=tune.minor) freq = dsp.randchoose(freqs) pw = lpd.get(2, low=0.01, high=1, default=1) pw = dsp.rand(0.01, 1) modr = lpd.get(6, low=0.001, high=0.1) modr = dsp.rand(0.001, 0.05) #modr = dsp.rand(0.1, 10.5) #modr = dsp.rand(0.001, 0.01) modr = dsp.rand(0, modr) modf = dsp.rand(0.01, 0.05) amp = lpd.get(1, low=0, high=2, default=0) #amp = dsp.rand(0.1, 0.5) #amp = 0 length = dsp.stf(lpd.get(5, low=0.5, high=14, default=1) * dsp.rand(0.75, 2)) length = dsp.stf(dsp.rand(5.5, 24) * dsp.rand(0.75, 2)) #length = dsp.stf(dsp.rand(0.5, 0.75) * dsp.rand(0.75, 2)) wf = dsp.breakpoint([0] + [ dsp.rand(-1, 1) for w in range(10) ] + [0], 512) #wf = dsp.wavetable('sine2pi', 512) #wf = dsp.wavetable('sine2pi', 512) #win = dsp.wavetable('sine', 512) win = dsp.breakpoint([0] + [ dsp.rand(0, 1) for w in range(5) ] + [0], 512) mod = dsp.breakpoint([0] + [ dsp.rand(0, 1) for m in range(5) ] + [0], 512) layers = [] harmonics = [1, 2, 3, 4] for harmonic in harmonics: f = freq * harmonic if harmonic > 4: a = dsp.rand(0.05, 0.1) else: a = amp * dsp.rand(0.1, 0.5) layer = dsp.pulsar(f, length, pw, wf, win, mod, modr, modf, a * 2) layer = dsp.env(layer, dsp.randchoose(['sine', 'tri', 'line', 'phasor'])) layer = dsp.taper(layer) layer = dsp.pan(layer, dsp.rand()) layer = dsp.mix([ dsp.drift(layer, dsp.rand(0.01, 0.03)), layer ]) if dsp.rand() > 0.5: layer = dsp.vsplit(layer, dsp.mstf(50), dsp.mstf(500)) bit = dsp.randchoose(layer) bit = bit * dsp.randint(1, 3) bit = dsp.transpose(bit, dsp.randchoose([1, 2, 4, 8])) layer = ''.join(layer) layer = dsp.insert_into(layer, bit, dsp.randint(0, dsp.flen(layer) - dsp.flen(bit))) layers += [ layer ] out = dsp.mix(layers) out = dsp.env(out, 'sine') out = dsp.env(out, 'hann') #out = dsp.env(out, 'phasor') out = dsp.taper(out) return out
layers = [] for i in range(30): l = dsp.pine(dsp.amp(thirty, 0.1), dsp.stf(30), dsp.randchoose(freqs)) l = dsp.pan(l, dsp.rand()) layers += [ l ] out = dsp.mix(layers) dsp.write(out, 'wesley_thirty_03') ## 04 out = '' for count in range(5): t = dsp.randchoose(snds) t = dsp.vsplit(t, 1, dsp.mstf(20)) for i, g in enumerate(t): if dsp.randint(0,5) == 0: t[i] = g * dsp.randint(1, 30) t[i] = dsp.pan(t[i], dsp.rand()) out += ''.join(t) dsp.write(out, 'wesley_thirty_04') ## 05 out = '' freqs = tune.fromdegrees([1, 3, 5, 9], 3, 'c') freqs2 = tune.fromdegrees([8, 6, 3, 1], 3, 'c') slen = dsp.flen(wesley) / 30
def play(voice_id): bpm = config('bpm') beat = dsp.bpm2frames(bpm) dsl = P(voice_id, 'drum', '["c","k","h"]') dsp.log(dsl) dsl = json.loads(dsl) def hat(beat): length = beat * 4 nbeats = 16 blen = length / nbeats out = '' for b in range(nbeats): h = dsp.transpose(tape1, 9) h = dsp.fill(h, dsp.mstf(dsp.rand(1, 20))) h = dsp.env(h, 'phasor') h = dsp.amp(h, dsp.rand(0, 0.8)) h = dsp.pad(h, 0, blen - dsp.flen(h)) out += h out *= 8 return out def kick(beat): out = drums.sinekick(length=beat, amp=dsp.rand(0.8, 1)) out = dsp.pad(out, 0, beat * dsp.randint(1, 2)) out *= 2 return out def clap1(beat): c = dsp.read('sounds/mikeclap.wav').data c = dsp.transpose(c, dsp.rand(1, 2.5)) c = dsp.fill(c, dsp.mstf(dsp.rand(10, 100))) c = dsp.env(c, 'phasor') c = dsp.amp(c, dsp.rand(1, 3)) c = dsp.pad(c, 0, beat - dsp.flen(c)) blen = beat / dsp.randchoose([1,2]) c = dsp.pad(c, blen, 0) c *= 4 return c def clap2(beat): nlens = [ beat * 2, beat, beat / 2, ] # length of pattern (in beats) nbeats = dsp.randint(10, 15) # beat lengths (from a set of bpm-derived note lengths defined in the nlens list) blens = [ dsp.randchoose(nlens) for b in range(nbeats) ] out = '' # synthesize the tones for i in range(nbeats): beat = dsp.transpose(dsp.randchoose([c1,c2]), dsp.rand(0.25, 40.0)) beat = dsp.pad(beat, 0, blens[i] - dsp.flen(beat)) beat = dsp.amp(beat, dsp.rand(1, 4)) # add it to the output out += beat return out all = [] if 'c' in dsl: clapper = dsp.randchoose([clap1,clap2]) all += [ clapper(beat) ] if 'k' in dsl: all += [ kick(beat) ] if 'h' in dsl: all += [ hat(beat) ] out = dsp.mix(all) # out = dsp.vsplit(out, dsp.mstf(dsp.rand(8, 140)), dsp.mstf(500)) # out = dsp.randshuffle(out) # out = ''.join(out) out = dsp.vsplit(out, 10, 1000) out = [ dsp.amp(o, dsp.rand(0, 4)) for o in out ] out = [ dsp.env(o, 'random') for o in out ] out = [ dsp.transpose(o, dsp.rand(0.25, 1)) for o in out ] out = dsp.randshuffle(out) out = ''.join(out) out = dsp.pine(out, int(dsp.flen(out) * dsp.rand(1.5, 4)), dsp.rand(10, 2000), dsp.randint(0, 2), dsp.rand(1, 3), dsp.randint(0, 2), dsp.rand(1, 3)) out = dsp.amp(out, 0.65) glass = dsp.read('sounds/s/glass2.wav').data glass = dsp.vsplit(glass, dsp.mstf(1), dsp.mstf(100)) glass = dsp.randshuffle(glass) # glass = [ dsp.pad(g, 0, dsp.randint(10, 1000)) for g in glass ] # glass = [ dsp.transpose(g, dsp.rand(0.5, 1.5)) * dsp.randint(1, 3) for g in glass ] glass = ''.join(glass) glass = dsp.fill(glass, dsp.flen(out)) out = dsp.mix([ out, glass ]) return out