Skip to content

walker

Yields a random walk on each call

Syntax

iout walker Sid [, istepsize] [, imodulo] [, ilower]
iout = walker(Sid [, istepsize] [, imodulo] [, ilower])

Usage

On each call, walker outputs a value either randomly incremented, or decremented from the last value output. A string channel name is used to save state.


Outputs and arguments

iout -- output

Sid -- String channel name to store state. Can be anything, but ideally is unique.

istepsize (optional, default=1) -- the amount to increment or decrement

imodulo (optional, default=0 / no limit) -- the upper limit for wandering values.

ilower (optional, default=0 / no limit) -- the lower limit for wandering values.

Example

See the example for walker.orc

walker
;tables for padoscil
gicusttable ftgen 5, 0, 16384, 8, -1, 2, 1, 4096, 0.1, 4096, -1, 7900, 1, 290, -1
giaftercust vco2init -gicusttable, 256, 1.05, 128, 2^16, gicusttable

instr pads
 ;; sound source  
  kcps = p5
  kwidth = p6
  iwave = -5 ; custom table
  iovrlap = 45

  kfmd1 =  expcurve(kwidth, 15) * 0.25 * kcps  
  kfnum vco2ft kcps, iwave
  apad oscbnk kcps, 1.0,  kfmd1, 0, 45, rnd:i(100), 0.1, 6.7, 0.15, 0.8, 132, 0.1, 0.3, 0, 0, 0, 0, -1, kfnum, -1, -1
  apad declickr apad, 0.5

  send apad*p4

endin

patchsig "pads","outs"

loopcode fillarray_i(6,4), "loop1", {{

gipitch = walker("walk",1,0,21)
;; a walking 'root'

istringsg1[] fillarray n("pads"), 0, iLOOPDUR, 0.3,gipitch,0.2
;; the 'seed' event

ichrd[] fillarray gipitch, gipitch+randint(0,3),gipitch+4
;; build a chord

chrdi istringsg1, ichrd,-3,0,0,0.1
;; and play

}},1