Example #1
0
    def __init__(self, chain):
        self.chain = chain

        self.pitch = pyo.Sig(0)
        self.vol = pyo.Sig(0)
        self.env = pyo.Adsr()

        self.sine = pyo.Sine(self.pitch, mul=self.vol * self.vol)
Example #2
0
 def __init__(self, sequence, amp=1, pan=0.5):
     self.sequence = sequence
     self.trig = self.sequence.trigger
     self.dur = self.sequence.time
     self.freq = self.sequence.signal
     self.amp = pyo.Sig(amp)
     self.master_amp = pyo.Port(pyo.Denorm(self.amp), init=amp, risetime=0, falltime=0)
     self.pan = pyo.Sig(pan)
     self.master_pan = pyo.Port(pyo.Denorm(self.pan), init=pan, risetime=0, falltime=0)
Example #3
0
def test_metronome(server):
    def trig_func():
        print(server.getCurrentTime(), 'trig')

    inp = pyo.Input([0,1])
    inx = pyo.Mix(inp)
    #atd = pyo.AttackDetector(inx)
    #prn = pyo.Print(atd, 1, message='attack')
    #avg = pyo.Average(inx)
    #prn = pyo.Print(avg, 1, message='avg')
    #sig = pyo.Sig(0.5)
    bpm = pyo.Sig(value=120)
    #bpm_round = pyo.Round(bpm)
    #bpm2 = pyo.Clip(bpm2, 30, 360)
    tpb = 2.5 / (pyo.Clip(pyo.Round(bpm), 30, 360))
    met = pyo.Metro(time=tpb)
    met.play()
    print(server.getBufferSize())
    trg = pyo.TrigFunc(met, trig_func)

    #ti = pyo.Timer(met, met)
    #prn = pyo.Print(met, 1, message='met')
    #bpm = pyo.Round(60 / ti)
    #bpm2 = pyo.Clip(bpm, 30, 360)
    #pr2 = pyo.Print(pyo.Clip(pyo.Round(60 / ti), 30, 360), 0, message='bpm')
    
    def update_met():
        print('update met')
        #met.setTime(0.4)
        bpm.setValue(150)
        #met.stop()
        #met.play()
    ca = pyo.CallAfter(update_met, 10)

    return bpm, trg, ca
Example #4
0
    def __init__(self, chain, extractor):
        self.chain = chain
        self.extractor = extractor

        self.table = pyo.NewTable(self.extractor.table.length)
        self.window = pyo.HannTable(self.table.size)
        self.samples = np.asarray(self.table.getBuffer())
        self.pitch = pyo.Sig(0)
        self.vol = pyo.Sig(0)
        self.env = pyo.Adsr()

        self.osc = pyo.Granule(self.table, self.window, dens=100)
        self.osc.setSync(False)

        self.sin = pyo.Blit(self.pitch, mul=self.vol)
        self.vocoder = pyo.Vocoder(self.sin, self.osc, self.pitch)
        self.compressor = pyo.Compress(self.vocoder)
Example #5
0
    def build(self):
        self.barCount = -1

        self.n_beats_bar = len(self.pheno.triggers)
        self.pitch_seq = self.pheno.sequences.get(
            self.data.pitch_seq_id).data.seq
        self.pitch_map = self.pheno.notes.get(self.data.pitch_map_id).data.map

        self.amp_seq = self.pheno.sequences.get(self.data.amp_seq_id).data.seq
        self.amp_map = self.pheno.amps.get(self.data.amp_map_id).data.map

        self.pitch = pyo.Sig(0)
        self.amp = pyo.Sig(0)
        self.callback(0)

        self.trigFuncs = []

        for i, g in enumerate(self.pheno.triggers):
            self.trigFuncs.append(pyo.TrigFunc(g.trigger, self.callback,
                                               arg=i))
Example #6
0
    def __init__(self):
        super().__init__()

        self.sine = pyo.CosTable([(0, 0), (100, 1), (1000, .25), (8191, 0)])
        self.square = pyo.SquareTable()
        self.saw = pyo.SawTable()
        self.synth = pyo.NewTable(8192 / 44100)

        self.pointer = pyo.Sig(0)
        self.morph = pyo.TableMorph(self.pointer, self.synth,
                                    [self.sine, self.square, self.saw])
        self.osc = pyo.Osc(self.synth, 440)
        self.filter = pyo.Biquad(self.osc)
        self.verb = pyo.WGVerb(self.filter).mix(2)
