; THIS IS AN FMH-AMBISONIC DECODER FOR 3RD ORDER ONLY
; *******************************************************************************************************************************
; Version 2.0 , Nov 2010 coded 2010 by Jan Jacob Hofmann
; jjh@sonicarchitecture.de +++ http://www.sonicarchitecture.de
; Comments and suggestions welcome.
; For non-comercial, artistic, scientific and educational use only - all rights reserved
; *******************************************************************************************************************************
; Please send comments and bug reports to jjh@sonicarchitecture.de on http://www.sonicarchitecture.de you will also find a small Ambisonic-tutorial.
; More info:
; To find out more about Ambisonics, see
; http://www.ambisonic.net/
; http://www.york.ac.uk/inst/mustech/3dkpeak_audio/ambison.htm (University of York)
; http://www.york.ac.uk/inst/mustech/3dkpeak_audio/ambison.htm (Richard Furse's pages)
; Credits:
; Thanks to Richard Furse and Dave Malham for the wonderful 2nd order equations.
; Last not least thanks to all csounders who made this
; possible by their contribution of work and thoughts!!!
; This .csd is displayed best with tab set to 56 pt or 8 spaces.
sr = 44100
kr = 441
ksmps = 100
nchnls = 8 ; number of output channels for real-time listning
;LAYOUT OF SPEAKERS
gidecchnls = 8.1 ; specifies the speaker setup:
; 2 = stereo speaker setup
; 8.1 = octogon1
; SOUNDFILE READ-IN SETTINGS
#define INFILE #NameOfInputSoundfile-# ; insert filename for input here (Example: "Name-" if the filename is "Name-w.aif").
; The original soundfile should carry the definition of the encoded track in small letter
; at the end of the name of the file. For example "Name-w", "Name-x", "Name-y", "Name-z"...etc..
; "Name-" is entered for the name of the sondfile only though, as all other extensions
; for soundfile in- and output are created automatically.
#define HEADER_INFILE #aif# ; insert filetype for input file here (Example: "aif" if the filename is "Test-w.aif")
; SOUNDFILE OUTPUT SETTINGS
#define FILE #Filename-# ; insert filename for name of output file here (note that the extension is just for the
; generation of the filename, the header of the file is specified below.
#define HEADER #aif# ; insert filetype for output file name here
giformat = 8 ; 1 = 16 bit integers without header (binary PCM multichannel file) for "fout"
; 2 = 16-bit integers with a header.
; The header type depends on the render format.
; The default header type is the IRCAM format.
; If the user chooses the AIFF format (using the -A flag),
; the header format will be a AIFF type. If the user chooses the WAV
; format (using the -W flag), the header format will be a WAV type.
; 8 = 24 bit integer with header like specified in options
; SCALING FACTOR
; According to different layouts of speakers, appropropiate adjustment of output-gain is necessary. Run the decode first as a test-decode with gain set to 1.0. Then look for
; the peak of the loudest output file in the output text and calculate the apropriate factor of gain dividing 32768 by the peak value of that file.
girescale = 1 ; for test decoding
; girescale = ; for 2chnl decoding
; girescale = ; for 2chnl decoding
; girescale = ; for 5 chnl encoding
; girescale = ; for 5.1 chnl encoding
; girescale = ; for 8chnl cube decoding
; girescale = ; for octogon1 decoding
; **************************************************************************************************************************
instr 1 ; INVOCATION
; **************************************************************************************************************************
iskip = p4
idur filelen "$INFILE.w.$HEADER_INFILE." ; checking length of the soundfile to trigger the decoding
event_i "i", 83, 0, idur, iskip ; triggering decode
endin
; **************************************************************************************************************************
instr 83 ; 2nd ORDER AMBISONICS DECODER coded 1999-2010 by Jan Jacob Hofmann.
; FURSE - MALHAM - SET OF EQUATIONS Version 2.0 - Nov. 2010
; More sets of speaker- layouts may be discovered at http://www.sonicarchitecture.de
; http://www.muse.demon.co.uk/ref/speakers.html Thanks to Richard Furse and Dave Malham
; **************************************************************************************************************************
iskip = p4
aw soundin "$INFILE.w.$HEADER_INFILE.", iskip ; input for encoded mono- files
ax soundin "$INFILE.x.$HEADER_INFILE.", iskip ; input for encoded mono- files
ay soundin "$INFILE.y.$HEADER_INFILE.", iskip ; input for encoded mono- files
az soundin "$INFILE.z.$HEADER_INFILE.", iskip ; input for encoded mono- files
ar soundin "$INFILE.r.$HEADER_INFILE.", iskip ; input for encoded mono- files
as soundin "$INFILE.s.$HEADER_INFILE.", iskip ; input for encoded mono- files
at soundin "$INFILE.t.$HEADER_INFILE.", iskip ; input for encoded mono- files
au soundin "$INFILE.u.$HEADER_INFILE.", iskip ; input for encoded mono- files
av soundin "$INFILE.v.$HEADER_INFILE.", iskip ; input for encoded mono- files
ak soundin "$INFILE.k.$HEADER_INFILE.", iskip ; input for encoded mono- files
al soundin "$INFILE.l.$HEADER_INFILE.", iskip ; input for encoded mono- files
am soundin "$INFILE.m.$HEADER_INFILE.", iskip ; input for encoded mono- files
an soundin "$INFILE.n.$HEADER_INFILE.", iskip ; input for encoded mono- files
ao soundin "$INFILE.o.$HEADER_INFILE.", iskip ; input for encoded mono- files
ap soundin "$INFILE.p.$HEADER_INFILE.", iskip ; input for encoded mono- files
aq soundin "$INFILE.q.$HEADER_INFILE.", iskip ; input for encoded mono- files
aw = aw * girescale
ax = ax * girescale
ay = ay * girescale
az = az * girescale
ar = ar * girescale
as = as * girescale
at = at * girescale
au = au * girescale
av = av * girescale
ak = ak * girescale
al = al * girescale
am = am * girescale
an = an * girescale
ao = ao * girescale
ap = ap * girescale
aq = aq * girescale
if nchnls == 2 goto stereo ; goto 2chnl decode
if gidecchnls == 8.1 goto octagon1 ; goto 8chnl decode (octogon 1)
; **************************************************************************************
stereo: ; 2chnl (stereo ) decode,2nd order (second order controlled opposites)
; **************************************************************************************
;Rig `Controlled Opposites' Decode Matrix (second Order)
; w x y z r s t u v
; Speaker1 <0.0000,1.0000,0.0000>
achnl_1 sum aw * 0.7071, ay * 0.5
; Speaker2 <0.0000,-1.0000,0.0000>
achnl_2 sum aw * 0.7071, ay * -0.5
kpeak1 peak achnl_1
kpeak2 peak achnl_2
printk p3, kpeak1,0
printk p3, kpeak2,4
fout "$FILE.stereo.$HEADER.", giformat, achnl_1, achnl_2
outc achnl_1, achnl_2
if gidecchnls == 2 goto skipend ; goto 2chnl decode
; **************************************************************************************
octagon1: ; 8chnl decode (octagon 1),2nd order (second order controlled opposites)
; **************************************************************************************
; w x y z r s t u v
; Speaker 1 <0.9239,0.3827,0.0000>
; Speaker 2 <0.3827,0.9239,0.0000>
; Speaker 3 <-0.3827,0.9239,0.0000>
; Speaker 4 <-0.9239,0.3827,0.0000>
; Speaker 5 <-0.9239,-0.3827,0.0000>
; Speaker 6 <-0.3827,-0.9239,0.0000>
; Speaker 7 <0.3827,-0.9239,0.0000>
; Speaker 8 <0.9239,-0.3827,0.0000>
achnl_1, achnl_2, achnl_3, achnl_4, achnl_5, achnl_6, achnl_7, achnl_8 bformdec1 4, aw, ax, ay, az, ar, as, at, au, av, ak, al, am, an, ao, ap, aq
kpeak1 peak achnl_1
kpeak2 peak achnl_2
kpeak3 peak achnl_3
kpeak4 peak achnl_4
kpeak5 peak achnl_5
kpeak6 peak achnl_6
kpeak7 peak achnl_7
kpeak8 peak achnl_8
printk p3, kpeak1, 0
printk p3, kpeak2, 3
printk p3, kpeak3, 6
printk p3, kpeak4, 9
printk p3, kpeak5, 12
printk p3, kpeak6, 15
printk p3, kpeak7, 18
printk p3, kpeak8, 21
fout "$FILE.oct1dec_1.$HEADER.", giformat, achnl_1
fout "$FILE.oct1dec_2.$HEADER.", giformat, achnl_2
fout "$FILE.oct1dec_3.$HEADER.", giformat, achnl_3
fout "$FILE.oct1dec_4.$HEADER.", giformat, achnl_4
fout "$FILE.oct1dec_5.$HEADER.", giformat, achnl_5
fout "$FILE.oct1dec_6.$HEADER.", giformat, achnl_6
fout "$FILE.oct1dec_7.$HEADER.", giformat, achnl_7
fout "$FILE.oct1dec_8.$HEADER.", giformat, achnl_8
if nchnls == 2 goto skipend ; do 2chnl steteo real-time output
outc achnl_1, achnl_2, achnl_3, achnl_4, achnl_5, achnl_6, achnl_7, achnl_8
skipend:
endin
i1 0 1 0 /*invocation for instr 83 3rd ORDER AMBISONIC DECODING UNIT */
e
72179400200true2552552551010400500{2dc9787c-15c2-4abc-a285-5e0b7fc2430a}true0-3
Courier
8000255255255
Version: 3
Render: Real
Ask: Yes
Functions: ioObject
Listing: Window
WindowBounds: 72 179 400 200
CurrentView: io
IOViewEdit: On
Options:
ioView nobackground {65535, 65535, 65535}
ioListing {10, 10} {400, 500}