ir sfload "filename" sfpassign istartndx, ifilhandle ir sfpreset iprog, ibank, ifilhandle, iprendx sfplist ifilhandle sfilist ifilhandle ar1, ar2 sfplay ivel, inotnum, xamp, xfreq, iprendx [, iflag] ar sfplaym ivel, inotnum, xamp, xfreq, iprendx [, iflag] ar1, ar2 sfinstr ivel, inotnum, xamp, xfreq, instrnum, ifilhandle [, iflag] ar sfinstrm ivel, inotnum, xamp, xfreq, instrnum, ifilhandle [, iflag]
Csound support for the SoundFont2 (SF2) sample file format, when the user's sound card supports SoundFont2. 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 Appendix.
Note that sfload, sfpassign, and sfpreset are placed in the header section of a Csound orchestra.
ir – output to be used by other SF2 opcodes. For sfload, ir is ifilhandle. For sfpreset, ir is iprendx.
filename – name of the SF2 file, with its complete path. It must be typed within double-quotes. Use "/" to separate directories. This applies to DOS and Windows as well, where using a backslash will generate an error.
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.
istartndx – starting index preset by the user in bulk preset assignments (see below).
iprendx – preset index
iprog – program number of a bank of presets in a SF2 file
ibank – number of a specific bank of a SF2 file
ivel – velocity value
inotnum – MIDI note number value
iflag – flag regarding the behavior of xfreq and inotnum
instrnum – number of an instrument of a SF2 file.
xamp – amplitude correction factor
xfreq – frequency value or frequency multiplier, depending by iflag. When iflag = 0, xfreq is a multiplier of a the default frequency, assigned by SF2 preset to the inotenum value. When iflag = 1, xfreq is the absolute frequency of the output sound, in Hz. Default is 0.
sfload loads an entire SF2 file into memory. It returns a file handle to be used by other opcodes. Several instances of sfload can placed in the header section of an orchestra, allowing use of more than one SF2 file in a single orchestra.
sfplist prints a list of all presets of a previously loaded SF2 file to the console.
sfilist prints a list of all instruments of a previously loaded SF2 file to the console.
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. istartndx 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.
sfpreset assigns an existing preset of a previously loaded SF2 file to an index number, to be used later with the opcodes sfplay and sfplaym. The user must previously know the program and the bank numbers of the preset in order to fill the corresponding arguments. Any number of sfpreset instances can be placed in the header section of an orchestra, each one assigning a different preset belonging to the same (or different) SF2 file to different index numbers.
sfplay plays a preset, generating a stereo sound. ivel does not directly affect the amplitude of the output, but informs sfplay about which sample should be chosen in multi-sample, velocity-split presets.
When iflag = 0, inotnum sets the frequency of the output according to the MIDI note number used, and xfreq is used as a multiplier. When iflag = 1, the frequency of the output, is set directly by xfreq. This allows the user to use any kind of micro-tuning based scales. However, this method is designed to work correctly only with presets tuned to the default equal temperament. Attempts to use this method with a preset already having non-standard tunings, or with drum-kit-based presets, could give unexpected results.
Adjustment of the amplitude can be done by varying the xamp argument, which acts as a multiplier.
Notice that both xamp and xfreq can use k-rate as well as a-rate signals. Both arguments must use variables of the same rate, or sfplay will not work correctly. iprendx must contain the number of a previously assigned preset, or Csound will crash.
sfplaym is a mono version of sfplay. It should be used with mono preset, or with the stereo presets in which stereo output is not required. It is faster than sfplay.
sfinstr plays an SF2 instrument instead of a preset (an SF2 instrument is the base of a preset layer). instrnum specifies the instrument number, and the user must be sure that the specified number belongs to an existing instrument of a determinate soundfont bank. Notice that both xamp and xfreq can operate at k-rate as well as a-rate, but both arguments must work at the same rate.
sfinstrm plays is a mono version of sfinstr. This is the fastest opcode of the SF2 family.
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.
May, 2000 (New in Csound Version 4.16)