Hello,
Using CSound I’m trying to change the volume of a note played by a soundfont “dynamically”, i.e like if you were playing the trumpet and blowing stronger and stronger while playing the same note. I believe this would be done via the breath controller. The following code from the CSound documentation shows how to apply a controller to a soundfont however I’m struggling to see how can I achieve the dynamic volume change. Looking a the soundfont I’m using, breath control is CC#02.
<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
-odac -+rtmidi=virtual -M0 ;;;realtime audio out and realtime midi in
;-iadc ;;;uncomment -iadc if realtime audio input is needed too
; For Non-realtime ouput leave only the line below:
;-o fluidCCi.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1
giengine fluidEngine
; soundfont path to manual/examples
isfnum fluidLoad "19Trumpet.sf2", giengine, 1
fluidProgramSelect giengine, 1, isfnum, 0, 56
instr 1
mididefault 60, p3
midinoteonkey p4, p5
ikey init p4
ivel init p5
fluidCCi giengine, 1, 93, 127 ;**=> change to CC #2 for breath control.**
**=>How to instruct instrument to play same note from a certain volume to another volume?**
fluidNote giengine, 1, ikey, ivel
endin
instr 99
imvol init 7
asigl, asigr fluidOut giengine
outs asigl*imvol, asigr*imvol
endin
</CsInstruments>
<CsScore>
i 1 0 5 60 100 ; **=> how to pass instructions to play the same note from volume 70 to volume 100 for instance?**
i 99 0 60 ;
e
</CsScore>
</CsoundSynthesizer>