コード例 #1
0
ファイル: test_graph.py プロジェクト: luvsound/pippi
    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')
コード例 #2
0
    def test_shape_pulsar(self):
        dsp.seed()
        for i in range(4):
            wts = [shapes.wt('sine', length=1) for _ in range(3)]
            wins = [shapes.win('sine', length=1) for _ in range(3)]
            wins = [w * dsp.win('hann') for w in wins]
            amp = shapes.win('sine', length=1)
            pw = dsp.win(shapes.win('sine', length=1), 0.1, 1)
            freq = dsp.win(shapes.win('sine', length=1), 20, 260)
            grid = dsp.win(shapes.win('sine', length=1), 0.001, 0.75)
            gl = dsp.win(shapes.win('sine', length=1), 0.03, 0.3)
            win = shapes.win('sine', length=1) * dsp.win('hann')
            out = oscs.Pulsar2d(
                wts,
                windows=wins,
                freq=freq,
                pulsewidth=pw,
                amp=amp,
            ).play(dsp.rand(0.2, 1)).cloud(length=20,
                                           window=win,
                                           grainlength=gl,
                                           grid=grid,
                                           speed=dsp.win(
                                               shapes.win('sine', length=1),
                                               0.03, 2),
                                           spread='rnd',
                                           jitter='rnd')

            out.write('tests/renders/shape_pulsar%s.wav' % i)
コード例 #3
0
 def test_shape_win(self):
     dsp.seed()
     wt = shapes.win('sine',
                     length=10,
                     density='rnd',
                     stability='rnd',
                     periodicity='rnd')
     amp = shapes.win('sine',
                      length=10,
                      density='rnd',
                      stability='rnd',
                      periodicity='rnd')
     wt = wt * amp
     wt.graph('tests/renders/shape_win.png')
コード例 #4
0
 def test_shape_win(self):
     dsp.seed()
     for i in range(4):
         wt = shapes.win('sine',
                         length=10,
                         density='rnd',
                         stability='rnd',
                         periodicity='rnd')
         amp = shapes.win('sine',
                          length=10,
                          density='rnd',
                          stability='rnd',
                          periodicity='rnd')
         wt = wt * amp
         wt.graph('tests/renders/shape_win%s.png' % i, width=1024)
コード例 #5
0
 def test_shape_synth(self):
     dsp.seed()
     out = shapes.synth('sine',
                        minfreq=80,
                        maxfreq=800,
                        stability=0.99,
                        length=10)
     amp = shapes.win('sine', length=10)
     out = out * amp
     out.write('tests/renders/shape_synth.wav')
コード例 #6
0
 def test_create_tukey(self):
     length = 10
     shape = dsp.win(shapes.win('sine', length=3), 0, 0.5)
     chord = tune.chord('i9', octave=2)
     out = dsp.buffer(length=length)
     for freq in chord:
         freq = dsp.wt('sinc', freq, freq*4)
         l = Tukey(freq=freq, shape=shape).play(length)
         l = l.pan(dsp.rand())
         out.dub(l)
     out = fx.norm(out, 0.8)
     out.write('tests/renders/osc_tukey.wav')
コード例 #7
0
    def test_fft_process(self):
        snd = dsp.read('tests/sounds/guitar1s.wav')
        length = 2

        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)

        bs = dsp.win(shapes.win('sine'), 0.05, 0.3)
        out = fft.process(snd, bs, length, callback=cb)
        out = fx.norm(out, 1)
        out.write('tests/renders/fft_process.wav')
コード例 #8
0
ファイル: telemetry.py プロジェクト: luvsound/pippi
    if A > B:
        A, B = B, A

    trunk = dsp.win('rsaw', A, B)
    trunk.graph('trunk-%s-rsaw.png' % numgrains, y=(0,1))

    branches = []
    for _ in range(numbranches):
        bD = dsp.rand(0.001, 0.999) # delta
        bA = dsp.rand(max(A - (bD/2), 0), min(A + (bD/2), 1))
        branches += [ dsp.buffer(dsp.win('rsaw', bA, B), channels=1) ]

    branches = dsp.stack(branches)
    branches.graph('branches-%s-rsaw.png' % numgrains, y=(0,1))

    curve = shapes.win('hann', length=0.1)
    trunk = dsp.win(curve, A, B)
    trunk.graph('trunk-%s-randhann.png' % numgrains, y=(0,1))

    branches = []
    for _ in range(numbranches):
        bD = dsp.rand(0.001, 0.999) # delta
        bA = dsp.rand(max(A - (bD/2), 0), min(A + (bD/2), 1))
        branches += [ dsp.buffer(dsp.win(curve, bA, B), channels=1) ]

    branches = dsp.stack(branches)
    branches.graph('branches-%s-randhann.png' % numgrains, y=(0,1))


コード例 #9
0
kick.write('docs/tutorials/renders/002-kick.flac')


def makeclap(length=dsp.MS * 80):
    lowhz = dsp.win('rnd', 3000, 6000)
    highhz = dsp.win('rnd', 2000, 8000)
    return noise.bln('tri', length, lowhz, highhz).env(pluckout)


clap = dsp.join([makeclap().pad(end=0.2)
                 for _ in range(8)])  # render a few claps
clap.write('docs/tutorials/renders/002-clap.flac')

from pippi import shapes

hat_lfo = dsp.win(shapes.win('sine'), 0.01,
                  1.1)  # More on the shapes module later...
clap_lfo = dsp.win(shapes.win('sine'), 0.01, 0.1)
kick_lfo = dsp.win(shapes.win('sine'), 0.05, 0.1)  # A variation for the kicks
time_lfo = dsp.win(
    'hann', 0.001, 0.2
)  # We'll use the same LFO for the hat smears, but in a different way...
out = dsp.buffer(length=30)
hats = dsp.buffer(length=30)

# We'll say a beat is 200ms
beat = 0.2

# First, lay down the kicks
elapsed = 0
while elapsed < 30:
コード例 #10
0
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 makeclap(length=dsp.MS*80):
    lowhz = dsp.win('rnd', 3000, 6000)
    highhz = dsp.win('rnd', 2000, 8000)
    return noise.bln('tri', length, lowhz, highhz).env(pluckout)

clap = dsp.join([ makeclap().pad(end=0.2) for _ in range(8) ]) # render a few claps
clap.write('docs/tutorials/renders/002-clap.flac')


from pippi import shapes

hat_lfo = dsp.win(shapes.win('sine'), 0.01, 1.1) # More on the shapes module later... 
clap_lfo = dsp.win(shapes.win('sine'), 0.01, 0.1) 
kick_lfo = dsp.win(shapes.win('sine'), 0.05, 0.1) # A variation for the kicks
time_lfo = dsp.win('hann', 0.001, 0.2) # We'll use the same LFO for the hat smears, but in a different way...
out = dsp.buffer(length=30) 
hats = dsp.buffer(length=30) 

# We'll say a beat is 200ms
beat = 0.2

# First, lay down the kicks
elapsed = 0 
while elapsed < 30:
    pos = elapsed / 30
    kicklength = kick_lfo.interp(pos) 
    kick = makekick(kicklength)