Skip to content

encode2, decode2

encode two audio signals into a single audio signal, and vice-versa.

Syntax

aencoded encode2 asig1, asig2
asig1, asig2 decode2 aencoded
aencoded = encode2(asig1, asig2)
asig1, asig2 decode2 aencoded   

Usage

encode2 combines two audio signals into a single encoded audio signal. The two signals can be extracted again using decode2. Potential uses could include synchronising audio channels over a network.


Outputs and arguments

aencoded -- the encoded audio signal

asig1, asig2 -- Input audio signals.

Example

See the example for encode2.orc

encode2/decode2
instr encodepan

  ares vco2 p4,p5
  kfr transeg 8000, 0.2, -5, p5*4, p3-0.4, 2, p5
  ares moogladder2 ares,kfr,0.6

  kautopan = oscil:k(0.5,1/3)+0.5
  aleft, aright pan2 ares, kautopan,0

  aout encode2 aleft, aright
  ;; encode the signal into a single audio signal

send aout
endin

EffectConstruct "decodepan", {{
ain = ains[0]

aleft, aright decode2 ain
;; decode the signal into left and right.

aouts[] fillarray aleft, aright
}},1,2

patchchain fillarray("encodepan", "decodepan","outs")
;; connect them together.

schedule "encodepan", nextbeat(1), tempodur(7),0.5,cpstuni(0,gi_CurrentScale)
;; make a noise