| 1 |
/*Getting started.. Function-Tables |
| 2 |
|
| 3 |
A function table (usually called f-table) is a space for number storage. It can hold a list of numbers. (1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1) |
| 4 |
Which numbers, depends on the user's choice. You can enter them manualy, load data from an audio-file in the harddisk (jep, this also just contains numbers) or choose a GEN Routine to compute numbers of a waveform. So f-tables are often used as a waveform-buffer. |
| 5 |
|
| 6 |
GEN routines are computer functions which automatically fill f-tables. There are different types of GEN routines for different functions. Some generate waveforms, some are good for envelopes, others create windowing functions, and other can read files from disk. You can see the available GEN routines in the CsoundQt Help Menu in the GEN Routines option. |
| 7 |
|
| 8 |
The numbers contained in f-tables are used by many opcodes to get the information about the waveform they will play. The shape of the waveform has a huge influence on the sound's frequency spectrum. |
| 9 |
(A sound without overtones is generated by the 'sine waveform'. The 'sawtooth waveform' in comparison, has many overtones.) |
| 10 |
|
| 11 |
An f-table can be created using the f-statement (or Function Table Statement) in the <CsScore> section. It creates the f-table and loads a GEN subroutine to fill values in the F-Table. |
| 12 |
|
| 13 |
;f p1 p2 p3 p4 p5 |
| 14 |
f 1 0 1024 10 1 |
| 15 |
|
| 16 |
p1 - gives the table a number (in this case 1) |
| 17 |
p2 - says, at which time the table becomes filled, time in seconds (0 = immediately, when started) |
| 18 |
p3 - sets the size of the table, which must be a power of 2 (1024 = 2**10) maxsize is 2**24 |
| 19 |
p4 - the number of the GEN ROUTINE (GEN 10 fills the table with a sine curve) |
| 20 |
p5++ - individual settings needed by some GEN ROUTINES with more arguments |
| 21 |
|
| 22 |
F-tables, filled with values from predefined functions like GEN 10 above, contain one cycle of the desired waveform. |
| 23 |
|
| 24 |
see: (ScoreGenRef SHIFT+F1),(f SHIFT+F1) |
| 25 |
*/ |
| 26 |
|
| 27 |
<CsoundSynthesizer> |
| 28 |
<CsOptions> |
| 29 |
-m0 |
| 30 |
</CsOptions> |
| 31 |
<CsInstruments> |
| 32 |
|
| 33 |
|
| 34 |
sr = 44100 |
| 35 |
ksmps = 32 |
| 36 |
nchnls = 2 |
| 37 |
0dbfs = 1 |
| 38 |
|
| 39 |
instr 1 |
| 40 |
aEnv madsr 0.1, 0.1, 1, 0.3 |
| 41 |
aWavetablePlayer oscili p4, cpspch(p5), p6 |
| 42 |
outs aWavetablePlayer*aEnv, aWavetablePlayer*aEnv |
| 43 |
endin |
| 44 |
|
| 45 |
</CsInstruments> |
| 46 |
|
| 47 |
<CsScore> |
| 48 |
f 1 0 1024 10 1 ; simple sinus waveform |
| 49 |
f 2 0 1024 10 1 1 1 1 1 1 1 1 ; sinus with 7 partials -> (Additive Synthesis) |
| 50 |
f 3 0 1024 9 1 3 0 3 1 0 9 0.3333 180 ; approx of square waveform ->see Help GEN09 |
| 51 |
|
| 52 |
; The r score statement repeats a section |
| 53 |
r16 BOO |
| 54 |
i 1 0.1 0.05 0.3 7.0 1 ; sinoid wavform |
| 55 |
s |
| 56 |
|
| 57 |
r8 BOO |
| 58 |
i 1 0.1 0.05 0.3 7.0 2 ; same note but 7 partials |
| 59 |
s |
| 60 |
|
| 61 |
r8 BOO |
| 62 |
i 1 0.1 0.05 0.3 7.0 3 ; same note with square waveform |
| 63 |
s |
| 64 |
|
| 65 |
r16 BOO |
| 66 |
i 1 0.1 0.05 0.3 [6.0+0.01*$BOO] 1 |
| 67 |
s |
| 68 |
|
| 69 |
r4 BOO |
| 70 |
i 1 0.1 0.05 0.3 6.0 2 |
| 71 |
i 1 0.3 0.05 0.3 8.0 2 |
| 72 |
s |
| 73 |
|
| 74 |
r8 BOO |
| 75 |
i 1 0.1 0.05 0.3 [7.09-0.01*$BOO] 3 |
| 76 |
s |
| 77 |
|
| 78 |
r8 BOO |
| 79 |
i 1 0.0 0.05 0.3 [8.09-0.01*$BOO] 3 |
| 80 |
s |
| 81 |
r8 BOO |
| 82 |
i 1 0.0 0.05 0.3 [7.09-0.01*$BOO] 3 |
| 83 |
s |
| 84 |
|
| 85 |
r1 BOO |
| 86 |
i 1 0.0 0.05 0.3 7.00 2 |
| 87 |
i 1 0.1 0.05 0.3 10.00 1 |
| 88 |
i 1 0.2 0.05 0.3 9.00 2 |
| 89 |
i 1 0.3 0.05 0.3 8.00 3 |
| 90 |
s |
| 91 |
|
| 92 |
r1 BOO |
| 93 |
i 1 0.0 0.05 0.3 7.07 2 |
| 94 |
i 1 0.1 0.05 0.3 9.07 1 |
| 95 |
i 1 0.2 0.05 0.3 9.07 2 |
| 96 |
i 1 0.3 0.05 0.3 8.07 3 |
| 97 |
s |
| 98 |
|
| 99 |
r4 BOO |
| 100 |
i 1 0.0 0.05 0.3 10.00 1 |
| 101 |
i 1 0.1 0.05 0.3 10.00 2 |
| 102 |
i 1 0.2 0.05 0.3 8.00 3 |
| 103 |
i 1 0.3 0.05 0.3 8.00 2 |
| 104 |
s |
| 105 |
|
| 106 |
r4 BOO |
| 107 |
t 0 60 |
| 108 |
i 1 0.1 0.05 0.3 8.00 1 |
| 109 |
i 1 0.2 0.05 0.3 8.00 2 |
| 110 |
i 1 0.3 0.05 0.3 8.00 3 |
| 111 |
i 1 0.6 0.05 0.3 8.00 2 |
| 112 |
s |
| 113 |
e |
| 114 |
</CsScore> |
| 115 |
</CsoundSynthesizer> |
| 116 |
/* |
| 117 |
(The F-Table size as a "power of 2" is not that limited anymore. By using a negativ operator in front of p3, you can choose freely (like -1023), but this can cause problems with some opcodes.) |
| 118 |
*/ |
| 119 |
; written by Alex Hofmann (Mar. 2010) - Incontri HMT-Hannover |
| 120 |
|
| 121 |
<bsbPanel> |
| 122 |
<label>Widgets</label> |
| 123 |
<objectName/> |
| 124 |
<x>1013</x> |
| 125 |
<y>279</y> |
| 126 |
<width>563</width> |
| 127 |
<height>397</height> |
| 128 |
<visible>true</visible> |
| 129 |
<uuid/> |
| 130 |
<bgcolor mode="background"> |
| 131 |
<r>255</r> |
| 132 |
<g>255</g> |
| 133 |
<b>255</b> |
| 134 |
</bgcolor> |
| 135 |
<bsbObject version="2" type="BSBGraph"> |
| 136 |
<objectName/> |
| 137 |
<x>7</x> |
| 138 |
<y>61</y> |
| 139 |
<width>253</width> |
| 140 |
<height>115</height> |
| 141 |
<uuid>{2b94b9d8-9c17-4f6c-84f3-ceed3cb1f77f}</uuid> |
| 142 |
<visible>true</visible> |
| 143 |
<midichan>0</midichan> |
| 144 |
<midicc>-3</midicc> |
| 145 |
<value>0</value> |
| 146 |
<objectName2/> |
| 147 |
<zoomx>1.00000000</zoomx> |
| 148 |
<zoomy>1.00000000</zoomy> |
| 149 |
<dispx>1.00000000</dispx> |
| 150 |
<dispy>1.00000000</dispy> |
| 151 |
<modex>auto</modex> |
| 152 |
<modey>auto</modey> |
| 153 |
<all>true</all> |
| 154 |
</bsbObject> |
| 155 |
<bsbObject version="2" type="BSBScope"> |
| 156 |
<objectName/> |
| 157 |
<x>6</x> |
| 158 |
<y>223</y> |
| 159 |
<width>258</width> |
| 160 |
<height>153</height> |
| 161 |
<uuid>{95ae72b5-8d91-48ee-9b31-9a558fa60d6e}</uuid> |
| 162 |
<visible>true</visible> |
| 163 |
<midichan>0</midichan> |
| 164 |
<midicc>-3</midicc> |
| 165 |
<value>-255.00000000</value> |
| 166 |
<type>scope</type> |
| 167 |
<zoomx>2.00000000</zoomx> |
| 168 |
<zoomy>1.00000000</zoomy> |
| 169 |
<dispx>1.00000000</dispx> |
| 170 |
<dispy>1.00000000</dispy> |
| 171 |
<mode>0.00000000</mode> |
| 172 |
</bsbObject> |
| 173 |
<bsbObject version="2" type="BSBLabel"> |
| 174 |
<objectName/> |
| 175 |
<x>6</x> |
| 176 |
<y>5</y> |
| 177 |
<width>254</width> |
| 178 |
<height>53</height> |
| 179 |
<uuid>{aff020c4-672c-4c00-8937-59ec577b32c5}</uuid> |
| 180 |
<visible>true</visible> |
| 181 |
<midichan>0</midichan> |
| 182 |
<midicc>-3</midicc> |
| 183 |
<label>In this graph, one can see the result of the generated F-Table values.</label> |
| 184 |
<alignment>left</alignment> |
| 185 |
<font>Lucida Grande</font> |
| 186 |
<fontsize>14</fontsize> |
| 187 |
<precision>3</precision> |
| 188 |
<color> |
| 189 |
<r>0</r> |
| 190 |
<g>0</g> |
| 191 |
<b>0</b> |
| 192 |
</color> |
| 193 |
<bgcolor mode="nobackground"> |
| 194 |
<r>255</r> |
| 195 |
<g>255</g> |
| 196 |
<b>255</b> |
| 197 |
</bgcolor> |
| 198 |
<bordermode>noborder</bordermode> |
| 199 |
<borderradius>1</borderradius> |
| 200 |
<borderwidth>1</borderwidth> |
| 201 |
</bsbObject> |
| 202 |
<bsbObject version="2" type="BSBLabel"> |
| 203 |
<objectName/> |
| 204 |
<x>7</x> |
| 205 |
<y>193</y> |
| 206 |
<width>256</width> |
| 207 |
<height>26</height> |
| 208 |
<uuid>{8edf0582-7277-4f42-8228-0ba867eea2ca}</uuid> |
| 209 |
<visible>true</visible> |
| 210 |
<midichan>0</midichan> |
| 211 |
<midicc>-3</midicc> |
| 212 |
<label>The output-waveform..</label> |
| 213 |
<alignment>left</alignment> |
| 214 |
<font>Lucida Grande</font> |
| 215 |
<fontsize>14</fontsize> |
| 216 |
<precision>3</precision> |
| 217 |
<color> |
| 218 |
<r>0</r> |
| 219 |
<g>0</g> |
| 220 |
<b>0</b> |
| 221 |
</color> |
| 222 |
<bgcolor mode="nobackground"> |
| 223 |
<r>255</r> |
| 224 |
<g>255</g> |
| 225 |
<b>255</b> |
| 226 |
</bgcolor> |
| 227 |
<bordermode>noborder</bordermode> |
| 228 |
<borderradius>1</borderradius> |
| 229 |
<borderwidth>1</borderwidth> |
| 230 |
</bsbObject> |
| 231 |
</bsbPanel> |
| 232 |
<bsbPresets> |
| 233 |
</bsbPresets> |
| 234 |
<EventPanel name="" tempo="60.00000000" loop="8.00000000" x="320" y="218" width="596" height="322" visible="true" loopStart="0" loopEnd="0"> </EventPanel> |