コード例 #1
0
def filtered_square(delay, note, amp, dur=1.):

    a = np.sqrt(np.linspace(1., 0., 15))
    t = pyo.HarmTable(a.tolist())

    dur *= 2.

    env = pyo.Fader(fadein=.02, fadeout=0.02, dur=dur * 0.9,
                    mul=amp).play(dur=2.5 * dur, delay=delay)

    adsr = pyo.Adsr(attack=dur * 0.05,
                    sustain=0.707,
                    decay=0.1 * dur,
                    release=dur * 0.7,
                    dur=dur * 0.9,
                    mul=amp).play(dur=2.5 * dur, delay=delay)
    osc = pyo.Osc(t, freq=pyo.midiToHz(note), mul=adsr).mix(1)

    rev = pyo.Freeverb(osc, size=1., damp=0.5, bal=1.,
                       mul=env).play(dur=2.5 * dur, delay=delay)
    # rev.out(delay=delay, dur=dur)

    eq = pyo.Biquad(rev, freq=500, q=1., type=2).play(dur=2.5 * dur,
                                                      delay=delay)
    eq.out(delay=delay, dur=dur)
    # eq = None

    return osc, env, rev, eq
コード例 #2
0
def filtered_saw(delay, note, amp, dur=1.):
    t = pyo.SawTable(order=15).normalize()

    dur *= 2.

    env = pyo.Fader(fadein=.02, fadeout=0.02, dur=dur * 0.9,
                    mul=amp).play(dur=2.5 * dur, delay=delay)

    adsr = pyo.Adsr(attack=dur * 0.05,
                    decay=0.05 * dur,
                    sustain=0.3,
                    release=dur * 0.7,
                    dur=dur * 0.9,
                    mul=amp).play(dur=2.5 * dur, delay=delay)
    osc = pyo.Osc(t, freq=pyo.midiToHz(note), mul=adsr).mix(1)

    rev = pyo.Freeverb(osc, size=1., damp=0.5, bal=1.,
                       mul=env).play(dur=2.5 * dur, delay=delay)
    # rev.out(delay=delay, dur=dur)

    eq = pyo.Biquad(rev, freq=800, q=1., type=0).play(dur=2.5 * dur,
                                                      delay=delay)
    eq.out(delay=delay, dur=dur)
    # eq = None

    return osc, env, rev, eq
コード例 #3
0
 def __init__(self, freq=500):
     self.trig = pyo.Trig()
     self.decayTable = pyo.ExpTable([(0,1),(8191,0.001)], exp=5, inverse=False)
     self.growthTable = pyo.ExpTable([(0,freq),(8191,2*freq)], exp=5, inverse=True)
     self.env = pyo.TrigEnv(self.trig, table=self.decayTable, dur=0.1, mul=0).mix(2)
     self.sweep = pyo.TrigEnv(self.trig, table=self.growthTable, dur=0.1)
     self.sin = pyo.Sine(freq=self.sweep, mul=self.env)
     #self.output = pyo.Delay(self.sin, delay=0.1, feedback=0.5).out()
     self.output = pyo.Freeverb(self.sin, size=[.79,.8], damp=.9, bal=.3).out()
コード例 #4
0
def listen(device_num, initial_files):
    """Start listening for MIDI. This function will not block, just
    start the audio serber and all the midi handling."""
    server = pyo.Server(nchnls=1)
    server.deactivateMidi()
    server.boot().start()
    players = {
        note: pyo.SfPlayer(path, mul=.1).stop()
        for note, path in initial_files.items()
    }
    mixdown = pyo.Mix(list(players.values()))
    out = pyo.Compress(mixdown)
    out = pyo.Freeverb(out).out()

    raw = pyo.MidiListener(make_callback(players, out), device_num).start()

    return players, server
コード例 #5
0
            size += 0.05
        x_count += 1
    elif y_button:
        if y_count % 30 == 0 and size > 0.0:
            size -= 0.05
        y_count += 1

    if a_button:
        if a_count % 30 == 0 and damp < 1.0:
            damp += 0.05
        a_count += 1
    elif b_button:
        if b_count % 30 == 0 and damp > 0.0:
            damp -= 0.05
        b_count += 1

    if L_button:
        if L_count % 30 == 0 and bal > 0.0:
            bal -= 0.05
        L_count += 1
    elif R_button:
        if R_count % 30 == 0 and bal < 1.0:
            bal += 0.05
        R_count += 1

    # Execution Section
    audioIn.out()
    reverb = pyo.Freeverb(audioIn, size=size, damp=damp, bal=bal).out()

    clock.tick(60)
pygame.quit()