def singit(lyrics, mult): words = text2wave(lyrics) root = config('key') quality = getattr(tune, config('quality')) ratios = getattr(tune, config('tune')) pitches = [dsp.randint(1, 9) for i in range(dsp.randint(2, 4))] pitches = tune.fromdegrees(pitches, octave=dsp.randint(1, 4), root=root, ratios=ratios, scale=quality) return words sings = [ dsp.pine(words, dsp.flen(words) * mult, pitch) for pitch in pitches ] sings = dsp.mix(sings) # sings = sox("sox %s %s tempo 1.0", sings) return sings
def singit(lyrics, mult): words = text2wave(lyrics) pitches = [ dsp.randint(1, 10) for i in range(dsp.randint(2, 4)) ] pitches = tune.fromdegrees(pitches, octave=dsp.randint(1, 4), root='a') sings = [ dsp.pine(words, dsp.flen(words) * mult, pitch) for pitch in pitches ] sings = dsp.mix(sings) sings = sox("sox %s %s tempo 5.0", sings) return sings
def make_pulses(degrees, bpm): freqs = tune.fromdegrees(degrees, 3, 'c') layers = [] for freq in freqs: l = dsp.pine(dsp.amp(thirty, 0.5), int(dsp.flen(thirty) * 20), freq) l = dsp.pan(l, dsp.rand()) layers += [ l ] t = dsp.mix(layers) t = dsp.split(t, dsp.mstf(dsp.bpm2ms(bpm))) t = dsp.randshuffle(t) return ''.join(t)
def singit(lyrics, mult): words = text2wave(lyrics) root = config('key') quality = getattr(tune, config('quality')) ratios = getattr(tune, config('tune')) pitches = [ dsp.randint(1, 9) for i in range(dsp.randint(2, 4)) ] pitches = tune.fromdegrees(pitches, octave=dsp.randint(1, 4), root=root, ratios=ratios, scale=quality) return words sings = [ dsp.pine(words, dsp.flen(words) * mult, pitch) for pitch in pitches ] sings = dsp.mix(sings) # sings = sox("sox %s %s tempo 1.0", sings) return sings
def sing(lyrics, freqs, speed=0, voice='english'): """ sing it mad slow in chords """ out = speak(lyrics, speed, voice) layers = [] for freq in freqs: layer = dsp.transpose(out, 0.25) layer = dsp.pine(layer, dsp.flen(layer) * 4, freq) slop = int(dsp.flen(layer) * 0.12) layer = dsp.cut(layer, slop, dsp.flen(layer) - (slop * 2)) layer = dsp.transpose(layer, 4) layer = dsp.pan(layer, dsp.rand()) layer = dsp.amp(layer, 0.5) layers += [ layer ] out = dsp.mix(layers) return out
def play(params): length = params.get('length', dsp.stf(dsp.rand(0.1, 1))) volume = params.get('volume', 100.0) / 100.0 speed = params.get('speed', dsp.rand(0.3, 0.5)) octave = params.get('octave', 2) note = params.get('note', ['c'])[0] env = params.get('envelope', False) pad = params.get('padding', False) bend = params.get('bend', 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) lyrics = params.get('ww', '1-2-3-4-5-6-7-8-9-10').split('-') bpm = params.get('bpm', 100) if shuffle: lyrics = dsp.randshuffle(lyrics) lyrics = ' '.join(lyrics) words = text2wave(lyrics) words = sox("sox %s %s silence 1 0.1 1%% -1 0.1 1%%", words) words = dsp.transpose(words, speed) pitches = tune.fromdegrees(scale, octave=octave, root=note) length = dsp.flen(words) * dsp.randint(30, 32) sings = [ dsp.pine(words, length, pitch) for pitch in pitches ] sings = dsp.mix(sings) sings = sox("sox %s %s tempo 6.0", sings) out = dsp.pan(sings, dsp.rand()) return out
def play(ctl): param = ctl.get('param') lpd = ctl.get('midi').get('lpd') pc = ctl.get('midi').get('pc') #pc.setOffset(111) gamut = { 'high': [ (10000, 15000), (5000, 15000), (5000, 10000), ], 'mid': [ (1000, 5000), (1000, 2000), ], 'pitch': [ tuple([ dsp.rand(500, 2000) for p in range(2) ]), tuple([ dsp.rand(100, 1000) for p in range(2) ]), tuple([ dsp.rand(1000, 5000) for p in range(2) ]), ], 'low': [ (20, 5000), (30, 10000), (40, 10000), ] } area = param.get('wash-area', default='high') area = dsp.randchoose(['high', 'mid', 'pitch', 'low']) area = 'pitch' dsp.log(area) freqs = dsp.randchoose(gamut[area]) freqscale = pc.get(16, low=0.125, high=2, default=1) #freqscale = dsp.rand(0.125, 2) low = freqs[0] * freqscale high = freqs[1] * freqscale wform = dsp.randchoose(['sine2pi', 'tri', 'vary', 'square']) timescale = pc.get(17, low=1, high=4, default=1) #timescale = dsp.rand(1, 4) lengthscale = pc.get(18, low=0.125, high=2.5) #lengthscale = dsp.rand(0.125, 2.5) amp = pc.get(0, low=0, high=0.5, default=0.5) #amp = dsp.rand(0, 0.5) if area == 'high': low = dsp.rand(low * 0.9, low) high = dsp.rand(high, high * 1.1) length = dsp.stf(dsp.rand(0.01, 0.3) * lengthscale) out = dsp.bln(length, low, high, wform) out = dsp.env(out, 'phasor') if dsp.rand() > 10.5: beep = dsp.tone(dsp.flen(out), high * 2, amp=dsp.rand(0.5, 1)) out = dsp.mix([out, beep]) out = dsp.pad(out, 0, dsp.mstf(dsp.rand(1, 400) * timescale)) out = out * dsp.randint(1, 3) out = dsp.drift(out, dsp.rand(0, 1)) elif area == 'mid': low = dsp.rand(low * 0.9, low) high = dsp.rand(high, high * 1.1) length = dsp.stf(dsp.rand(0.01, 0.5) * lengthscale) out = dsp.bln(length, low, high, wform) out = dsp.env(out, 'random') if timescale > 1: out = dsp.pad(out, 0, dsp.mstf(500 * timescale * dsp.rand(0.5, 1.5))) elif area == 'pitch': low = dsp.rand(low * 0.9, low) high = dsp.rand(high, high * 1.1) length = dsp.stf(dsp.rand(0.01, 0.5) * lengthscale) out = dsp.bln(length, low, high, wform) out = dsp.env(out, 'random') if timescale > 1: out = dsp.pad(out, 0, dsp.mstf(500 * timescale * dsp.rand(0.5, 1.5))) elif area == 'low': low = dsp.rand(low * 0.9, low) high = dsp.rand(high, high * 1.1) length = dsp.stf(dsp.rand(0.2, 2) * lengthscale) out = dsp.bln(length, low, high, wform) out = dsp.env(out, 'random') out = dsp.mix([out, dsp.tone(length, low)]) if dsp.rand() > 0.5: beep = dsp.tone(dsp.flen(out), high, amp=dsp.rand(0.015, 0.1), wavetype=dsp.randchoose(['hann', 'impulse', 'square', 'vary', 'sine'])) out = dsp.mix([out, beep]) if timescale > 1: out = dsp.pad(out, 0, dsp.mstf(500 * timescale * dsp.rand(0.5, 1.5))) if dsp.rand() > pc.get(19, low=0, high=1, default=0.75): plength = length * dsp.randint(2, 6) freq = tune.ntf(param.get('key', default='c'), octave=dsp.randint(0, 4)) out = dsp.mix([ dsp.pine(out, plength, freq), dsp.pine(out, plength, freq * 1.25) ]) out = dsp.fill(out, length) out = dsp.pan(out, dsp.rand()) out = dsp.amp(out, amp) return out
for high, low, amp, pan, length in zip(highs, lows, amps, pans, lengths): p = dsp.bln(length, low, high, wform=dsp.randchoose(['hann', 'sine2pi', 'tri'])) p = dsp.env(p, 'hann') p = dsp.taper(p, 20) p = dsp.amp(p, amp) p = dsp.pan(p, pan) layer += p layers += [ layer ] freqs = tune.fromdegrees([dsp.randint(1, 9) for _ in range(nlayers)], octave=1, root='a') for i, freq in enumerate(freqs): layers[i] = dsp.pine(layer, dsp.flen(layer) * 10, freq) section = dsp.fill(dsp.mix(layers), sectionlength) plen = dsp.randint(16, 32) pattern = dsp.eu(plen, dsp.randint(4, plen)) pattern = [ 'x' if h == 1 else '.' for h in pattern ] beat = dsp.flen(section) / plen kicks = ctl.makeBeat(pattern, [ beat for _ in range(plen) ], makeKick) pattern = 'x..' rimshots = ctl.makeBeat(pattern, [ dsp.flen(section) / 16 for _ in range(16) ], makeRimshot) pattern = ctl.parseBeat('xxxx') pdiv = dsp.randint(32, 64) hats = ctl.makeBeat(pattern, [ dsp.flen(section) / pdiv for _ in range(pdiv) ], orc.hat.make)
if canPlay('jam', bigoldsection) or canPlay('breakdown', bigoldsection): # Hats if len(seg) >= 2: if bigoldsection > 11: maxbeats = dsp.randint(len(seg) / 2, len(seg)) hatpat = drums.eu(len(seg), maxbeats) else: hatpat = [1] * len(seg) hats = drums.make(drums.hihat, hatpat, seg) hats = dsp.amp(hats, 0.3) hats = mixdrift(hats) if dsp.randint(0, 3) == 0: hats = dsp.pine(hats, tlen, dsp.randchoose(scale)) if canPlay('breakdown', bigoldsection): hats = mixdrift(hats) hatsPlay += 1 layers += [ hats ] # Percussion if bigoldsection > 9: kpat = single else: kpat = dsp.rotate(single, vary=True) kicks = drums.make(drums.kick, kpat, seg)
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(params): pinecone = params.get('pinecone', False) wild = params.get('wild', False) pad = params.get('pad', False) high = params.get('high', True) up = params.get('up', False) long = params.get('long', False) wide = params.get('wide', False) layers = [] if long == True: numgrains = dsp.randint(8000, 20000) else: numgrains = dsp.randint(10, 1000) def dosweep(wtype, start_freq, freq_range, numgrains, cycle_type): out = '' pitch_curve = dsp.curve(wtype, numgrains, math.pi * 0.5, freq_range, 0.0, start_freq) pan_curve = dsp.curve(1, numgrains, math.pi * dsp.rand(1, 80)) for i, freq in enumerate(pitch_curve): grain = dsp.cycle(freq, cycle_type, 0.01) grain = dsp.pan(grain, pan_curve[i]) out += grain return out wtype = 2 if up == True else 1 if wild == True: cycle_types = ['sine', 'impulse', 'vary', 'tri'] cycle_type = dsp.randchoose(cycle_types) else: cycle_type = 'sine' numsweeps = dsp.randint(1, 10) for i in range(numsweeps): if high == True: start_freq = dsp.rand(1000, 19000) else: start_freq = dsp.rand(50, 1000) if wide == True: freq_range = dsp.rand(500, 1000) else: freq_range = dsp.rand(1, 50) layer = dosweep(wtype, start_freq, freq_range, numgrains, cycle_type) if pinecone == True: if wild == True: windows = [0, 1, 2, 6] window = dsp.randchoose(windows) scrubs = [0, 1, 2, 6] scrub = dsp.randchoose(scrubs) else: window = 2 scrub = 5 length = dsp.stf(dsp.rand(0.05, 1)) layer = dsp.pine(layer, length, dsp.rand(50, 10000), window, dsp.rand(1, 10), scrub, dsp.rand(1, 10)) layers += [ layer ] out = dsp.mix(layers) if pad == True: pad = dsp.stf(dsp.rand(0.01, 1)) out = dsp.pad(out, 0, pad) env_types = ['hann', 'line','phasor', 'sine', 'impulse', 'vary', 'tri'] env_type = dsp.randchoose(env_types) out = dsp.env(out, env_type) return out
wform=dsp.randchoose(['hann', 'sine2pi', 'tri'])) p = dsp.env(p, 'hann') p = dsp.taper(p, 20) p = dsp.amp(p, amp) p = dsp.pan(p, pan) layer += p layers += [layer] freqs = tune.fromdegrees([dsp.randint(1, 9) for _ in range(nlayers)], octave=1, root='a') for i, freq in enumerate(freqs): layers[i] = dsp.pine(layer, dsp.flen(layer) * 10, freq) section = dsp.fill(dsp.mix(layers), sectionlength) plen = dsp.randint(16, 32) pattern = dsp.eu(plen, dsp.randint(4, plen)) pattern = ['x' if h == 1 else '.' for h in pattern] beat = dsp.flen(section) / plen kicks = ctl.makeBeat(pattern, [beat for _ in range(plen)], makeKick) pattern = 'x..' rimshots = ctl.makeBeat(pattern, [dsp.flen(section) / 16 for _ in range(16)], makeRimshot) pattern = ctl.parseBeat('xxxx')
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
from pippi import dsp main = dsp.read('base_loop.wav').data synth = dsp.read('synthloop.wav').data beat = dsp.flen(main) / 128 freq = 430 s = dsp.pine(synth, dsp.flen(main) * 8, freq) s = dsp.split(s, beat) s = dsp.randshuffle(s) s = [dsp.alias(ss) for ss in s] s = [dsp.amp(ss, dsp.rand(0.5, 2)) 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.split(synth, beat) s2 = dsp.randshuffle(s2) s2 = [dsp.transpose(ss, dsp.randchoose([1, 2, 4])) for ss in s2] s2 = [dsp.fill(ss, beat) for ss in s2] s2 = [dsp.env(ss, 'phasor') for ss in s2] s2 = ''.join(s2) synth = dsp.mix([s, s2]) synth = dsp.fill(synth, dsp.flen(main)) #synth = dsp.fill(synth, dsp.flen(main)) out = dsp.mix([main, synth]) #out = synth
out = '' t = dsp.split(thirty, dsp.mstf(40)) t = [ dsp.env(tt, 'sine') for tt in t ] t = [ tt * 4 for tt in t ] out = ''.join(t) dsp.write(out, 'wesley_thirty_02') ## 03 out = '' freqs = tune.fromdegrees([1, 3, 5, 9], 3, 'c') 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:
cycle_length = dsp.randint(min_length, max_length) harmonics = [ dsp.tone( length=cycle_length, freq=root * dsp.randchoose(val_harmonics), amp=dsp.rand(0.1, 0.4), wavetype='impulse' ) for h in range(num_harmonics) ] harmonics = [ dsp.pan(harmonic, dsp.rand()) for harmonic in harmonics ] harmonics = [ dsp.env(harmonic, 'gauss') for harmonic in harmonics ] cycles += [ dsp.mix(harmonics) ] elapsed += cycle_length return ''.join(cycles) cycles = [ make_cycles(dsp.stf(60 * 2)) for i in range(4) ] out = dsp.mix(cycles) out = dsp.pine(out, dsp.stf(60 * 8), 80.0 * 2) cycles = [ make_cycles(dsp.stf(60 * 8)) for i in range(4) ] cycles = dsp.mix(cycles) out = dsp.mix([ out, cycles ]) dsp.write(out, 'newly')
from pippi import dsp main = dsp.read('base_loop.wav').data synth = dsp.read('synthloop.wav').data beat = dsp.flen(main) / 128 freq = 430 s = dsp.pine(synth, dsp.flen(main) * 8, freq) s = dsp.split(s, beat) s = dsp.randshuffle(s) s = [ dsp.alias(ss) for ss in s ] s = [ dsp.amp(ss, dsp.rand(0.5, 2)) 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.split(synth, beat) s2 = dsp.randshuffle(s2) s2 = [ dsp.transpose(ss, dsp.randchoose([1,2,4])) for ss in s2 ] s2 = [ dsp.fill(ss, beat) for ss in s2 ] s2 = [ dsp.env(ss, 'phasor') for ss in s2 ] s2 = ''.join(s2) synth = dsp.mix([ s, s2 ]) synth = dsp.fill(synth, dsp.flen(main)) #synth = dsp.fill(synth, dsp.flen(main)) out = dsp.mix([ main, synth ]) #out = synth
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(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)
if canPlay('jam', bigoldsection) or canPlay('breakdown', bigoldsection): # Hats if len(seg) >= 2: if bigoldsection > 11: maxbeats = dsp.randint(len(seg) / 2, len(seg)) hatpat = drums.eu(len(seg), maxbeats) else: hatpat = [1] * len(seg) hats = drums.make(drums.hihat, hatpat, seg) hats = dsp.amp(hats, 0.3) hats = mixdrift(hats) if dsp.randint(0, 3) == 0: hats = dsp.pine(hats, tlen, dsp.randchoose(scale)) if canPlay('breakdown', bigoldsection): hats = mixdrift(hats) hatsPlay += 1 layers += [hats] # Percussion if bigoldsection > 9: kpat = single else: kpat = dsp.rotate(single, vary=True) kicks = drums.make(drums.kick, kpat, seg)
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)
freqs = [ tune.fromdegrees([ cr - 1 for cr in chords[root]], 3, 'c', scale=range(12)) for root in roots ] return freqs out = '' for times in range(1): freqs = make_chords() for r in range(6): layers = [] for i in range(3): f = freqs[r % len(freqs)] notes = [] for n in range(dsp.randint(70, 100)): note_len = dsp.mstf(dsp.rand(30, 40)) note_freq = f[n % len(f)] note = rhodes.rhodes(note_len, note_freq) note = dsp.pine(note, note_len * 4, note_freq) notes += [ note ] layers += [ ''.join(notes) ] out += dsp.mix(layers) dsp.write(out, 'riley')