Exemplo n.º 1
0
    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())
Exemplo n.º 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)
Exemplo n.º 3
0
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)
Exemplo n.º 4
0
    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')
Exemplo n.º 5
0
    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)
Exemplo n.º 6
0
def make_note(freq, amp, length):
    numtables = random.randint(1, random.randint(3, 12))
    lfo = dsp.randline(random.randint(10, 100))
    lfo_freq = random.triangular(0.3, 30)

    mod = dsp.randline(random.randint(10, 100))
    mod_freq = random.triangular(0.3, 3)
    mod_range = random.triangular(0, 0.03)
    pulsewidth = random.random()

    wavetables = []
    for _ in range(numtables):
        if random.random() > 0.5:
            wavetables += [random.choice(['sine', 'square', 'tri', 'saw'])]
        else:
            wavetables += [dsp.randline(random.randint(3, 300))]

    return oscs.Pulsar2d(wavetables,
                         windows=['sine'],
                         pulsewidth=pulsewidth,
                         freq=freq,
                         amp=amp).play(length)