Debian Codegraph @

src/Examples/McCurdy Collection/Miscellaneous/StereoToMono.csd

raw
1 ;Written by Iain McCurdy, 2010
2
3 ;Modified for QuteCsound by René, February 2011
4 ;Tested on Ubuntu 10.04 with csound-float 5.13.0 and QuteCsound svn rev 817
5
6 ;Notes on modifications from original csd:
7 ; Add Browser for audio file and use of FilePlay2a udo
8
9
10 ;my flags on Ubuntu: -odac -b1024 -B2048 -+rtaudio=alsa -+rtmidi=null -m0
11 <CsoundSynthesizer>
12 <CsOptions>
13 --env:SSDIR+=../../SourceMaterials
14 </CsOptions>
15 <CsInstruments>
16 sr = 44100 ;SAMPLE RATE
17 ksmps = 100 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE
18 nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO)
19
20
21 opcode FilePlay2a, aa, Skoo ; Credit to Joachim Heintz
22 ;gives stereo output regardless your soundfile is mono or stereo
23 Sfil, kspeed, iskip, iloop xin
24 ichn filenchnls Sfil
25 if ichn == 1 then
26 outvalue "_Browse", "Please select a stereo audio file"
27 else
28 aL, aR diskin2 Sfil, kspeed, iskip, iloop
29 endif
30 xout aL, aR
31 endop
32
33
34 instr 1
35 gSfile invalue "_Browse"
36
37 ilen filelen gSfile ;DERIVE LENGTH OF INPUT SOUND FILE
38 event_i "i", 2, 0, ilen ;TRIGGER INSTRUMENT 2
39 endin
40
41 instr 2
42 asigL, asigR FilePlay2a gSfile, 1, 0, 1 ;GENERATE 2 AUDIO SIGNALS FROM A STEREO SOUND FILE
43
44 Sfile_Left strcat gSfile, "_Left.wav"
45 Sfile_Right strcat gSfile, "_Right.wav"
46 fout Sfile_Left, 8, asigL ;LEFT CHANNEL IS OUTPUT TO FILE
47 fout Sfile_Right, 8, asigR ;RIGHT CHANNEL IS OUTPUT TO FILE
48 outs asigL, asigR ;REAL TIME AUDIO OUTPUT - USEFUL FOR MONITORING THE PROGRESS OF THE CONVERSION PROCESS
49 endin
50 </CsInstruments>
51 <CsScore>
52 f 0 3600
53 </CsScore>
54 </CsoundSynthesizer>
55
56 <bsbPanel>
57 <label>Widgets</label>
58 <objectName/>
59 <x>73</x>
60 <y>206</y>
61 <width>640</width>
62 <height>232</height>
63 <visible>true</visible>
64 <uuid/>
65 <bgcolor mode="background">
66 <r>241</r>
67 <g>226</g>
68 <b>185</b>
69 </bgcolor>
70 <bsbObject version="2" type="BSBLabel">
71 <objectName/>
72 <x>2</x>
73 <y>2</y>
74 <width>638</width>
75 <height>230</height>
76 <uuid>{aa607456-d368-4d59-8497-d16d608404c3}</uuid>
77 <visible>true</visible>
78 <midichan>0</midichan>
79 <midicc>0</midicc>
80 <label> CONVERT A STEREO FILE TO TWO MONO FILES IN REALTIME </label>
81 <alignment>center</alignment>
82 <font>Liberation Sans</font>
83 <fontsize>18</fontsize>
84 <precision>3</precision>
85 <color>
86 <r>255</r>
87 <g>255</g>
88 <b>255</b>
89 </color>
90 <bgcolor mode="background">
91 <r>5</r>
92 <g>27</g>
93 <b>150</b>
94 </bgcolor>
95 <bordermode>border</bordermode>
96 <borderradius>5</borderradius>
97 <borderwidth>2</borderwidth>
98 </bsbObject>
99 <bsbObject version="2" type="BSBLabel">
100 <objectName/>
101 <x>9</x>
102 <y>101</y>
103 <width>627</width>
104 <height>128</height>
105 <uuid>{e41f02b8-6ad4-46dc-805c-0b2eeafbd476}</uuid>
106 <visible>true</visible>
107 <midichan>0</midichan>
108 <midicc>0</midicc>
109 <label>---------------------------------------------------------------------------------------------------------------------------------------------------------
110 This example takes a stereo file input and writes a 2 mono files, one for each channel, to disk.
111 The advantage of this method over the offline method is that both channels can be output to separate files in one go. The disadvantage is that it must be done in real-time.
112 This example could easily be adapted to merge two mono files to a single stereo output. Conversion of files with more than two channels are also possible.</label>
113 <alignment>left</alignment>
114 <font>Liberation Sans</font>
115 <fontsize>14</fontsize>
116 <precision>3</precision>
117 <color>
118 <r>255</r>
119 <g>255</g>
120 <b>255</b>
121 </color>
122 <bgcolor mode="nobackground">
123 <r>255</r>
124 <g>255</g>
125 <b>255</b>
126 </bgcolor>
127 <bordermode>noborder</bordermode>
128 <borderradius>1</borderradius>
129 <borderwidth>1</borderwidth>
130 </bsbObject>
131 <bsbObject version="2" type="BSBButton">
132 <objectName>_Browse</objectName>
133 <x>11</x>
134 <y>62</y>
135 <width>170</width>
136 <height>30</height>
137 <uuid>{b9431a61-61f7-432b-bf6f-c47ddc7f9050}</uuid>
138 <visible>true</visible>
139 <midichan>0</midichan>
140 <midicc>0</midicc>
141 <type>value</type>
142 <pressedValue>1.00000000</pressedValue>
143 <stringvalue>808loop.wav</stringvalue>
144 <text>Browse Audio File</text>
145 <image>/</image>
146 <eventLine/>
147 <latch>false</latch>
148 <latched>false</latched>
149 </bsbObject>
150 <bsbObject version="2" type="BSBLineEdit">
151 <objectName>_Browse</objectName>
152 <x>182</x>
153 <y>63</y>
154 <width>330</width>
155 <height>28</height>
156 <uuid>{68b5f90b-b78e-4581-b434-232db5f4c40f}</uuid>
157 <visible>true</visible>
158 <midichan>0</midichan>
159 <midicc>0</midicc>
160 <label>808loop.wav</label>
161 <alignment>left</alignment>
162 <font>Liberation Sans</font>
163 <fontsize>10</fontsize>
164 <precision>3</precision>
165 <color>
166 <r>0</r>
167 <g>0</g>
168 <b>0</b>
169 </color>
170 <bgcolor mode="nobackground">
171 <r>229</r>
172 <g>229</g>
173 <b>229</b>
174 </bgcolor>
175 <background>nobackground</background>
176 </bsbObject>
177 <bsbObject version="2" type="BSBLabel">
178 <objectName/>
179 <x>11</x>
180 <y>41</y>
181 <width>150</width>
182 <height>30</height>
183 <uuid>{936f6eb0-5225-4bd7-a5fe-a49df1c9c5ac}</uuid>
184 <visible>true</visible>
185 <midichan>0</midichan>
186 <midicc>0</midicc>
187 <label>Audio File</label>
188 <alignment>left</alignment>
189 <font>Liberation Sans</font>
190 <fontsize>10</fontsize>
191 <precision>3</precision>
192 <color>
193 <r>255</r>
194 <g>255</g>
195 <b>255</b>
196 </color>
197 <bgcolor mode="nobackground">
198 <r>255</r>
199 <g>255</g>
200 <b>255</b>
201 </bgcolor>
202 <bordermode>noborder</bordermode>
203 <borderradius>1</borderradius>
204 <borderwidth>1</borderwidth>
205 </bsbObject>
206 <bsbObject version="2" type="BSBButton">
207 <objectName/>
208 <x>525</x>
209 <y>62</y>
210 <width>100</width>
211 <height>30</height>
212 <uuid>{62b97053-e7ad-4193-99be-3fd837581838}</uuid>
213 <visible>true</visible>
214 <midichan>0</midichan>
215 <midicc>0</midicc>
216 <type>event</type>
217 <pressedValue>1.00000000</pressedValue>
218 <stringvalue/>
219 <text>Convert</text>
220 <image>/</image>
221 <eventLine>i 1 0 0.01</eventLine>
222 <latch>false</latch>
223 <latched>false</latched>
224 </bsbObject>
225 </bsbPanel>
226 <bsbPresets>
227 </bsbPresets>
228 <EventPanel name="" tempo="60.00000000" loop="8.00000000" x="913" y="162" width="655" height="346" visible="true" loopStart="0" loopEnd="0"> </EventPanel>