Csound Csound-dev Csound-tekno Search About

[Csnd] 3D audio using headphones

Date1999-11-10 10:51
FromVarga István
Subject[Csnd] 3D audio using headphones
Some headphone 3d audio stuff using HRTF responses (well,
there is "hrtfer", but this seems to be better :)

To compile the test orc, you need the include files from
http://www.geocities.com/SiliconValley/Bit/5683/Effects.Incl
ude-1.0.3.zip
and the convolve files from
http://www.geocities.com/SiliconValley/Bit/5683/HRTF_files-
1.0.zip


-------- test.orc --------

sr      =  44100
kr      =  1378.125
ksmps   =  32
nchnls  =  2

#include "Effects.Header.orc"
#include "Delays.include.orc"
#include "Plain_Stereo.include.orc"
#include "Spatial_Stereo.include.orc"
#include "HRTF_Stereo.include.orc"

/* macro for i-rate parameters */

#define STATICMACRO # $HRTFStereo #

/* spat. macro for k-rate parameters */

#define DYNMACRO # $HRTFStereoDynHQ #

/* mono output file */

#define OUTFLNAME # "foobar.pcm" #

$InitHQDelay

        seed 0

gabar   init 0

#define OSCILLATOR #

/* generate some test signal */

afoo    phasor 201
abar    phasor 200
afoo    =  afoo-abar
afoo_   tone afoo, 800
afoo    =  afoo-afoo_

ablah   phasor 25
ablah   =  2*ablah-1
abaz    phasor 100*(1+ablah*0.25)
abaz    =  2*abaz-1
abaz    =  abaz + afoo

aenv    linseg 1, p3-0.1, 1, 0.025, 0, 1, 0

a0      =  abaz*16000*aenv

#

/* i-rate */

        instr 2

i_az_   =  p4   /* azimuth */
i_el_   =  p5   /* elevation */
i_d_    =  p6   /* distance */

$OSCILLATOR

a_      =  a0   /* input signal */

gabar   =  gabar + a_

$STATICMACRO

        outs a_L_, a_R_

        endin

/* k-rate */

        instr 3

i_az_   =  0    /* init. value for azimuth */
i_el_   =  -40  /* init. value for elevation */
i_d_    =  2    /* init. value for distance */

k_az_   init i_az_
k_el_   init i_el_
k_d_    init i_d_

k_az_   line 0, 10, 1440        /* azimuth */
k_el_   line -40, 10, 20        /* elevation */
k_d_    linseg 3, 5, 1.5, 5, 3  /* distance */

$OSCILLATOR

a_      =  a0   /* input signal */

gabar   =  gabar + a_

$DYNMACRO

        outs a_L_, a_R_

        endin

/* output instrument */

        instr 90

        soundout gabar, $OUTFLNAME, 6
gabar   =  0

        endin

-------- test.sco --------

t 0 60

/* p4 = azimuth, p5 = elevation, p6 = distance */

i 2 0 0.5 -60 -40 2
i 2 0.75 0.5 -90 40 2
i 2 1.5 0.5 120 0 2.0
i 2 2.25 0.5 120 0 1.5
i 2 3.0 0.5 120 0 1.0
i 2 3.75 0.5 0 0 1

/* dynamic (k-rate) spatialization */

i 3 5 10

/* output instr. */

i 90 0 16

e

--------------------------------



--