Example #1
0
def test_beat3b(server):
    inp = pyo.Input([0, 1])
    mix = pyo.Mix(inp)

    flr1 = pyo.Follower2(mix, 0.005, 0.005)
    spl1 = pyo.AToDB(flr1)
    flr2 = pyo.Follower2(mix, 0.1, 0.1)
    spl2 = pyo.AToDB(flr2)
    diff = spl2 - spl1
    thr = pyo.Thresh(diff, 6)
    nxt = pyo.TrackHold(diff, thr, 1)
    tmr = pyo.Timer(thr, thr)
    prn = pyo.Print(tmr, 1, message='thr')

    return prn, nxt
Example #2
0
 def play(self):
     if not self._but_lp:
         inp = pyo.Input(self._input_channels)
         mix = pyo.Mix(inp)
         self._but_lp = pyo.ButLP(mix, self._lpf)
     if not self._follower:
         self._follower = pyo.Follower2(self._but_lp,
                                        risetime=self._attack,
                                        falltime=self._release)
     if not self._peak_amp:
         self._peak_amp = pyo.PeakAmp(self._follower,
                                      self._peak_amp_callback)
Example #3
0
def test_beat1(server):

    server.server_ms = 0
    last_ms = 0
    server.last_bpm = 0
    server.bpms = []
    server.last_avg = 0

    def trig_func():
        #ct = server.getCurrentTime()
        delta = server_ms - last_ms
        last_ms = server_ms
        
        #delta = ct - last_ct
        #bpm = 
        print(delta, 'trig')

    def time_callback(hours, minutes, seconds, milliseconds):
        #print(hours, minutes, seconds, milliseconds)
        server.server_ms = hours * 3600000 + minutes * 60000 + seconds * 1000 + milliseconds

    def process_callback():
        if ad.minthresh != thr.get():
            ad.minthresh = thr.get()
        #if server.last_avg != avg.get():
        #    print('avg', avg.get())
        #    server.last_avg = avg.get()
        return 
        #bpm = 120 / (tmr.get() or 0.001)
        #while bpm > 360:
        #    bpm /= 2
        #while bpm < 40:
        #    bpm *= 2
        #print('bpm?', bpm)
        data = table.getTable()
        if len(data):
            #data = [d for d in data if d]
            #print(len(data), sum(data), server.server_ms)
            bpm = len(data) * 60 / (sum(data) or 0.001)
            while bpm > 360:
                bpm /= 2
            while bpm < 40:
                bpm *= 2
            #server.bpms.append()
            bpm = int(bpm)
            if bpm != server.last_bpm:
                server.last_bpm = bpm
                print('bpm?', bpm)
        
        table.reset()
        #tfl.play()
            #print(ad.minthresh)

    server.setTimeCallable(time_callback)
    server.setCallback(process_callback)

    table = pyo.DataTable(size=32) 

    inp = pyo.Input([0, 1])
    mix = pyo.Mix(inp)
    
    flr = pyo.Follower2(mix, 0.5, 0.5)
    fla = pyo.Average(flr, server.getBufferSize())
    #flr.ctrl()
    spl = pyo.AToDB(flr)
    thr = spl - 6
    ad = pyo.AttackDetector(mix, 0.005, 1000, 12, -30, 0.05)
    #ad.ctrl()
    #prn = pyo.Print(ad, 1, message='ad')
    prn = None
    tmr = pyo.Timer(ad, ad)
    #avg = pyo.Average(tmr, server.getBufferSize())
    #bpm = 60 / pyo.Min(tmr, 0.001)
    #trg = pyo.TrigFunc(ad, trig_func)
    prn2 = pyo.Print(tmr, 1, message='tmr')
    #tfl = pyo.TableFill(tmr, table)
    return ad, prn, thr, prn2