diff options
Diffstat (limited to 'site/udo/tempo_tools.udo')
-rwxr-xr-x | site/udo/tempo_tools.udo | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/site/udo/tempo_tools.udo b/site/udo/tempo_tools.udo new file mode 100755 index 0000000..a678f7a --- /dev/null +++ b/site/udo/tempo_tools.udo @@ -0,0 +1,72 @@ +#ifndef UDO_TEMPOTOOLS
+#define UDO_TEMPOTOOLS ##
+/*
+ Tempo tools
+
+ This file is part of the SONICS UDO collection by Richard Knight 2021
+ License: GPL-2.0-or-later
+ http://1bpm.net
+*/
+
+/*
+ Get the beat time (1/4 note) and quarter beat time (1/16 note) in seconds
+ for a given BPM
+
+ ibeattime, iquartertime tempotime ibpm
+
+ ibeattime the 1/4 note time in seconds
+ iquartertime the 1/16 note time in seconds
+ ibpm the beats per minute value
+*/
+opcode tempotime, ii, i
+ itempo xin
+ ibeattime = 60.0 / itempo
+ iquartertime = ibeattime * .25
+ xout ibeattime, iquartertime
+endop
+
+
+/*
+ Get the swung time (when iquarterindex is 1 or 3) for a given time
+ Using iquartertime as the 1/16 beat time and iswing as multiplier of
+ iquartertime to add to the time (iswing should be less than one)
+
+ itime swinger iquarterindex, iquartertime, itime, iswing
+
+ itime the time with swing applied
+ iquarterindex the quarter beat index MIN(0) MAX(3)
+ iquartertime time of one 1/16th beat
+ itime the normal/quantised time
+ iswing the swing amount MIN(0) MAX(1)
+
+*/
+opcode swinger, i, iiii
+ iquarterindex, iquartertime, itime, iswing xin
+ if (iquarterindex == 1 || iquarterindex == 3) then
+ itime = itime + (iswing * iquartertime)
+ endif
+ xout itime
+endop
+
+
+/*
+ Metronome with random variation
+
+ ktrigger drunkenmetro kfreq
+
+ ktrigger the metronome trigger
+ kfreq metronome frequency in hz
+*/
+opcode drunkenmetro, k, k
+ kfreq xin
+ kbtime = 1.0 / kfreq
+ kmetro metro kfreq
+ kdeltime random 0, (1.0 / kfreq) * 0.9
+ kout vdel_k kmetro, kdeltime, 1
+ xout kout
+endop
+
+
+
+
+#end
\ No newline at end of file |