| 1 |
/* Getting started.. File Output |
| 2 |
|
| 3 |
Now we are going to write an audiofile to hardisk. The easiest way, is pressing the red "Record" button in the menu-bar. |
| 4 |
|
| 5 |
But when automating the process (eg. for sound-installations), it is useful to trigger the process from Csound and give each recorded file a unique name. In this case date and time fits best. |
| 6 |
The date information is stored into a stringvariable. This string becomes included into the file name. |
| 7 |
|
| 8 |
Make sure you save this file first to a known location, as the audio file will be created in the same directory as the running file, and if you haven't saved the example, this could be anywhere! |
| 9 |
|
| 10 |
Manipulation of strings, see in manual: -> Opcodes Overview -> Strings ( StringsTop ) |
| 11 |
*/ |
| 12 |
<CsoundSynthesizer> |
| 13 |
<CsOptions> |
| 14 |
</CsOptions> |
| 15 |
<CsInstruments> |
| 16 |
|
| 17 |
instr 1 |
| 18 |
; generate a testtone |
| 19 |
iAmp = 10000 |
| 20 |
kFreq line p4, 3, p5 |
| 21 |
asig poscil3 iAmp, kFreq, 1 |
| 22 |
out asig |
| 23 |
; prepare writing the audiofile with it's unique name |
| 24 |
Sdate dates -1 ; Returns date and time as a string but including the weekday |
| 25 |
; extract useful information from the string |
| 26 |
Stime strsub Sdate, 10, 19 ; cut the time information |
| 27 |
Shour strsub Stime, 1, 3 |
| 28 |
Smin strsub Stime, 4, 6 |
| 29 |
Ssec strsub Stime, 7, 9 |
| 30 |
Syear strsub Sdate, 19, 24 ; cut the year information |
| 31 |
Sday strsub Sdate, 8, 10 ; cut the day information |
| 32 |
Smonth strsub Sdate, 4, 7 ; cut the month information |
| 33 |
SfileName sprintf "%s-%s-%s-%s_%s_%s-sweep.aiff", Syear, Smonth, Sday, Shour, Smin, Ssec ; create a unique filename as stringvariable |
| 34 |
puts SfileName, 1 ; output the filename to the console for checking |
| 35 |
fout SfileName, 2, asig ; write the audio-file to disk |
| 36 |
endin |
| 37 |
|
| 38 |
|
| 39 |
</CsInstruments> |
| 40 |
<CsScore> |
| 41 |
f 1 0 1024 10 1 |
| 42 |
|
| 43 |
i 1 0 1 200 500 |
| 44 |
i 1 3 1 1000 800 |
| 45 |
i 1 5 1 500 700 |
| 46 |
e |
| 47 |
</CsScore> |
| 48 |
</CsoundSynthesizer> |
| 49 |
; written by Alex Hofmann (Mar. 2010) - Incontri HMT-Hannover |
| 50 |
|
| 51 |
<bsbPanel> |
| 52 |
<label>Widgets</label> |
| 53 |
<objectName/> |
| 54 |
<x>825</x> |
| 55 |
<y>316</y> |
| 56 |
<width>359</width> |
| 57 |
<height>167</height> |
| 58 |
<visible>true</visible> |
| 59 |
<uuid/> |
| 60 |
<bgcolor mode="background"> |
| 61 |
<r>255</r> |
| 62 |
<g>255</g> |
| 63 |
<b>255</b> |
| 64 |
</bgcolor> |
| 65 |
<bsbObject version="2" type="BSBLabel"> |
| 66 |
<objectName/> |
| 67 |
<x>137</x> |
| 68 |
<y>55</y> |
| 69 |
<width>80</width> |
| 70 |
<height>25</height> |
| 71 |
<uuid>{31b59d0f-c6d7-4353-b51e-78dec450ad9f}</uuid> |
| 72 |
<visible>true</visible> |
| 73 |
<midichan>0</midichan> |
| 74 |
<midicc>-3</midicc> |
| 75 |
<label>Nothing here...</label> |
| 76 |
<alignment>left</alignment> |
| 77 |
<font>Arial</font> |
| 78 |
<fontsize>10</fontsize> |
| 79 |
<precision>3</precision> |
| 80 |
<color> |
| 81 |
<r>0</r> |
| 82 |
<g>0</g> |
| 83 |
<b>0</b> |
| 84 |
</color> |
| 85 |
<bgcolor mode="nobackground"> |
| 86 |
<r>255</r> |
| 87 |
<g>255</g> |
| 88 |
<b>255</b> |
| 89 |
</bgcolor> |
| 90 |
<bordermode>noborder</bordermode> |
| 91 |
<borderradius>1</borderradius> |
| 92 |
<borderwidth>1</borderwidth> |
| 93 |
</bsbObject> |
| 94 |
</bsbPanel> |
| 95 |
<bsbPresets> |
| 96 |
</bsbPresets> |
| 97 |
<MacOptions> |
| 98 |
Version: 3 |
| 99 |
Render: Real |
| 100 |
Ask: Yes |
| 101 |
Functions: ioObject |
| 102 |
Listing: Window |
| 103 |
WindowBounds: 825 316 359 167 |
| 104 |
CurrentView: io |
| 105 |
IOViewEdit: On |
| 106 |
Options: |
| 107 |
</MacOptions> |
| 108 |
<MacGUI> |
| 109 |
ioView background {65535, 65535, 65535} |
| 110 |
ioText {137, 55} {80, 25} label 0.000000 0.00100 "" left "Arial" 10 {0, 0, 0} {65280, 65280, 65280} nobackground noborder Nothing here... |
| 111 |
</MacGUI> |
| 112 |
<EventPanel name="" tempo="60.00000000" loop="8.00000000" x="320" y="218" width="604" height="322" visible="true" loopStart="0" loopEnd="0"> </EventPanel> |