nextbeat
Returns the time interval in seconds for the clock to reach the beat n beats from now.
Syntax
Usage
nextbeat is a useful tool to align rhythms to the next n value on the clock.
A nextbeat value of 3.5 will calculate a delay of at least 3 beats, plus whatever fractional delay is required to align to a half-beat on the clock.
This is useful for keeping scheduled events 'in time' with each other, as the events are aligned to the global clock.
Outputs and arguments
iseconds -- delay time in seconds to reach the input ibeats on the clock.
ibeats -- Scheduled beat time from now to the value on the clock.
Example
See the example for tempo.orc
| An example using nextbeat, tempoget and temposet |
|---|
| instr Sound101
;; Audio source
ares fmrhode p4,p5,5,0.5,0.01,3,-1,-1,-1,-1,-1
ares declickr ares
send ares
endin
patchsig "Sound101", "outs"
instr Sched11
;; Event trigger - a temporal recursion instrument
ipit = iterArr(fillarray(0,1,4,3,4,5), "ostinato1",0.27)
;; iterate through an array of pitches
schedule "Sound101",0,tempodur(1.1),0.5,cpstuni(ipit, gi_CurrentScale)
;; trigger our audio source. Note that tempodur converts beats to durations in seconds.
schedule p1, nextbeat(1), 1
;; re-trigger this recursion instrument in 1 beat.
turnoff ; no need for a k-rate pass
endin
instr Sched12
;; another temporal resursion instrument
itempo tempoget
;; get the current tempo
temposet wrap:i(itempo + 3, 60,510)
;; increment the value within a range, and update the tempo.
;; re-trigger in 0.5 beats time.
schedule p1, nextbeat(0.5), 1
turnoff
endin
schedule "Sched11", 0,1 ;; launch the event trigger instrument.
schedule "Sched12", 0,1 ;; launch the tempo setting instrument.
|