| 1 | |
| 2 | <refentry id="pinkish"> |
| 3 | <indexterm id="IndexPinkish"><primary>pinkish</primary></indexterm> |
| 4 | <refentryinfo><title>Signal Generators:Random (Noise) Generators</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>pinkish</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | |
| 10 | |
| 11 | <refnamediv> |
| 12 | <refname>pinkish</refname> |
| 13 | <refpurpose> |
| 14 | Generates approximate pink noise. |
| 15 | </refpurpose> |
| 16 | </refnamediv> |
| 17 | |
| 18 | <refsect1> |
| 19 | <title>Description</title> |
| 20 | <para> |
| 21 | Generates approximate pink noise (-3dB/oct response) by one of two different methods: |
| 22 | <itemizedlist> |
| 23 | <listitem> |
| 24 | <para>a multirate noise generator after Moore, coded by Martin Gardner</para> |
| 25 | </listitem> |
| 26 | |
| 27 | <listitem> |
| 28 | <para>a filter bank designed by Paul Kellet</para> |
| 29 | </listitem> |
| 30 | </itemizedlist> |
| 31 | </para> |
| 32 | </refsect1> |
| 33 | |
| 34 | <refsect1> |
| 35 | <title>Syntax</title> |
| 36 | <synopsis>ares <command>pinkish</command> xin [, imethod] [, inumbands] [, iseed] [, iskip]</synopsis> |
| 37 | </refsect1> |
| 38 | |
| 39 | <refsect1> |
| 40 | <title>Initialization</title> |
| 41 | <para> |
| 42 | <emphasis>imethod</emphasis> (optional, default=0) -- selects filter method: |
| 43 | <itemizedlist> |
| 44 | <listitem> |
| 45 | <para>0 = Gardner method (default).</para> |
| 46 | </listitem> |
| 47 | |
| 48 | <listitem> |
| 49 | <para>1 = Kellet filter bank.</para> |
| 50 | </listitem> |
| 51 | |
| 52 | <listitem> |
| 53 | <para>2 = A somewhat faster filter bank by Kellet, with less accurate response.</para> |
| 54 | </listitem> |
| 55 | </itemizedlist> |
| 56 | </para> |
| 57 | |
| 58 | <para> |
| 59 | <emphasis>inumbands</emphasis> (optional) -- only effective with Gardner method. The number of noise bands to generate. Maximum is 32, minimum is 4. Higher levels give smoother spectrum, but above 20 bands there will be almost DC-like slow fluctuations. Default value is 20. |
| 60 | </para> |
| 61 | |
| 62 | <para> |
| 63 | <emphasis>iseed</emphasis> (optional, default=0) -- only effective with Gardner method. If non-zero, seeds the random generator. If zero, the generator will be seeded from current time. Default is 0. |
| 64 | </para> |
| 65 | |
| 66 | <para> |
| 67 | <emphasis>iskip</emphasis> (optional, default=0) -- if non-zero, skip (re)initialization of internal state (useful for tied notes). Default is 0. |
| 68 | </para> |
| 69 | </refsect1> |
| 70 | |
| 71 | <refsect1> |
| 72 | <title>Performance</title> |
| 73 | <para> |
| 74 | <emphasis>xin</emphasis> -- for Gardner method: k- or a-rate amplitude. For Kellet filters: normally a-rate uniform random noise from rand (31-bit) or unirand, but can be any a-rate signal. The output peak value varies widely (±15%) even over long runs, and will usually be well below the input amplitude. Peak values may also occasionally overshoot input amplitude or noise. |
| 75 | </para> |
| 76 | |
| 77 | <para> |
| 78 | <emphasis>pinkish</emphasis> attempts to generate pink noise (i.e., noise with equal energy in each octave), by one of two different methods. |
| 79 | </para> |
| 80 | |
| 81 | <para> |
| 82 | The first method, by Moore & Gardner, adds several (up to 32) signals of white noise, generated at octave rates (sr, sr/2, sr/4 etc). It obtains pseudo-random values from an internal 32-bit generator. This random generator is local to each opcode instance and seedable (similar to <emphasis>rand</emphasis>). |
| 83 | </para> |
| 84 | |
| 85 | <para> |
| 86 | The second method is a lowpass filter with a response approximating -3dB/oct. If the input is uniform white noise, it outputs pink noise. Any signal may be used as input for this method. The high quality filter is slower, but has less ripple and a slightly wider operating frequency range than less computationally intense versions. With the Kellet filters, seeding is not used. |
| 87 | </para> |
| 88 | |
| 89 | <para> |
| 90 | The Gardner method output has some frequency response anomalies in the low-mid and high-mid frequency ranges. More low-frequency energy can be generated by increasing the number of bands. It is also a bit faster. The refined Kellet filter has very smooth spectrum, but a more limited effective range. The level increases slightly at the high end of the spectrum. |
| 91 | </para> |
| 92 | </refsect1> |
| 93 | |
| 94 | <refsect1> |
| 95 | <title>Examples</title> |
| 96 | <para> |
| 97 | Here is an example of the pinkish opcode. It uses the file <ulink url="examples/pinkish.csd"><citetitle>pinkish.csd</citetitle></ulink>. |
| 98 | |
| 99 | <example> |
| 100 | <title>Example of the pinkish opcode.</title> |
| 101 | |
| 102 | |
| 103 | |
| 104 | <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> |
| 105 | <xi:include href="examples-xml/pinkish.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 106 | </example> |
| 107 | |
| 108 | Kellet-filtered noise for a tied note (<emphasis>iskip</emphasis> is non-zero). |
| 109 | </para> |
| 110 | </refsect1> |
| 111 | |
| 112 | <refsect1> |
| 113 | <title>See also</title> |
| 114 | <para><link linkend="SiggenNoise"><citetitle>Random (Noise) Generators</citetitle></link></para> |
| 115 | </refsect1> |
| 116 | |
| 117 | <refsect1> |
| 118 | <title>Credits</title> |
| 119 | <para> |
| 120 | <simplelist> |
| 121 | <member>Authors: Phil Burk and &namejohn;</member> |
| 122 | <member>University of Bath/Codemist Ltd.</member> |
| 123 | <member>Bath, UK</member> |
| 124 | <member>May 2000</member> |
| 125 | </simplelist> |
| 126 | </para> |
| 127 | |
| 128 | <para>New in Csound Version 4.07</para> |
| 129 | |
| 130 | <para> |
| 131 | Adapted for Csound by &namerasmus; |
| 132 | </para> |
| 133 | |
| 134 | <para> |
| 135 | The noise bands method is due to F. R. Moore (or R. F. Voss), and was presented by Martin Gardner in an oft-cited article in Scientific American. The present version was coded by Phil Burk as the result of discussion on the music-dsp mailing list, with significant optimizations suggested by James McCartney. |
| 136 | </para> |
| 137 | |
| 138 | <para> |
| 139 | The filter bank was designed by Paul Kellet, posted to the music-dsp mailing list. |
| 140 | </para> |
| 141 | |
| 142 | <para> |
| 143 | The whole pink noise discussion was collected on a HTML page by Robin Whittle, which is currently available at <ulink url="http://www.firstpr.com.au/dsp/pink-noise/"><citetitle>http://www.firstpr.com.au/dsp/pink-noise/</citetitle></ulink>. |
| 144 | </para> |
| 145 | |
| 146 | <para>Added notes by &namerasmus; on September 2002.</para> |
| 147 | </refsect1> |
| 148 | </refentry> |