I've programmed 2 oscillators to play a melody, and one of them is supposed to be a human voice.
I'm trying to use an lfo to add a vibrato to the longer notes in the melody, and so far I've not been very successful. I can't seem to control the depth of the oscillator, only the overall amplitude of it. which is fine. I can deal with that. but if that is going to be the case I only want vibrato on certain notes.. not the whole bloody score. because if I put the lfo amplitude to 0, when I multiply it by my output I get 0 and no sound.
So I wanted to put an if else statement in there to route it for me.
I use the vibrato volume as parameter p6 in the score, after the note frequency and amplitude. I wanted to be able to put 0 in there to have no vibrato.
so the logic goes:
IF the lfo amplitude IS NOT zero,
then multiply the LFO signal into the main output.
ELSE
use the normal output without the LFO
Csound apparently doesn't like my syntax. it says I dont complete the IF statement, and since that didn't work. the else statement is invalid.
It also tells me that the { and } characters are illegal ....
any help?
Code:
instr 1 ;human voice, or choir ; setting up parameters for the score ifreq = p4 ;parameter 4 is freqency iamp = p5*32767 ;parameter 5 is amplitude from 0 to 1 ; envelope settings to sound like a Staccato human voice. The song is supposed ; to be majestic and stately so the attacks will be accented, with a slow decay ; and quick release of the note for separation. iatt = 0.01 idec = 0.04 irel = 0.02 islev = 0.8 kenv adsr iatt, idec, islev, irel ; variable kenv is an ADSR with these variables ; within it kamp = iamp * kenv ; adding the envelope to the amplitude ;declaring variables for the lfo, used to simulate vibrato on human voice ;kwobble = p6 ;paramter 6 is the volume change the LFO does ;a value of 0 should cause no vibrato (hopefully) ;kcps = 4 ;rate of LFO in Hz ;itype = 0 ;type of wave for LFO is sine (type 0) ;ktrem lfo kwobble, kcps, itype ;define tremolo variable as an LFO with the previous 3 paramters ;note: I could not get this to work, the LFO type of object does not allow you to set the depth of the LFO ; only the over volume of the tone. Despite this I tried to at least use an If Else statement to allow ; only those notes I wanted vibrato on, but Csound refuses to accept that they are syntactically correct ; which I believe they are, unless Csound doesn't follow the same syntax as C or C++ ;fundamental and partials apart1 oscil kamp, 1*ifreq, 1 ; fundamental frequency with 4 partials above it apart2 oscil kamp, 3*ifreq, 1 ; these are odd partials because the human voice apart3 oscil kamp, 5*ifreq, 1 ; acts like a closed tube apart4 oscil kamp, 7*ifreq, 1 apart5 oscil kamp, 9*ifreq, 1 iamp1 = 0.6 ;amplitude of partials decreasing rapidly iamp2 = 0.2 iamp3 = 0.1 iamp4 = 0.06 iamp5 = 0.04 ;if (kwobble != 0) then ;acomplex = (iamp1*apart1 + iamp2*apart2 + iamp3*apart3 + iamp4*apart4 + iamp5*apart5) * ktrem ;else acomplex = (iamp1*apart1 + iamp2*apart2 + iamp3*apart3 + iamp4*apart4 + iamp5*apart5) out acomplex endin












