Exemple #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
Exemple #2
0
 def __init__(self):
    self.trig = pyo.Trig()
    decaytable = pyo.LinTable(list=[(0,0), (100, 1.0), (8191, 0.0)])
    self.env = pyo.TrigEnv(self.trig, table=decaytable, dur=0.6, mul=[0,0])
    self.spectrum = [1.]+[0.]*15  # 16 total
    self.waveform = pyo.HarmTable(self.spectrum)
    self.osc = pyo.Osc(self.waveform, freq=[0.,0.], mul=self.env)
    self.filter = pyo.Biquad(self.osc, freq=[300.,300.], type=2, q=2.)
    self.output = self.filter.out()
Exemple #3
0
 def create_synth_triangle(self):
     '''Create a sawtooth wave synthesizer as a sum of sines
     using the PYO HarmTable module.'''
     self.log.debug('creating triangle synth [additive]')
     c = cycle([1, -1])
     l = [next(c)/(i*i) if i % 2 == 1 else 0
          for i in range(1, (2*self.nharmonics))]
     t = pyo.HarmTable(list=l, size=self.tsize)
     return pyo.Osc(table=t,
                    mul=0,
                    freq=[FREQ_C4, FREQ_C4])
Exemple #4
0
    def playback2(self):
        print('pb2')
        fader = pyo.Fader(fadein=0.2, fadeout=0.2, dur=5, mul=.2)
        table = pyo.HarmTable([1, 2, 2, 5, 9])
        glissando = pyo.SigTo(value=self.message_translation[0],
                              time=0.1,
                              init=self.message_translation[0])
        osc = pyo.Osc(
            table=table,
            freq=[glissando / 2, (glissando - 1) / 2, (glissando + 100) / 2],
            mul=fader)
        panner = pyo.Pan(osc,
                         outs=2,
                         pan=random.random(),
                         spread=random.random()).out()

        def pat():
            freq = random.choice(self.message_translation)
            glissando.value = freq

        p = pyo.Pattern(pat, [self.message_length, .25, .75]).play()
        fader.play()
        time.sleep(fader.dur + .05)
        osc.stop()
from scipy.signal import argrelextrema
if ENABLE_SONIFICATION: import pyo

RATE = 48000  # audio sampling rate, should stay like this.
# other rates might require new energy calibration
# and will in any case require modification of analysis scripts
FRAME_SIZE = 4096  # size of waveform frame size. could be modified, but not tested

if ENABLE_SONIFICATION:
    s = pyo.Server(duplex=0).boot()
    s.deactivateMidi()
    s.setOutputDevice(1)
    pyo.pa_list_devices()
    s.start()
    tab_m = pyo.HarmTable([
        1, 0, 0, 0, 0, .3, 0, 0, 0, 0, 0, .2, 0, 0, 0, 0, 0, .1, 0, 0, 0, 0,
        .05
    ]).normalize()
    tab_p = pyo.HarmTable([1, 0, .33, 0, .2, 0, .143, 0, .111])


class Ring:
    def __init__(self, fport=250, fmod=100, amp=.3):
        self.mod = pyo.Osc(tab_m, freq=fmod, mul=amp)
        self.port = pyo.Osc(tab_p, freq=fport, mul=self.mod)

    def out(self):
        self.port.out()
        return self

    def sig(self):
        return self.port