<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>hrtfmove2</title> <link rel="stylesheet" type="text/css" href="csound.css" /> <meta name="generator" content="DocBook XSL Stylesheets V1.76.1" /> <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" /> <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" /> <link rel="prev" href="hrtfmove.html" title="hrtfmove" /> <link rel="next" href="hrtfreverb.html" title="hrtfreverb" /> </head> <body> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center">hrtfmove2</th> </tr> <tr> <td width="20%" align="left"><a accesskey="p" href="hrtfmove.html">Prev</a> </td> <th width="60%" align="center">Orchestra Opcodes and Operators</th> <td width="20%" align="right"> <a accesskey="n" href="hrtfreverb.html">Next</a></td> </tr> </table> <hr /> </div> <div class="refentry" title="hrtfmove2"> <a id="hrtfmove2"></a> <div class="titlepage"></div> <a id="IndexHrtfmove2" class="indexterm"></a> <div class="refnamediv"> <h2> <span class="refentrytitle">hrtfmove2</span> </h2> <p>hrtfmove2 — Generates dynamic 3d binaural audio for headphones using a Woodworth based spherical head model with improved low frequency phase accuracy. </p> </div> <div class="refsect1" title="Description"> <a id="idp26022712"></a> <h2>Description</h2> <p> This opcode takes a source signal and spatialises it in the 3 dimensional space around a listener using head related transfer function (HRTF) based filters. </p> </div> <div class="refsect1" title="Syntax"> <a id="idp26077104"></a> <h2>Syntax</h2> <pre class="synopsis">aleft, aright <span class="command"><strong>hrtfmove2</strong></span> asrc, kAz, kElev, ifilel, ifiler [,ioverlap, iradius, isr]</pre> </div> <div class="refsect1" title="Initialization"> <a id="idp26078192"></a> <h2>Initialization</h2> <p> <span class="emphasis"><em>ifilel</em></span> -- left HRTF spectral data file </p> <p> <span class="emphasis"><em>ifiler</em></span> -- right HRTF spectral data file </p> <div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"> <table border="0" summary="Note"> <tr> <td rowspan="2" align="center" valign="top" width="25"> <img alt="[Note]" src="images/note.png" /> </td> <th align="left">Note</th> </tr> <tr> <td align="left" valign="top"> <p> Spectral datafiles (based on the MIT HRTF database) are available in 3 different sampling rates: 44.1, 48 and 96 khz and are labelled accordingly. Input and processing <span class="emphasis"><em>sr</em></span> should match datafile <span class="emphasis"><em>sr</em></span>. Files should be in the current directory or the SADIR (see <a class="link" href="CommandEnvironment.html" title="Csound Environment Variables"><em class="citetitle">Environment Variables</em></a>). </p> </td> </tr> </table> </div> <div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"> <table border="0" summary="Note"> <tr> <td rowspan="2" align="center" valign="top" width="25"> <img alt="[Note]" src="images/note.png" /> </td> <th align="left">Note</th> </tr> <tr> <td align="left" valign="top"> <p> HRTF Data files for use with <a class="link" href="hrtfmove.html" title="hrtfmove"><em class="citetitle">hrtfmove</em></a>, <a class="link" href="hrtfmove2.html" title="hrtfmove2"><em class="citetitle">hrtfmove2</em></a>, <a class="link" href="hrtfstat.html" title="hrtfstat"><em class="citetitle">hrtfstat</em></a>, <a class="link" href="hrtfearly.html" title="hrtfearly"><em class="citetitle">hrtfearly</em></a>, <a class="link" href="hrtfreverb.html" title="hrtfreverb"><em class="citetitle">hrtfreverb</em></a> were updated for Csound 5.15 and later (the code was updated and is more efficient). Old datafiles are now deprecated. </p> </td> </tr> </table> </div> <p> <span class="emphasis"><em>ioverlap</em></span> -- optional, number of overlaps for STFT processing (default 4). See STFT section of manual. </p> <p> <span class="emphasis"><em>iradius</em></span> -- optional, head radius used for phase spectra calculation in centimeters (default 9.0) </p> <p> <span class="emphasis"><em>isr</em></span> - optional, default 44.1kHz, legal values: 44100, 48000 and 96000. </p> </div> <div class="refsect1" title="Performance"> <a id="idp26085504"></a> <h2>Performance</h2> <p> <span class="emphasis"><em>asrc</em></span> -- Input/source signal. </p> <p> <span class="emphasis"><em>kAz</em></span> -- azimuth value in degrees. Positive values represent position on the right, negative values are positions on the left. </p> <p> <span class="emphasis"><em>kElev</em></span> -- elevation value in degrees. Positive values represent position above horizontal, negative values are positions below horizontal (min -40). </p> <p> Artifact-free user-defined trajectories are made possible using an interpolation algorithm based on spectral magnitude interpolation and a derived phase spectrum based on the Woodworth spherical head model. Accuracy is increased for the data set provided by extracting and applying a frequency dependent scaling factor to the phase spectra, leading to a more precise low frequency interaural time difference. Users can control head radius for the phase derivation, allowing a crude level of individualisation. The dynamic source version of the opcode uses a Short Time Fourier Transform algorithm to avoid artefacts caused by derived phase spectra changes. STFT processing means this opcode is more computationally intensive than <a class="link" href="hrtfmove.html" title="hrtfmove"><em class="citetitle">hrtfmove</em></a> using phase truncation, but phase is constantly updated by <span class="emphasis"><em>hrtfmove2</em></span>. </p> </div> <div class="refsect1" title="Examples"> <a id="idp26089152"></a> <h2>Examples</h2> <p> Here is an example of the hrtfmove2 opcode. It uses the file <a class="ulink" href="examples/hrtfmove2.csd" target="_top"><em class="citetitle">hrtfmove2.csd</em></a>. </p> <div class="example"> <a id="idp26090208"></a> <p class="title"> <strong>Example 342. Example of the htrfmove2 opcode.</strong> </p> <div class="example-contents"> <pre class="programlisting"> <span class="csdtag"><CsoundSynthesizer></span> <span class="csdtag"><CsOptions></span> <span class="comment">; Select flags here</span> <span class="comment">; realtime audio out </span> -o dac <span class="comment">; For Non-realtime ouput leave only the line below:</span> <span class="comment">; -o hrtf.wav</span> <span class="csdtag"></CsOptions></span> <span class="csdtag"><CsInstruments></span> <span class="ohdr">sr</span> <span class="op">=</span> 44100 <span class="ohdr">kr</span> <span class="op">=</span> 4410 <span class="ohdr">ksmps</span> <span class="op">=</span> 10 <span class="ohdr">nchnls</span> <span class="op">=</span> 2 gasrc <span class="opc">init</span> 0 <span class="oblock">instr</span> 1 <span class="comment">;a plucked string</span> kamp <span class="op">=</span> p4 kcps <span class="op">=</span> <span class="opc">cpspch</span>(p5) icps <span class="op">=</span> <span class="opc">cpspch</span>(p5) a1 <span class="opc">pluck</span> kamp, kcps, icps, 0, 1 gasrc <span class="op">=</span> a1 <span class="oblock">endin</span> <span class="oblock">instr</span> 10 <span class="comment">;uses output from instr1 as source</span> kaz <span class="opc">linseg</span> 0, p3, 720 <span class="comment">;2 full rotations</span> aleft,aright <span class="opc">hrtfmove2</span> gasrc, kaz,0, "hrtf<span class="op">-</span>44100<span class="op">-</span>left.dat","hrtf<span class="op">-</span>44100<span class="op">-</span>right.dat" <span class="opc">outs</span> aleft, aright <span class="oblock">endin</span> <span class="csdtag"></CsInstruments></span> <span class="csdtag"><CsScore></span> <span class="comment">; Play Instrument 1: a simple arpeggio</span> <span class="stamnt">i</span>1 0 .2 15000 8.00 <span class="stamnt">i</span>1 + .2 15000 8.04 <span class="stamnt">i</span>1 + .2 15000 8.07 <span class="stamnt">i</span>1 + .2 15000 8.11 <span class="stamnt">i</span>1 + .2 15000 9.02 <span class="stamnt">i</span>1 + 1.5 15000 8.11 <span class="stamnt">i</span>1 + 1.5 15000 8.07 <span class="stamnt">i</span>1 + 1.5 15000 8.04 <span class="stamnt">i</span>1 + 1.5 15000 8.00 <span class="stamnt">i</span>1 + 1.5 15000 7.09 <span class="stamnt">i</span>1 + 1.5 15000 8.00 <span class="comment">; Play Instrument 10 for 10 seconds.</span> <span class="stamnt">i</span>10 0 10 <span class="csdtag"></CsScore></span> <span class="csdtag"></CsoundSynthesizer></span> </pre> </div> </div> <br class="example-break" /> </div> <div class="refsect1" title="See Also"> <a id="idp26091160"></a> <h2>See Also</h2> <p> <a class="link" href="hrtfmove.html" title="hrtfmove"><em class="citetitle">hrtfmove</em></a>, <a class="link" href="hrtfstat.html" title="hrtfstat"><em class="citetitle">hrtfstat</em></a>, <a class="link" href="hrtfer.html" title="hrtfer"><em class="citetitle">hrtfer</em></a>. </p> <p> More information on this opcode: <a class="ulink" href="http://www.csounds.com/journal/issue9/newHRTFOpcodes.html" target="_top"><em class="citetitle">http://www.csounds.com/journal/issue9/newHRTFOpcodes.html</em></a> , written by Brian Carty </p> </div> <div class="refsect1" title="Credits"> <a id="idp26093920"></a> <h2>Credits</h2> <p> </p> <table border="0" summary="Simple list" class="simplelist"> <tr> <td>Author: Brian Carty</td> </tr> <tr> <td>Maynooth</td> </tr> <tr> <td>2008</td> </tr> </table> <p> </p> </div> </div> <div class="navfooter"> <hr /> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"><a accesskey="p" href="hrtfmove.html">Prev</a> </td> <td width="20%" align="center"> <a accesskey="u" href="OpcodesTop.html">Up</a> </td> <td width="40%" align="right"> <a accesskey="n" href="hrtfreverb.html">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top">hrtfmove </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> <td width="40%" align="right" valign="top"> hrtfreverb</td> </tr> </table> </div> </body> </html>