hrtfstat — Generates static 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. It produces a static output (azimuth and elevation parameters are i-rate), because a static source allows much more efficient processing than hrtfmove and hrtfmove2,.
iAz -- azimuth value in degrees. Positive values represent position on the right, negative values are positions on the left.
iElev -- elevation value in degrees. Positive values represent position above horizontal, negative values are positions below horizontal (min -40).
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). |
iradius -- optional, head radius used for phase spectra calculation in centimeters (default 9.0)
isr - optional (default 44.1kHz). Legal values are 44100, 48000 and 96000.
Artifact-free user-defined static spatialisation is made possible using an interpolation algorithm based on spectral magnitude interpolation and a derived phase 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 static source version of the opcode uses overlap add convolution (it does not need STFT processing, see hrtfmove2), and is thus considerably more efficient than hrtfmove2 or hrtfmove, but cannot generate moving sources.
It can be found in the file htrfstat.csd.
Example 195. Example of the htrfstat 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 aleft,aright hrtfstat gasrc, 90,0, "hrtf-44100-left.dat","hrtf-44100-right.dat" outs aleft, aright endin </CsInstruments> <CsScore> ; Play Instrument 1: a plucked string i1 0 2 20000 8.00 ; Play Instrument 10 for 2 seconds. i10 0 2 </CsScore> </CsoundSynthesizer>