| 1 | |
| 2 | <refentry id="specptrk"> |
| 3 | <indexterm id="IndexSpecptrk"><primary>specptrk</primary></indexterm> |
| 4 | <refentryinfo><title>Spectral Processing:Non-Standard</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>specptrk</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | <refnamediv> |
| 10 | <refname>spectrk</refname> |
| 11 | <refpurpose> |
| 12 | Estimates the pitch of the most prominent complex tone in the spectrum. |
| 13 | </refpurpose> |
| 14 | </refnamediv> |
| 15 | |
| 16 | <refsect1> |
| 17 | <title>Description</title> |
| 18 | <para> |
| 19 | Estimate the pitch of the most prominent complex tone in the spectrum. |
| 20 | </para> |
| 21 | </refsect1> |
| 22 | |
| 23 | <refsect1> |
| 24 | <title>Syntax</title> |
| 25 | <synopsis>koct, kamp <command>specptrk</command> wsig, kvar, ilo, ihi, istr, idbthresh, inptls, \ |
| 26 | irolloff [, iodd] [, iconfs] [, interp] [, ifprd] [, iwtflg]</synopsis> |
| 27 | </refsect1> |
| 28 | |
| 29 | <refsect1> |
| 30 | <title>Initialization</title> |
| 31 | <para> |
| 32 | <emphasis>ilo, ihi, istr</emphasis> -- pitch range conditioners (low, high, and starting) expressed in decimal octave form. |
| 33 | </para> |
| 34 | |
| 35 | <para> |
| 36 | <emphasis>idbthresh</emphasis> -- energy threshold (in decibels) for pitch tracking to occur. Once begun, tracking will be continuous until the energy falls below one half the threshold (6 dB down), whence the <emphasis>koct</emphasis> and <emphasis>kamp</emphasis> outputs will be zero until the full threshold is again surpassed. <emphasis>idbthresh</emphasis> is a guiding value. At initialization it is first converted to the <emphasis>idbout</emphasis> mode of the source spectrum (and the 6 dB down point becomes .5, .25, or 1/root 2 for modes 0, 2 and 3). The values are also further scaled to allow for the weighted partial summation used during correlation.The actual thresholding is done using the internal weighted and summed <emphasis>kamp</emphasis> value that is visible as the second output parameter. |
| 37 | </para> |
| 38 | |
| 39 | <para> |
| 40 | <emphasis>inptls, irolloff</emphasis> -- number of harmonic partials used as a matching template in the spectrally-based pitch detection, and an amplitude rolloff for the set expressed as some fraction per octave (linear, so don't roll off to negative). Since the partials and rolloff fraction can affect the pitch following, some experimentation will be useful: try 4 or 5 partials with .6 rolloff as an initial setting; raise to 10 or 12 partials with rolloff .75 for complex timbres like the bassoon (weak fundamental). Computation time is dependent on the number of partials sought. The maximum number is 16. |
| 41 | </para> |
| 42 | |
| 43 | <para> |
| 44 | <emphasis>iodd</emphasis> (optional) -- if non-zero, employ only odd partials in the above set (e.g. <emphasis>inptls</emphasis> of 4 would employ partials 1,3,5,7). This improves the tracking of some instruments like the clarinet The default value is 0 (employ all partials). |
| 45 | </para> |
| 46 | |
| 47 | <para> |
| 48 | <emphasis>iconfs</emphasis> (optional) -- number of confirmations required for the pitch tracker to jump an octave, pro-rated for fractions of an octave (i.e. the value 12 implies a semitone change needs 1 confirmation (two hits) at the <emphasis>spectrum</emphasis> generating <emphasis>iprd</emphasis>). This parameter limits spurious pitch analyses such as octave errors. A value of 0 means no confirmations required; the default value is 10. |
| 49 | </para> |
| 50 | |
| 51 | <para> |
| 52 | <emphasis>interp</emphasis> (optional) -- if non-zero, interpolate each output signal (<emphasis>koct</emphasis>, <emphasis>kamp</emphasis>) between incoming <emphasis>wsig</emphasis> frames. The default value is 0 (repeat the signal values between frames). |
| 53 | </para> |
| 54 | |
| 55 | <para> |
| 56 | <emphasis>ifprd</emphasis> (optional) -- if non-zero, display the internally computed spectrum of candidate fundamentals. The default value is 0 (no display). |
| 57 | </para> |
| 58 | |
| 59 | <para> |
| 60 | <emphasis>iwtftg</emphasis> (optional) -- wait flag. If non-zero, hold each display until released by the user. The default value is 0 (no wait). |
| 61 | </para> |
| 62 | </refsect1> |
| 63 | |
| 64 | <refsect1> |
| 65 | <title>Performance</title> |
| 66 | <para> |
| 67 | At note initialization this unit creates a template of <emphasis>inptls</emphasis> harmonically related partials (odd partials, if <emphasis>iodd</emphasis> non-zero) with amplitude rolloff to the fraction <emphasis>irolloff</emphasis> per octave. At each new frame of <emphasis>wsig</emphasis>, the spectrum is cross-correlated with this template to provide an internal spectrum of candidate fundamentals (optionally displayed). A likely pitch/amp pair (<emphasis>koct</emphasis>, <emphasis>kamp</emphasis>, in decimal octave and summed <emphasis>idbout</emphasis> form) is then estimated. <emphasis>koct</emphasis> varies from the previous <emphasis>koct</emphasis> by no more than plus or minus <emphasis>kvar</emphasis> decimal octave units. It is also guaranteed to lie within the hard limit range <emphasis>ilo</emphasis> -- <emphasis>ihi</emphasis> (decimal octave low and high pitch). <emphasis>kvar</emphasis> can be dynamic, e.g. onset amp dependent. Pitch resolution uses the originating <emphasis>spectrum</emphasis> <emphasis>ifrqs</emphasis> bins/octave, with further parabolic interpolation between adjacent bins. Settings of root magnitude, <emphasis>ifrqs</emphasis> = 24, <emphasis>iq</emphasis> = 15 should capture all the inflections of interest. Between frames, the output is either repeated or interpolated at the k-rate. (See <link linkend="spectrum"><citetitle>spectrum</citetitle></link>.) |
| 68 | </para> |
| 69 | </refsect1> |
| 70 | |
| 71 | <refsect1> |
| 72 | <title>Examples</title> |
| 73 | <para> |
| 74 | <informalexample> |
| 75 | <programlisting> |
| 76 | a1, a2 <emphasis role="opc">ins</emphasis> <emphasis role="comment">; read a stereo clarinet input</emphasis> |
| 77 | krms <emphasis role="opc">rms</emphasis> a1, 20 <emphasis role="comment">; find a monaural rms value</emphasis> |
| 78 | kvar <emphasis role="op">=</emphasis> 0.6 <emphasis role="op">+</emphasis> krms<emphasis role="op">/</emphasis>8000 <emphasis role="comment">; & use to gate the pitch variance</emphasis> |
| 79 | wsig <emphasis role="opc">spectrum</emphasis> a1, 0.01, 7, 24, 15, 0, 3 <emphasis role="comment">; get a 7-oct spectrum, 24 bibs/oct</emphasis> |
| 80 | <emphasis role="opc">specdisp</emphasis> wsig, 0.2 <emphasis role="comment">; display this and now estimate</emphasis> |
| 81 | koct, ka <emphasis role="opc">spectrk</emphasis> wsig, kvar, 7.0, 10, 9, 20, 4, 0.7, 1, 5, 1, 0.2 <emphasis role="comment">; the pch and amp</emphasis> |
| 82 | aosc <emphasis role="opc">oscil</emphasis> ka <emphasis role="op">*</emphasis> ka <emphasis role="op">*</emphasis> 10, cpsoct(koct), 2 <emphasis role="comment">; & generate \ new tone with these</emphasis> |
| 83 | koct <emphasis role="op">=</emphasis> (koct <emphasis role="op"><</emphasis> 7.0 <emphasis role="op">?</emphasis> 7.0 <emphasis role="op">:</emphasis> koct) <emphasis role="comment">; replace non pitch with low C</emphasis> |
| 84 | <emphasis role="opc">display</emphasis> koct <emphasis role="op">-</emphasis> 7.0, 0.25, 20 <emphasis role="comment">; & display the pitch track</emphasis> |
| 85 | <emphasis role="opc">display</emphasis> ka, 0.25, 20 <emphasis role="comment">; plus the summed root mag</emphasis> |
| 86 | <emphasis role="opc">outs</emphasis> a1, aosc <emphasis role="comment">; output 1 original and 1 new track</emphasis></programlisting> |
| 87 | </informalexample> |
| 88 | </para> |
| 89 | </refsect1> |
| 90 | </refentry> |