sfpassign — Assigns all presets of a SoundFont2 (SF2) sample file to a sequence of progressive index numbers.
Assigns all presets of a previously loaded SoundFont2 (SF2) sample file to a sequence of progressive index numbers. These opcodes allow management the sample-structure of SF2 files. In order to understand the usage of these opcodes, the user must have some knowledge of the SF2 format, so a brief description of this format can be found in the SoundFont2 File Format section.
sfpassign should be placed in the header section of a Csound orchestra.
istartindex -- starting index preset by the user in bulk preset assignments.
ifilhandle -- unique number generated by sfload opcode to be used as an identifier for a SF2 file. Several SF2 files can be loaded and activated at the same time.
imsgs -- if non-zero messages are suppressed.
sfpassign assigns all presets of a previously loaded SF2 file to a sequence of progressive index numbers, to be used later with the opcodes sfplay and sfplaym istartindex specifies the starting index number. Any number of sfpassign instances can be placed in the header section of an orchestra, each one assigning presets belonging to different SF2 files. The user must take care that preset index numbers of different SF2 files do not overlap.
These opcodes only support the sample structure of SF2 files. The modulator structure of the SoundFont2 format is not supported in Csound. Any modulation or processing to the sample data is left to the Csound user, bypassing all restrictions forced by the SF2 standard.
Here is an example of the sfpassign opcode. Play sfpassign.csd
Example 967. Example of the sfpassign opcode.
See the sections Real-time Audio and Command Line Flags for more information on using command line flags.
<CsoundSynthesizer> <CsOptions> ; Select audio/midi flags here according to platform -odac ;;;realtime audio out, virtual midi in ;-iadc ;;;uncomment -iadc if RT audio input is needed too ; For Non-realtime ouput leave only the line below: ; -o sfpassign.wav -W ;;; for file output any platform </CsOptions> <CsInstruments> ; By Menno Knevel - 2020 sr = 44100 ksmps = 32 nchnls = 2 0dbfs = 1 ;load three soundfonts gisf sfload "sf_GMbank.sf2" gir sfload "01hpschd.sf2" giv sfload "07AcousticGuitar.sf2" sfplist gisf sfplist gir sfplist giv ; first, sf_GMbank.sf2 is loaded and assigned to start at 0 and counting up to 328 ; as there are 329 presets in sf_GMbank.sf2. ; then 01hpschd.sf2 is loaded and assigned to replace the 100th preset of sf_GMbank.sf2 ; then 07AcousticGuitar.sf2 is loaded and assigned to replace the 20th preset of sf_GMbank.sf2 sfpassign 0, gisf sfpassign 100, gir sfpassign 20, giv instr 1 inum = p4 ivel = p5 kamp linsegr 1, 1, 1, .1, 0 kamp = kamp/600000 * ivel ;scale amplitude and velocity dependent kfreq = 1 ;do not change freq from sf a1,a2 sfplay3 ivel, inum, kamp, kfreq, p6 ;preset index starts at 0, counting up outs a1, a2 endin </CsInstruments> <CsScore> i1 0 1 60 100 0 ; Piano 1 from sf_GMbank.sf2 i1 + 1 62 < . i1 + 1 65 < . i1 + 1 69 10 . i1 5 1 60 100 100 ; harpsichord from 01hpschd.sf2 i1 + 1 62 < . i1 + 1 65 < . i1 + 1 69 10 . i1 10 1 60 100 20 ; guitar from 07AcousticGuitar.sf2 i1 + 1 62 < . i1 + 1 65 < . i1 + 1 69 10 . i1 15 1 60 100 101 ; Goblin from sf_GMbank.sf2 i1 + 1 62 < . i1 + 1 65 < . i1 + 1 69 10 . e </CsScore> </CsoundSynthesizer>