hrtfer

hrtfer — Creates 3D audio for two speakers.

Description

Output is binaural (headphone) 3D audio.

Syntax

aleft, aright hrtfer asig, kaz, kelev, “HRTFcompact

Initialization

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 above horizontal.

At present, the only file which can be used with hrtfer is HRTFcompact. It must be passed to the opcode as the last argument within quotes as shown above.

HRTFcompact may also be obtained via anonymous ftp from: ftp://ftp.cs.bath.ac.uk/pub/dream/utilities/Analysis/HRTFcompact

Performance

These unit generators place a mono input signal in a virtual 3D space around the listener by convolving the input with the appropriate HRTF data specified by the opcode's azimuth and elevation values. hrtfer allows these values to be k-values, allowing for dynamic spatialization. hrtfer can only place the input at the requested position because the HRTF is loaded in at i-time (remember that currently, CSound has a limit of 20 files it can hold in memory, otherwise it causes a segmentation fault). The output will need to be scaled either by using balance or by multiplying the output by some scaling constant.

[Note] Note

The sampling rate of the orchestra must be 44.1kHz. This is because 44.1kHz is the sampling rate at which the HRTFs were measured. In order to be used at a different rate, the HRTFs would need to be re-sampled at the desired rate.

Examples

Here is an example of the hrtfer opcode. It uses the file hrtfer.csd, HRTFcompact, and beats.wav.

Example 192. Example of the hrtfer opcode.

See the sections Real-time Audio and Command Line Flags for more information on using command line flags.

<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
; Audio out   Audio in    No messages
-odac           -iadc     -d     ;;;RT audio I/O
; For Non-realtime ouput leave only the line below:
; -o hrtfer.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

; Initialize the global variables.
sr = 44100
kr = 4410
ksmps = 10
nchnls = 2

instr 1
  kaz          linseg 0, p3, -360  ; move the sound in circle
  kel          linseg -40, p3, 45  ; around the listener, changing
                                    ; elevation as its turning
  asrc         soundin "beats.wav"
  aleft,aright hrtfer asrc, kaz, kel, "HRTFcompact"
  aleftscale   = aleft * 200
  arightscale  = aright * 200

  outs         aleftscale, arightscale
endin        


</CsInstruments>
<CsScore>

i 1 0 2
e


</CsScore>
</CsoundSynthesizer>


See Also

hrtfmove, hrtfmove2, hrtfstat.

Credits

Authors: Eli Breder and David MacIntyre
Montreal
1996

Fixed the example thanks to a message from Istvan Varga.