summaryrefslogtreecommitdiff
path: root/opcodes/sfplay3.xml
blob: ab4d992a267d9949baca8ae81ffa6c25d31d9397 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<refentry id="sfplay3">
<indexterm id="IndexSfplay3"><primary>sfplay3</primary></indexterm>
  <refentryinfo><title>Signal Generators:Sample Playback</title></refentryinfo>
  <refmeta>
    <refentrytitle>sfplay3</refentrytitle>
  </refmeta>

  <refnamediv>
    <refname>sfplay3</refname>
    <refpurpose>
      Plays a SoundFont2 (SF2) sample preset, generating a stereo sound with cubic interpolation.
    </refpurpose>
  </refnamediv>

  <refsect1>
    <title>Description</title>
    <para>
      Plays a SoundFont2 (SF2) sample preset, generating a stereo sound with cubic interpolation. 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="MiscSf2"><citetitle>SoundFont2 File Format Appendix</citetitle></link>.
    </para>
  </refsect1>

  <refsect1>
    <title>Syntax</title>
    <synopsis>ar1, ar2 <command>sfplay3</command> ivel, inotenum, xamp, xfreq, ipreindex [, iflag] [, ioffset] [, ienv]</synopsis>
  </refsect1>

  <refsect1>
    <title>Initialization</title>
    <para>
      <emphasis>ivel</emphasis> -- velocity value
    </para>

    <para>
      <emphasis>inotenum</emphasis> -- MIDI note number value
    </para>

    <para>
      <emphasis>ipreindex</emphasis> -- preset index
    </para>

    <para>
      <emphasis>iflag</emphasis> (optional) -- flag regarding the behavior of <emphasis>xfreq</emphasis> and <emphasis>inotenum</emphasis>
    </para>

    <para>
      <emphasis>ioffset</emphasis> (optional) -- start playing at offset, in samples.
    </para>

    <para>
      <emphasis>ienv</emphasis> (optional) -- enables and determines amplitude envelope. 0 = no envelope, 1 = linear attack and decay, 2 = linear attack, exponential decay (see below). Default = 0.
    </para>
  </refsect1>

  <refsect1>
    <title>Performance</title>
    <para>
      <emphasis>xamp</emphasis> -- amplitude correction factor
    </para>

    <para>
      <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.
    </para>

    <para>
      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.
    </para>

    <para>
      Adjustment of the amplitude can be done by varying the <emphasis>xamp</emphasis> argument, which acts as a multiplier.
    </para>

    <para>
      Notice that both <emphasis>xamp</emphasis> and <emphasis>xfreq</emphasis> can use k-rate as well as a-rate signals. Both arguments must use variables of the same rate, or <emphasis>sfplay3</emphasis> will not work correctly. <emphasis>ipreindex</emphasis> must contain the number of a previously assigned preset, or Csound will crash.
    </para>

    <para>
      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.
    </para>

    <para>
      The <emphasis>ienv</emphasis> parameter enables and determines the type of amplitude envelope used. The default value is 0, or no envelope. If <emphasis>ienv</emphasis> is set to 1, the attack and decay portions are linear. If set to 2, the attack is linear and the decay is exponential. The release portion of the envelope has not yet been implemented.
    </para>

    <para>
      <emphasis>sfplay3</emphasis> plays a preset, generating a stereo sound with cubic interpolation. <emphasis>ivel</emphasis> does not directly affect the amplitude of the output, but informs <emphasis>sfplay3</emphasis> about which sample should be chosen in multi-sample, velocity-split presets.
    </para>

    <para>
      <emphasis>sfplay3</emphasis> is a cubic-interpolation version of <link linkend="sfplay"><citetitle>sfplay</citetitle></link>. Difference of sound-quality is noticeable specially in bass-frequency-transposed samples. In high-freq-transposed samples the difference is less noticeable, and I suggest to use linear-interpolation versions, because they are faster.
    </para>

    <para>
      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.
    </para>
  </refsect1>

  <refsect1>
    <title>See Also</title>
    <para>
      <link linkend="sfilist"><citetitle>sfilist</citetitle></link>,
      <link linkend="sfinstr3"><citetitle>sfinstr3</citetitle></link>,
      <link linkend="sfinstr3m"><citetitle>sfinstr3m</citetitle></link>,
      <link linkend="sfinstr"><citetitle>sfinstr</citetitle></link>,
      <link linkend="sfinstrm"><citetitle>sfinstrm</citetitle></link>,
      <link linkend="sfload"><citetitle>sfload</citetitle></link>,
      <link linkend="sfpassign"><citetitle>sfpassign</citetitle></link>,
      <link linkend="sfplay3m"><citetitle>sfplay3m</citetitle></link>,
      <link linkend="sfplaym"><citetitle>sfplaym</citetitle></link>,
      <link linkend="sfplay"><citetitle>sfplay</citetitle></link>,
      <link linkend="sfplist"><citetitle>sfplist</citetitle></link>,
      <link linkend="sfpreset"><citetitle>sfpreset</citetitle></link>
    </para>
  </refsect1>
 
  <refsect1>
    <title>Credits</title>
    <para>
      <simplelist>
        <member>Author: &namegabriel;</member>
        <member>Italy</member>
        <member>May 2000</member>
      </simplelist>
    </para>

    <para>New in Csound Version 4.07</para>
    <para>New optional parameter <emphasis>ienv</emphasis> in version 5.09</para>
  </refsect1>
</refentry>