Example #7
0
 def play(self):
     if not self._sig:
         self._sig = pyo.Sig(value=self._bpm)
     if not self._met:
         tpb = 2.5 / (pyo.Clip(pyo.Round(self._sig), 30, 360))
         self._met = pyo.Metro(time=tpb)
         self._met.play()
         if self._callback:
             self._callback(b'\xfa')
     if not self._met.isPlaying():
         self._met.play()
         if self._callback:
             self._callback(b'\xfb')
     if not self._trg:
         self._trg = pyo.TrigFunc(self._met, self._trig_callback)
Example #8
0
 def __init__(self, freq=440, base_freq=55, samplerate=44100, phase=0, mul=1, add=0):
     PyoObject.__init__(self, mul, add)
     self._freq = freq
     self._phase = phase
     self._base_freq = base_freq
     self._samplerate = samplerate
     self._max_freq = int(samplerate / 4)
     self._table_size = int((self._max_freq / self._base_freq) * 4)
     self._col_size = 1
     #freq,mul,add,lmax = convertArgsToLists(freq,mul,add)
     
     tables = tables_gen(sine_gen, self._table_size, self._col_size, self._base_freq, self._max_freq)
     self._matrix = pyo.NewMatrix(self._table_size, self._col_size, tables)
     self._ramp = pyo.Phasor(freq, phase)
     self._wave = pyo.MatrixPointer(self._matrix, self._ramp, pyo.Sig(0))
     self._base_objs = self._wave.getBaseObjects()
Example #9
0
 def __init__(self, freq=440, base_freq=55, samplerate=44100, phase=0, mul=1, add=0):
     PyoObject.__init__(self, mul, add)
     self._freq = freq
     self._phase = phase
     self._base_freq = base_freq
     self._samplerate = samplerate
     self._max_freq = int(samplerate / 4)
     self._table_size = int((self._max_freq / self._base_freq) * 4)
     self._col_size = int((self._max_freq / self._base_freq) / 2)
     #freq,mul,add,lmax = convertArgsToLists(freq,mul,add)
     
     tables = tables_gen(tri_gen, self._table_size, self._col_size, self._base_freq, self._max_freq)
     self._matrix = pyo.NewMatrix(self._table_size, self._col_size, tables)
     self._ramp = pyo.Phasor(freq, phase)
     self._table_selector_freq = pyo.Sig(freq)
     self._table_selector = pyo.Min(pyo.Max(((pyo.Abs(self._table_selector_freq) / (self._base_freq * 2)) - 0.5) / self._col_size, 0), (self._col_size - 1) / self._col_size)
     self._wave = pyo.MatrixPointer(self._matrix, self._ramp, self._table_selector)
     self._base_objs = self._wave.getBaseObjects()
Example #10
0
    def __init__(self, **config):
        super(BinauralBeat, self).__init__(**config)

        self.server = pyo.Server(buffersize=1024).boot()
        centerFreq = pyo.Sig(256)
        binauralFreq = pyo.Sine(freq=0.05, add=10.5, mul=1.5)

        left = pyo.Sine(freq=centerFreq - binauralFreq / 2)
        right = pyo.Sine(freq=centerFreq + binauralFreq / 2)
        left.out(chnl=0)
        right.out(chnl=1)

        #left = pyo.PinkNoise().mix(2).out()

        import thread
        thread.start_new_thread(self.server.start, ())

        self.left = left
        self.right = right
Example #11
0
    def __init__(self, inp):
        self.inp = inp
        self.sounds = np.zeros((N_SEGMENTS, pyo.secToSamps(MAX_NOTE_LEN)))
        self.lens = np.zeros(N_SEGMENTS, dtype=np.int32)
        self.iw = 0
        self.on = False

        self.thresh = pyo.Sig(0.01)

        self.follower = pyo.Follower(self.inp, freq=10)
        self.up = pyo.Thresh(self.follower, self.thresh, dir=0)
        self.down = pyo.Thresh(self.follower, self.thresh, dir=1)

        self.table = pyo.NewTable(MAX_NOTE_LEN)
        self.rec = pyo.TableRec(self.inp, self.table)

        self.trig_start = pyo.TrigFunc(self.up, self.start_rec)
        self.trig_save = pyo.TrigFunc(self.down, self.save_sound)
        self.trig_drop = pyo.TrigFunc(self.rec['trig'], self.drop_rec)

        self.samples = np.asarray(self.table.getBuffer())
