Skip to content

chrdi

Generates a series of concurrent score events separated by intervals.

Syntax

chrdi i/kevent[],i/kintervals[] [,idbdamp,iturnofftm,iautoinvert,irndspread,insincr,iscale]
chrdi = i/kevent[],i/kintervals[] [,idbdamp,iturnofftm,iautoinvert,irndspread,insincr,iscale]

Usage

chrdi generates 'chords' from a note, and an array of pitches.

Given an array of values representing a score event (p-fields), chrdi generates additional score events. An array specifies pitch intervals around p5 in the event. Other than pitches, all other parameters in the event are duplicated.


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, p3=duration, p4=amplitude(0-1), p5=pitch Additional pfields up to p10 are optional (lenarray(kevent) <= 10)

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")).

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/kintervals[] -- Intervals (as specified in iscale). The pitches of generated events sum the pitch from p5 in i/kevent with the values in i/kintervals.

idbamp (optional, default=0) -- reduces the p4 values of events as the number of concurrent events increases. Assuming p4 is amplitude, a value of -3 reduces this by 3db every doubling of notes. Default is 0 (no reduction)

iturnofftm (optional, default=0) -- When greater than zero (iturnofftm > 0), turns off the most recent instance after iturnofftm seconds. When less than zero (iturnofftm < 0), turns off the oldest instance after abs(iturnofftm) This can be useful if using i/kevent[] with negative p3 (always on).

iautoinvert (optional, default=-1, no inversion) -- constrains pitches to pitch classes within n octaves, starting from zero (within one octave). For example, if kintervals[] fillarray 4,6,8, and iautoinvert = 0 in a diatonic major scale, then the resultant pitches 1,4,6 are generated (the 8 drops an octave).

irndspread (optional, default=0) -- Add some randomisation to the onsets of generated events. The onset is calculated as i/kevent onset + betarand:i(ievent[2],irndspread,2-irndspread. Expected values between 0 - 1. Small values (c.a. 0.05) are useful to 'humanise' chord onsets.

insincr (optional, default=0, -p3 default=0.01) -- Increment the p1 value of generated events by a fractional amount. Useful for 'always on' events. Expected values are between 0 < 1. A value of 1 is converted to 0.01. If a negative p3 is detected in i/kevent, insincr uses 0.01.

i/kscale (optional, default=gi_CurrentScale) -- Use this scale for pitch generation.

Example

chrdi.orc

chrdi
scalemode31 0, "m7"

instr Sound101
  ;; Sound source

  ares1 fmb3 p4,p5,1.3,0.75,0.08, 5.31,-1,-1,-1,-1,-1
  ares2 fmb3 p4,p5,1.3,0.75,0.06, 7.11,-1,-1,-1,-1,-1

send ares1,ares2
endin

patchsig "Sound101", "outs"

instr Sched13
  ;; recursive trigger instrument.

  ichrdseq = iterArr(fillarray(0,-2,-4,-3,-2,-1),"hb3")
  ;;iterate through a sequence

  ievent[] = fillarray_i(n("Sound101"), 0,3,0.6,ichrdseq)
  ;; create an event array, with pitch following the sequence.

  ichrd[] fillarray -1,0,2,4,6
  ;; build a five note chord

  chrdi ievent,ichrd, -3,0,0
  ;; apply chords to ievent.

  schedule "Sound101",0,3,0.3,cpstuni(ichrdseq - 14,gi_CurrentScale)
  ;; add a bass line.

  schedule p1, nextbeat(3), 3, 5 ;; and around again
turnoff
endin

schedule "Sched13", nextbeat(1),3
;; start the show.