Skip to content

mixerreceive

Receives an arate signal that has been mixed onto a channel of a buss.

📝 Note

Up to Csound 6, this opcode was called MixerReceive.

Syntax

asignal = mixerreceive(ibuss, ichannel)
asignal MixerReceive ibuss, ichannel

Initialization

ibuss -- The number of the buss, for example the number of the instrument receiving the signal.

ichannel -- The number of the channel. Each buss has nchnls channels.

Performance

asignal -- The signal that has been mixed onto the indicated channel of the buss.

Use of the mixer requires that instruments setting gains have smaller numbers than instruments sending signals, and that instruments sending signals have smaller numbers than instruments receiving those signals. However, an instrument may have any number of sends or receives. After the final signal is received, mixerclear must be invoked to reset the busses to 0 before the next kperiod.

Examples

instr 220 ; Master output
  ; It applies a bass enhancement, compression and fadeout
  ; to the whole piece, outputs signals, and clears the mixer.
  a1 = mixerreceive(220, 0)
  a2 = mixerreceive(220, 1)
  ; Bass enhancement
  al1 = butterlp(a1, 100)
  al2 = butterlp(a2, 100)
  a1 = al1*1.5 + a1
  a2 = al2*1.5 + a2 

  ; Global amplitude shape
  env:k = linseg(0.0, p5/2.0, p4, p3-p5, p4, p5/2.0, 0.0)
  a1 *= env
  a2 *= env 

  ; Compression
  a1 = dam(a1, 5000, 0.5, 1, 0.2, 0.1)
  a2 = dam(a2, 5000, 0.5, 1, 0.2, 0.1)

  ; Remove DC bias
  blocked1:a = dcblock(a1)
  blocked2:a = dcblock(a2)

  ; Output signals
  out(blocked1, blocked2)
  mixerclear()
endin

Here is a complete example of the mixerreceive opcode. It uses the file Mixer-modern.csd

Complete example of the mixerreceive opcode.
<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
; Audio out   Audio in
-odac       ;   -iadc    ;;;RT audio out
; For Non-realtime ouput leave only the line below:
; -o Mixer.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

sr = 44100
ksmps = 32
nchnls = 2
0dbfs  = 1

instr 1
  att:k = expon(0.01, p3, 1)    ;create an attack
  Out:a = poscil(0.7, 440)
  mixersetlevel(1, 3, att)      ;impose attack on the gain level
  mixersend(Out, 1, 3, 0)       ;send to channel 0
endin

instr 2
  Out:a = vco2(0.5, 110)        ;saw wave
  mixersetlevel(2, 3, 0.25)     ;set level to .25 of vco2
  mixersend(Out, 2, 3, 1)       ;send to channel 1
endin

instr 3 ;mix instr.1 and 2 with reverb
  gain1:k = mixergetlevel(1, 3)       ;get level form buss 3
  gain2:k = mixergetlevel(2, 3)       ;get level form buss 3
  a1 = mixerreceive(3, 0)             ;receive channel 0
  a2 = mixerreceive(3, 1)             ;receive channel 1
  Out:a = a1*gain1 + a2*gain2         ;mix them
  outL:a, outR:a = reverbsc(Out, Out,  0.85, 12000)  ;add a nice reverb
  out(outL, outR)
  mixerclear()
endin

</CsInstruments>
<CsScore>
;f1 0 4096 10 1

i1 0 2
i2 0 2
i3 0 8  ;reverb stays on for 8 sec.

e
</CsScore>
</CsoundSynthesizer>

Here is a complete example of the MixerReceive opcode. It uses the file Mixer.csd

Complete example of the MixerReceive opcode.
<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
; Audio out   Audio in
-odac       ;   -iadc    ;;;RT audio out
; For Non-realtime ouput leave only the line below:
; -o Mixer.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

sr = 44100
ksmps = 32
nchnls = 2
0dbfs  = 1

instr 1

katt    expon 0.01, p3, 1               ;create an attack
aout    poscil .7, 440,1
        MixerSetLevel   1, 3, katt      ;impose attack on the gain level
        MixerSend aout, 1, 3, 0         ;send to channel 0
endin

instr 2

aout    vco2 .5, 110                    ;saw wave
        MixerSetLevel 2, 3, .25         ;set level to .25 of vco2
        MixerSend aout, 2, 3, 1         ;send to channel 1
endin

instr 3 ;mix instr.1 and 2 with reverb

kgain1  MixerGetLevel   1,3             ;get level form buss 3
kgain2  MixerGetLevel   2,3             ;get level form buss 3
a1      MixerReceive    3,0             ;receive channel 0
a2      MixerReceive    3,1             ;receive channel 1
aout    = a1*kgain1+a2*kgain2           ;mix them
aoutL, aoutR reverbsc aout, aout,  0.85, 12000  ;add a nice reverb
        outs  aoutL, aoutR
        MixerClear
endin

</CsInstruments>
<CsScore>
f1 0 4096 10 1

i1 0 2
i2 0 2
i3 0 8  ;reverb stays on for 8 sec.

e
</CsScore>
</CsoundSynthesizer>

See also

Mixer Opcodes

Credits

Michael Gogins (gogins at pipeline dot com).