Skip to content

tempoget, temposet and tempodur

Set and return the speed of the clock

Syntax

temposet ibpm

ibpm tempoget

iseconds tempodur ibeats
kseconds tempodur_k kbeats
temposet(ibpm)

ibpm = tempoget()

iseconds = tempodur(ibeats)
kseconds = tempodur_k(kbeats)

Usage

temposet sets the tempo of the global clock in 'beats per minute' (default is 60)

tempoget returns the current tempo of the clock.

tempodur/tempodur_k returns the value in seconds of ibpm beats according to the current tempo.

Note that event generators use tempodur internally to calculate event times.


Outputs and Arguments

ibpm -- tempo in beats per minute (bpm)

i/kseconds (for tempodur) -- Converts the beat value into duration in seconds for the current tempo.

Example

tempo.orc

Example of using now to select ranges of random pitch
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.