<!-- Converted to DocBook/SGML by Kevin Conder -->
<refentry id="pvinterp">
  <refmeta>
    <refentrytitle>pvinterp</refentrytitle>
  </refmeta>
 
  <refnamediv>
    <refname>pvinterp</refname>
    <refpurpose>
      Interpolates between the amplitudes and frequencies of two phase vocoder analysis files.
      <indexterm id="IndexPvinterp"><primary>pvinterp</primary></indexterm>
    </refpurpose>
  </refnamediv>
 
  <refsect1>
    <title>Description</title>
    <para>
      <emphasis>pvinterp</emphasis> interpolates between the amplitudes and frequencies, on a bin by bin basis, of two phase vocoder analysis files (one from a previously called <emphasis>pvbufread</emphasis> unit and the other from within its own argument list), allowing for user defined transitions between analyzed sounds. It also allows for general scaling of the amplitudes and frequencies of each file separately before the interpolated values are calculated and sent to the resynthesis routines. The <emphasis>kfmod</emphasis> argument in <emphasis>pvinterp</emphasis> performs its frequency scaling on the frequency values after their derivation from the separate scaling and subsequent interpolation is performed so that this acts as an overall scaling value of the new frequency components.
    </para>
  </refsect1>
 
  <refsect1>
    <title>Syntax</title>
    <synopsis>ar <command>pvinterp</command> ktimpnt, kfmod, ifile, kfreqscale1, kfreqscale2, kampscale1, kampscale2, kfreqinterp, kampinterp</synopsis>
  </refsect1>
 
  <refsect1>
    <title>Initialization</title>
    <para>
      <emphasis>ifile</emphasis> -- the <emphasis>pvoc</emphasis> number (n in pvoc.n) or the name in quotes of the analysis file made using pvanal. (See <link linkend="pvoc"><citetitle>pvoc</citetitle></link>.)
    </para>
  </refsect1>
 
  <refsect1>
    <title>Performance</title>
    <para>
      <emphasis>ktimpnt</emphasis> -- the passage of time, in seconds, through this file. <emphasis>ktimpnt</emphasis> must always be positive, but can move forwards or backwards in time, be stationary or discontinuous, as a pointer into the analysis file.
    </para>

    <para>
      <emphasis>kfmod</emphasis> -- a control-rate transposition factor: a value of 1 incurs no transposition, 1.5 transposes up a perfect fifth, and .5 down an octave. 
    </para>

    <para>
      <emphasis>kfreqscale1</emphasis>, <emphasis>kfreqscale2</emphasis>, <emphasis>kampscale1</emphasis>, <emphasis>kampscale2</emphasis> -- used in <emphasis>pvinterp</emphasis> to scale the frequencies and amplitudes stored in each frame of the phase vocoder analysis file. <emphasis>kfreqscale1</emphasis> and <emphasis>kampscale1</emphasis> scale the frequencies and amplitudes of the data from the file read by the previously called <link linkend="pvbufread"><citetitle>pvbufread</citetitle></link> (this data is passed internally to the pvinterp unit). <emphasis>kfreqscale2</emphasis> and <emphasis>kampscale2</emphasis> scale the frequencies and amplitudes of the file named by <emphasis>ifile</emphasis> in the <emphasis>pvinterp</emphasis> argument list and read within the <emphasis>pvinterp</emphasis> unit. 
    </para>

    <para>
      By using these arguments, it is possible to adjust these values before applying the interpolation. For example, if file1 is much louder than file2, it might be desirable to scale down the amplitudes of file1 or scale up those of file2 before interpolating. Likewise one can adjust the frequencies of each to bring them more in accord with one another (or just the opposite, of course!) before the interpolation is performed.
    </para>

    <para>
      <emphasis>kfreqinterp</emphasis>, <emphasis>kampinterp</emphasis> -- used in <emphasis>pvinterp</emphasis>, determine the interpolation distance between the values of one phase vocoder file and the values of a second file. When the value of <emphasis>kfreqinterp</emphasis> is 0, the frequency values will be entirely those from the first file (read by the <emphasis>pvbufread</emphasis>), post scaling by the <emphasis>kfreqscale1</emphasis> argument. When the value of <emphasis>kfreqinterp</emphasis> is 1 the frequency values will be those of the second file (read by the <emphasis>pvinterp</emphasis> unit itself), post scaling by kfreqscale2. When <emphasis>kfreqinterp</emphasis> is between 0 and 1 the frequency values will be calculated, on a bin, by bin basis, as the percentage between each pair of frequencies (in other words, <emphasis>kfreqinterp</emphasis>=.5 will cause the frequencies values to be half way between the values in the set of data from the first file and the set of data from the second file). 
    </para>

    <para>
      <emphasis>kampinterp</emphasis> works in the same way upon the amplitudes of the two files. Since these are k-rate arguments, the percentages can change over time making it possible to create many kinds of transitions between sounds.
    </para>
  </refsect1>
 
  <refsect1>
    <title>Examples</title>
    <para>
      The example below shows an example using <emphasis>pvbufread</emphasis> with <emphasis>pvinterp</emphasis> to interpolate between the sound of an oboe and the sound of a clarinet. The value of <emphasis>kinterp</emphasis> returned by a linseg is used to determine the timing of the transitions between the two sounds. The interpolation of frequencies and amplitudes are controlled by the same factor in this example, but for other effects it might be interesting to not have them synchronized in this way. In this example the sound will begin as a clarinet, transform into the oboe and then return again to the clarinet sound. The value of <emphasis>kfreqscale2</emphasis> is 1.065 because the oboe in this case is a semitone higher in pitch than the clarinet and this brings them approximately to the same pitch. The value of <emphasis>kampscale2</emphasis> is .75 because the analyzed clarinet was somewhat louder than the analyzed oboe. The setting of these two parameters make the transition quite smooth in this case, but such adjustments are by no means necessary or even advocated.
    </para>

    <para>
      <informalexample>
        <programlisting>
ktime1  <emphasis>line</emphasis>      0, p3, 3.5 ; used as index in the &quot;oboe.pvoc&quot; file
ktime2  <emphasis>line</emphasis>      0, p3, 4.5 ; used as index in the  &quot;clar.pvoc&quot; file
kinterp <emphasis>linseg</emphasis>    1, p3*.15, 1, p3*.35, 0, p3*.25, 0, p3*.15, 1, p3*.1, 1
        <emphasis>pvbufread</emphasis> ktime1, &quot;oboe.pvoc&quot;
apv     <emphasis>pvinterp</emphasis>  ktime2,1,&quot;clar.pvoc&quot;,1,1.065,1,.75,1-kinterp,1-kinterp
        </programlisting>
      </informalexample>
    </para>
  </refsect1>

  <refsect1>
    <title>See Also</title>
    <para>
      <link linkend="pvbufread"><citetitle>pvbufread</citetitle></link>,
      <link linkend="pvcross"><citetitle>pvcross</citetitle></link>,
      <link linkend="pvread"><citetitle>pvread</citetitle></link>,
      <link linkend="tableseg"><citetitle>tableseg</citetitle></link>,
      <link linkend="tablexseg"><citetitle>tablexseg</citetitle></link>
    </para>
  </refsect1>
 
  <refsect1>
    <title>Credits</title>
    <para>
      <simplelist>
        <member>Author: Richard Karpen</member>
        <member>Seattle, Wash</member>
        <member>1997</member>
      </simplelist>
    </para>
  </refsect1>
</refentry>
