def test_svf_lp(self): snd = dsp.read('tests/sounds/whitenoise10s.wav') freq = [20, 10000] res = 0 out = fx.lpf(snd, freq, res) out.write('tests/renders/fx_svf_lp-r0.wav') freq = [20, 10000] res = 1 out = fx.lpf(snd, freq, res) out.write('tests/renders/fx_svf_lp-r1.wav')
def makekick(length=0.25): out = noise.bln('square', length, [dsp.rand(80, 100), dsp.rand(50, 100)], [dsp.rand(150, 200), dsp.rand(50, 70)]) out = fx.fold(out, amp=dsp.win('saw', 1, dsp.rand(6, 10))) out = fx.lpf(out, 200).vspeed([1, 0.5]) return out.env('pluckout').taper(0.02) * dsp.rand(0.6, 1)
def makekick(ctx): length = kick_lfo.interp(ctx.pos) out = noise.bln('square', length, [dsp.rand(80, 100), dsp.rand(50, 100)], [dsp.rand(150, 200), dsp.rand(50, 70)]) out = fx.crush(out, dsp.rand(6, 10), dsp.rand(11000, 44100)) out = fx.lpf(out, 200).vspeed([1, 0.5]) return out.env('pluckout').taper(0.02) * dsp.rand(0.6, 1)
def theme_synth(length, pos, total_length): notes = [ rhodes.rhodes(dsp.rand(4, 7), freq, 0.3) for freq in scale ] themes = [ [ note.speed(dsp.choice(speeds)) for note in notes * 2 ] for theme in range(8) ] theme = dsp.choice(themes) theme_note = dsp.choice(theme) note = fx.crush(theme_note) return fx.lpf(fx.softclip(note), dsp.win('rnd', 1000, 5000))
def bass(amp, length, oct=2): if amp == 0: return dsp.buffer(length=length) bass_note = dsp.choice(scale) * 0.25 stack = Waveset(rmx, limit=dsp.randint(5, 20), offset=dsp.randint(0, 100)) stack.normalize() out = oscs.Pulsar2d(stack, windows=['sine'], freq=bass_note).play(length) * dsp.rand(0.02, 0.2) out = fx.lpf(out, bass_note*2) return out.env('hannout').taper(dsp.MS*10)
def test_butlp(self): snd = dsp.read('tests/sounds/guitar1s.wav') freq = 100 out = fx.lpf(snd, freq) out.write('tests/renders/fx_lpf.wav')
# at the current position in the output buffer hatlength = length_lfo.interp(pos) # Call out hi hat function which returns a SoundBuffer hat = makehat(hatlength) # Dub the hi hat sound into our output buffer at the current position in seconds out.dub(hat, elapsed) # Sample a length from the time_lfo at this position to determine how far ahead to # move before the loop comes back around to dub another hat. beat = time_lfo.interp(pos) elapsed += beat # Add a butterworth lowpass with a 3k cutoff -- multiply output by 0.5 to attenuate signal to 50% out = fx.lpf(out, 3000) * 0.5 out.write('docs/tutorials/renders/002-hats-slipping-on-ice.flac') def makekick(length=0.25): out = noise.bln('square', length, [dsp.rand(80, 100), dsp.rand(50, 100)], [dsp.rand(150, 200), dsp.rand(50, 70)]) out = fx.fold(out, amp=dsp.win('saw', 1, dsp.rand(6, 10))) out = fx.lpf(out, 200).vspeed([1, 0.5]) return out.env('pluckout').taper(0.02) * dsp.rand(0.6, 1) kick = dsp.join([makekick().pad(end=0.2) for _ in range(8)]) # render a few kicks kick.write('docs/tutorials/renders/002-kick.flac')
def drumset(length, pos, total_length): print('DRUMSET', length, pos) if length < 10: div = dsp.choice([2,3,4]) else: div = dsp.choice([4,6,8,12,16]) beat = length / div seg = [ beat for _ in range(div) ] layers = [] maxbeats = dsp.randint(len(seg) / 2, len(seg)) hatpat = drums.eu(len(seg), maxbeats) hats = drums.make(drums.hihat, hatpat, seg) * 0.3 hats = mixdrift(hats) if dsp.rand() > 0.5: hats = hats.cloud(length=length, grainlength=1.0/dsp.choice(scale)) if dsp.rand() > 0.5: hats = mixdrift(hats) print('MADE HATS') layers += [ hats ] kpat = drums.eu(len(seg), maxbeats) kicks = drums.make(drums.kick, kpat, seg) if dsp.randint(0,1) == 1: kicks = kicks.cloud(length=length, grainlength=1.0/dsp.choice(scale)) else: kdivs = dsp.randint(2, 4) kicks = kicks.cloud(length=length / kdivs, grainlength=(1.0/dsp.choice(scale)) * kdivs) if dsp.rand() > 0.5: kicks = mixdrift(kicks) layers += [ kicks * 0.4 ] maxbeats = dsp.randint(2, len(seg) / 2) clappat = drums.eu(len(seg), maxbeats) claps = drums.make(drums.clap, rotate(clappat, vary=True), seg) if dsp.randint(0,1): claps = claps.cloud(length=length, grainlength=1.0/dsp.choice(scale)) else: cdivs = dsp.randint(2, 4) claps = claps.cloud(length=length / cdivs, grainlength=(dsp.choice(scale)) * cdivs) if dsp.rand() > 0.5: claps = mixdrift(claps) layers += [ claps * 0.4 ] drms = fx.softclip(dsp.mix(layers)) if dsp.rand() > 0.5: return fx.lpf(drms, dsp.rand(500, 1000)) else: return fx.bpf(drms, dsp.rand(500, 5000))
def cb(pos, real, imag): mag, arg = fft.to_polar(real, imag) mag = fx.lpf(mag, pos * 5000 + 100) return fft.to_xy(mag, arg)