コード例 #1
0
ファイル: analysis.py プロジェクト: mpdehaan/beatdown
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
コード例 #2
0
ファイル: utils.py プロジェクト: Kyntaz/sound-music
    def __init__(self, extractor):
        self.extractor = extractor

        self.table = pyo.NewTable(extractor.table.length)
        self.player = pyo.TableRead(self.table, freq=self.table.getRate())
        self.metro = pyo.Metro()
        self.trig = pyo.Percent(self.metro)

        self.trig_play = pyo.TrigFunc(self.trig, self.play)
        self.samples = np.asarray(self.table.getBuffer())
コード例 #3
0
ファイル: engine.py プロジェクト: cchurch/beatdown
 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)
コード例 #4
0
    def __init__(self, update_rate, tick_nb, init_funct):
        #Rate at which events are called.
        self.update_rate = update_rate
        #Metronome ticking at the update rate.
        self.master_metro = pyo.Metro(self.update_rate)
        #Signal equal to the current position in the piece.
        self.counter = pyo.Counter(self.master_metro, min=0, max=tick_nb)
        #Calls the events at the current counter position every update tick
        self.event_tf = pyo.TrigFunc(self.master_metro, self._call_event)
        #Calls the init function as soo as .
        self.init_tf = pyo.TrigFunc(pyo.Select(self.counter, value=0),
                                    init_funct)
        #Dictionary containing lists of tuples (function_to_call, args*) at [tick_nb].
        self.structure = {}

        self.master_metro.play()
コード例 #5
0
    def __init__(self, input=None, buf_size=SAMPLE_RATE//4, overlap=0, patience=None, buffer_count=2, mul=1, add=0):
        """
        Parameters
        ----------
        input : PyoObject
            Parent PyoObject (stub)
        length : int
            Number of samples per buffer
        overlap : int
            Number of overlapping samples between adjacent buffers
        """
        pyo.PyoObject.__init__(self, mul, add)
        self.input = input
        self.buf_size = buf_size
        self.overlap = overlap
        self.patience = patience

        self.fifo = Queue()
        self.is_tfilling = True # filling tables (upon initial play)
        self.is_qfilling = False # filling queue (until patience reached)
        self.is_ready = False # ready to play
        self.is_playing = False # should be playing when ready

        # Tables and table readers do process grains of audio
        self.curr_buf = 0
        assert overlap <= buf_size / 2
        self.buffer_count = buffer_count
        if self.patience is None: self.patience = self.buffer_count
        self.tables = [pyo.DataTable(buf_size) for _ in range(self.buffer_count)]
        self.faders = [pyo.Fader(fadein=overlap/SAMPLE_RATE, fadeout=overlap/SAMPLE_RATE, dur=buf_size/SAMPLE_RATE, mul=mul) for _ in range(self.buffer_count)]
        self.oscs = [pyo.TableRead(t, freq=t.getRate(), mul=f) for t, f in zip(self.tables, self.faders)]
        self.sum = reduce(lambda a, b: a + b, self.oscs) + add
        
        # Timing mechanism to coordinate the tables
        self.p_metros = [pyo.Metro(time=(self.buffer_count * (buf_size - overlap) / SAMPLE_RATE)) for i in range(self.buffer_count)]
        self.p_trigs = [pyo.TrigFunc(m, self._play_table, arg=(i)) for i, m in enumerate(self.p_metros)]
        self.l_trigs = [pyo.TrigFunc(tbr['trig'], self._load_table, arg=(i)) for i, tbr in enumerate(self.oscs)]

        self._base_objs = self.sum.getBaseObjects()
コード例 #6
0
ファイル: midi_src.py プロジェクト: pauljohnleonard/pyo-ga
import pyo

srate = 44100.0
s = pyo.Server().boot().start()


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)