| 1 |
<CsoundSynthesizer> |
| 2 |
<CsOptions> |
| 3 |
-+max_str_len=10000 -n |
| 4 |
</CsOptions> |
| 5 |
<CsInstruments> |
| 6 |
|
| 7 |
/****SOUNDFILE SPLITTER**** |
| 8 |
joachim heintz june 2010**/ |
| 9 |
|
| 10 |
0dbfs = 1 |
| 11 |
ksmps = 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 |
| 12 |
nchnls = 1 |
| 13 |
|
| 14 |
|
| 15 |
instr 1 |
| 16 |
gSfile invalue "_Browse1" |
| 17 |
ilen filelen gSfile |
| 18 |
;as time resolution in csound is bound to ksmps, one control period must be added to avoid omitting samples |
| 19 |
p3 = (ksmps == 1 ? ilen : ilen + ksmps/sr) |
| 20 |
inchnls 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 |
| 30 |
endin |
| 31 |
|
| 32 |
instr 12; split stereo file |
| 33 |
a1, a2 soundin gSfile |
| 34 |
ibit filebit gSfile |
| 35 |
ibitform = (ibit == 24 ? 8 : (ibit == 32 ? 6 : 4)) |
| 36 |
iposp strrindex gSfile, "." |
| 37 |
Spath strsub gSfile, 0, iposp; path without suffix |
| 38 |
Suff strsub gSfile, iposp; suffix |
| 39 |
S1 sprintf "%s_1%s", Spath, Suff |
| 40 |
S2 sprintf "%s_2%s", Spath, Suff |
| 41 |
fout S1, ibitform, a1 |
| 42 |
fout S2, ibitform, a2 |
| 43 |
endin |
| 44 |
|
| 45 |
instr 14; split quadro file |
| 46 |
a1, a2, a3, a4 soundin gSfile |
| 47 |
ibit filebit gSfile |
| 48 |
ibitform = (ibit == 24 ? 8 : (ibit == 32 ? 6 : 4)) |
| 49 |
iposp strrindex gSfile, "." |
| 50 |
Spath strsub gSfile, 0, iposp; path without suffix |
| 51 |
Suff strsub gSfile, iposp; suffix |
| 52 |
S1 sprintf "%s_1%s", Spath, Suff |
| 53 |
S2 sprintf "%s_2%s", Spath, Suff |
| 54 |
S3 sprintf "%s_3%s", Spath, Suff |
| 55 |
S4 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 |
| 60 |
endin |
| 61 |
|
| 62 |
instr 18; split octo file |
| 63 |
a1, a2, a3, a4, a5, a6, a7, a8 soundin gSfile |
| 64 |
ibit filebit gSfile |
| 65 |
ibitform = (ibit == 24 ? 8 : (ibit == 32 ? 6 : 4)) |
| 66 |
iposp strrindex gSfile, "." |
| 67 |
Spath strsub gSfile, 0, iposp; path without suffix |
| 68 |
Suff strsub gSfile, iposp; suffix |
| 69 |
S1 sprintf "%s_1%s", Spath, Suff |
| 70 |
S2 sprintf "%s_2%s", Spath, Suff |
| 71 |
S3 sprintf "%s_3%s", Spath, Suff |
| 72 |
S4 sprintf "%s_4%s", Spath, Suff |
| 73 |
S5 sprintf "%s_5%s", Spath, Suff |
| 74 |
S6 sprintf "%s_6%s", Spath, Suff |
| 75 |
S7 sprintf "%s_7%s", Spath, Suff |
| 76 |
S8 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 |
| 85 |
endin |
| 86 |
|
| 87 |
instr 20; splits any type of multichannel file. depends on ths system opcode, so it might only work on linux and osx |
| 88 |
Sfil = gSfile |
| 89 |
inchnls = p4 |
| 90 |
ilen = p5 |
| 91 |
ibit filebit Sfil |
| 92 |
ibitform = (ibit == 24 ? 8 : (ibit == 32 ? 6 : 4)) |
| 93 |
|
| 94 |
;format a .csd file |
| 95 |
Scsd1 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 |
| 128 |
Stask sprintf {{cat<<EOF>>/tmp/tmp.csd\n%s\nEOF |
| 129 |
/usr/local/bin/csound /tmp/tmp.csd |
| 130 |
rm /tmp/tmp.csd}}, Scsd1 |
| 131 |
ires system_i 1, Stask, 1 |
| 132 |
endin |
| 133 |
|
| 134 |
|
| 135 |
</CsInstruments> |
| 136 |
<CsScore> |
| 137 |
i 1 0 1 |
| 138 |
e |
| 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> |