hrtfmove
Prev | Orchestra Opcodes and Operators | Next

## hrtfmove

hrtfmove — Generates dynamic 3d binaural audio for headphones using magnitude interpolation and phase truncation.

## Description

This opcode takes a source signal and spatialises it in the 3 dimensional space around a listener by convolving the source with stored head related transfer function (HRTF) based filters.

## Syntax

    aleft, aright hrtfmove asrc, kAz, kElev, ifilel, ifiler [, imode, ifade, isr]

## Initialization

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.

imode -- optional, default 0 for phase truncation, 1 for minimum phase

ifade -- optional, number of processing buffers for phase change crossfade (default 8). Legal range is 1-24. A low value is recommended for complex sources (4 or less: a higher value may make the crossfade audible), a higher value (8 or more: a lower value may make the inconsistency when the filter changes phase values audible) for narrowband sources. Does not effect minimum phase processing.

| Note
Ocassionally fades may overlap (when unnaturally fast/complex trajectories are requested). In this case, a warning will be printed. Use a smaller crossfade or slightly change trajectory to avoid any possible inconsistencies that may arise.

isr - optional, default 44.1kHz, legal values: 44100, 48000 and 96000.

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 phase truncation. Crossfades are implemented to minimise/eliminate any inconsistencies caused by updating phase values. These crossfades are performed over a user definable number of convolution processing buffers. Complex sources may only need to crossfade over 1 buffer; narrow band sources may need several. The opcode also offers minimum phase based processing, a more traditional and complex method. In this mode, the hrtf filters used are reduced to minimum phase representations and the interpolation process then uses the relationship between minimum phase magnitude and phase spectra. Interaural time difference, which is inherent to the phase truncation process, is reintroduced in the minimum phase process using variable delay lines.

## Examples

Here is an example of the hrtfmove opcode. It uses the file hrtfmove.csd.

Example 415. Example of the htrfmove 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 hrtfmove 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>

## See Also

hrtfmove2, hrtfstat, hrtfer.

More information on this opcode: http://www.csoundjournal.com/issue9/newHRTFOpcodes.html , written by Brian Carty

## Credits

Author: Brian Carty
Maynooth
2008

Prev | Up | Next
hrtfearly | Home | hrtfmove2