1<CsoundSynthesizer> 2<CsOptions> 3-+max_str_len=10000 -n 4</CsOptions> 5<CsInstruments> 6 7/****SOUNDFILE SPLITTER**** 8joachim heintz june 2010**/ 9 100dbfs = 1 11ksmps = 128; if you want to avoid that some samples without sound are added at the end of the soundfile, use ksmps=1. but this will be slow for large files 12nchnls = 1 13 14 15instr 1 16gSfile invalue "_Browse1" 17ilen filelen gSfile 18;as time resolution in csound is bound to ksmps, one control period must be added to avoid omitting samples 19p3 = (ksmps == 1 ? ilen : ilen + ksmps/sr) 20inchnls filenchnls gSfile 21 if inchnls == 2 then 22 event_i "i", 12, 0, p3 23 elseif inchnls == 4 then 24 event_i "i", 14, 0, p3 25 elseif inchnls == 8 then 26 event_i "i", 18, 0, p3 27 else 28 event_i "i", 20, 0, .1, inchnls, p3 29 endif 30endin 31 32instr 12; split stereo file 33a1, a2 soundin gSfile 34ibit filebit gSfile 35ibitform = (ibit == 24 ? 8 : (ibit == 32 ? 6 : 4)) 36iposp strrindex gSfile, "." 37Spath strsub gSfile, 0, iposp; path without suffix 38Suff strsub gSfile, iposp; suffix 39S1 sprintf "%s_1%s", Spath, Suff 40S2 sprintf "%s_2%s", Spath, Suff 41 fout S1, ibitform, a1 42 fout S2, ibitform, a2 43endin 44 45instr 14; split quadro file 46a1, a2, a3, a4 soundin gSfile 47ibit filebit gSfile 48ibitform = (ibit == 24 ? 8 : (ibit == 32 ? 6 : 4)) 49iposp strrindex gSfile, "." 50Spath strsub gSfile, 0, iposp; path without suffix 51Suff strsub gSfile, iposp; suffix 52S1 sprintf "%s_1%s", Spath, Suff 53S2 sprintf "%s_2%s", Spath, Suff 54S3 sprintf "%s_3%s", Spath, Suff 55S4 sprintf "%s_4%s", Spath, Suff 56 fout S1, ibitform, a1 57 fout S2, ibitform, a2 58 fout S3, ibitform, a3 59 fout S4, ibitform, a4 60endin 61 62instr 18; split octo file 63a1, a2, a3, a4, a5, a6, a7, a8 soundin gSfile 64ibit filebit gSfile 65ibitform = (ibit == 24 ? 8 : (ibit == 32 ? 6 : 4)) 66iposp strrindex gSfile, "." 67Spath strsub gSfile, 0, iposp; path without suffix 68Suff strsub gSfile, iposp; suffix 69S1 sprintf "%s_1%s", Spath, Suff 70S2 sprintf "%s_2%s", Spath, Suff 71S3 sprintf "%s_3%s", Spath, Suff 72S4 sprintf "%s_4%s", Spath, Suff 73S5 sprintf "%s_5%s", Spath, Suff 74S6 sprintf "%s_6%s", Spath, Suff 75S7 sprintf "%s_7%s", Spath, Suff 76S8 sprintf "%s_8%s", Spath, Suff 77 fout S1, ibitform, a1 78 fout S2, ibitform, a2 79 fout S3, ibitform, a3 80 fout S4, ibitform, a4 81 fout S5, ibitform, a5 82 fout S6, ibitform, a6 83 fout S7, ibitform, a7 84 fout S8, ibitform, a8 85endin 86 87instr 20; splits any type of multichannel file. depends on ths system opcode, so it might only work on linux and osx 88Sfil = gSfile 89inchnls = p4 90ilen = p5 91ibit filebit Sfil 92ibitform = (ibit == 24 ? 8 : (ibit == 32 ? 6 : 4)) 93 94;format a .csd file 95Scsd1 sprintf {{ 96 <CsoundSynthesizer> 97 <CsOptions> 98 -+max_str_len=10000 -n -i%s 99 </CsOptions> 100 <CsInstruments> 101 0dbfs = 1 102 ksmps = %d 103 nchnls = %d 104 opcode SF_Split, 0, Siii 105 Sfile, inchnls, ichn, ibitform xin 106 ain inch ichn 107 iposp strrindex Sfile, "." 108 Spath strsub Sfile, 0, iposp 109 Suff strsub Sfile, iposp 110 Soutnam sprintf "%s", Spath, ichn, Suff 111 fout Soutnam, ibitform, ain 112 if ichn < inchnls then 113 SF_Split Sfile, inchnls, ichn+1, ibitform 114 endif 115 endop 116 instr 1 117 SF_Split "%s", %d, 1, %d 118 endin 119 %s 120 <CsScore> 121 i 1 0 %d 122 e 123 </CsScore> 124 </CsoundSynthesizer> 125 }}, Sfil, ksmps, inchnls, "%s_%d%s", Sfil, inchnls, ibitform, "</CsInstruments>", ilen 126 127;write the file and execute it 128Stask sprintf {{cat<<EOF>>/tmp/tmp.csd\n%s\nEOF 129 /usr/local/bin/csound /tmp/tmp.csd 130 rm /tmp/tmp.csd}}, Scsd1 131ires system_i 1, Stask, 1 132endin 133 134 135</CsInstruments> 136<CsScore> 137i 1 0 1 138e 139</CsScore> 140</CsoundSynthesizer> 141 142<bsbPanel> 143 <label>Widgets</label> 144 <objectName/> 145 <x>0</x> 146 <y>0</y> 147 <width>524</width> 148 <height>263</height> 149 <visible>true</visible> 150 <uuid/> 151 <bgcolor mode="background"> 152 <r>170</r> 153 <g>170</g> 154 <b>127</b> 155 </bgcolor> 156 <bsbObject version="2" type="BSBButton"> 157 <objectName>_Browse1</objectName> 158 <x>364</x> 159 <y>69</y> 160 <width>100</width> 161 <height>30</height> 162 <uuid>{6d6f3649-5d94-4759-afc8-887cc1872c39}</uuid> 163 <visible>true</visible> 164 <midichan>0</midichan> 165 <midicc>-3</midicc> 166 <type>value</type> 167 <pressedValue>1.00000000</pressedValue> 168 <stringvalue/> 169 <text>Select File</text> 170 <image>/</image> 171 <eventLine/> 172 <latch>false</latch> 173 <latched>false</latched> 174 </bsbObject> 175 <bsbObject version="2" type="BSBLineEdit"> 176 <objectName>_Browse1</objectName> 177 <x>17</x> 178 <y>72</y> 179 <width>345</width> 180 <height>24</height> 181 <uuid>{dcd7f769-c32b-4cc8-bc82-9848d5b36937}</uuid> 182 <visible>true</visible> 183 <midichan>0</midichan> 184 <midicc>-3</midicc> 185 <label/> 186 <alignment>left</alignment> 187 <font>Lucida Grande</font> 188 <fontsize>12</fontsize> 189 <precision>3</precision> 190 <color> 191 <r>0</r> 192 <g>0</g> 193 <b>0</b> 194 </color> 195 <bgcolor mode="nobackground"> 196 <r>206</r> 197 <g>206</g> 198 <b>206</b> 199 </bgcolor> 200 <background>nobackground</background> 201 </bsbObject> 202 <bsbObject version="2" type="BSBButton"> 203 <objectName>_Render</objectName> 204 <x>163</x> 205 <y>107</y> 206 <width>151</width> 207 <height>31</height> 208 <uuid>{a9b11523-b4f3-419f-8637-88da098e53f3}</uuid> 209 <visible>true</visible> 210 <midichan>0</midichan> 211 <midicc>-3</midicc> 212 <type>value</type> 213 <pressedValue>1.00000000</pressedValue> 214 <stringvalue/> 215 <text>Split!</text> 216 <image>/</image> 217 <eventLine>i1 0 10</eventLine> 218 <latch>false</latch> 219 <latched>true</latched> 220 </bsbObject> 221 <bsbObject version="2" type="BSBLabel"> 222 <objectName/> 223 <x>85</x> 224 <y>16</y> 225 <width>335</width> 226 <height>39</height> 227 <uuid>{46df577d-4fc5-4d07-a9cb-08d73733ad30}</uuid> 228 <visible>true</visible> 229 <midichan>0</midichan> 230 <midicc>-3</midicc> 231 <label>SOUNDFILE SPLITTER</label> 232 <alignment>center</alignment> 233 <font>Arial</font> 234 <fontsize>24</fontsize> 235 <precision>3</precision> 236 <color> 237 <r>0</r> 238 <g>0</g> 239 <b>0</b> 240 </color> 241 <bgcolor mode="nobackground"> 242 <r>255</r> 243 <g>255</g> 244 <b>255</b> 245 </bgcolor> 246 <bordermode>noborder</bordermode> 247 <borderradius>1</borderradius> 248 <borderwidth>1</borderwidth> 249 </bsbObject> 250 <bsbObject version="2" type="BSBLabel"> 251 <objectName/> 252 <x>19</x> 253 <y>147</y> 254 <width>446</width> 255 <height>81</height> 256 <uuid>{e54e17da-3808-49a3-84a6-608f476c3200}</uuid> 257 <visible>true</visible> 258 <midichan>0</midichan> 259 <midicc>0</midicc> 260 <label>Splits any stereo or multichannel soundfile in mono files. Just browse your file and press the Split! button. Find the split files in the same folder as the source file.</label> 261 <alignment>center</alignment> 262 <font>Arial</font> 263 <fontsize>14</fontsize> 264 <precision>3</precision> 265 <color> 266 <r>0</r> 267 <g>0</g> 268 <b>0</b> 269 </color> 270 <bgcolor mode="nobackground"> 271 <r>255</r> 272 <g>255</g> 273 <b>255</b> 274 </bgcolor> 275 <bordermode>noborder</bordermode> 276 <borderradius>1</borderradius> 277 <borderwidth>1</borderwidth> 278 </bsbObject> 279</bsbPanel> 280<bsbPresets> 281</bsbPresets> 282<EventPanel name="" tempo="60.00000000" loop="8.00000000" x="360" y="248" width="612" height="322" visible="false" loopStart="0" loopEnd="0"> </EventPanel> 283