def test_retrograde(self): sound = SoundBuffer(filename='tests/sounds/linux.wav') for crossings in [3,30,100,300]: waveset = Waveset(sound, crossings=crossings) waveset.retrograde() out = waveset.render() out.write('tests/renders/waveset_retrograde_%s_crossings.wav' % crossings)
def test_render(self): sound = SoundBuffer(filename='tests/sounds/guitar1s.wav') waveset = Waveset(sound) out = waveset.render(channels=1) out.write('tests/renders/waveset_render.wav') self.assertEqual(len(out), len(sound))
def test_waveset_pulsar2d(self): rain = dsp.read('tests/sounds/rain.wav').cut(0, 10) ws = Waveset(rain) ws.normalize() osc = Pulsar2d(ws, windows=['sine'], freq=200.0, amp=0.2) out = osc.play(60) out.write('tests/renders/osc_waveset_pulsar2d.wav')
def test_substitute_reversed(self): sound = SoundBuffer(filename='tests/sounds/linux.wav') waveset = Waveset(sound) rev = waveset.reversed() out = waveset.replace(rev) out = fx.norm(out, 1) out.write('tests/renders/waveset_substitute_reversed.wav')
def test_morph(self): sound = SoundBuffer(filename='tests/sounds/linux.wav') tsound = SoundBuffer(filename='tests/sounds/guitar10s.wav') waveset = Waveset(sound) target = Waveset(tsound) out = waveset.morph(target, 'phasor') out.write('tests/renders/waveset_morph_phasor.wav')
def test_harmonic(self): sound = SoundBuffer(filename='tests/sounds/guitar10s.wav') waveset = Waveset(sound) harmonics = [1, 2, 3] weights = [1, 0.5, 0.25] out = waveset.harmonic(harmonics, weights) out.write('tests/renders/waveset_harmonic_distortion.wav')
def makeArps(seg, oct=3, reps=4): arp_degrees = [1,2,3,5,8,9,10] if dsp.randint(0,1) == 0: arp_degrees.reverse() arp_degrees = rotate(arp_degrees, vary=True) arp_notes = tune.fromdegrees(arp_degrees[:reps], octave=oct, root='e') arps = [] arp_count = 0 for arp_length in seg: arp_length /= 2 arp_pair = arp_notes[ arp_count % len(arp_notes) ], arp_notes[ (arp_count + 1) % len(arp_notes) ] stack = Waveset(rmx, limit=dsp.randint(5, 20), offset=dsp.randint(0, 100)) stack.normalize() arp_one = oscs.Pulsar2d(stack, windows=['tri'], freq=arp_pair[0]*dsp.choice([1,2]), pulsewidth=dsp.win('rnd', 0.1, 1)).play(arp_length).env('hannout').taper(0.01) * dsp.rand(0.02, 0.2) arp_two = oscs.Pulsar2d(stack, windows=['tri'], freq=arp_pair[1]*dsp.choice([1,2]), pulsewidth=dsp.win('rnd', 0.1, 1)).play(arp_length).env('hannout').taper(0.01) * dsp.rand(0.02, 0.2) arp_one.dub(arp_two) arps += [ arp_one ] arp_count += 2 return dsp.join(arps).env('rnd').pan(dsp.rand())
def bass_and_lead(length, pos, total_length): numbeats = int(length//BEAT) maxbeats = dsp.randint(2, 16) layers = [] 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) if dsp.rand() > 0.5: basses = bass(0.5, length, 1) else: bpat = drums.eu(numbeats, maxbeats) basses = drums.make(bass, bpat, [BEAT]*numbeats) layers += [ basses ] lead_note = dsp.choice(scale) stack = Waveset(rmx, limit=dsp.randint(5, 20), offset=dsp.randint(0, 100)) stack.normalize() lead = oscs.Pulsar2d(stack, windows=['tri'], freq=lead_note*2, pulsewidth=dsp.win('rnd', 0.1, 1)).play(length/dsp.rand(1,5)).env('hannout').taper(0.01) * dsp.rand(0.02, 0.2) layers += [ lead ] return fx.norm(dsp.mix(layers), 1)
def test_interleave(self): sound1 = SoundBuffer(filename='tests/sounds/linux.wav') sound2 = SoundBuffer(filename='tests/sounds/guitar10s.wav') waveset1 = Waveset(sound1, limit=10, offset=1000) waveset2 = Waveset(sound2, limit=10, offset=1000) waveset1.interleave(waveset2) out = waveset1.render() out.write('tests/renders/waveset_interleave.wav')
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_pulsar_from_waveset(self): sound = SoundBuffer(filename='tests/sounds/guitar1s.wav') waveset = Waveset(sound, limit=20, modulo=1) waveset.normalize() osc = Pulsar2d(waveset, windows=['sine'], wt_mod=dsp.wt('saw', 0, 1), win_mod=0.0, pulsewidth=1.0, freq=80.0, amp=0.8) length = 30 out = osc.play(length) out.write('tests/renders/waveset_pulsar2d_wavetables-80hz.wav') self.assertEqual(len(out), int(length * out.samplerate))
def test_sandwich_board(self): l = dsp.read('tests/sounds/linux.wav') g = dsp.read('tests/sounds/guitar1s.wav') f = fx.crossover(l, dsp.win('phasor', 0, 1), dsp.rand(0.1, 0.3), dsp.win('rnd', 0, 1)).graph(fontsize=50, label='Weird FX') ws = Waveset(g).substitute('sine').graph(fontsize=50, label='Waveset Manipulation') ps = oscs.Pulsar2d(freq=dsp.rand(10, 80), pulsewidth=shapes.win('hann')).play(2).graph( fontsize=50, label='Pulsar Synthesis') wt = shapes.win('hann', length=0.4) * shapes.win('sine') * shapes.win('rnd') wt.graph( 'tests/renders/graph_sandwich_board.png', insets=[ps, ws, f], width=900, height=340, label='Pippi: Computer Music With Python', stroke=30, fontsize=30, ) # For the readme shutil.copy('tests/renders/graph_sandwich_board.png', 'banner.png')
def test_pulsar_from_waveset(self): sound = SoundBuffer(filename='tests/sounds/guitar1s.wav') waveset = Waveset(sound, limit=20, modulo=1) waveset.normalize() osc = Pulsar2d( waveset, windows=['sine'], wt_mod=dsp.wt('saw', 0, 1), win_mod=0.0, pulsewidth=1.0, freq=80.0, amp=0.8 ) length = 30 out = osc.play(length) out.write('tests/renders/waveset_pulsar2d_wavetables-80hz.wav') self.assertEqual(len(out), int(length * out.samplerate))
def test_stretch(self): sound = SoundBuffer(filename='tests/sounds/linux.wav') waveset = Waveset(sound) factor = dsp.wt('phasor', 1, 10) out = waveset.stretch(factor) out.write('tests/renders/waveset_stretch.wav')
def test_substitute(self): sound = SoundBuffer(filename='tests/sounds/linux.wav') waveset = Waveset(sound) out = waveset.substitute('sine') out.write('tests/renders/waveset_substitute_sine.wav')
def test_normalize(self): sound = SoundBuffer(filename='tests/sounds/linux.wav') waveset = Waveset(sound) waveset.normalize() out = waveset.render() out.write('tests/renders/waveset_normalize.wav')
def test_reverse(self): sound = SoundBuffer(filename='tests/sounds/linux.wav') waveset = Waveset(sound) waveset.reverse() out = waveset.render() out.write('tests/renders/waveset_reverse.wav')