Example #12
0
 def __init__(self) -> None:
     self.fader = pyo.Fader(fadein=0.005, fadeout=self._fadeout_time)
     self.trigger1 = pyo.Trig()
     self._mul = self.max_vol
     self.spatialisation = [[pyo.Sig(0) for _ in range(4)]
                            for _ in range(2)]
     self.table_reads = [
         pyo.TableRead(
             table,
             freq=table.getRate(),
         ) for table in self.snd_tables[0]
     ]
     self.processed_tables = [
         pyo.ButLP(table_read, freq=6000) for table_read in self.table_reads
     ]
     self.spatialised_tables = [
         pyo.Mix(signal,
                 voices=4,
                 mul=[self.fader * spat_value for spat_value in spat])
         for signal, spat in zip(self.processed_tables, self.spatialisation)
     ]
     self.generator = self.spatialised_tables[0] + self.spatialised_tables[1]
Example #13
0
    def __init__(self):
        super().__init__()

        self.wv1 = pyo.CosTable([(0, 0), (4060, 1), (8191, 0)])
        self.wv2 = pyo.CosTable([(0, 0.00), (2074, 0.59), (4060, 1.00),
                                 (8191, 0.00)])
        self.wv3 = pyo.CosTable([(0, 0.00), (2074, 0.59), (4060, 1.00),
                                 (6117, 0.60), (8191, 0.00)])
        self.wv4 = pyo.CosTable([(0, 0.00), (2039, 0.29), (2039, 0.60),
                                 (4060, 1.00), (6117, 0.60), (6117, 0.30),
                                 (8191, 0.00)])
        self.wv5 = pyo.CosTable([(0, 0.00), (2039, 0.29), (2039, 0.60),
                                 (3255, 0.29), (4060, 1.00), (4900, 0.30),
                                 (6117, 0.60), (6117, 0.30), (8191, 0.00)])
        self.wv6 = pyo.CosTable([(0, 0.00), (769, 1.00), (2039, 0.29),
                                 (2039, 0.60), (3255, 0.29), (4060, 1.00),
                                 (4900, 0.30), (6117, 0.60), (6117, 0.30),
                                 (7333, 1.00), (8191, 0.00)])
        self.wv7 = pyo.CosTable([(0, 0.00), (769, 0.00), (769, 1.00),
                                 (2039, 0.29), (2039, 0.60), (3255, 0.29),
                                 (4060, 1.00), (4900, 0.30), (6117, 0.60),
                                 (6117, 0.30), (7333, 1.00), (7333, 0.00),
                                 (8191, 0.00)])
        self.wv8 = pyo.CosTable([(0, 0.00), (769, 0.00), (769, 1.00),
                                 (2039, 0.29), (2039, 0.60), (3255, 0.29),
                                 (3255, 1.00), (4900, 1.00), (4900, 0.30),
                                 (6117, 0.60), (6117, 0.30), (7333, 1.00),
                                 (7333, 0.00), (8191, 0.00)])
        self.synth = pyo.NewTable(8192 / 44100)

        self.pointer = pyo.Sig(0)
        self.morph = pyo.TableMorph(self.pointer, self.synth, [
            self.wv1, self.wv2, self.wv3, self.wv4, self.wv5, self.wv6,
            self.wv7, self.wv8
        ])
        self.osc = pyo.Osc(self.synth, 440)
        self.filter = pyo.Biquad(self.osc)
        self.verb = pyo.WGVerb(self.filter).mix(2)
Example #14
0
 def __init__(self, signal: pyo.PyoObject, n_voices: int):
     self._control_signals = [pyo.Sig(0) for _ in range(n_voices)]
     super().__init__(signal, voices=n_voices, mul=self.control_signals)
Example #15
0
def trighandler(id):
    print id
    on.setValue(id)


dur = 1.0
delay1 = 0.2
trigs = []
trigs.append(pyo.Metro(dur))
trigs.append(pyo.SDelay(trigs[0], delay=delay1))

trigFuncs = []
for i in range(len(trigs)):
    trigFuncs.append(pyo.TrigFunc(trigs[i], trighandler, arg=i))

freq = pyo.Sig(400)

on = pyo.Sig(0)

e = pyo.MidiAdsr(on, attack=0.001, decay=0.005, sustain=0.70, release=0.010)

hifreq = srate

b1 = pyo.LFO(freq=freq, mul=e)

v = pyo.Biquad(input=b1, freq=1000, q=2, type=2).out()

#
#f1.ctrl()
#f2.ctrl()
#f3.ctrl()