def play(voice_id): bpm = config('bpm') beat = dsp.bpm2frames(bpm) root = config('key') quality = getattr(tune, config('quality')) ratios = getattr(tune, config('tune')) bar = beat * dsp.randchoose([8, 16, 32]) groot = tune.ntf('c') scale = tune.fromdegrees([1,3,5,6,8,9], root=root, octave=2, ratios=ratios) v = dsp.read('sounds/vibesc1.wav').data out = '' # lens = [ bar / 5, bar / 8, bar / 12 ] lens = [ bar / 6, bar / 8, bar / 16 ] maxbend = 2 maxbend = 0.02 layers = [] for nlen in lens: layer = '' nlen /= 2 note = dsp.transpose(v, (dsp.randchoose(scale) * 2**dsp.randint(0, 3)) / groot) note = dsp.fill(note, nlen) note = dsp.env(note, 'phasor') note = dsp.amp(note, 0.125) nbeats = bar / nlen for b in range(nbeats): b = dsp.pan(note, dsp.rand()) b = dsp.drift(b, dsp.rand(0, dsp.rand(0.01, maxbend))) if dsp.flen(b) < nlen: b = dsp.pad(b, 0, nlen - dsp.flen(b)) # if dsp.rand() > 0.5: # b = dsp.vsplit(b, dsp.flen(b) / 3, dsp.flen(b) / 2) # b = dsp.randshuffle(b) # b = [ dsp.amp(bb, dsp.rand(0.5, 2)) for bb in b ] # b = ''.join(b) layer += b # layer = dsp.fill(layer, bar) layers += [ layer ] out = dsp.mix(layers) out = dsp.fill(out, bar) 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) nlen = beat / dsp.randchoose([4,5,6,7,8,9,10]) root = 340.0 target = tune.ntf(key) n = dsp.read('sounds/mike.wav').data n = dsp.transpose(n, target / root) n = dsp.amp(n, 0.4) length = dsp.randint(16, 64) * beat ngrains = length / nlen n = dsp.transpose(n, dsp.randchoose([0.5, 1, 2, 2, 4, 4])) n = dsp.split(n, nlen) snd = dsp.randchoose(n) snd = dsp.env(snd, 'sine') grains = [ snd for i in range(ngrains) ] grains = [ dsp.pan(grain, dsp.rand()) for grain in grains ] out = ''.join(grains) out = dsp.env(out, 'sine') # out = dsp.pad(out, 0, dsp.stf(dsp.randint(0.5, 3))) return out
def play(voice_id): """ Every generator script must define a play() function, which accepts a voice_id integer (so you can read and write params for each voice) and returns a sound. The shortname and name metadata above are optional, if you don't include them the name will be drawn from the filename and the shortname will be the first two characters of that name. """ # Get the current bpm set in our session bpm = C('bpm') # Convert it to a length in frames beat = dsp.bpm2frames(bpm) # Read per-instance param, with a default value volume = P(voice_id, 'volume', default=1.0) # Get a frequency for the beep freq = tune.ntf('a', octave=2) # Beep for a beat out = dsp.tone(length=beat, freq=freq, wavetype='sine2pi', amp=volume) # Be silent for a beat after the beep out = dsp.pad(out, 0, beat) # Log the length of the computed buffer. # I like to tail -f pippi.log during performance. dsp.log('voice %s length: %.2f' % (voice_id, dsp.fts(dsp.flen(out)))) # Pass along the final buffer for playback return out
def play(voice_id): reload(keys) bpm = config('bpm') root = config('key') quality = getattr(tune, config('quality')) ratios = getattr(tune, config('tune')) scale = [1,5,8] if dsp.rand() > 0.5: scale = reversed(scale) freqs = tune.fromdegrees(scale, root=root, octave=dsp.randint(1, 3), ratios=ratios, scale=quality) freqs = dsp.rotate(freqs, dsp.randint(0, len(freqs))) out = '' length = int(dsp.bpm2frames(bpm) * dsp.randchoose([0.25, 0.5, 1]) * 0.5) length = dsp.bpm2frames(bpm) * 4 length = dsp.stf(dsp.rand(1, 8)) for n in range(dsp.randint(1, 3)): amp = dsp.rand(0.3, 0.65) freq = dsp.randchoose(freqs) freq = freqs[n%len(freqs)] b = keys.chippy(length=length, freq=freq, amp=amp) b = dsp.split(b, 100) oenvs = dsp.breakpoint([0,0,0,0] + [ dsp.rand() for i in range(len(b) / 10) ], len(b)) opans = dsp.breakpoint([dsp.rand(0.4, 0.6)] + [ dsp.rand() for i in range(len(b) / 100) ] + [0.5], len(b)) b = [ dsp.amp(b[i], oenvs[i]) for i in range(len(b)) ] b = [ dsp.pan(b[i], opans[i]) for i in range(len(b)) ] b = ''.join(b) #b = dsp.env(b, 'phasor') b = dsp.env(b, 'sine') out += b return out
def play(voice_id): bpm = config('bpm') root = config('key') quality = getattr(tune, config('quality')) ratios = getattr(tune, config('tune')) bendfactor = 0.05 # bendfactor = 0 bdiv = 4 bdiv *= dsp.randchoose([16, 24, 32]) loctave = 1 hoctave = 4 si = 32 * dsp.randint(1, 2) beat = dsp.bpm2frames(bpm) / bdiv y = [easeOutQuad(float(i), 0, 1, si) for i in range(si)] z = [easeOutQuad(float(i), 0, 1, si) for i in reversed(range(si))] freqs = tune.fromdegrees([1, 2, 3, 4, 5, 6, 7, 8], root=root, octave=dsp.randint(loctave, hoctave), ratios=ratios, scale=quality) freqs = freqs[:dsp.randint(1, len(freqs))] if dsp.rand() > 0.5: freqs = [f for f in reversed(freqs)] freqs = dsp.rotate(freqs, dsp.randint(0, len(freqs))) y = y + z y = [dsp.mstf(v * beat) + dsp.mstf(2) for v in y] x = range(len(y)) def make(length, freq): freq *= dsp.rand(1 - (bendfactor / 2.0), 1 + (bendfactor / 2.0)) out = keys.chippy(length=int(length * dsp.rand(0.01, 0.4)), freq=freq, amp=0.7) out = dsp.env(out, 'phasor') out = dsp.pad(out, 0, length - dsp.flen(out)) return out out = [make(v, freqs[i % len(freqs)]) for i, v in enumerate(y)] out = ''.join(out) out = dsp.pan(out, dsp.rand(0, 1)) 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') 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')) bendfactor = 0.05 # bendfactor = 0 bdiv = 4 bdiv *= dsp.randchoose([16, 24, 32]) loctave = 1 hoctave = 4 si = 32 * dsp.randint(1, 2) beat = dsp.bpm2frames(bpm) / bdiv y = [ easeOutQuad(float(i), 0, 1, si) for i in range(si) ] z = [ easeOutQuad(float(i), 0, 1, si) for i in reversed(range(si)) ] freqs = tune.fromdegrees([1,2,3,4,5,6,7,8], root=root, octave=dsp.randint(loctave, hoctave), ratios=ratios, scale=quality) freqs = freqs[:dsp.randint(1, len(freqs))] if dsp.rand() > 0.5: freqs = [ f for f in reversed(freqs) ] freqs = dsp.rotate(freqs, dsp.randint(0, len(freqs))) y = y + z y = [ dsp.mstf(v * beat) + dsp.mstf(2) for v in y ] x = range(len(y)) def make(length, freq): freq *= dsp.rand(1 - (bendfactor / 2.0), 1 + (bendfactor / 2.0)) out = keys.chippy(length=int(length*dsp.rand(0.01, 0.4)), freq=freq, amp=0.7) out = dsp.env(out, 'phasor') out = dsp.pad(out, 0, length - dsp.flen(out)) return out out = [ make(v, freqs[i % len(freqs)]) for i,v in enumerate(y) ] out = ''.join(out) out = dsp.pan(out, dsp.rand(0,1)) 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 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 play(voice_id): bpm = C('bpm') beat = dsp.bpm2frames(bpm) volume = P(voice_id, 'volume', default=1.0) chord = dsp.read('sounds/sag1.wav').data bass = dsp.read('sounds/sag2.wav').data out = '' for i in range(32): b = dsp.amp(bass, 0.5) b = dsp.transpose(b, 2) b *= 2 bar = dsp.flen(b) / 2 blayers = [] for blayer in range(3): blayer = dsp.split(b, bar / dsp.randchoose([6, 12])) blayer = dsp.randshuffle(blayer) blayer = blayer[:2] blayer = ''.join(blayer) blayer = dsp.pan(blayer, dsp.rand()) # blayer *= dsp.randint(2, 8) blayers += [ blayer ] b = dsp.mix(blayers) c = dsp.amp(chord, 0.5) c = dsp.fill(c, bar / dsp.randchoose([8, 16, 12, 24])) c = dsp.fill(c, dsp.flen(b)) out += dsp.mix([ b, c ]) dsp.log('voice %s length: %.2f' % (voice_id, dsp.fts(dsp.flen(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
from pippi import dsp, tune from hcj import drums, keys ssnd = dsp.read('samples/jess/snare.wav').data lssnd = dsp.read('samples/jess/rimshot.wav').data hsnd = dsp.read('samples/jess/tamb_rattle.wav').data ohsnd = dsp.read('samples/jess/skitter.wav').data ksnd = dsp.read('samples/jess/kickshuffle.wav').data bksnd = dsp.read('samples/jess/kickcym.wav').data bksnd = dsp.mix([ bksnd, dsp.read('samples/jess/smash.wav').data ]) beat = dsp.bpm2frames(166) key = 'b' out = '' elapsed = 0 count = 0 tlength = dsp.stf(120) def makeRhodes(length, beat, freqs): root = tune.ntf(key, 2) for i, freq in enumerate(freqs): if freq > root * 2.5: freqs[i] = freq * 0.5 chord = [ keys.rhodes(length, freq, dsp.rand(0.4, 0.6)) for freq in freqs ] chord = dsp.randshuffle(chord) pause = 0 for i, c in enumerate(chord):
def play(ctl): mpk = ctl.get('midi').get('mpk') ccs = [ i + 48 for i in range(24) ] notes = [] for cc in ccs: if mpk.get(cc) < 1: notes += [ cc ] ssnd = dsp.read('/home/hecanjog/sounds/drums/78sd.wav').data ssnd = dsp.read('jesssnare.wav').data hsnd = dsp.read('/home/hecanjog/sounds/drums/Shaker.wav').data ksnd = dsp.read('/home/hecanjog/sounds/drums/Drybd2.wav').data #ksnd = dsp.read('jesskick.wav').data beat = dsp.bpm2frames(90) #beat = dsp.mstf(290 * 2) length = beat * 4 hat = 'xxx ' kick = 'x ' snare = ' x ' #snare = ' x xx' #snare = ' ' def makeHat(length, i, amp): h = hsnd h = dsp.env(h, 'phasor') h = dsp.pad(h, 0, length - dsp.flen(h)) return h def makeKick(length, i, amp): k = dsp.mix([ ksnd, drums.sinekick(length, i, amp) ]) #k = dsp.env(ksnd, 'phasor') k = dsp.fill(k, length, silence=True) k = dsp.amp(k, 1) return k def makeSnare(length, i, amp): s = ssnd s = dsp.amp(s, 1.2) s = dsp.transpose(s, dsp.rand(1.5, 3)) s = dsp.fill(s, length, silence=True) #ss = dsp.drift(s, dsp.rand(0.001, 0.1)) #s = dsp.mix([s, ss]) return s #hats = drums.parsebeat(hat, 16, beat, length, makeHat, 25) hats = drums.parsebeat(hat, 16, beat, length, makeHat, 0) kicks = drums.parsebeat(kick, 16, beat, length, makeKick, 0) snares = drums.parsebeat(snare, 8, beat, length, makeSnare, 0) out = dsp.mix([hats,kicks,snares]) shuf = True shuf = False if shuf: out = dsp.split(out, beat) out = dsp.randshuffle(out) out = ''.join(out) out = dsp.amp(out, 2) cuts = True if dsp.rand() > 0.5 else False cuts = True #cuts = False if cuts: o = dsp.split(out, beat / 2) o = dsp.randshuffle(o) o = [ dsp.amp(oo, dsp.rand(0, 2.5)) for oo in o ] o = [ dsp.env(oo, 'random') for oo in o ] out = dsp.mix([ ''.join(o), out ]) dsp.log(notes) synthy = False #synthy = True if synthy == True: s = '' for ii in range(dsp.flen(out) / (beat/2)): layers = [] if len(notes) > 0: scale = [ n - 47 for n in notes ] scale = [1,5,8,12] scale = tune.fromdegrees(scale, octave=3, root='d') p = ''.join([ keys.pulsar(scale[ii % len(scale)], pulsewidth=dsp.rand(0.1, 1), amp=0.5, length=(beat/2) / 3) for _ in range(3) ]) layers += [ p ] else: layers += [ dsp.pad('', beat / 2, 0) ] s += dsp.mix(layers) out = dsp.mix([ s, out ]) #out = dsp.alias(out) #out = dsp.drift(out, dsp.rand(0.5, 2)) 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) amp = dsp.rand(0.1, 0.65) nlens = [ beat * 4, beat * 3, beat * 2, beat + (beat / 2), beat, beat / 2, beat / 4, ] scale = [2, 4, 6, 9] scale = [1, 4, 6, 8] # scale = [1,3,4,5,6,8,9] # scale = [1,2,3,5,6,8,9] # scale = [1,5,8] freqs = tune.fromdegrees(scale, root=root, octave=dsp.randint(2, 4), ratios=ratios, scale=quality) # length of pattern (in beats) elen = 0 tlen = beat * dsp.randint(2, 8) # beat lengths (from a set of bpm-derived note lengths defined in the nlens list) blens = [] while elen < tlen: l = dsp.randchoose(nlens) blens += [l] elen += l # beat pulsewidths bpws = [dsp.rand(0.1, 1) for pw in range(len(blens))] out = '' # choose a pitch from the scale freq = dsp.randchoose(freqs) # synthesize the tones for i in range(len(blens)): # find the length of the pulse blen = int(round(blens[i] * bpws[i])) # find the length of the rest brest = blens[i] - blen # make a rhodes tone with a random amplitude #beat = keys.rhodes(length=blen, freq=freq, amp=dsp.rand(0.3, 0.5)) beat = keys.rhodes(length=blen, freq=freq, amp=amp) # pan the tone to a random position beat = dsp.pan(beat, dsp.rand()) # bitcrush the tone a random amount # beat = dsp.alias(beat) # pad the tone with silence beat = dsp.pad(beat, 0, brest) # add it to the output out += beat out *= dsp.randint(1, 2) if dsp.rand() > 0.75: out = dsp.split(out, dsp.bpm2frames(bpm) / dsp.randchoose([1, 2, 4])) out = dsp.randshuffle(out) out = ''.join(out) return out
def play(voice_id): tel = bot.getTel() if 'sparse' in tel['name'] or 'ballsout' in tel['name'] and dsp.rand(0, 100) > 70: dsp.log('') dsp.log(voice_id + ' pulsar silent') bot.show_telemetry(tel) #return dsp.pad('', 0, dsp.stf(dsp.rand(1, 10))) ##################### # PARAMS ##################### volume = dsp.rand(0.4, 0.7) melodies = [[dsp.randchoose([1, 5, 6])]] if tel['density'] >= 4: melodies += [ [ dsp.randchoose([1, 2, 9, 5, 6]) for i in range(2) ] for m in range(dsp.randint(2, 4)) ] if tel['density'] >= 6: melodies += [ [ dsp.randchoose([1, 2, 9, 3, 4, 5, 6, 7]) for i in range(dsp.randint(3, 6)) ] for m in range(dsp.randint(2, 5)) ] try: notes = dsp.randchoose(melodies) except IndexError: dsp.log(melodies) notes = [1] if tel['harmonicity'] <= 5: octave = (tel['register'] / 10.0) * dsp.randint(1, 3) + 1 else: octave = int(round((tel['register'] / 10.0) * dsp.randint(1, 3) + 1)) bpm = p(voice_id, 'bpm', 80.0) if 'ballsout' in tel['name']: length = int((1.0 / (tel['pace'] / 10.0)) * dsp.stf(3)) else: length = int((1.0 / (tel['pace'] / 10.0)) * dsp.stf(4)) + dsp.stf(dsp.rand(0.25, 1)) # Cap voice length at 60 secs if length > dsp.stf(60): length = dsp.stf(60) env = 'sine' mod = p(voice_id, 'mod', 'random') modFreq = p(voice_id, 'modfreq', dsp.rand(1.0, 2.5) / dsp.fts(length)) modRange = dsp.rand(0.01, 0.04) modRange = dsp.rand(0, modRange) pulsewidth = 1.0 / (tel['roughness'] / 10.0) pulsewidth -= dsp.rand(0, 0.09) if pulsewidth < 0.1: pulsewidth = 0.1 beat = dsp.bpm2frames(bpm) try: freqs = tune.fromdegrees(notes, octave=octave, ratios=tune.just, root='c') except TypeError: print 'hm', notes, octave freqs = tune.fromdegrees([1,5], octave=octave, ratios=tune.just, root='c') ##################### # NORMAL ##################### numgrains = int(dsp.rand(50, 500)) if tel['roughness'] <= 2: window = 'sine' waveform = 'sine2pi' minplen = dsp.ftms(length / 4) maxplen = 30000 elif tel['roughness'] <= 4: window = 'sine' waveform = 'sine2pi' minplen = 10 maxplen = 350 elif tel['roughness'] > 4: window = 'tri' waveform = 'tri' minplen = 10 maxplen = 120 elif tel['roughness'] >= 7: window = 'vary' waveform = 'tri' minplen = 5 maxplen = 80 mod = dsp.wavetable(mod, 512) window = dsp.wavetable(window, 512) waveform = dsp.wavetable(waveform, 512) pc = dsp.breakpoint([ dsp.rand(0, 1) for i in range(int(dsp.rand(5, numgrains))) ], numgrains) out = '' outlen = 0 count = 0 bar = dsp.randint(4, 8) dobeats = tel['density'] > 5 and dsp.rand(0, 100) > 20 if dobeats: numbeats = bar * dsp.randint(3, 7) while outlen < length: layers = [] if dobeats: plen = beat / dsp.randint(1, 10) else: plen = dsp.mstf(dsp.rand(minplen, maxplen)) if tel['register'] >= 6 and tel['density'] >= 4: maxo = dsp.randint(2, 6) else: maxo = 1 if dobeats: freqs = dsp.randshuffle(freqs) for b in range(numbeats): f = freqs[b % len(freqs)] if dsp.rand(0, 100) > 70: f *= 2**dsp.randint(0, maxo) b = dsp.pulsar(f, plen, pulsewidth, waveform, window, mod, modRange, modFreq, volume) b = dsp.pan(b, dsp.rand()) out += b outlen += dsp.flen(b) else: for iff, freq in enumerate(freqs): if 'gentle' in tel['name']: volume = dsp.rand(0.5, 0.6) elif 'sparse' in tel['name']: volume = dsp.rand(0.3, 0.6) elif 'upbeat' in tel['name'] or 'ballsout' in tel['name']: volume = dsp.rand(0.5, 0.6) else: volume = dsp.rand(0.4, 0.6) if dsp.rand(0, 100) > 60: freq *= 2**dsp.randint(0, maxo) layer = dsp.pulsar(freq, plen, pulsewidth, waveform, window, mod, modRange, modFreq, volume) layer = dsp.env(layer, 'sine') layer = dsp.pan(layer, dsp.rand()) layers += [ layer ] layer = dsp.mix(layers) out += layer outlen += dsp.flen(layer) count += 1 out = dsp.env(out, 'sine') #if dsp.flen(out) > dsp.mstf(100) and dsp.rand(0, 100) > 50: #out = dsp.drift(out, (tel['harmonicity'] - 10.0) * -1 * 0.1, dsp.randint(4, 441)) dsp.log('') dsp.log('pulsar') dsp.log('%s length: %.2f' % (voice_id, dsp.fts(dsp.flen(out)))) bot.show_telemetry(tel) return out
def play(ctl): mpk = ctl.get('midi').get('mpk') ssnd = dsp.read('/home/hecanjog/sounds/drums/78sd.wav').data lssnd = dsp.read('jesssnare.wav').data hsnd = dsp.read('/home/hecanjog/sounds/drums/78ch.wav').data ohsnd = dsp.read('/home/hecanjog/sounds/drums/78oh.wav').data ksnd = dsp.read('jesskick.wav').data beat = dsp.bpm2frames(166) length = beat * 8 if dsp.rand() > 0.5: kick = 'x--x-x-x--------' else: kick = 'x----x----------' hat = 'x-x-x-x-xx-x-x-x' ohat = 'x------x--------' lsnare = '---------x--x---' if dsp.rand() > 0.5: lsnare = '---------x--x---' else: lsnare = '--x--x--x--x--x-' snare = '--x--x--x--x--x-' def makeOHat(length, i, amp): return dsp.fill(hsnd, length, silence=True) def makeHat(length, i, amp): return dsp.fill(ohsnd, length, silence=True) def makeKick(length, i, amp): k = dsp.fill(ksnd, length, silence=True) return dsp.amp(k, 3) def makeSnare(length, i, amp): s = dsp.fill(ssnd, length, silence=True) return dsp.amp(s, 2) def makeLSnare(length, i, amp): s = dsp.fill(lssnd, length, silence=True) return dsp.amp(s, 1) hats = drums.parsebeat(hat, 8, beat, length, makeHat, 5) ohats = drums.parsebeat(ohat, 8, beat, length, makeOHat, 0) kicks = drums.parsebeat(kick, 8, beat, length, makeKick, 0) snares = drums.parsebeat(snare, 8, beat, length, makeSnare, 0) lsnares = drums.parsebeat(lsnare, 8, beat, length, makeLSnare, 0) snaresnstuff = dsp.mix([ohats,snares]) snaresnstuff= dsp.split(snaresnstuff, dsp.flen(snaresnstuff) / 32) snaresnstuff = dsp.randshuffle(snaresnstuff) snaresnstuff = ''.join(snaresnstuff) snaresnstuff = dsp.amp(snaresnstuff, 0.35) out = dsp.mix([kicks,lsnares,snares,hats,ohats,snaresnstuff]) return out
from pippi import dsp, tune from hcj import drums, keys ssnd = dsp.read("samples/jess/snare.wav").data lssnd = dsp.read("samples/jess/rimshot.wav").data hsnd = dsp.read("samples/jess/tamb_rattle.wav").data ohsnd = dsp.read("samples/jess/skitter.wav").data ksnd = dsp.read("samples/jess/kickshuffle.wav").data bksnd = dsp.read("samples/jess/kickcym.wav").data bksnd = dsp.mix([bksnd, dsp.read("samples/jess/smash.wav").data]) beat = dsp.bpm2frames(166) key = "b" out = "" elapsed = 0 count = 0 tlength = dsp.stf(120) def makeRhodes(length, beat, freqs): root = tune.ntf(key, 2) for i, freq in enumerate(freqs): if freq > root * 2.5: freqs[i] = freq * 0.5 chord = [keys.rhodes(length, freq, dsp.rand(0.4, 0.6)) for freq in freqs] chord = dsp.randshuffle(chord) pause = 0
def play(ctl): p = ctl.get('param') key = p.get('key', 'c') mpk = ctl.get('midi').get('mpk') bpm = p.get('bpm', 100) beat = dsp.bpm2frames(bpm) length = beat * 2 * mpk.geti(6, low=1, high=6) gamut = mpk.geti(20) poly = mpk.geti(21) logistic = mpk.geti(22) layered = mpk.geti(23) fixed = mpk.get(24) perc = mpk.get(25) wobble = mpk.get(26) min_octave = mpk.geti(4, low=1, high=4) max_octave = mpk.geti(4, low=3, high=7) octave = dsp.randint(min_octave, max_octave) k = dsp.randchoose(snds.search('mc303/*kick*')) h = dsp.randchoose(snds.search('mc303/*hat*')) c = dsp.randchoose(snds.search('mc303/*clap*')) pointer = p.get('pointer', default=0) log = data.Logistic(r=dsp.rand(3.9, 3.99), x=0.5, size=1024, pointer=pointer) if fixed: seed = mpk.get(5) else: seed = time.time() dsp.seed(str(seed)) def makeOnsets(length, wobble, div, num_beats, offset=False): if offset: offset = dsp.randint(0, 3) else: offset = 0 pattern = dsp.eu(num_beats, dsp.randint(1, num_beats/div), offset) dsp.log(pattern) if wobble: points = [ dsp.mstf(100, 500) for _ in range(dsp.randint(2, 8)) ] plength = sum(points) mult = length / float(plength) onsets = curves.bezier(points, num_beats) onsets = [ int(o * mult) for o in onsets ] else: beat = float(length) / num_beats num_beats = length / beat beat = int(round(beat)) onsets = [ beat * i for i in range(int(round(num_beats))) ] return onsets def makeKicks(length, wobble): out = Tracks() onsets = makeOnsets(length, wobble, 2, 4, True) kick = dsp.taper(k, 20) kick = dsp.transpose(kick, dsp.rand(1, 2)) for onset in onsets: out.add(kick, onset) out = out.mix() out = dsp.fill(out, length, silence=False) return dsp.taper(out, 40) def makeHats(length, wobble): out = Tracks() onsets = makeOnsets(length, wobble, 1, 16, True) for onset in onsets: out.add(h, onset) out = out.mix() out = dsp.split(out, dsp.flen(out) / dsp.randchoose([2, 3, 4])) out = dsp.randshuffle(out) out = ''.join(out) out = dsp.fill(out, length, silence=False) return dsp.taper(out, 40) def makeClaps(length, wobble): out = Tracks() onsets = makeOnsets(length, wobble, 2, 8, True) for onset in onsets: clap = dsp.stretch(c, int(dsp.flen(c) * log.get(1, 10)), grain_size=dsp.randint(20, 120)) out.add(clap, onset) out = out.mix() out = dsp.split(out, dsp.flen(out) / dsp.randchoose([2, 3, 4])) out = [ dsp.taper(o, 20) for o in out ] out = dsp.randshuffle(out) out = ''.join(out) out = dsp.fill(out, length, silence=False) return dsp.taper(out, 40) if mpk.get(8) == 0: return dsp.pad('', 0, dsp.mstf(100)) def randomScale(): scale = [1,2,3,4,5,6,7,8] freqs = tune.fromdegrees(scale, octave=octave, root=key) return freqs def gamutScale(): num_notes = dsp.randint(3, 6) scale = [ dsp.randchoose([1,2,3,4,5,6,7,8]) for _ in range(num_notes) ] freqs = tune.fromdegrees(scale, octave=octave, root=key) return freqs if gamut: freqs = gamutScale() else: freqs = randomScale() if layered: num_layers = dsp.randint(2, 4) else: num_layers = 1 layers = [] for _ in range(num_layers): layer = '' elapsed = 0 while elapsed < length: if poly: num_poly = dsp.randint(1, 3) else: num_poly = 1 note_length = beat / dsp.randchoose([1, 2, 3, 4]) notes = [] for _ in range(num_poly): freq = dsp.randchoose(freqs) if logistic: pulsewidth = log.get(low=0.05, high=1) if log.get() > 0.5: wf = log.choose(['sine', 'tri', 'saw']) wf = dsp.wavetable(wf, 512) else: points = [ log.get(-1, 1) for _ in range(log.geti(4, 20)) ] wf = dsp.breakpoint(points, 512) else: pulsewidth = 1 wf = dsp.wavetable('sine', 512) note = keys.pulsar(length=note_length, freq=freq, wf=wf, env='phasor', pulsewidth=pulsewidth) notes += [ note ] notes = dsp.mix(notes) layer += notes elapsed += dsp.flen(notes) layers += [ layer ] out = dsp.mix(layers) out = dsp.amp(out, 0.75) out = dsp.fill(out, length) #out = dsp.pad(out, 0, int(dsp.stf(0.5, 1) * mpk.get(7))) p.set('pointer', log.pointer) if perc: kicks = makeKicks(length, wobble) hats = makeHats(length, wobble) claps = makeClaps(length, wobble) out = dsp.mix([ out, kicks, hats, claps ]) out = dsp.amp(out, mpk.get(8)) return out
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(ctl): param = ctl.get("param") lpd = ctl.get("midi").get("pc") lpd.setOffset(111) key = "g" # bd = dsp.read('/home/hecanjog/sounds/drums/Tinyrim2.wav').data # bd = dsp.read('/home/hecanjog/sounds/drums/Jngletam.wav').data # bd = dsp.read('/home/hecanjog/sounds/drums/78oh.wav').data # bd = dsp.amp(bd, 1) # bd = dsp.transpose(bd, dsp.rand(0.65, 0.72) / 1) # bd = dsp.transpose(bd, dsp.rand(0.3, 0.32) / 1) chord = tune.fromdegrees([1, 8], root="g", octave=dsp.randint(0, 2)) chord.reverse() chord = dsp.rotate(chord, lpd.geti(4, low=0, high=len(chord) - 1)) # chord = dsp.randshuffle(chord) reps = param.get("reps", default=16) rep = param.get("rep", default=0) beat = dsp.bpm2frames(130) / 4 beat = dsp.mstf(4100) / 32 # length = beat out = "" for n in range(4): freq = chord[int(rep) % len(chord)] if dsp.rand() > 0.5: freq *= 2 ** dsp.randint(0, lpd.geti(7, low=0, high=8, default=0)) pw = lpd.get(8, low=0.1, high=1, default=1) # length = dsp.mstf(lpd.get(2, low=50, high=2500, default=500) * dsp.rand(0.5, 2)) length = dsp.mstf(lpd.get(14, low=50, high=5000, default=500)) wf = dsp.wavetable("tri", 512) wf = dsp.wavetable("impulse", 512) wf = dsp.wavetable("sine2pi", 512) wf = dsp.breakpoint([0] + [dsp.rand(-1, 1) for w in range(lpd.geti(15, low=4, high=200, default=4))] + [0], 512) win = dsp.wavetable("sine", 512) mod = [dsp.rand(0, 1) for m in range(512)] modr = dsp.rand(0.01, 0.02) modr = lpd.get(16, low=0.01, high=1, default=1) modf = dsp.rand(0.5, 2) amp = lpd.get(6, low=0, high=2, default=0) amp = dsp.rand(0, 2) o = dsp.pulsar(freq, length, pw, wf, win, mod, modr, modf, amp) o = dsp.env(o, "random") o = dsp.taper(o, dsp.mstf(10)) o = dsp.pan(o, dsp.rand()) rep = rep + 1 out += o # out = dsp.mix([ dsp.fill(bd, dsp.flen(out), silence=True), out ]) param.set("rep", (rep + 1) % reps) return out
from pippi import dsp g = dsp.read('sounds/seneca3bars.wav').data beat = dsp.bpm2frames(112) g = dsp.split(g, dsp.flen(g) / 48) out = '' osts = [dsp.randchoose(g) for a in range(3)] for p in range(32): alts = [dsp.randchoose(g) for a in range(4)] for b in range(dsp.randint(4, 12)): out += osts[p % len(osts)] out += alts[b % len(alts)] dsp.write(out, 'pulsechord')
def play(ctl): lpd = ctl.get('midi').get('lpd') ssnd = dsp.read('/home/hecanjog/sounds/drums/Tinysd.wav').data hsnd = dsp.read('/home/hecanjog/sounds/drums/Shaker.wav').data ksnd = dsp.read('/home/hecanjog/sounds/drums/Drybd2.wav').data beat = dsp.bpm2frames(120) length = beat * 4 hat = 'xx' kick = 'x ' #kick = ''.join([ dsp.randchoose([' ', 'x']) for s in range(dsp.randint(3, 5))]) #hat = ''.join([ dsp.randchoose([' ', 'x']) for s in range(dsp.randint(3, 5))]) if dsp.rand() > 0.75: snare = ''.join([ dsp.randchoose([' ', 'x']) for s in range(dsp.randint(6, 8))]) else: snare = ' x ' # x.-.x.-.x.-.x.-.x.-. def makeHat(length, i, amp): """ h = dsp.tone(dsp.mstf(dsp.rand(1, 3)), dsp.rand(11900, 12000)) h = dsp.env(h, 'phasor') h = dsp.pad(h, 0, length - dsp.flen(h)) h = dsp.amp(h, amp * 0.25) """ #h = dsp.cut(hsnd, 0, dsp.mstf(dsp.rand(3, 10))) h = hsnd h = dsp.env(h, 'phasor') h = dsp.pad(h, 0, length - dsp.flen(h)) #h = dsp.amp(h, amp * 0.75) return h def makeKick(length, i, amp): #k = drums.sinekick(length, i, amp) k = dsp.fill(ksnd, length, silence=True) k = dsp.amp(k, 2) return k def makeSnare(length, i, amp): s = ssnd s = dsp.amp(s, 10) s = dsp.transpose(s, dsp.rand(0.8, 1)) s = dsp.fill(s, length, silence=True) ss = dsp.drift(s, dsp.rand(0.001, 0.1)) s = dsp.mix([s, ss]) return s hats = drums.parsebeat(hat, 16, beat, length, makeHat, 25) kicks = drums.parsebeat(kick, 8, beat, length, makeKick, 10) snares = drums.parsebeat(snare, 8, beat, length, makeSnare, 0) out = dsp.mix([hats,kicks,snares]) out = dsp.split(out, beat) out = dsp.randshuffle(out) out = ''.join(out) out = dsp.amp(out, 2) #out = dsp.drift(out, dsp.rand(0.5, 2)) 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(ctl): p = ctl.get('param') key = p.get('key', 'c') mpk = ctl.get('midi').get('mpk') bpm = p.get('bpm', 100) beat = dsp.bpm2frames(bpm) length = beat * 2 * mpk.geti(6, low=1, high=6) gamut = mpk.geti(20) poly = mpk.geti(21) logistic = mpk.geti(22) layered = mpk.geti(23) fixed = mpk.get(24) perc = mpk.get(25) wobble = mpk.get(26) min_octave = mpk.geti(4, low=1, high=4) max_octave = mpk.geti(4, low=3, high=7) octave = dsp.randint(min_octave, max_octave) k = dsp.randchoose(snds.search('mc303/*kick*')) h = dsp.randchoose(snds.search('mc303/*hat*')) c = dsp.randchoose(snds.search('mc303/*clap*')) pointer = p.get('pointer', default=0) log = data.Logistic(r=dsp.rand(3.9, 3.99), x=0.5, size=1024, pointer=pointer) if fixed: seed = mpk.get(5) else: seed = time.time() dsp.seed(str(seed)) def makeOnsets(length, wobble, div, num_beats, offset=False): if offset: offset = dsp.randint(0, 3) else: offset = 0 pattern = dsp.eu(num_beats, dsp.randint(1, num_beats / div), offset) dsp.log(pattern) if wobble: points = [dsp.mstf(100, 500) for _ in range(dsp.randint(2, 8))] plength = sum(points) mult = length / float(plength) onsets = curves.bezier(points, num_beats) onsets = [int(o * mult) for o in onsets] else: beat = float(length) / num_beats num_beats = length / beat beat = int(round(beat)) onsets = [beat * i for i in range(int(round(num_beats)))] return onsets def makeKicks(length, wobble): out = Tracks() onsets = makeOnsets(length, wobble, 2, 4, True) kick = dsp.taper(k, 20) kick = dsp.transpose(kick, dsp.rand(1, 2)) for onset in onsets: out.add(kick, onset) out = out.mix() out = dsp.fill(out, length, silence=False) return dsp.taper(out, 40) def makeHats(length, wobble): out = Tracks() onsets = makeOnsets(length, wobble, 1, 16, True) for onset in onsets: out.add(h, onset) out = out.mix() out = dsp.split(out, dsp.flen(out) / dsp.randchoose([2, 3, 4])) out = dsp.randshuffle(out) out = ''.join(out) out = dsp.fill(out, length, silence=False) return dsp.taper(out, 40) def makeClaps(length, wobble): out = Tracks() onsets = makeOnsets(length, wobble, 2, 8, True) for onset in onsets: clap = dsp.stretch(c, int(dsp.flen(c) * log.get(1, 10)), grain_size=dsp.randint(20, 120)) out.add(clap, onset) out = out.mix() out = dsp.split(out, dsp.flen(out) / dsp.randchoose([2, 3, 4])) out = [dsp.taper(o, 20) for o in out] out = dsp.randshuffle(out) out = ''.join(out) out = dsp.fill(out, length, silence=False) return dsp.taper(out, 40) if mpk.get(8) == 0: return dsp.pad('', 0, dsp.mstf(100)) def randomScale(): scale = [1, 2, 3, 4, 5, 6, 7, 8] freqs = tune.fromdegrees(scale, octave=octave, root=key) return freqs def gamutScale(): num_notes = dsp.randint(3, 6) scale = [ dsp.randchoose([1, 2, 3, 4, 5, 6, 7, 8]) for _ in range(num_notes) ] freqs = tune.fromdegrees(scale, octave=octave, root=key) return freqs if gamut: freqs = gamutScale() else: freqs = randomScale() if layered: num_layers = dsp.randint(2, 4) else: num_layers = 1 layers = [] for _ in range(num_layers): layer = '' elapsed = 0 while elapsed < length: if poly: num_poly = dsp.randint(1, 3) else: num_poly = 1 note_length = beat / dsp.randchoose([1, 2, 3, 4]) notes = [] for _ in range(num_poly): freq = dsp.randchoose(freqs) if logistic: pulsewidth = log.get(low=0.05, high=1) if log.get() > 0.5: wf = log.choose(['sine', 'tri', 'saw']) wf = dsp.wavetable(wf, 512) else: points = [ log.get(-1, 1) for _ in range(log.geti(4, 20)) ] wf = dsp.breakpoint(points, 512) else: pulsewidth = 1 wf = dsp.wavetable('sine', 512) note = keys.pulsar(length=note_length, freq=freq, wf=wf, env='phasor', pulsewidth=pulsewidth) notes += [note] notes = dsp.mix(notes) layer += notes elapsed += dsp.flen(notes) layers += [layer] out = dsp.mix(layers) out = dsp.amp(out, 0.75) out = dsp.fill(out, length) #out = dsp.pad(out, 0, int(dsp.stf(0.5, 1) * mpk.get(7))) p.set('pointer', log.pointer) if perc: kicks = makeKicks(length, wobble) hats = makeHats(length, wobble) claps = makeClaps(length, wobble) out = dsp.mix([out, kicks, hats, claps]) out = dsp.amp(out, mpk.get(8)) return out
from pippi import dsp import orc, pat, fx drums = [ orc.clap, orc.hihat, orc.kick ] out = '' beat = dsp.bpm2frames(125) / 2 for bar in range(8): perc = '' for i in range(32): if dsp.randint(0, 2) == 0: perc += dsp.randchoose(drums)(dsp.rand(), beat) else: perc += dsp.pad('', beat, 0) kick = orc.kick(1, beat * 32) out += dsp.mix([ perc, kick ]) dsp.write(out, 'drums')
from pippi import dsp from noise import pnoise1 import seq freqs = [200, 350, 500, 700, 1000, 1400, 2000, 3500] bpm = 100.0 beat = int(dsp.bpm2frames(bpm) * 0.25) nump = 100 def make_pulse(snd): snd_len = dsp.flen(snd) blip = dsp.cut(snd, 0, dsp.mstf(20)) blip = dsp.env(blip, 'sine') blip = dsp.pad(blip, 0, snd_len - dsp.flen(blip)) return blip def make_vary(index, length, freq): def i(index, offset): return ((index + offset) % nump) / float(nump) pulsewidth = int(pnoise1(i(index, 100), 2) * (length / 2)) snd = dsp.tone(pulsewidth, freq, amp=pnoise1(i(index, 99), 3) * 0.5) snd = dsp.env(snd, 'sine') snd = dsp.pad(snd, 0, length - pulsewidth) return snd
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): 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
progression = 'v9 v9 ii7 vi9 IV69'.split(' ') numbeats = 16 + (4 * dsp.randint(2, 4)) if canPlay('prog3', section): progression = 'II7 II7 V69'.split(' ') cname = progression[ count % len(progression) ] if section == 'float': numbeats = 16 * dsp.randint(2, 20) if section == 'ending': numbeats = dsp.randint(16, 40) bpm = 84 beat = dsp.bpm2frames(bpm) / 4 bar_length = beat * numbeats bar = dsp.pad('', 0, bar_length) if canPlay('choppy', section): dl = ''.join([ dsp.mix([ dsp.randchoose([ dloop1, dloop2 ]), dsp.randchoose([ kickhard, kicksoft ]) ]) for _ in range(3) ]) dl = dsp.split(dl, dsp.flen(dl) / 16) dl = dsp.randshuffle(dl) dl = [ dsp.env(dd, 'phasor') for dd in dl ] for i, b in enumerate(dl): if dsp.rand() > 0.75: dl[i] = dsp.pad('', 0, dsp.flen(b)) elif dsp.rand() > 0.75: dl[i] = dsp.split(b, dsp.flen(b) / 2)[0] * 2
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 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(ctl): mpk = ctl.get('midi').get('mpk') ccs = [i + 48 for i in range(24)] notes = [] for cc in ccs: if mpk.get(cc) < 1: notes += [cc] ssnd = dsp.read('/home/hecanjog/sounds/drums/78sd.wav').data ssnd = dsp.read('jesssnare.wav').data hsnd = dsp.read('/home/hecanjog/sounds/drums/Shaker.wav').data ksnd = dsp.read('/home/hecanjog/sounds/drums/Drybd2.wav').data #ksnd = dsp.read('jesskick.wav').data beat = dsp.bpm2frames(90) #beat = dsp.mstf(290 * 2) length = beat * 4 hat = 'xxx ' kick = 'x ' snare = ' x ' #snare = ' x xx' #snare = ' ' def makeHat(length, i, amp): h = hsnd h = dsp.env(h, 'phasor') h = dsp.pad(h, 0, length - dsp.flen(h)) return h def makeKick(length, i, amp): k = dsp.mix([ksnd, drums.sinekick(length, i, amp)]) #k = dsp.env(ksnd, 'phasor') k = dsp.fill(k, length, silence=True) k = dsp.amp(k, 1) return k def makeSnare(length, i, amp): s = ssnd s = dsp.amp(s, 1.2) s = dsp.transpose(s, dsp.rand(1.5, 3)) s = dsp.fill(s, length, silence=True) #ss = dsp.drift(s, dsp.rand(0.001, 0.1)) #s = dsp.mix([s, ss]) return s #hats = drums.parsebeat(hat, 16, beat, length, makeHat, 25) hats = drums.parsebeat(hat, 16, beat, length, makeHat, 0) kicks = drums.parsebeat(kick, 16, beat, length, makeKick, 0) snares = drums.parsebeat(snare, 8, beat, length, makeSnare, 0) out = dsp.mix([hats, kicks, snares]) shuf = True shuf = False if shuf: out = dsp.split(out, beat) out = dsp.randshuffle(out) out = ''.join(out) out = dsp.amp(out, 2) cuts = True if dsp.rand() > 0.5 else False cuts = True #cuts = False if cuts: o = dsp.split(out, beat / 2) o = dsp.randshuffle(o) o = [dsp.amp(oo, dsp.rand(0, 2.5)) for oo in o] o = [dsp.env(oo, 'random') for oo in o] out = dsp.mix([''.join(o), out]) dsp.log(notes) synthy = False #synthy = True if synthy == True: s = '' for ii in range(dsp.flen(out) / (beat / 2)): layers = [] if len(notes) > 0: scale = [n - 47 for n in notes] scale = [1, 5, 8, 12] scale = tune.fromdegrees(scale, octave=3, root='d') p = ''.join([ keys.pulsar(scale[ii % len(scale)], pulsewidth=dsp.rand(0.1, 1), amp=0.5, length=(beat / 2) / 3) for _ in range(3) ]) layers += [p] else: layers += [dsp.pad('', beat / 2, 0)] s += dsp.mix(layers) out = dsp.mix([s, out]) #out = dsp.alias(out) #out = dsp.drift(out, dsp.rand(0.5, 2)) 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) amp = dsp.rand(0.1, 0.65) nlens = [ beat * 4, beat * 3, beat * 2, beat + (beat / 2), beat, beat / 2, beat / 4, ] scale = [2,4,6,9] scale = [1,4,6,8] # scale = [1,3,4,5,6,8,9] # scale = [1,2,3,5,6,8,9] # scale = [1,5,8] freqs = tune.fromdegrees(scale, root=root, octave=dsp.randint(2,4), ratios=ratios, scale=quality) # length of pattern (in beats) elen = 0 tlen = beat * dsp.randint(2, 8) # beat lengths (from a set of bpm-derived note lengths defined in the nlens list) blens = [] while elen < tlen: l = dsp.randchoose(nlens) blens += [ l ] elen += l # beat pulsewidths bpws = [ dsp.rand(0.1, 1) for pw in range(len(blens)) ] out = '' # choose a pitch from the scale freq = dsp.randchoose(freqs) # synthesize the tones for i in range(len(blens)): # find the length of the pulse blen = int(round(blens[i] * bpws[i])) # find the length of the rest brest = blens[i] - blen # make a rhodes tone with a random amplitude #beat = keys.rhodes(length=blen, freq=freq, amp=dsp.rand(0.3, 0.5)) beat = keys.rhodes(length=blen, freq=freq, amp=amp) # pan the tone to a random position beat = dsp.pan(beat, dsp.rand()) # bitcrush the tone a random amount # beat = dsp.alias(beat) # pad the tone with silence beat = dsp.pad(beat, 0, brest) # add it to the output out += beat out *= dsp.randint(1, 2) if dsp.rand() > 0.75: out = dsp.split(out, dsp.bpm2frames(bpm) / dsp.randchoose([1,2,4])) out = dsp.randshuffle(out) out = ''.join(out) return out
from pippi import dsp, tune from hcj import keys, fx, drums kick = dsp.read('../../sounds/organkick.wav').data hat = dsp.read('../../sounds/mc303shake.wav').data snare = dsp.read('../../sounds/organsnare.wav').data bpm = 100 target_length = dsp.stf(60 * 2) beat = dsp.bpm2frames(bpm) out = '' chord = [dsp.randint(1, 15) for _ in range(4)] def nextChord(last): degs = dsp.randshuffle(last)[:dsp.randint(1, 2)] for deg in degs: newdeg = deg + dsp.randchoose([-1, 1]) if newdeg == 0: newdeg = 1 elif newdeg > 15: newdeg = 15 last[last.index(deg)] = newdeg return last kickp = 'x '