Skip to content

loopevent

Generate a repeating sequence of score events.

Syntax

loopevent i/kevent[] [, i/kpitches[], i/krhythms[], istatus, itonic, irhgate, ipitdur]
loopevent(i/kevent[] [, i/kpitches[], i/krhythms[], istatus, itonic, irhgate, ipitdur])

Usage

While similar to an arpeggiator, loopevent doesn't require a duration in advance. Instead loopevent continuously generates events 'live' according to the parameter arrays and settings provided.

Re-evaluating a loopevent replaces any currently running loops with a matching p1 in i/kevent[] with immediate effect.

loopevent is useful in performance as it can be re-evaluated repeatedly in Csound global space (outside instrument definitions).


Arguments

i/kevent[] -- An array with values holding p-fields for a score event. kevent must have at least five p-fields representing the following values: p1=instrument, p2=onset (in beats), p3=duration (in beats), p4=amplitude(0-1), p5=pitch (in scale degrees). Additional pfields are permitted (no limit).

P-fields

For p1 i/kevent[], the number of the instrument is required (rather than the name). For named instruments, it is recommended to extract this using n (e.g. n("piano")).

Fractional p1 (i/kevent[0]) will generate multiple loopevent instances of the same instrument (with fractional instrument numbers).

For p2 and p3, note that onset time and duration are assumed to be in 'beats' rather than seconds.

For p5. pitch is assumed to be a scale degree index in gi_CurrentScale.

i/kpitches[] (optional, default=[0] (repeated pitches)) -- Scale degrees from gi_CurrentScale, calculated as intervals from p5 in kevent (kevent[4]). The pitches of generated events will cycle repeatedly through this array in the direction specified by ipitdir.

i/krhythms[] (optional, default=[1]) -- Relative onset time intervals between events. The selected value for the next event iterates sequentially through this array. Negative values signify a rest, and an event will not be generated at the specified time.

istatus (optional, default=1) -- An on/off switch. If istatus=0, the loop stops. If istatus=1, the loop starts.

itonic (optional, default=-1 (Use default key centre)) -- when set to a positive integer, this sets the key centre for the generated pitches.

irhgate (optional, default=1) -- Randomly remove generated events. Range is from zero (remove all), to 1 (generate all).

ipitdir (optional, default=1) -- Sets the direction of iterations through i/kpitches. Can be fractional and negative. See also iterArr.

See also setnode

Example

loopevent.orc

loopevent
instr Sound101
  ;; Sound source

  ares vco2 p4,p5
  kfr transeg 8000, 0.2, -5, p5*4, p3-0.4, 2, p5
  ares moogladder2 ares,kfr/(cosr(12, 5, 5.5)),0.6
send ares
endin

patchsig "Sound101", "outs"
;; connect sound to output.

loopevent fillarray_i(n("Sound101"),0,-1/9,0.5,0), fillarray_i(2,4,6,5,4,5,8,9) - 14, fillarray_i(1/12),1
;; A flamboyant run.