| 1 | |
| 2 | <refentry id="tempest"> |
| 3 | <indexterm id="IndexTempest"><primary>tempest</primary></indexterm> |
| 4 | <refentryinfo><title>Instrument Control:Sensing and Control</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>tempest</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | <refnamediv> |
| 10 | <refname>tempest</refname> |
| 11 | |
| 12 | <refpurpose> |
| 13 | Estimate the tempo of beat patterns in a control signal. |
| 14 | </refpurpose> |
| 15 | </refnamediv> |
| 16 | |
| 17 | <refsect1> |
| 18 | <title>Description</title> |
| 19 | <para> |
| 20 | Estimate the tempo of beat patterns in a control signal. |
| 21 | </para> |
| 22 | </refsect1> |
| 23 | |
| 24 | <refsect1> |
| 25 | <title>Syntax</title> |
| 26 | <synopsis>ktemp <command>tempest</command> kin, iprd, imindur, imemdur, ihp, ithresh, ihtim, ixfdbak, \ |
| 27 | istartempo, ifn [, idisprd] [, itweek]</synopsis> |
| 28 | </refsect1> |
| 29 | |
| 30 | <refsect1> |
| 31 | <title>Initialization</title> |
| 32 | <para> |
| 33 | <emphasis>iprd</emphasis> -- period between analyses (in seconds). Typically about .02 seconds. |
| 34 | </para> |
| 35 | |
| 36 | <para> |
| 37 | <emphasis>imindur</emphasis> -- minimum duration (in seconds) to serve as a unit of tempo. Typically about .2 seconds. |
| 38 | </para> |
| 39 | |
| 40 | <para> |
| 41 | <emphasis>imemdur</emphasis> -- duration (in seconds) of the <emphasis>kin</emphasis> short-term memory buffer which will be scanned for periodic patterns. Typically about 3 seconds. |
| 42 | </para> |
| 43 | |
| 44 | <para> |
| 45 | <emphasis>ihp</emphasis> -- half-power point (in Hz) of a low-pass filter used to smooth input <emphasis>kin</emphasis> prior to other processing. This will tend to suppress activity that moves much faster. Typically 2 Hz. |
| 46 | </para> |
| 47 | |
| 48 | <para> |
| 49 | <emphasis>ithresh</emphasis> -- loudness threshold by which the low-passed <emphasis>kin</emphasis> is center-clipped before being placed in the short-term buffer as tempo-relevant data. Typically at the noise floor of the incoming data. |
| 50 | </para> |
| 51 | |
| 52 | <para> |
| 53 | <emphasis>ihtim</emphasis> -- half-time (in seconds) of an internal forward-masking filter that masks new <emphasis>kin</emphasis> data in the presence of recent, louder data. Typically about .005 seconds. |
| 54 | </para> |
| 55 | |
| 56 | <para> |
| 57 | <emphasis>ixfdbak</emphasis> -- proportion of this unit's <emphasis>anticipated value</emphasis> to be mixed with the incoming <emphasis>kin</emphasis> prior to all processing. Typically about .3. |
| 58 | </para> |
| 59 | |
| 60 | <para> |
| 61 | <emphasis>istartempo</emphasis> -- initial tempo (in beats per minute). Typically 60. |
| 62 | </para> |
| 63 | |
| 64 | <para> |
| 65 | <emphasis>ifn</emphasis> -- table number of a stored function (drawn left-to-right) by which the short-term memory data is attenuated over time. |
| 66 | </para> |
| 67 | |
| 68 | <para> |
| 69 | <emphasis>idisprd</emphasis> (optional) -- if non-zero, display the short-term past and future buffers every <emphasis>idisprd</emphasis> seconds (normally a multiple of <emphasis>iprd</emphasis>). The default value is 0 (no display). |
| 70 | </para> |
| 71 | |
| 72 | <para> |
| 73 | <emphasis>itweek</emphasis> (optional) -- fine-tune adjust this unit so that it is stable when analyzing events controlled by its own output. The default value is 1 (no change). |
| 74 | </para> |
| 75 | </refsect1> |
| 76 | |
| 77 | <refsect1> |
| 78 | <title>Performance</title> |
| 79 | <para> |
| 80 | <emphasis>tempest</emphasis> examines <emphasis>kin</emphasis> for amplitude periodicity, and estimates a current tempo. The input is first low-pass filtered, then center-clipped, and the residue placed in a short-term memory buffer (attenuated over time) where it is analyzed for periodicity using a form of autocorrelation. The period, expressed as a <emphasis>tempo</emphasis> in beats per minute, is output as <emphasis>ktemp</emphasis>. The period is also used internally to make predictions about future amplitude patterns, and these are placed in a buffer adjacent to that of the input. The two adjacent buffers can be periodically displayed, and the predicted values optionally mixed with the incoming signal to simulate expectation. |
| 81 | </para> |
| 82 | |
| 83 | <para> |
| 84 | This unit is useful for sensing the metric implications of any k-signal (e.g.- the RMS of an audio signal, or the second derivative of a conducting gesture), before sending to a <link linkend="tempo"><citetitle>tempo</citetitle></link> statement. |
| 85 | </para> |
| 86 | </refsect1> |
| 87 | |
| 88 | |
| 89 | <refsect1> |
| 90 | <title>Examples</title> |
| 91 | <para> |
| 92 | Here is an example of the tempest opcode. It uses the file <ulink url="examples/tempest.csd"><citetitle>tempest.csd</citetitle></ulink>, and <ulink url="examples/drumsMlp.wav"><citetitle>drumsMlp.wav</citetitle></ulink>. |
| 93 | <example> |
| 94 | <title>Example of the tempest opcode.</title> |
| 95 | <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> |
| 96 | <xi:include href="examples-xml/tempest.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 97 | </example> |
| 98 | |
| 99 | The tempo of the audio file <quote>drumsMlp.wav</quote> is 120 beats per minute. In this examples, tempest will print out its best guess as the audio file plays. Its output should include lines like this: |
| 100 | <screen> |
| 101 | . i1 118.24654 |
| 102 | . i1 121.72949</screen> |
| 103 | </para> |
| 104 | </refsect1> |
| 105 | |
| 106 | <refsect1> |
| 107 | <title>See also</title> |
| 108 | <para><link linkend="ControlSensing"><citetitle>Sensing and Control: Tempo and Pitch estimation</citetitle></link></para> |
| 109 | </refsect1> |
| 110 | |
| 111 | </refentry> |