| 1 | |
| 2 | <refentry id="sfinstr"> |
| 3 | <indexterm id="IndexSfinstr"><primary>sfinstr</primary></indexterm> |
| 4 | <refentryinfo><title>Signal Generators:Sample Playback</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>sfinstr</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | |
| 10 | |
| 11 | <refnamediv> |
| 12 | <refname>sfinstr</refname> |
| 13 | <refpurpose> |
| 14 | Plays a SoundFont2 (SF2) sample instrument, generating a stereo sound. |
| 15 | </refpurpose> |
| 16 | </refnamediv> |
| 17 | |
| 18 | <refsect1> |
| 19 | <title>Description</title> |
| 20 | <para> |
| 21 | Plays a SoundFont2 (SF2) sample instrument, generating a stereo sound. 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 <link linkend="SiggenSample"><citetitle>SoundFont2 File Format</citetitle></link> section. |
| 22 | </para> |
| 23 | </refsect1> |
| 24 | |
| 25 | <refsect1> |
| 26 | <title>Syntax</title> |
| 27 | <synopsis>ar1, ar2 <command>sfinstr</command> ivel, inotenum, xamp, xfreq, instrnum, ifilhandle \ |
| 28 | [, iflag] [, ioffset]</synopsis> |
| 29 | </refsect1> |
| 30 | |
| 31 | <refsect1> |
| 32 | <title>Initialization</title> |
| 33 | <para> |
| 34 | <emphasis>ivel</emphasis> -- velocity value |
| 35 | </para> |
| 36 | |
| 37 | <para> |
| 38 | <emphasis>inotenum</emphasis> -- MIDI note number value |
| 39 | </para> |
| 40 | |
| 41 | <para> |
| 42 | <emphasis>instrnum</emphasis> -- number of an instrument of a SF2 file. |
| 43 | </para> |
| 44 | |
| 45 | <para> |
| 46 | <emphasis>ifilhandle</emphasis> -- unique number generated by <emphasis>sfload</emphasis> opcode to be used as an identifier for a SF2 file. Several SF2 files can be loaded and activated at the same time. |
| 47 | </para> |
| 48 | |
| 49 | <para> |
| 50 | <emphasis>iflag</emphasis> (optional) -- flag regarding the behavior of <emphasis>xfreq</emphasis> and <emphasis>inotenum</emphasis> |
| 51 | </para> |
| 52 | |
| 53 | <para> |
| 54 | <emphasis>ioffset</emphasis> (optional) -- start playing at offset, in samples. |
| 55 | </para> |
| 56 | </refsect1> |
| 57 | |
| 58 | |
| 59 | <refsect1> |
| 60 | <title>Performance</title> |
| 61 | <para> |
| 62 | <emphasis>xamp</emphasis> -- amplitude correction factor |
| 63 | </para> |
| 64 | |
| 65 | <para> |
| 66 | <emphasis>xfreq</emphasis> -- frequency value or frequency multiplier, depending by <emphasis>iflag</emphasis>. When <emphasis>iflag</emphasis> = 0, <emphasis>xfreq</emphasis> is a multiplier of a the default frequency, assigned by SF2 preset to the <emphasis>inotenum</emphasis> value. When <emphasis>iflag</emphasis> = 1, <emphasis>xfreq</emphasis> is the absolute frequency of the output sound, in Hz. Default is 0. |
| 67 | </para> |
| 68 | |
| 69 | <para> |
| 70 | When <emphasis>iflag</emphasis> = 0, <emphasis>inotenum</emphasis> sets the frequency of the output according to the MIDI note number used, and <emphasis>xfreq</emphasis> is used as a multiplier. When <emphasis>iflag</emphasis> = 1, the frequency of the output, is set directly by <emphasis>xfreq</emphasis>. 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. |
| 71 | </para> |
| 72 | |
| 73 | <para> |
| 74 | Adjustment of the amplitude can be done by varying the <emphasis>xamp</emphasis> argument, which acts as |
| 75 | a multiplier. |
| 76 | </para> |
| 77 | |
| 78 | <para> |
| 79 | The <emphasis>ioffset</emphasis> parameter allows the sound to start from a sample different than the first one. The user should make sure that its value is within the length of the specific sound. Otherwise, Csound will probably crash. |
| 80 | </para> |
| 81 | |
| 82 | <para> |
| 83 | <emphasis>sfinstr</emphasis> plays an SF2 instrument instead of a preset (an SF2 instrument is the base of a preset layer). <emphasis>instrnum</emphasis> 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 <emphasis>xamp</emphasis> and <emphasis>xfreq</emphasis> can operate at k-rate as well as a-rate, but both arguments must work at the same rate. |
| 84 | </para> |
| 85 | |
| 86 | <para> |
| 87 | 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. |
| 88 | </para> |
| 89 | </refsect1> |
| 90 | |
| 91 | <refsect1> |
| 92 | <title>Examples</title> |
| 93 | <para> |
| 94 | Here is an example of the sfinstr opcode. It uses the file <ulink url="examples/sfinstr.csd"><citetitle>sfinstr.csd</citetitle></ulink>. |
| 95 | <example> |
| 96 | <title>Example of the sfinstr opcode.</title> |
| 97 | <para>See the sections <link linkend="UsingRealTime"><citetitle>Real-time Audio</citetitle></link> and <link linkend="CommandFlags"><citetitle>Command Line Flags</citetitle></link> for more information on using command line flags.</para> |
| 98 | <xi:include href="examples-xml/sfinstr.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 99 | </example> |
| 100 | </para> |
| 101 | </refsect1> |
| 102 | |
| 103 | <refsect1> |
| 104 | <title>See also</title> |
| 105 | <para><link linkend="SiggenSample"><citetitle>Soundfonts</citetitle></link></para> |
| 106 | <para> More information on soundfonts is in the Floss Manuals: <ulink url="https://flossmanual.csound.com/midi/reading-midi-files"><citetitle>https://flossmanual.csound.com/midi/reading-midi-files</citetitle></ulink></para> |
| 107 | <para> For other information on soundfonts look in the Wikipedia: <ulink url="http://en.wikipedia.org/wiki/Soundfont"><citetitle>http://en.wikipedia.org/wiki/Soundfont</citetitle></ulink></para> |
| 108 | </refsect1> |
| 109 | |
| 110 | <refsect1> |
| 111 | <title>Credits</title> |
| 112 | <para> |
| 113 | <simplelist> |
| 114 | <member>Author: &namegabriel;</member> |
| 115 | <member>Italy</member> |
| 116 | <member>May 2000</member> |
| 117 | </simplelist> |
| 118 | </para> |
| 119 | |
| 120 | <para>New in Csound Version 4.07</para> |
| 121 | </refsect1> |
| 122 | </refentry> |