Cabbage Logo
Back to Cabbage Site

Function tables not changing while playing

Hello
I am learning Csound using the beginner’s guide by Christopher Watts. I am at the first couple of exercises and I have a p6 parameter which should change the function table in the score and as such play a different soundwave. However, I end up with 4 sinewaves instead of hearing distinct waves /square, sawtooth). Can anyone tell me what I did wrong please?

sr = 44100
kr = 4410
ksmps = 10
nchnls = 1

instr 1
asig oscil p4, p5, p6
out asig
endin

f1 0 8192 10 1 f2 0 8192 10 1 .5 .33 .25 .2 .16 .14 .12 .11 .1 .09 ;1 0 .33 0 .2 0 .14 0 .11 f3 0 8192 10 1 .11 .04 .02 .01 .008 f4 0 8192 10 1 .5 .33 .25 .2 .16 .14 .12 .11 .1 .09

i1 0 5 10000 440 1
i1 6 3 20000 200 2
i1 10 2 10000 300 3
i1 12 3 20000 400 4

This looks good to me. Seems like a perfectly reasonable way to change the function tables. Could it be the upper harmonics are too low in amplitude to be heard correctly?

I tried the code. It works for me. Although it seems like an old tutorial because of those amplitude values.

Edit: There is something funny about the values though. f3 gives me a sine wave. Try the following ones I took from the GEN10 manual page:

f1 0 16384 10 1 ; Sine
f2 0 16384 10 1 0.5 0.3 0.25 0.2 0.167 0.14 0.125 .111 ; Sawtooth
f3 0 16384 10 1 0 0.3 0 0.2 0 0.14 0 .111 ; Square
f4 0 16384 10 1 1 1 1 0.7 0.5 0.3 0.1 ; Pulse

The difference is simply not that pronounced, when you do something like this in Max, the difference between the different types is bigger.

The tutorial is from 2008. If you know better tutorials, please let me know. The more I can learn, the better. And learning Csound will definitely take me some time.

I think the FLOSS manual (http://write.flossmanuals.net/csound/preface/) is your best bet for a free tutorial. Otherwise, I’d say “Csound - A Sound and Music Computing System” (http://www.springer.com/gp/book/9783319453682).

I don’t know Max, but I guess it’s because of the small number of partials being defined in each table. You could use the vco2 opcode for more defined sounds with pre-computed tables. Check the manual page for other possible iModes (http://www.csounds.com/manual/html/vco2.html):

instr 1
a1 vco2 10000, 440, 0 ; try changing this last value to 6, 10 and 12.
out a1
endin

Cheers.

This method of creating square and sawtooth waves using a small number of partials using GEN10 is a bit limited. For most frequencies it will be rather lacking in upper harmonics and this is why the different waveforms don’t sound so different. You might like to look at vco2 instead, or drawing the waveshape with GEN07 and then band-limiting it with GEN30.