You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: book/03-d-function-tables.md
+138-9Lines changed: 138 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -215,6 +215,59 @@ i 1 0 0 2; prints function table 2
215
215
;example by joachim heintz
216
216
```
217
217
218
+
Most of the GEN routines offer the possibility to insert the arguments as array rather than as single values. The manual page for ftgen shows this line:
219
+
220
+
```csound
221
+
gir ftgen ifn, itime, isize, igen, iarray
222
+
```
223
+
224
+
The `iarray` will contain the arguments of the GEN routine as array. Note that you cannot mix here numbers and strings as currently Csound can only have an array of one single type. Usually the array will contain numbers. This is a simple example in which we generate an array containing the numbers from 1 to 7, and then put the array in a GEN02 function table. As in the previsou example, we simply print the content of the table.
225
+
226
+
#### **_EXAMPLE 03D03_ftgen_array_arg.csd_**
227
+
228
+
```csound
229
+
<CsoundSynthesizer>
230
+
<CsOptions>
231
+
-nm0
232
+
</CsOptions>
233
+
<CsInstruments>
234
+
235
+
// create i-array
236
+
iArray[] = genarray(1,7)
237
+
238
+
// put this array into a function table via GEN02
239
+
giFt ftgen 0, 0, -7, -2, iArray
240
+
241
+
instr 1; prints the values of giFt
242
+
prints("%nFunction Table giFt:%n")
243
+
indx = 0
244
+
while (indx < 7) do
245
+
prints(" Index %d = %f%n", indx, table:i(indx,giFt))
246
+
indx += 1
247
+
od
248
+
endin
249
+
250
+
</CsInstruments>
251
+
<CsScore>
252
+
i 1 0 0
253
+
</CsScore>
254
+
</CsoundSynthesizer>
255
+
;example by joachim heintz
256
+
```
257
+
258
+
Prints:
259
+
260
+
Function Table giFt:
261
+
Index 0 = 1.000000
262
+
Index 1 = 2.000000
263
+
Index 2 = 3.000000
264
+
Index 3 = 4.000000
265
+
Index 4 = 5.000000
266
+
Index 5 = 6.000000
267
+
Index 6 = 7.000000
268
+
269
+
This feature is very powerful, and can be much more than an abbreviation. Have a look at example 03D06 below, at the end of the GEN10 explanation.
270
+
218
271
### GEN01: Importing a Soundfile
219
272
220
273
[GEN01](http://www.csound.com/docs/manual/GEN01.html) is used for
@@ -265,7 +318,7 @@ and then plays it. Reading the function table here is done using
265
318
the [poscil3](http://www.csound.com/docs/manual/poscil3.html) opcode,
266
319
as one of many choices in Csound.
267
320
268
-
#### **_EXAMPLE 03D03_Sample_to_table.csd_**
321
+
#### **_EXAMPLE 03D04_Sample_to_table.csd_**
269
322
270
323
```csound
271
324
<CsoundSynthesizer>
@@ -317,7 +370,7 @@ sinusoids. This is done in the next example by instruments 1-5.
317
370
Instrument 6 uses the sine wavetable twice: for generating both the
The last example for GEN10 continues what was explained above (example 03D03) about the usage of arrays. It is rather complex; if you are a beginner in Csound, just skip it.
444
+
445
+
We use four arrays here to create four random GEN10 tables, representing four different timbres. Each of these arrays are filled with 40 amplitude values for the first 40 harmonics. In a loop a random number between -1 and +1 is generated. If its absolut value is below 0.8, the value is set to zero. If its absolut value is above 0.8, it is kept with a standard attenuation for the higher partials.
446
+
For the wavetable transformation we imagine a square with the four tables as corners. We imagine a two-dimensional area with a range of 0-1 for both, the horizontal and vertical axis. In the example we move from table 1 (bottom left of the square) to table to (bottom right), to table 3 (top right), to table 4 (top left), and back to table 1. Then we move in the diagonal to the middle in which all four tables mix to one sound.
0 commit comments