| 1 |
<CsoundSynthesizer> |
| 2 |
<CsOptions> |
| 3 |
; Select audio/midi flags here according to platform |
| 4 |
;Anna.mid is a midi file, a song by The Beatles and can be found on the internet |
| 5 |
-odac -T -F Anna.mid;;;realtime audio I/O and midifile in |
| 6 |
;-iadc ;;;uncomment -iadc if realtime audio input is needed too |
| 7 |
; For Non-realtime ouput leave only the line below: |
| 8 |
; -o fluidControl-advanced.csd.wav -W ;;; for file output any platform |
| 9 |
</CsOptions> |
| 10 |
<CsInstruments> |
| 11 |
|
| 12 |
sr = 44100 |
| 13 |
ksmps = 32 |
| 14 |
nchnls = 2 |
| 15 |
0dbfs = 1 |
| 16 |
|
| 17 |
; Example by Istvan Varga |
| 18 |
|
| 19 |
; disable triggering of instruments by MIDI events |
| 20 |
|
| 21 |
ichn = 1 |
| 22 |
lp1: |
| 23 |
massign ichn, 0 |
| 24 |
loop_le ichn, 1, 16, lp1 |
| 25 |
pgmassign 0, 0 |
| 26 |
|
| 27 |
; initialize FluidSynth |
| 28 |
|
| 29 |
gifld fluidEngine |
| 30 |
gisf2 fluidLoad "sf_GMbank.sf2", gifld, 1 |
| 31 |
|
| 32 |
; k-rate version of fluidProgramSelect |
| 33 |
|
| 34 |
opcode fluidProgramSelect_k, 0, kkkkk |
| 35 |
keng, kchn, ksf2, kbnk, kpre xin |
| 36 |
igoto skipInit |
| 37 |
doInit: |
| 38 |
fluidProgramSelect i(keng), i(kchn), i(ksf2), i(kbnk), i(kpre) |
| 39 |
reinit doInit |
| 40 |
rireturn |
| 41 |
skipInit: |
| 42 |
endop |
| 43 |
|
| 44 |
instr 1 |
| 45 |
; initialize channels |
| 46 |
kchn init 1 |
| 47 |
if (kchn == 1) then |
| 48 |
lp2: |
| 49 |
fluidControl gifld, 192, kchn - 1, 0, 0 |
| 50 |
fluidControl gifld, 176, kchn - 1, 7, 100 |
| 51 |
fluidControl gifld, 176, kchn - 1, 10, 64 |
| 52 |
loop_le kchn, 1, 16, lp2 |
| 53 |
endif |
| 54 |
|
| 55 |
; send any MIDI events received to FluidSynth |
| 56 |
nxt: |
| 57 |
kst, kch, kd1, kd2 midiin |
| 58 |
if (kst != 0) then |
| 59 |
if (kst != 192) then |
| 60 |
fluidControl gifld, kst, kch - 1, kd1, kd2 |
| 61 |
else |
| 62 |
fluidProgramSelect_k gifld, kch - 1, gisf2, 0, kd1 |
| 63 |
endif |
| 64 |
kgoto nxt |
| 65 |
endif |
| 66 |
|
| 67 |
; get audio output from FluidSynth |
| 68 |
ivol init 3 ;a bit louder |
| 69 |
aL, aR fluidOut gifld |
| 70 |
outs aL*ivol, aR*ivol |
| 71 |
endin |
| 72 |
|
| 73 |
</CsInstruments> |
| 74 |
<CsScore> |
| 75 |
|
| 76 |
i 1 0 3600 |
| 77 |
e |
| 78 |
|
| 79 |
</CsScore> |
| 80 |
</CsoundSynthesizer> |