User-Defined Opcode Database

PanPotStereo

pans stereo input to stereo output

Download UDO File

Description

Pans stereo input to stereo output. The behaviour should be the same as in an audio editor or a mixer:
pan pot "middle" gives 100% of L and R input;
"very left" gives 100% L and 0% R;
"half left" gives 100% L and 50% R;
and so on.

Syntax

aoutL, aoutR PanPotStereo ainL, ainR, kpan

Performance

ainL, ainR - audio input
kpan - panning from 0=left to 1=right
aoutL, aoutR - sudio output

Code

opcode PanPotStereo, aa, aak
ainL, ainR, kpan xin ;kpan 0=left to 1=right
kpan = (kpan < 0 ? 0 : (kpan > 1 ? 1 : kpan))
kmultL = (kpan < 0.5 ? 1 : (1 - kpan) * 2)
kmultR = (kpan > 0.5 ? 1 : kpan * 2)
aoutL = ainL * kmultL
aoutR = ainR * kmultR
xout aoutL, aoutR
endop

Examples

<CsoundSynthesizer>
<CsOptions>
-odac
</CsOptions>
<CsInstruments>

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

opcode PanPotStereo, aa, aak
ainL, ainR, kpan xin ;kpan 0=left to 1=right
kpan = (kpan < 0 ? 0 : (kpan > 1 ? 1 : kpan))
kmultL = (kpan < 0.5 ? 1 : (1 - kpan) * 2)
kmultR = (kpan > 0.5 ? 1 : kpan * 2)
aoutL = ainL * kmultL
aoutR = ainR * kmultR
xout aoutL, aoutR
endop

instr 1
kpan		linseg		0, 5, 1
asigL		oscils		1, 400, 0
asigR		oscils		1, 500, 0
aL, aR		PanPotStereo	asigL, asigR, kpan
		outs		aL, aR
endin


</CsInstruments>
<CsScore>
i 1 0 5
e
</CsScore>
</CsoundSynthesizer>

Credits

joachim heintz 2009


Previous Home Next
PfieldsToTable   FreqByRatioTab