hrtfmove2 — Generates dynamic 3d binaural audio for headphones using a Woodworth based spherical head model with improved low frequency phase accuracy.
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.
ifilel -- left HRTF spectral data file
ifiler -- right HRTF spectral data file
Note | |
---|---|
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 sr should match datafile sr. Files should be in the current directory or the SADIR (see Environment Variables). |
Note | |
---|---|
HRTF Data files for use with hrtfmove, hrtfmove2, hrtfstat, hrtfearly, hrtfreverb were updated for Csound 5.15 and later (the code was updated and is more efficient). Old datafiles are now deprecated. |
ioverlap -- optional, number of overlaps for STFT processing (default 4). See STFT section of manual.
iradius -- optional, head radius used for phase spectra calculation in centimeters (default 9.0)
isr - optional, default 44.1kHz, legal values: 44100, 48000 and 96000.
asrc -- Input/source signal.
kAz -- azimuth value in degrees. Positive values represent position on the right, negative values are positions on the left.
kElev -- elevation value in degrees. Positive values represent position above horizontal, negative values are positions below horizontal (min -40).
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 hrtfmove using phase truncation, but phase is constantly updated by hrtfmove2.
Here is an example of the hrtfmove2 opcode. It uses the file hrtfmove2.csd.
Example 442. Example of the htrfmove2 opcode.
<CsoundSynthesizer> <CsOptions> ; Select flags here ; realtime audio out -o dac ; For Non-realtime ouput leave only the line below: ; -o hrtf.wav </CsOptions> <CsInstruments> sr = 44100 kr = 4410 ksmps = 10 nchnls = 2 gasrc init 0 instr 1 ;a plucked string kamp = p4 kcps = cpspch(p5) icps = cpspch(p5) a1 pluck kamp, kcps, icps, 0, 1 gasrc = a1 endin instr 10 ;uses output from instr1 as source kaz linseg 0, p3, 720 ;2 full rotations aleft,aright hrtfmove2 gasrc, kaz,0, "hrtf-44100-left.dat","hrtf-44100-right.dat" outs aleft, aright endin </CsInstruments> <CsScore> ; Play Instrument 1: a simple arpeggio i1 0 .2 15000 8.00 i1 + .2 15000 8.04 i1 + .2 15000 8.07 i1 + .2 15000 8.11 i1 + .2 15000 9.02 i1 + 1.5 15000 8.11 i1 + 1.5 15000 8.07 i1 + 1.5 15000 8.04 i1 + 1.5 15000 8.00 i1 + 1.5 15000 7.09 i1 + 1.5 15000 8.00 ; Play Instrument 10 for 10 seconds. i10 0 10 </CsScore> </CsoundSynthesizer>
More information on this opcode: http://www.csoundjournal.com/issue9/newHRTFOpcodes.html , written by Brian Carty