fluidAllOut

fluidAllOut — Collects all audio from all Fluidsynth engines in a performance

Syntax

aleft, aright fluidAllOut

Description

Collects all audio from all Fluidsynth engines in a performance

Initialization

aleft -- Left channel audio output.

aright -- Right channel audio output.

Performance

Invoke fluidAllOut in an instrument definition numbered higher than any fluidcontrol instrument definitions. All SoundFonts send their audio output to this one opcode. Send a note with an indefinite duration to this instrument to turn the SoundFonts on for as long as required.

In this implementation, SoundFont effects such as chorus or reverb are used if and only if they are defaults for the preset. There is no means of turning such effects on or off, or of changing their parameters, from Csound.

Examples

sr = 44100
kr = 4410
ksmps = 10  
nchnls = 2
0dbfs = 32767

; LOAD SOUNDFONTS

fluidload	"Piano Steinway Grand Model C (21,738KB).sf2", 1, 1, 1 ; Bright Steinway, program 1, channel 1
fluidload	"Piano Steinway Grand Model C (21,738KB).sf2", 2, 3, 1 ; Concert Steinway with reverb, program 2, channel 3
fluidload	"63.3mg The Sound Site Album Bank V1.0.SF2",  50, 2, 1 ; General MIDI, program 50, channel 2

; SEND NOTES TO STEINWAY SOUNDFONT

instr 1 ; FluidSynth Steinway Rev
; INITIALIZATION
                   mididefault                  60, p3 ; Default duration of 60 -- overridden by score.
                   midinoteonkey                p4, p5 ; Channels MIDI input to pfields.
; Use channel assigned in fluidload.
ichannel           =                            3
ikey               =                            p4
ivelocity          =                            p5
istatus            =                            144
                   fluidcontrol                 istatus, ichannel, ikey, ivelocity
endin

; COLLECT AUDIO FROM ALL SOUNDFONTS

instr 100 ; Fluidsynth output
; INITIALIZATION
; Normalize so iamplitude for p5 of 80 == ampdb(80).
iamplitude         =                           ampdb(p5) * (10000.0 / 0.1)  
; AUDIO
aleft, aright      fluidAllOut
                   outs                        aleft * iamplitude, aright * iamplitude
endin

Credits

Opcode by Michael Gogins (gogins at pipeline dot com). Thanks to Peter Hanappe for Fluidsynth, and to Steven Yi for seeing that it is necessary to break up the Fluidsynth into several different Csound opcodes.