Skip to content

sclbend, sclbend_i

Returns the interpolated cps pitch when given a scale degree and a modifier (pitchbend) in a channel.

Syntax

icps sclbend_i isclin, Sbend [, iscale]

i/kcps sclbend i/ksclin, Sbend [, iscale]
icps = sclbend_i(isclin, Sbend [, iscale])

i/kcps = sclbend(i/ksclin, Sbend [, iscale])

Usage

sclbend accepts a scale degree and a channel name. The value read from the channel is added to the scale degree. Output is converted to cps pitch (using cpstun3).

The channel can be used as a pitch-bend signal, modifying the pitch with a continuous signal. However, unlike a standard midi pitchbend which typically applies a constant fixed interval to every pitch, sclbend applies a relative amount in reference to scale degrees in iscale.

For example, a channel value of -2 modifies the pitch down 2 steps in the scale (in a C major scale, an 'E' would move a major 3rd down to 'C', and a 'C' would move a minor 3rd to 'A'). Channel values can also be fractional. Fractional values are calculated as the distance to the next nearest note, thus a channel value of 0.5 finds the half-way point between the current pitch and the next pitch in the scale.


Outputs and Arguments

k/isclin -- An index of the scale. Think of this a bit like a pitch class. Can be fractional and negative.

Sbend -- A channel name expected to receive numerical values (through chnset).

iscale (optional, default=gi_CurrentScale)-- Function table containing the parameters (numgrades, interval, basefreq, basekeymidi) and tuning ratios (beginning at 1, and extending to the period of the scale).

See also the example for midiroute

Example

sclbend.orc

sclbend
scalemode31 0,"minor"

instr Sound101
  ;; Sound source

kamp = p4
kpit = p5

  ares vco2 kamp, sclbend(kpit, "pitchbend")
  ;; sclbend modifies kpit by scale-degrees in the "pitchbend" channel

  kfr transeg 4000, 0.4, -1, p5*4, p3-0.4, -2, p5

  ares moogladder2 ares,kfr,0.4

send ares
endin

patchsig "Sound101", "outs"

instr Sched12
  ;; recursive trigger instrument.

schedule "Sound101",0,7,0.3,cpstuni(-3,gi_CurrentScale)
schedule "Sound101",0,7,0.3,cpstuni(0,gi_CurrentScale)
schedule "Sound101",0,7,0.3,cpstuni(2,gi_CurrentScale)
;; play a chord  

linslide "pitchbend", 2, p4 % 3, 2
;; linslide updates the pitchbend channel.
;; The pitches glissando over two seconds after a 2 second delay.

schedule p1, nextbeat(5), 1, p4+1

turnoff
endin

schedule "Sched12", 0,1
;; start the show.