Skip to content

mctrl

Return the midi control change value for the controller number

Syntax

kval mctrl ictrlnum [, icinit], [imchannel]
ival mctrl_i ictrlnum [, icinit], [imchannel]
kval = mctrl(ictrlnum [, icinit], [imchannel])
ival = mctrl_i(ictrlnum [, icinit], [imchannel])

Usage

mctrl returns the midi cc value for the controller number (ictrlnum). The midi channel will be taken from the midi channel assigned to the enclosing instrument (see midiroute), unless specified in the optional argument imchannel.

Pitchbend

A special global string gsmidi_pb_channel captures midi pitch bend for each channel.

Sustain

CC# 64 is assumed to be a sustain pedal (note-off messages for midi generated events on the channel are ignored when the pedal is 'on').


Arguments

i/kval -- The output value of the controller. The range is scaled between 0 - 1.

ictrlnum -- The controller number.

icinit (optional, default=last known value) -- set an initial value.

imchannel (optional, default=mapped p1) -- listen on this midi channel

Example

midi.orc

midi.orc
giS1 = 73 ;; Slider mapped to CC# 73 (attack rate)
giS2 = 75 ;; Slider mapped to CC# 75 (decay rate)
giP9 = 17 ;; Pot 9 mapped to CC# 17 (fm index)
;; HARDWARE mappings. Adjust for your midi device.


opcode bassfm,a,kkk
kamp, kpit, kmod xin
kfmndx = 100*(2^kmod)/kpit ;richer harmonics with lower frequencies
kmndx = kfmndx * transeg:k(1,limit(abs(p3),0.5,7),-3,0.25)
aenv = mxadsr:a(0.007,0,1,0.2,0,0.1)
  ares foscili kamp,kpit,1,1,kmndx,-1
xout ares*aenv
endop
;; a bass tone generator.

midiroute 1, "bass"
;; map midi channel 1 to the bass instrument.

instr bass

  ares bassfm p4,sclbend(p5, gSmidi_pb_channel), mctrl(giP9,p6)
  ares declickr ares, mctrl_i(giS1,0.0015)*1.5,mctrl_i(giS2,0.0015)*1.5
  ;; Using declick as an envelope control.

  send ares
endin