| 1 |
;Written by Iain McCurdy, 2008 |
| 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 table for exp slider |
| 8 |
|
| 9 |
|
| 10 |
;my flags on Ubuntu: -odac -b1024 -B2048 -+rtaudio=alsa -+rtmidi=null -m0 |
| 11 |
<CsoundSynthesizer> |
| 12 |
<CsOptions> |
| 13 |
|
| 14 |
</CsOptions> |
| 15 |
<CsInstruments> |
| 16 |
sr = 44100 ;SAMPLE RATE |
| 17 |
ksmps = 1 ;NUMBER OF AUDIO SAMPLES IN EACH CONTROL CYCLE |
| 18 |
nchnls = 2 ;NUMBER OF CHANNELS (2=STEREO) |
| 19 |
0dbfs = 1 ;MAXIMUM AMPLITUDE REGARDLESS OF BIT DEPTH |
| 20 |
|
| 21 |
|
| 22 |
gidata ftgen 0,0,4,-2,0 |
| 23 |
giDataTypeFlag = 1 ;0=BINARY NON-ZERO=TEXT - THIS DEFINES THE DATA TYPE IN THE FILE SAVED TO SUBSEQUENTLY LOADED FROM DISK |
| 24 |
gisine ftgen 0, 0, 1024, 10, 1 ;SINE WAVE |
| 25 |
giexp ftgen 0, 0, 1024, 19, .5, .5, 270, .5 ;EXPONENTIAL CURVE |
| 26 |
|
| 27 |
;TABLE FOR EXP SLIDER |
| 28 |
giExp1 ftgen 0, 0, 129, -25, 0, 1.0, 128, 5000.0 |
| 29 |
giExp3 ftgen 0, 0, 129, -25, 0, 50.0, 128, 5000.0 |
| 30 |
|
| 31 |
|
| 32 |
instr 10 ;GUI |
| 33 |
ktrig metro 10 |
| 34 |
if (ktrig == 1) then |
| 35 |
gkSlider1 invalue "Slider1" |
| 36 |
gkSlider11 tablei gkSlider1, giExp1, 1 |
| 37 |
gkSlider2 invalue "Slider2" |
| 38 |
gkSlider3 invalue "Slider3" |
| 39 |
gkSlider33 tablei gkSlider3, giExp3, 1 |
| 40 |
endif |
| 41 |
endin |
| 42 |
|
| 43 |
instr 1 ;SAVE DATA |
| 44 |
tableiw i(gkSlider1), 0, gidata ;SLIDER DATA IS WRITTEN TO THE FUNCTION TABLE |
| 45 |
tableiw i(gkSlider2), 1, gidata ;SLIDER DATA IS WRITTEN TO THE FUNCTION TABLE |
| 46 |
tableiw i(gkSlider3), 2, gidata ;SLIDER DATA IS WRITTEN TO THE FUNCTION TABLE |
| 47 |
ftsave "Data.txt", giDataTypeFlag, gidata ;FUNCTION TABLE IS SAVED AS A TEXT FILE (FILE EXTENSION COULD BE ANYTHING OR NOTHING BUT MAKING IT A TEXT FILE MAKES IT EASY TO OPEN AND EXAMINE AND POSSIBLY ALTER - FOR THIS, DATA TYPE FLAG SHOULD BE NON-ZERO) |
| 48 |
endin |
| 49 |
|
| 50 |
instr 2 ;LOAD DATA |
| 51 |
ftload "Data.txt", giDataTypeFlag, gidata ;LOAD FILE Data.txt TO FUNCTION TABLE gidata |
| 52 |
iSlider1 table 0, gidata ;READ DATA ITEM FROM TABLE |
| 53 |
outvalue "Slider1", iSlider1 ;SEND DATA TO THE APPROPRIATE SLIDER |
| 54 |
iSlider2 table 1, gidata ;READ DATA ITEM FROM TABLE |
| 55 |
outvalue "Slider2", iSlider2 ;SEND DATA TO THE APPROPRIATE SLIDER |
| 56 |
iSlider3 table 2, gidata ;READ DATA ITEM FROM TABLE |
| 57 |
outvalue "Slider3", iSlider3 ;SEND DATA TO THE APPROPRIATE SLIDER |
| 58 |
endin |
| 59 |
|
| 60 |
instr 3 ;SOUND IS PRODUCED BY THE FOF OPCODE: |
| 61 |
;ASIG FOF GKAMP | KFUND | KFORM | GKOCT | GKBAND | GKRIS | GKDUR | GKDEC | IOLAPS | IFNA | IFNB | ITOTDUR |
| 62 |
asig fof 0.2, gkSlider11, gkSlider33, gkSlider2, 50, .003, .1, .007, 500, gisine, giexp, 3600 |
| 63 |
outs asig, asig |
| 64 |
endin |
| 65 |
</CsInstruments> |
| 66 |
<CsScore> |
| 67 |
i 10 0 3600 ;GUI |
| 68 |
i 3 0 3600 |
| 69 |
</CsScore> |
| 70 |
</CsoundSynthesizer> |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
<bsbPanel> |
| 75 |
<label>Widgets</label> |
| 76 |
<objectName/> |
| 77 |
<x>72</x> |
| 78 |
<y>179</y> |
| 79 |
<width>400</width> |
| 80 |
<height>200</height> |
| 81 |
<visible>true</visible> |
| 82 |
<uuid/> |
| 83 |
<bgcolor mode="background"> |
| 84 |
<r>241</r> |
| 85 |
<g>226</g> |
| 86 |
<b>185</b> |
| 87 |
</bgcolor> |
| 88 |
<bsbObject version="2" type="BSBLabel"> |
| 89 |
<objectName/> |
| 90 |
<x>2</x> |
| 91 |
<y>2</y> |
| 92 |
<width>790</width> |
| 93 |
<height>321</height> |
| 94 |
<uuid>{049f4dd4-ff71-4d6d-9157-43c84efad8a4}</uuid> |
| 95 |
<visible>true</visible> |
| 96 |
<midichan>0</midichan> |
| 97 |
<midicc>0</midicc> |
| 98 |
<label>ftsave, ftload</label> |
| 99 |
<alignment>center</alignment> |
| 100 |
<font>Liberation Sans</font> |
| 101 |
<fontsize>18</fontsize> |
| 102 |
<precision>3</precision> |
| 103 |
<color> |
| 104 |
<r>255</r> |
| 105 |
<g>255</g> |
| 106 |
<b>255</b> |
| 107 |
</color> |
| 108 |
<bgcolor mode="background"> |
| 109 |
<r>5</r> |
| 110 |
<g>27</g> |
| 111 |
<b>150</b> |
| 112 |
</bgcolor> |
| 113 |
<bordermode>border</bordermode> |
| 114 |
<borderradius>5</borderradius> |
| 115 |
<borderwidth>2</borderwidth> |
| 116 |
</bsbObject> |
| 117 |
<bsbObject version="2" type="BSBHSlider"> |
| 118 |
<objectName>Slider2</objectName> |
| 119 |
<x>159</x> |
| 120 |
<y>62</y> |
| 121 |
<width>500</width> |
| 122 |
<height>27</height> |
| 123 |
<uuid>{e5fa660d-82a5-412a-a76a-500a0632ee0c}</uuid> |
| 124 |
<visible>true</visible> |
| 125 |
<midichan>0</midichan> |
| 126 |
<midicc>0</midicc> |
| 127 |
<minimum>0.00000000</minimum> |
| 128 |
<maximum>4.00000000</maximum> |
| 129 |
<value>0.38400000</value> |
| 130 |
<mode>lin</mode> |
| 131 |
<mouseControl act="jump">continuous</mouseControl> |
| 132 |
<resolution>-1.00000000</resolution> |
| 133 |
<randomizable group="0">false</randomizable> |
| 134 |
</bsbObject> |
| 135 |
<bsbObject version="2" type="BSBHSlider"> |
| 136 |
<objectName>Slider1</objectName> |
| 137 |
<x>159</x> |
| 138 |
<y>36</y> |
| 139 |
<width>500</width> |
| 140 |
<height>27</height> |
| 141 |
<uuid>{3911e6c3-0337-45b0-81d8-e63c67cae1f3}</uuid> |
| 142 |
<visible>true</visible> |
| 143 |
<midichan>0</midichan> |
| 144 |
<midicc>0</midicc> |
| 145 |
<minimum>0.00000000</minimum> |
| 146 |
<maximum>1.00000000</maximum> |
| 147 |
<value>0.65399998</value> |
| 148 |
<mode>lin</mode> |
| 149 |
<mouseControl act="jump">continuous</mouseControl> |
| 150 |
<resolution>-1.00000000</resolution> |
| 151 |
<randomizable group="0">false</randomizable> |
| 152 |
</bsbObject> |
| 153 |
<bsbObject version="2" type="BSBHSlider"> |
| 154 |
<objectName>Slider3</objectName> |
| 155 |
<x>159</x> |
| 156 |
<y>88</y> |
| 157 |
<width>500</width> |
| 158 |
<height>27</height> |
| 159 |
<uuid>{efb2995a-4ef2-403a-b994-9661bc9f673e}</uuid> |
| 160 |
<visible>true</visible> |
| 161 |
<midichan>0</midichan> |
| 162 |
<midicc>0</midicc> |
| 163 |
<minimum>0.00000000</minimum> |
| 164 |
<maximum>1.00000000</maximum> |
| 165 |
<value>0.46399999</value> |
| 166 |
<mode>lin</mode> |
| 167 |
<mouseControl act="jump">continuous</mouseControl> |
| 168 |
<resolution>-1.00000000</resolution> |
| 169 |
<randomizable group="0">false</randomizable> |
| 170 |
</bsbObject> |
| 171 |
<bsbObject version="2" type="BSBLabel"> |
| 172 |
<objectName/> |
| 173 |
<x>5</x> |
| 174 |
<y>114</y> |
| 175 |
<width>785</width> |
| 176 |
<height>208</height> |
| 177 |
<uuid>{d53e476a-429b-46b1-8781-cc346c263b62}</uuid> |
| 178 |
<visible>true</visible> |
| 179 |
<midichan>0</midichan> |
| 180 |
<midicc>0</midicc> |
| 181 |
<label>------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 182 |
ftsave and ftload allow the contents of function tables to be saved to and loaded from files stored on the computer's hard disk. There could be many practical uses for this function. In this example I am using ftsave and ftload to store the locations of sliders (and therefore the variables they output). When the 'Save' button is pressed the values from the three sliders are first stored into a function table and then that function table is stored as a file on the hard disk which in this example I have named 'data.txt'. When the 'Load' button is pressed the reverse procedure is carried out - the file 'data.txt' is loaded into a function table, relevant values are read from the table and then sent to the sliders. The advantage that this method of storing presets might have over the method using QuteCsound embedded presets is that the user has control over which valuators to store in the preset file. When using ftsave and ftload we can save the data as binary data or as text. It doesn't really matter which we choose except that we need to be consistant with the choice we make for ftsave and for ftload. Choosing 'text' makes the file more readable in a text editor. The audio is a simple FOF sound.</label> |
| 183 |
<alignment>left</alignment> |
| 184 |
<font>Liberation Sans</font> |
| 185 |
<fontsize>14</fontsize> |
| 186 |
<precision>3</precision> |
| 187 |
<color> |
| 188 |
<r>255</r> |
| 189 |
<g>255</g> |
| 190 |
<b>255</b> |
| 191 |
</color> |
| 192 |
<bgcolor mode="nobackground"> |
| 193 |
<r>255</r> |
| 194 |
<g>255</g> |
| 195 |
<b>255</b> |
| 196 |
</bgcolor> |
| 197 |
<bordermode>noborder</bordermode> |
| 198 |
<borderradius>1</borderradius> |
| 199 |
<borderwidth>1</borderwidth> |
| 200 |
</bsbObject> |
| 201 |
<bsbObject version="2" type="BSBButton"> |
| 202 |
<objectName/> |
| 203 |
<x>19</x> |
| 204 |
<y>63</y> |
| 205 |
<width>60</width> |
| 206 |
<height>24</height> |
| 207 |
<uuid>{a20ec77f-2565-41d5-9d36-c2e9fe243e3d}</uuid> |
| 208 |
<visible>true</visible> |
| 209 |
<midichan>0</midichan> |
| 210 |
<midicc>0</midicc> |
| 211 |
<type>event</type> |
| 212 |
<pressedValue>1.00000000</pressedValue> |
| 213 |
<stringvalue/> |
| 214 |
<text>Save</text> |
| 215 |
<image>/</image> |
| 216 |
<eventLine>i 1 0 0.01</eventLine> |
| 217 |
<latch>false</latch> |
| 218 |
<latched>false</latched> |
| 219 |
</bsbObject> |
| 220 |
<bsbObject version="2" type="BSBButton"> |
| 221 |
<objectName/> |
| 222 |
<x>86</x> |
| 223 |
<y>63</y> |
| 224 |
<width>60</width> |
| 225 |
<height>24</height> |
| 226 |
<uuid>{48393902-ffd6-43f6-abac-f72a0cd66ee1}</uuid> |
| 227 |
<visible>true</visible> |
| 228 |
<midichan>0</midichan> |
| 229 |
<midicc>0</midicc> |
| 230 |
<type>event</type> |
| 231 |
<pressedValue>1.00000000</pressedValue> |
| 232 |
<stringvalue/> |
| 233 |
<text>Load</text> |
| 234 |
<image>/</image> |
| 235 |
<eventLine>i 2 0 0.01</eventLine> |
| 236 |
<latch>false</latch> |
| 237 |
<latched>false</latched> |
| 238 |
</bsbObject> |
| 239 |
</bsbPanel> |
| 240 |
<bsbPresets> |
| 241 |
</bsbPresets> |
| 242 |
<EventPanel name="" tempo="60.00000000" loop="8.00000000" x="913" y="162" width="655" height="346" visible="true" loopStart="0" loopEnd="0"> </EventPanel> |