| 1 |
<CsoundSynthesizer> |
| 2 |
<CsOptions> |
| 3 |
-odac |
| 4 |
</CsOptions> |
| 5 |
<CsInstruments> |
| 6 |
sr = 44100 |
| 7 |
ksmps = 32 |
| 8 |
nchnls = 2 |
| 9 |
0dbfs = 1 |
| 10 |
|
| 11 |
instr 1 |
| 12 |
imethod = p4 ; read panning method variable from score (p4) |
| 13 |
|
| 14 |
;---------------- generate a source sound ------------------- |
| 15 |
a1 pinkish 0.1 ; pink noise |
| 16 |
a1 reson a1, 500, 30, 2 ; bandpass filtered |
| 17 |
aPan lfo 0.5, 1, 1 ; panning controlled by an lfo |
| 18 |
aPan = aPan + 0.5 ; offset shifted +0.5 |
| 19 |
;------------------------------------------------------------ |
| 20 |
|
| 21 |
if imethod=1 then |
| 22 |
;------------------------ method 1 -------------------------- |
| 23 |
aPanL = 1 - aPan |
| 24 |
aPanR = aPan |
| 25 |
;------------------------------------------------------------ |
| 26 |
endif |
| 27 |
|
| 28 |
if imethod=2 then |
| 29 |
;------------------------ method 2 -------------------------- |
| 30 |
aPanL = sqrt(1 - aPan) |
| 31 |
aPanR = sqrt(aPan) |
| 32 |
;------------------------------------------------------------ |
| 33 |
endif |
| 34 |
|
| 35 |
if imethod=3 then |
| 36 |
;------------------------ method 3 -------------------------- |
| 37 |
aPanL = cos(aPan*$M_PI_2) |
| 38 |
aPanR = sin(aPan*$M_PI_2) |
| 39 |
;------------------------------------------------------------ |
| 40 |
endif |
| 41 |
|
| 42 |
if imethod=4 then |
| 43 |
;------------------------ method 4 -------------------------- |
| 44 |
aPanL = cos((aPan + 0.5) * $M_PI_2) |
| 45 |
aPanR = sin((aPan + 0.5) * $M_PI_2) |
| 46 |
;------------------------------------------------------------ |
| 47 |
endif |
| 48 |
|
| 49 |
outs a1*aPanL, a1*aPanR ; audio sent to outputs |
| 50 |
endin |
| 51 |
|
| 52 |
</CsInstruments> |
| 53 |
|
| 54 |
<CsScore> |
| 55 |
; 4 notes one after the other to demonstrate 4 different methods of panning |
| 56 |
; p1 p2 p3 p4(method) |
| 57 |
i 1 0 4.5 1 |
| 58 |
i 1 5 4.5 2 |
| 59 |
i 1 10 4.5 3 |
| 60 |
i 1 15 4.5 4 |
| 61 |
e |
| 62 |
</CsScore> |
| 63 |
</CsoundSynthesizer> |
| 64 |
;example by Iain McCurdy |