| 1 |
STEREO TO MONO CONVERSION (OFFLINE) |
| 2 |
Written by Iain McCurdy, 2010 |
| 3 |
|
| 4 |
This example takes a stereo file input and writes a mono file to disk. |
| 5 |
Three methods of conversion are available by uncommenting the relevant section of code: |
| 6 |
1) Left channel |
| 7 |
2) Right channel |
| 8 |
3) Mix both channels |
| 9 |
Left channel is output by default. |
| 10 |
|
| 11 |
Because this task is performed offline without realtime performance it is suitable for quick conversion of long sound files. |
| 12 |
The disadvantage is that the process must be repeated for each channel. |
| 13 |
|
| 14 |
This example could easily be adapted to convert a mono file to stereo |
| 15 |
|
| 16 |
<CsoundSynthesizer> |
| 17 |
<CsOptions> |
| 18 |
;OUTPUT FLAGS ARE FOR 24BIT WAV |
| 19 |
-oStereoToMonoRender.wav -W -3 |
| 20 |
</CsOptions> |
| 21 |
<CsInstruments> |
| 22 |
sr = 44100 ;SAMPLE RATE |
| 23 |
ksmps = 100 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE |
| 24 |
nchnls = 1 ;NUMBER OF CHANNELS (2=STEREO) |
| 25 |
|
| 26 |
;REPLACE THIS FILE NAME WITH THE NAME OF YOUR DESIRED STEREO INPUT SOUND FILE |
| 27 |
#define FILE #"StereoInputSoundfile.wav"# |
| 28 |
|
| 29 |
instr 1 |
| 30 |
ilen filelen $FILE ;DERIVE LENGTH OF INPUT SOUND FILE |
| 31 |
event_i "i", 2, 0, ilen ;TRIGGER INSTRUMENT 2 |
| 32 |
endin |
| 33 |
|
| 34 |
instr 2 |
| 35 |
asigL, asigR diskin2 $FILE, 1, 0, 1 ;GENERATE 2 AUDIO SIGNALS FROM A STEREO SOUND FILE |
| 36 |
|
| 37 |
;LEFT CHANNEL------------------------------------------------------------------------ |
| 38 |
out asigL ;LEFT CHANNEL IS OUTPUT TO FILE |
| 39 |
;------------------------------------------------------------------------------------ |
| 40 |
|
| 41 |
;RIGHT CHANNEL----------------------------------------------------------------------- |
| 42 |
; out asigR ;LEFT CHANNEL IS OUTPUT TO FILE |
| 43 |
;------------------------------------------------------------------------------------ |
| 44 |
|
| 45 |
;MIX CHANNELS------------------------------------------------------------------------ |
| 46 |
; out (asigL+asigR)*0.5 ;MIX OF CHANNELS IS OUTPUT TO FILE |
| 47 |
;------------------------------------------------------------------------------------ |
| 48 |
endin |
| 49 |
</CsInstruments> |
| 50 |
<CsScore> |
| 51 |
i 1 0 0.01 ;SHORT SCORE EVENT - DURATION REQUIRED FOR OUTPUT FILE WILL BE DERIVED FROM DURATION OF INPUT FILE |
| 52 |
</CsScore> |
| 53 |
</CsoundSynthesizer> |
| 54 |
<bsbPanel> |
| 55 |
<label>Widgets</label> |
| 56 |
<objectName/> |
| 57 |
<x>2</x> |
| 58 |
<y>74</y> |
| 59 |
<width>30</width> |
| 60 |
<height>110</height> |
| 61 |
<visible>true</visible> |
| 62 |
<uuid/> |
| 63 |
<bgcolor mode="nobackground"> |
| 64 |
<r>231</r> |
| 65 |
<g>46</g> |
| 66 |
<b>255</b> |
| 67 |
</bgcolor> |
| 68 |
<bsbObject version="2" type="BSBVSlider"> |
| 69 |
<objectName>slider1</objectName> |
| 70 |
<x>5</x> |
| 71 |
<y>5</y> |
| 72 |
<width>20</width> |
| 73 |
<height>100</height> |
| 74 |
<uuid>{c7e34204-b813-4f7f-a4f3-1e54e3bd8c4e}</uuid> |
| 75 |
<visible>true</visible> |
| 76 |
<midichan>0</midichan> |
| 77 |
<midicc>-3</midicc> |
| 78 |
<minimum>0.00000000</minimum> |
| 79 |
<maximum>1.00000000</maximum> |
| 80 |
<value>0.00000000</value> |
| 81 |
<mode>lin</mode> |
| 82 |
<mouseControl act="jump">continuous</mouseControl> |
| 83 |
<resolution>-1.00000000</resolution> |
| 84 |
<randomizable group="0">false</randomizable> |
| 85 |
</bsbObject> |
| 86 |
</bsbPanel> |
| 87 |
<bsbPresets> |
| 88 |
</bsbPresets> |