Skip to content

euclidean

Use a euclidean rhythm algorithm to return an array of rhythm values.

Syntax

krhythms[] euclidean iseqlen, inumhits [, ibarlen, irotate, kmode]
irhythms[] euclidean_i iseqlen, inumhits [, ibarlen, irotate, imode]    
krhythms[] = euclidean(iseqlen, inumhits [, ibarlen, irotate, kmode])
irhythms[] = euclidean_i(iseqlen, inumhits [, ibarlen, irotate, imode])     

Usage

euclidean outputs an array of rhythm values in beats, suitable for use in event generator UDO's, or nextrh.


Outputs and arguments

i/krhythms[] -- the output array of rhythm values.

iseqlen -- duration in beats of the sequence.

inumhits -- number of events in the sequence

ibarlen (optional, default=iseqlen) -- ibarlen applies a scalar multiplier to the beat values such that the sum of the array == ibarlen. The effect is to speed up or slow down the rhythms to fit within ibarlen beats.

irotate (optional, default=0) -- permute/rotate the position of events in the sequence by n positions.

Example

euclidean.orc

nextrh
temposet 60

instr Sound101
  ;; Audio source

  ares fmrhode p4,p5,3,0.05,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,2,4,-3,-1,1), "ostinato1",1)
  ;; iterate through an array of pitches

  schedule "Sound101",0,tempodur(0.3),0.7,cpstuni(ipit-7, gi_CurrentScale)
  ;; play the note.

  irhythms[] euclidean_i 8,3,1
  ;; tresillo rhythm 
  printarray irhythms

  irh nextrh irhythms,"rhid2"
  schedule p1, irh, 1
  ;; re-trigger this according to irh rhythms.

  turnoff ; no need for a k-rate pass
endin

schedule "Sched11",0,1