| 1 | |
| 2 | <refentry id="pluck"> |
| 3 | <indexterm id="IndexPluck"><primary>pluck</primary></indexterm> |
| 4 | <refentryinfo><title>Signal Generators:Waveguide Physical Modeling</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>pluck</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | <refnamediv> |
| 10 | <refname>pluck</refname> |
| 11 | <refpurpose> |
| 12 | Produces a naturally decaying plucked string or drum sound. |
| 13 | </refpurpose> |
| 14 | </refnamediv> |
| 15 | |
| 16 | <refsect1> |
| 17 | <title>Description</title> |
| 18 | <para> |
| 19 | Audio output is a naturally decaying plucked string or drum sound based on the Karplus-Strong algorithms. |
| 20 | </para> |
| 21 | </refsect1> |
| 22 | |
| 23 | <refsect1> |
| 24 | <title>Syntax</title> |
| 25 | <synopsis>ares <command>pluck</command> kamp, kcps, icps, ifn, imeth [, iparm1] [, iparm2]</synopsis> |
| 26 | </refsect1> |
| 27 | |
| 28 | <refsect1> |
| 29 | <title>Initialization</title> |
| 30 | <para> |
| 31 | <emphasis>icps</emphasis> -- intended pitch value in Hz, used to set up a buffer of 1 cycle of audio samples which will be smoothed over time by a chosen decay method. <emphasis>icps</emphasis> normally anticipates the value of <emphasis>kcps</emphasis>, but may be set artificially high or low to influence the size of the sample buffer. |
| 32 | </para> |
| 33 | |
| 34 | <para> |
| 35 | <emphasis>ifn</emphasis> -- table number of a stored function used to initialize the cyclic decay buffer. If <emphasis>ifn</emphasis> = 0, a random sequence will be used instead. |
| 36 | </para> |
| 37 | |
| 38 | <para> |
| 39 | <emphasis>imeth</emphasis> -- method of natural decay. There are six, some of which use parameters values that follow. |
| 40 | <orderedlist> |
| 41 | <listitem> |
| 42 | <para> |
| 43 | simple averaging. A simple smoothing process, uninfluenced by parameter values. |
| 44 | </para> |
| 45 | </listitem> |
| 46 | |
| 47 | <listitem> |
| 48 | <para> |
| 49 | stretched averaging. As above, with smoothing time stretched by a factor of <emphasis>iparm1</emphasis> (>=1). |
| 50 | </para> |
| 51 | </listitem> |
| 52 | |
| 53 | <listitem> |
| 54 | <para> |
| 55 | simple drum. The range from pitch to noise is controlled by a 'roughness factor' in <emphasis>iparm1</emphasis> (0 to 1). Zero gives the plucked string effect, while 1 reverses the polarity of every sample (octave down, odd harmonics). The setting .5 gives an optimum snare drum. |
| 56 | </para> |
| 57 | </listitem> |
| 58 | |
| 59 | <listitem> |
| 60 | <para> |
| 61 | stretched drum. Combines both roughness and stretch factors. <emphasis>iparm1</emphasis> is roughness (0 to 1), and <emphasis>iparm2</emphasis> the stretch factor (>=1). |
| 62 | </para> |
| 63 | </listitem> |
| 64 | |
| 65 | <listitem> |
| 66 | <para> |
| 67 | weighted averaging. As method 1, with <emphasis>iparm1</emphasis> weighting the current sample (the status quo) and <emphasis>iparm2</emphasis> weighting the previous adjacent one. <emphasis>iparm1 + iparm2</emphasis> must be <= 1. |
| 68 | </para> |
| 69 | </listitem> |
| 70 | |
| 71 | <listitem> |
| 72 | <para> |
| 73 | 1st order recursive filter, with coefs .5. Unaffected by parameter values. |
| 74 | </para> |
| 75 | </listitem> |
| 76 | </orderedlist> |
| 77 | </para> |
| 78 | |
| 79 | <para> |
| 80 | <emphasis>iparm1, iparm2</emphasis> (optional) -- parameter values for use by the smoothing algorithms (above). The default values are both 0. |
| 81 | </para> |
| 82 | </refsect1> |
| 83 | |
| 84 | <refsect1> |
| 85 | <title>Performance</title> |
| 86 | <para> |
| 87 | <emphasis>kamp</emphasis> -- the output amplitude. |
| 88 | </para> |
| 89 | |
| 90 | <para> |
| 91 | <emphasis>kcps</emphasis> -- the resampling frequency in cycles-per-second. |
| 92 | </para> |
| 93 | |
| 94 | <para> |
| 95 | An internal audio buffer, filled at i-time according to <emphasis>ifn</emphasis>, is continually resampled with periodicity <emphasis>kcps</emphasis> and the resulting output is multiplied by <emphasis>kamp</emphasis>. Parallel with the sampling, the buffer is smoothed to simulate the effect of natural decay. |
| 96 | </para> |
| 97 | |
| 98 | <para> |
| 99 | Plucked strings (1, 2, 5, 6) are best realized by starting with a random noise source, which is rich in initial harmonics. Drum sounds (methods 3, 4) work best with a flat source (wide pulse), which produces a deep noise attack and sharp decay. |
| 100 | </para> |
| 101 | |
| 102 | <para> |
| 103 | The original Karplus-Strong algorithm used a fixed number of samples per cycle, which caused serious quantization of the pitches available and their intonation. This implementation resamples a buffer at the exact pitch given by <emphasis>kcps</emphasis>, which can be varied for vibrato and glissando effects. For low values of the orch sampling rate (e.g. <emphasis>sr</emphasis> = 10000), high frequencies will store only very few samples (<emphasis>sr / icps</emphasis>). Since this may cause noticeable noise in the resampling process, the internal buffer has a minimum size of 64 samples. This can be further enlarged by setting <emphasis>icps</emphasis> to some artificially lower pitch. |
| 104 | </para> |
| 105 | </refsect1> |
| 106 | |
| 107 | <refsect1> |
| 108 | <title>Examples</title> |
| 109 | <para> |
| 110 | Here is an example of the pluck opcode. It uses the file <ulink url="examples/pluck.csd"><citetitle>pluck.csd</citetitle></ulink>. |
| 111 | <example> |
| 112 | <title>Example of the pluck opcode.</title> |
| 113 | <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> |
| 114 | <xi:include href="examples-xml/pluck.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 115 | </example> |
| 116 | <para> |
| 117 | A musical example featuring the pluck opcode: <ulink url="examples/musical/ResonPluck_Cucchi.csd"><citetitle>ResonPluck_Cucchi.csd</citetitle></ulink> by Stefano Cucchi. |
| 118 | </para> |
| 119 | </para> |
| 120 | </refsect1> |
| 121 | |
| 122 | <refsect1> |
| 123 | <title>See also</title> |
| 124 | <para><link linkend="SiggenWavguide"><citetitle>Waveguide Physical Modeling</citetitle></link></para> |
| 125 | </refsect1> |
| 126 | |
| 127 | </refentry> |