Csound Csound-dev Csound-tekno Search About

[Csnd] global ambisonic decode

Date2014-05-28 22:22
FromDavid Worrall
Subject[Csnd] global ambisonic decode
Hi all,

I have multiple sound instruments writing into ambisonic format (1st order) using the bformenc1 opcode. For example:

aw, ax, ay, az, ar, as, at, au, av bformenc1 asig, kloc, kbeta ; generate Bfmat

and decoding to a quad array:
a1, a2, a3, a4 bformdec1 2, aw, ax, ay, az ; decode Bfmat to 4chan speaker array
outo a1, a2, a3, a4 ; audio out

Given that multiple individual (w, x, y, z) channels of ambisonically-encoded signals can be
summed, does it makes sense to run a single global decode instrument, running much like a global reverb? It has to be more efficient than doing the decode in each instrument.

Perhaps the logic of this is flawed - or obvious - but I did a bit of a search but couldn’t find a demo illustration of this; Nor, anyone reporting on the effect of such an approach.


Before I cut and paste my code, does anyone have config. they’ve tried, or can report (dangers of etc) of - or even some example code they’d be willing to share?

thanks,

David


_____________________________________
Prof. Dr. David Worrall
Emerging Audio Research (EAR)
Audio Department
International Audio Laboratories Erlangen
Fraunhofer-Institut für Integrierte Schaltungen IIS
Am Wolfsmantel 33
91058 Erlangen
Telefon  +49 (0) 91 31 / 7 76-62 44
Fax      +49 (0) 91 31 / 7 76-20 99
E-Mail: david.worrall@iis.fraunhofer.de
Internet: www.iis.fraunhofer.de 
---
Adjunct Senior Research Fellow
School of Music, Australian National University


Date2014-05-28 23:03
FromMichael Gogins
SubjectRe: [Csnd] global ambisonic decode
Yes. You can also encode to, and decode from, a-rate array variables and send and receive these using the outletv and inletv signal flow graph opcodes. I am working on a spatialization system that works this way, it is almost ready to share.

Regards,
Mike


-----------------------------------------------------
Michael Gogins
Irreducible Productions
http://michaelgogins.tumblr.com
Michael dot Gogins at gmail dot com


On Wed, May 28, 2014 at 5:22 PM, David Worrall <david.worrall@iis.fraunhofer.de> wrote:
Hi all,

I have multiple sound instruments writing into ambisonic format (1st order) using the bformenc1 opcode. For example:

aw, ax, ay, az, ar, as, at, au, av bformenc1 asig, kloc, kbeta ; generate Bfmat

and decoding to a quad array:
a1, a2, a3, a4 bformdec1 2, aw, ax, ay, az ; decode Bfmat to 4chan speaker array
outo a1, a2, a3, a4 ; audio out

Given that multiple individual (w, x, y, z) channels of ambisonically-encoded signals can be
summed, does it makes sense to run a single global decode instrument, running much like a global reverb? It has to be more efficient than doing the decode in each instrument.

Perhaps the logic of this is flawed - or obvious - but I did a bit of a search but couldn’t find a demo illustration of this; Nor, anyone reporting on the effect of such an approach.


Before I cut and paste my code, does anyone have config. they’ve tried, or can report (dangers of etc) of - or even some example code they’d be willing to share?

thanks,

David


_____________________________________
Prof. Dr. David Worrall
Emerging Audio Research (EAR)
Audio Department
International Audio Laboratories Erlangen
Fraunhofer-Institut für Integrierte Schaltungen IIS
Am Wolfsmantel 33
91058 Erlangen
Telefon  +49 (0) 91 31 / 7 76-62 44
Fax      +49 (0) 91 31 / 7 76-20 99
E-Mail: david.worrall@iis.fraunhofer.de
Internet: www.iis.fraunhofer.de 
---
Adjunct Senior Research Fellow
School of Music, Australian National University



Date2014-05-29 08:16
FromDavid Worrall
SubjectRe: [Csnd] global ambisonic decode
Wow - thanks for replying, Mike.
I couldn't find any reference to these opcodes in the manuals, but I see they are included w. 6.03.2
Are they like outleta / inleta?
If I can help bu testing a uniplanar (2D) version, I'd be happy to - I have an installation opening in a week and I'm on the hunt for CPU cycles!

Speaking of which - your alwayson opcode ….  it presummably holds the instrument in memory
Are there any (CPU) savings to  had by applying this to all insruments, given enough memory?
and 
Given I want this system to run continuously for weeks on end, does alwayson do away with the need for an f 0 z as well?

So many questions, sorry!

David



On 29.05.2014, at 00:03, Michael Gogins <michael.gogins@gmail.com> wrote:

Yes. You can also encode to, and decode from, a-rate array variables and send and receive these using the outletv and inletv signal flow graph opcodes. I am working on a spatialization system that works this way, it is almost ready to share.

Regards,
Mike


-----------------------------------------------------
Michael Gogins
Irreducible Productions
http://michaelgogins.tumblr.com
Michael dot Gogins at gmail dot com


On Wed, May 28, 2014 at 5:22 PM, David Worrall <david.worrall@iis.fraunhofer.de> wrote:
Hi all,

I have multiple sound instruments writing into ambisonic format (1st order) using the bformenc1 opcode. For example:

aw, ax, ay, az, ar, as, at, au, av bformenc1 asig, kloc, kbeta ; generate Bfmat

and decoding to a quad array:
a1, a2, a3, a4 bformdec1 2, aw, ax, ay, az ; decode Bfmat to 4chan speaker array
outo a1, a2, a3, a4 ; audio out

Given that multiple individual (w, x, y, z) channels of ambisonically-encoded signals can be
summed, does it makes sense to run a single global decode instrument, running much like a global reverb? It has to be more efficient than doing the decode in each instrument.

Perhaps the logic of this is flawed - or obvious - but I did a bit of a search but couldn’t find a demo illustration of this; Nor, anyone reporting on the effect of such an approach.


Before I cut and paste my code, does anyone have config. they’ve tried, or can report (dangers of etc) of - or even some example code they’d be willing to share?

thanks,

David


_____________________________________
Prof. Dr. David Worrall
Emerging Audio Research (EAR)
Audio Department
International Audio Laboratories Erlangen
Fraunhofer-Institut für Integrierte Schaltungen IIS
Am Wolfsmantel 33
91058 Erlangen
Telefon  +49 (0) 91 31 / 7 76-62 44
Fax      +49 (0) 91 31 / 7 76-20 99
E-Mail: david.worrall@iis.fraunhofer.de
Internet: www.iis.fraunhofer.de 
---
Adjunct Senior Research Fellow
School of Music, Australian National University



______________________________________
Prof. Dr. David Worrall
Emerging Audio Research (EAR)
Audio Department
International Audio Laboratories Erlangen
Fraunhofer-Institut für Integrierte Schaltungen IIS
Am Wolfsmantel 33
91058 Erlangen
Telefon  +49 (0) 91 31 / 7 76-62 44
Fax      +49 (0) 91 31 / 7 76-20 99
E-Mail: david.worrall@iis.fraunhofer.de
Internet: www.iis.fraunhofer.de 
---
Adjunct Senior Research Fellow
School of Music, Australian National University





Date2014-05-29 11:56
Fromjoachim heintz
SubjectRe: [Csnd] global ambisonic decode
hi david -

i think collecting the signals and then decoding all together is 
certainly a good idea. below is a simple example.

best -

	joachim






sr = 44100
nchnls = 4
0dbfs = 1
ksmps=32

/*declare channels (not required but clearer)*/
chn_a "W", 3
chn_a "X", 3
chn_a "Y", 3
chn_a "Z", 3

/*instruments for encoding*/
instr Ambi_Enc_A
aSig poscil .2, 400
aW, aX, aY, aZ bformenc1 aSig, 90, 0
chnmix aW, "W"
chnmix aX, "X"
chnmix aY, "Y"
chnmix aZ, "Z"
endin

instr Ambi_Enc_B
aSig poscil .2, 600
aW, aX, aY, aZ bformenc1 aSig, -90, 0
chnmix aW, "W"
chnmix aX, "X"
chnmix aY, "Y"
chnmix aZ, "Z"
endin

/*instrument for decoding and output*/
instr Ambi_Dec
aW chnget "W"
aX chnget "X"
aY chnget "Y"
aZ chnget "Z"
a1, a2, a3, a4 bformdec1 2, aW, aX, aY, aZ
outch 1, a1, 2, a2, 3, a3, 4, a4
endin

/*clear channels*/
instr Clear
chnclear "W"
chnclear "X"
chnclear "Y"
chnclear "Z"
endin



i "Ambi_Enc_A" 0 10
i "Ambi_Enc_B" 0 10
i "Ambi_Dec" 0 10
i "Clear" 0 10



Date2014-05-29 12:20
FromMichael Gogins
SubjectRe: [Csnd] global ambisonic decode
alwayson is not for instruments that play notes. It would not save you anything in that use case.

These are just some snippets from my system.

instr Moogy

iattack = 0.003

isustain = p3

irelease = 0.01

iduration = isustain + iattack + isustain

p3 = iduration + 2

ihz = cpsmidinn(p4)

iamplitude = ampdb(p5)

; Use ftgenonce instead of ftgen, ftgentmp, or f statement.

isine ftgenonce 0, 0, 65536, 10, 1

asignal vco iamplitude, ihz, 1, 0.5, isine

kfco line 200, iduration, 2000

krez init 0.9

asignal moogvcf asignal, kfco, krez, 100000

adamping linsegr 0, iattack, 1, isustain, 1, irelease, 0

asignal = asignal * adamping

aglobalreverbsend init 0

aspatializedsignal[] init 16

kline linseg 10, p3, -10

aspatializedsignal, aglobalreverbsend Spatialize asignal, kline, 5, -kline

outleta "out", aglobalreverbsend

outletv "outbformat", aspatializedsignal

endin


"Spatialize" is a UDO.


opcode Spatialize, a[]a, akkk

asignal, kx, ky, kz xin

kazimuth, kelevation, kdistance CartesianToPolarDegrees kx, ky, kz

adoppleredSignal DopplerByDistance asignal, kdistance

afilteredSignal LowpassByDistance adoppleredSignal, kdistance

abspatializedSignal[] init 16

; Use only minimal distance cues for plain stereo.

if gk_BformatDecoder_SpeakerRig == 0 then

abspatializedSignal bformenc1 afilteredSignal, kazimuth, kelevation

xout abspatializedSignal, afilteredSignal

elseif gk_BformatDecoder_SpeakerRig == 1 then

adistanceCuedSignal, aglobalReverbSend LocalReverbByDistance afilteredSignal, kdistance

abspatializedSignal bformenc1 adistanceCuedSignal, kazimuth, kelevation

xout abspatializedSignal, aglobalReverbSend

else

adistanceCuedSignal, aglobalReverbSend LocalReverbByDistance afilteredSignal, kdistance

abspatializedSignal bformenc1 adistanceCuedSignal, kazimuth, kelevation

abdiffuseEarlyReflectionsSignal[] init 16

abdiffuseEarlyReflectionsSignal DiffuseEarlyReflections adistanceCuedSignal, kx, ky, kz

abspatializedSignal[ 0] = abspatializedSignal[ 0] + abdiffuseEarlyReflectionsSignal[ 0]

abspatializedSignal[ 1] = abspatializedSignal[ 1] + abdiffuseEarlyReflectionsSignal[ 1]

abspatializedSignal[ 2] = abspatializedSignal[ 2] + abdiffuseEarlyReflectionsSignal[ 2]

abspatializedSignal[ 3] = abspatializedSignal[ 3] + abdiffuseEarlyReflectionsSignal[ 3]

abspatializedSignal[ 4] = abspatializedSignal[ 4] + abdiffuseEarlyReflectionsSignal[ 4]

abspatializedSignal[ 5] = abspatializedSignal[ 5] + abdiffuseEarlyReflectionsSignal[ 5]

abspatializedSignal[ 6] = abspatializedSignal[ 6] + abdiffuseEarlyReflectionsSignal[ 6]

abspatializedSignal[ 7] = abspatializedSignal[ 7] + abdiffuseEarlyReflectionsSignal[ 7]

abspatializedSignal[ 8] = abspatializedSignal[ 8] + abdiffuseEarlyReflectionsSignal[ 8]

abspatializedSignal[ 9] = abspatializedSignal[ 9] + abdiffuseEarlyReflectionsSignal[ 9]

abspatializedSignal[10] = abspatializedSignal[10] + abdiffuseEarlyReflectionsSignal[10]

abspatializedSignal[11] = abspatializedSignal[11] + abdiffuseEarlyReflectionsSignal[11]

abspatializedSignal[12] = abspatializedSignal[12] + abdiffuseEarlyReflectionsSignal[12]

abspatializedSignal[13] = abspatializedSignal[13] + abdiffuseEarlyReflectionsSignal[13]

abspatializedSignal[14] = abspatializedSignal[14] + abdiffuseEarlyReflectionsSignal[14]

abspatializedSignal[15] = abspatializedSignal[15] + abdiffuseEarlyReflectionsSignal[15]

abspecularEarlyReflectionsSignal[] init 16

abspecularEarlyReflectionsSignal SpecularEarlyReflections afilteredSignal, kx, ky, kz

abspatializedSignal[ 0] = abspatializedSignal[ 0] + abspecularEarlyReflectionsSignal[ 0]

abspatializedSignal[ 1] = abspatializedSignal[ 1] + abspecularEarlyReflectionsSignal[ 1]

abspatializedSignal[ 2] = abspatializedSignal[ 2] + abspecularEarlyReflectionsSignal[ 2]

abspatializedSignal[ 3] = abspatializedSignal[ 3] + abspecularEarlyReflectionsSignal[ 3]

abspatializedSignal[ 4] = abspatializedSignal[ 4] + abspecularEarlyReflectionsSignal[ 4]

abspatializedSignal[ 5] = abspatializedSignal[ 5] + abspecularEarlyReflectionsSignal[ 5]

abspatializedSignal[ 6] = abspatializedSignal[ 6] + abspecularEarlyReflectionsSignal[ 6]

abspatializedSignal[ 7] = abspatializedSignal[ 7] + abspecularEarlyReflectionsSignal[ 7]

abspatializedSignal[ 8] = abspatializedSignal[ 8] + abspecularEarlyReflectionsSignal[ 8]

abspatializedSignal[ 9] = abspatializedSignal[ 9] + abspecularEarlyReflectionsSignal[ 9]

abspatializedSignal[10] = abspatializedSignal[10] + abspecularEarlyReflectionsSignal[10]

abspatializedSignal[11] = abspatializedSignal[11] + abspecularEarlyReflectionsSignal[11]

abspatializedSignal[12] = abspatializedSignal[12] + abspecularEarlyReflectionsSignal[12]

abspatializedSignal[13] = abspatializedSignal[13] + abspecularEarlyReflectionsSignal[13]

abspatializedSignal[14] = abspatializedSignal[14] + abspecularEarlyReflectionsSignal[14]

abspatializedSignal[15] = abspatializedSignal[15] + abspecularEarlyReflectionsSignal[15]

xout abspatializedSignal, aglobalReverbSend

endif

endop


THis is the decoder that receives all the spatial B-format signals, decodes them, and outputs them:


instr BformatDecoder

irig init i(gk_BformatDecoder_SpeakerRig)

asignal[] init nchnls

prints "%5.2f BformatDecoder irig: %d channels: %d\n", p1, irig, lenarray(asignal)

absignal[] init 16

absignal[] inletv "inbformat"

if irig == 0 then

asignal bformdec1 1, absignal

elseif irig == 1 then

asignal Bformat2DecodeBinaural, absignal, sr

else

asignal bformdec1 irig, absignal

endif

out asignal

endin


In the orchestra header things are connected like this:


; Connect up the instruments to create a signal flow graph.


connect "SimpleSine", "out", "SpatialReverb", "in"

connect "SimpleSine", "outbformat", "BformatDecoder", "inbformat"

connect "Moogy", "out", "SpatialReverb", "in"

connect "Moogy", "outbformat", "BformatDecoder", "inbformat"

connect "Harpsichord", "out", "SpatialReverb", "in"

connect "Harpsichord", "outbformat", "BformatDecoder", "inbformat"

connect "SpatialReverb", "outbformat", "BformatDecoder", "inbformat"


; Turn on the global units in the signal flow graph.


alwayson "SpatialReverb"

alwayson "BformatDecoder"





-----------------------------------------------------
Michael Gogins
Irreducible Productions
http://michaelgogins.tumblr.com
Michael dot Gogins at gmail dot com


On Wed, May 28, 2014 at 6:03 PM, Michael Gogins <michael.gogins@gmail.com> wrote:
Yes. You can also encode to, and decode from, a-rate array variables and send and receive these using the outletv and inletv signal flow graph opcodes. I am working on a spatialization system that works this way, it is almost ready to share.

Regards,
Mike


-----------------------------------------------------
Michael Gogins
Irreducible Productions
http://michaelgogins.tumblr.com
Michael dot Gogins at gmail dot com


On Wed, May 28, 2014 at 5:22 PM, David Worrall <david.worrall@iis.fraunhofer.de> wrote:
Hi all,

I have multiple sound instruments writing into ambisonic format (1st order) using the bformenc1 opcode. For example:

aw, ax, ay, az, ar, as, at, au, av bformenc1 asig, kloc, kbeta ; generate Bfmat

and decoding to a quad array:
a1, a2, a3, a4 bformdec1 2, aw, ax, ay, az ; decode Bfmat to 4chan speaker array
outo a1, a2, a3, a4 ; audio out

Given that multiple individual (w, x, y, z) channels of ambisonically-encoded signals can be
summed, does it makes sense to run a single global decode instrument, running much like a global reverb? It has to be more efficient than doing the decode in each instrument.

Perhaps the logic of this is flawed - or obvious - but I did a bit of a search but couldn’t find a demo illustration of this; Nor, anyone reporting on the effect of such an approach.


Before I cut and paste my code, does anyone have config. they’ve tried, or can report (dangers of etc) of - or even some example code they’d be willing to share?

thanks,

David


_____________________________________
Prof. Dr. David Worrall
Emerging Audio Research (EAR)
Audio Department
International Audio Laboratories Erlangen
Fraunhofer-Institut für Integrierte Schaltungen IIS
Am Wolfsmantel 33
91058 Erlangen
Telefon  +49 (0) 91 31 / 7 76-62 44
Fax      +49 (0) 91 31 / 7 76-20 99
E-Mail: david.worrall@iis.fraunhofer.de
Internet: www.iis.fraunhofer.de 
---
Adjunct Senior Research Fellow
School of Music, Australian National University




Date2014-05-29 12:22
FromMichael Gogins
SubjectRe: [Csnd] global ambisonic decode
I should add that my system is based on Joachim's system and borrows a lot of his code.

Also, for array variables, you must use outletv and inletv, not outleta and inleta.

Regards,
Mike


-----------------------------------------------------
Michael Gogins
Irreducible Productions
http://michaelgogins.tumblr.com
Michael dot Gogins at gmail dot com


On Thu, May 29, 2014 at 7:20 AM, Michael Gogins <michael.gogins@gmail.com> wrote:
alwayson is not for instruments that play notes. It would not save you anything in that use case.

These are just some snippets from my system.

instr Moogy

iattack = 0.003

isustain = p3

irelease = 0.01

iduration = isustain + iattack + isustain

p3 = iduration + 2

ihz = cpsmidinn(p4)

iamplitude = ampdb(p5)

; Use ftgenonce instead of ftgen, ftgentmp, or f statement.

isine ftgenonce 0, 0, 65536, 10, 1

asignal vco iamplitude, ihz, 1, 0.5, isine

kfco line 200, iduration, 2000

krez init 0.9

asignal moogvcf asignal, kfco, krez, 100000

adamping linsegr 0, iattack, 1, isustain, 1, irelease, 0

asignal = asignal * adamping

aglobalreverbsend init 0

aspatializedsignal[] init 16

kline linseg 10, p3, -10

aspatializedsignal, aglobalreverbsend Spatialize asignal, kline, 5, -kline

outleta "out", aglobalreverbsend

outletv "outbformat", aspatializedsignal

endin


"Spatialize" is a UDO.


opcode Spatialize, a[]a, akkk

asignal, kx, ky, kz xin

kazimuth, kelevation, kdistance CartesianToPolarDegrees kx, ky, kz

adoppleredSignal DopplerByDistance asignal, kdistance

afilteredSignal LowpassByDistance adoppleredSignal, kdistance

abspatializedSignal[] init 16

; Use only minimal distance cues for plain stereo.

if gk_BformatDecoder_SpeakerRig == 0 then

abspatializedSignal bformenc1 afilteredSignal, kazimuth, kelevation

xout abspatializedSignal, afilteredSignal

elseif gk_BformatDecoder_SpeakerRig == 1 then

adistanceCuedSignal, aglobalReverbSend LocalReverbByDistance afilteredSignal, kdistance

abspatializedSignal bformenc1 adistanceCuedSignal, kazimuth, kelevation

xout abspatializedSignal, aglobalReverbSend

else

adistanceCuedSignal, aglobalReverbSend LocalReverbByDistance afilteredSignal, kdistance

abspatializedSignal bformenc1 adistanceCuedSignal, kazimuth, kelevation

abdiffuseEarlyReflectionsSignal[] init 16

abdiffuseEarlyReflectionsSignal DiffuseEarlyReflections adistanceCuedSignal, kx, ky, kz

abspatializedSignal[ 0] = abspatializedSignal[ 0] + abdiffuseEarlyReflectionsSignal[ 0]

abspatializedSignal[ 1] = abspatializedSignal[ 1] + abdiffuseEarlyReflectionsSignal[ 1]

abspatializedSignal[ 2] = abspatializedSignal[ 2] + abdiffuseEarlyReflectionsSignal[ 2]

abspatializedSignal[ 3] = abspatializedSignal[ 3] + abdiffuseEarlyReflectionsSignal[ 3]

abspatializedSignal[ 4] = abspatializedSignal[ 4] + abdiffuseEarlyReflectionsSignal[ 4]

abspatializedSignal[ 5] = abspatializedSignal[ 5] + abdiffuseEarlyReflectionsSignal[ 5]

abspatializedSignal[ 6] = abspatializedSignal[ 6] + abdiffuseEarlyReflectionsSignal[ 6]

abspatializedSignal[ 7] = abspatializedSignal[ 7] + abdiffuseEarlyReflectionsSignal[ 7]

abspatializedSignal[ 8] = abspatializedSignal[ 8] + abdiffuseEarlyReflectionsSignal[ 8]

abspatializedSignal[ 9] = abspatializedSignal[ 9] + abdiffuseEarlyReflectionsSignal[ 9]

abspatializedSignal[10] = abspatializedSignal[10] + abdiffuseEarlyReflectionsSignal[10]

abspatializedSignal[11] = abspatializedSignal[11] + abdiffuseEarlyReflectionsSignal[11]

abspatializedSignal[12] = abspatializedSignal[12] + abdiffuseEarlyReflectionsSignal[12]

abspatializedSignal[13] = abspatializedSignal[13] + abdiffuseEarlyReflectionsSignal[13]

abspatializedSignal[14] = abspatializedSignal[14] + abdiffuseEarlyReflectionsSignal[14]

abspatializedSignal[15] = abspatializedSignal[15] + abdiffuseEarlyReflectionsSignal[15]

abspecularEarlyReflectionsSignal[] init 16

abspecularEarlyReflectionsSignal SpecularEarlyReflections afilteredSignal, kx, ky, kz

abspatializedSignal[ 0] = abspatializedSignal[ 0] + abspecularEarlyReflectionsSignal[ 0]

abspatializedSignal[ 1] = abspatializedSignal[ 1] + abspecularEarlyReflectionsSignal[ 1]

abspatializedSignal[ 2] = abspatializedSignal[ 2] + abspecularEarlyReflectionsSignal[ 2]

abspatializedSignal[ 3] = abspatializedSignal[ 3] + abspecularEarlyReflectionsSignal[ 3]

abspatializedSignal[ 4] = abspatializedSignal[ 4] + abspecularEarlyReflectionsSignal[ 4]

abspatializedSignal[ 5] = abspatializedSignal[ 5] + abspecularEarlyReflectionsSignal[ 5]

abspatializedSignal[ 6] = abspatializedSignal[ 6] + abspecularEarlyReflectionsSignal[ 6]

abspatializedSignal[ 7] = abspatializedSignal[ 7] + abspecularEarlyReflectionsSignal[ 7]

abspatializedSignal[ 8] = abspatializedSignal[ 8] + abspecularEarlyReflectionsSignal[ 8]

abspatializedSignal[ 9] = abspatializedSignal[ 9] + abspecularEarlyReflectionsSignal[ 9]

abspatializedSignal[10] = abspatializedSignal[10] + abspecularEarlyReflectionsSignal[10]

abspatializedSignal[11] = abspatializedSignal[11] + abspecularEarlyReflectionsSignal[11]

abspatializedSignal[12] = abspatializedSignal[12] + abspecularEarlyReflectionsSignal[12]

abspatializedSignal[13] = abspatializedSignal[13] + abspecularEarlyReflectionsSignal[13]

abspatializedSignal[14] = abspatializedSignal[14] + abspecularEarlyReflectionsSignal[14]

abspatializedSignal[15] = abspatializedSignal[15] + abspecularEarlyReflectionsSignal[15]

xout abspatializedSignal, aglobalReverbSend

endif

endop


THis is the decoder that receives all the spatial B-format signals, decodes them, and outputs them:


instr BformatDecoder

irig init i(gk_BformatDecoder_SpeakerRig)

asignal[] init nchnls

prints "%5.2f BformatDecoder irig: %d channels: %d\n", p1, irig, lenarray(asignal)

absignal[] init 16

absignal[] inletv "inbformat"

if irig == 0 then

asignal bformdec1 1, absignal

elseif irig == 1 then

asignal Bformat2DecodeBinaural, absignal, sr

else

asignal bformdec1 irig, absignal

endif

out asignal

endin


In the orchestra header things are connected like this:


; Connect up the instruments to create a signal flow graph.


connect "SimpleSine", "out", "SpatialReverb", "in"

connect "SimpleSine", "outbformat", "BformatDecoder", "inbformat"

connect "Moogy", "out", "SpatialReverb", "in"

connect "Moogy", "outbformat", "BformatDecoder", "inbformat"

connect "Harpsichord", "out", "SpatialReverb", "in"

connect "Harpsichord", "outbformat", "BformatDecoder", "inbformat"

connect "SpatialReverb", "outbformat", "BformatDecoder", "inbformat"


; Turn on the global units in the signal flow graph.


alwayson "SpatialReverb"

alwayson "BformatDecoder"





-----------------------------------------------------
Michael Gogins
Irreducible Productions
http://michaelgogins.tumblr.com
Michael dot Gogins at gmail dot com


On Wed, May 28, 2014 at 6:03 PM, Michael Gogins <michael.gogins@gmail.com> wrote:
Yes. You can also encode to, and decode from, a-rate array variables and send and receive these using the outletv and inletv signal flow graph opcodes. I am working on a spatialization system that works this way, it is almost ready to share.

Regards,
Mike


-----------------------------------------------------
Michael Gogins
Irreducible Productions
http://michaelgogins.tumblr.com
Michael dot Gogins at gmail dot com


On Wed, May 28, 2014 at 5:22 PM, David Worrall <david.worrall@iis.fraunhofer.de> wrote:
Hi all,

I have multiple sound instruments writing into ambisonic format (1st order) using the bformenc1 opcode. For example:

aw, ax, ay, az, ar, as, at, au, av bformenc1 asig, kloc, kbeta ; generate Bfmat

and decoding to a quad array:
a1, a2, a3, a4 bformdec1 2, aw, ax, ay, az ; decode Bfmat to 4chan speaker array
outo a1, a2, a3, a4 ; audio out

Given that multiple individual (w, x, y, z) channels of ambisonically-encoded signals can be
summed, does it makes sense to run a single global decode instrument, running much like a global reverb? It has to be more efficient than doing the decode in each instrument.

Perhaps the logic of this is flawed - or obvious - but I did a bit of a search but couldn’t find a demo illustration of this; Nor, anyone reporting on the effect of such an approach.


Before I cut and paste my code, does anyone have config. they’ve tried, or can report (dangers of etc) of - or even some example code they’d be willing to share?

thanks,

David


_____________________________________
Prof. Dr. David Worrall
Emerging Audio Research (EAR)
Audio Department
International Audio Laboratories Erlangen
Fraunhofer-Institut für Integrierte Schaltungen IIS
Am Wolfsmantel 33
91058 Erlangen
Telefon  +49 (0) 91 31 / 7 76-62 44
Fax      +49 (0) 91 31 / 7 76-20 99
E-Mail: david.worrall@iis.fraunhofer.de
Internet: www.iis.fraunhofer.de 
---
Adjunct Senior Research Fellow
School of Music, Australian National University





Date2014-05-29 15:53
FromDavid Worrall
SubjectRe: [Csnd] global ambisonic decode
Golly,  thanks Mike, thanks Joachim.
I'll need some time to study these is there anything like a manual entry for outletv and inletv or are the fields the same as for outleta/inleta?
or do I need to go to the code…?
(I didn't really follow the discussions on vector processing on the list over the last year or so)

D.

On 29.05.2014, at 13:22, Michael Gogins <michael.gogins@gmail.com> wrote:

I should add that my system is based on Joachim's system and borrows a lot of his code.

Also, for array variables, you must use outletv and inletv, not outleta and inleta.

Regards,
Mike


-----------------------------------------------------
Michael Gogins
Irreducible Productions
http://michaelgogins.tumblr.com
Michael dot Gogins at gmail dot com


On Thu, May 29, 2014 at 7:20 AM, Michael Gogins <michael.gogins@gmail.com> wrote:
alwayson is not for instruments that play notes. It would not save you anything in that use case.

These are just some snippets from my system.

instr Moogy
iattack = 0.003
isustain = p3
irelease = 0.01
iduration = isustain + iattack + isustain
p3 = iduration + 2
ihz = cpsmidinn(p4)
iamplitude = ampdb(p5)
; Use ftgenonce instead of ftgen, ftgentmp, or f statement.
isine ftgenonce 0, 0, 65536, 10, 1
asignal vco iamplitude, ihz, 1, 0.5, isine
kfco line 200, iduration, 2000
krez init 0.9
asignal moogvcf asignal, kfco, krez, 100000
adamping linsegr 0, iattack, 1, isustain, 1, irelease, 0
asignal = asignal * adamping
aglobalreverbsend init 0
aspatializedsignal[] init 16
kline linseg 10, p3, -10
aspatializedsignal, aglobalreverbsend Spatialize asignal, kline, 5, -kline
outleta "out", aglobalreverbsend
outletv "outbformat", aspatializedsignal
endin

"Spatialize" is a UDO.

opcode Spatialize, a[]a, akkk
asignal, kx, ky, kz xin
kazimuth, kelevation, kdistance CartesianToPolarDegrees kx, ky, kz
adoppleredSignal DopplerByDistance asignal, kdistance
afilteredSignal LowpassByDistance adoppleredSignal, kdistance
abspatializedSignal[] init 16
; Use only minimal distance cues for plain stereo.
if gk_BformatDecoder_SpeakerRig == 0 then
abspatializedSignal bformenc1 afilteredSignal, kazimuth, kelevation
xout abspatializedSignal, afilteredSignal
elseif gk_BformatDecoder_SpeakerRig == 1 then
adistanceCuedSignal, aglobalReverbSend LocalReverbByDistance afilteredSignal, kdistance
abspatializedSignal bformenc1 adistanceCuedSignal, kazimuth, kelevation
xout abspatializedSignal, aglobalReverbSend
else
adistanceCuedSignal, aglobalReverbSend LocalReverbByDistance afilteredSignal, kdistance
abspatializedSignal bformenc1 adistanceCuedSignal, kazimuth, kelevation
abdiffuseEarlyReflectionsSignal[] init 16
abdiffuseEarlyReflectionsSignal DiffuseEarlyReflections adistanceCuedSignal, kx, ky, kz
abspatializedSignal[ 0] = abspatializedSignal[ 0] + abdiffuseEarlyReflectionsSignal[ 0]
abspatializedSignal[ 1] = abspatializedSignal[ 1] + abdiffuseEarlyReflectionsSignal[ 1]
abspatializedSignal[ 2] = abspatializedSignal[ 2] + abdiffuseEarlyReflectionsSignal[ 2]
abspatializedSignal[ 3] = abspatializedSignal[ 3] + abdiffuseEarlyReflectionsSignal[ 3]
abspatializedSignal[ 4] = abspatializedSignal[ 4] + abdiffuseEarlyReflectionsSignal[ 4]
abspatializedSignal[ 5] = abspatializedSignal[ 5] + abdiffuseEarlyReflectionsSignal[ 5]
abspatializedSignal[ 6] = abspatializedSignal[ 6] + abdiffuseEarlyReflectionsSignal[ 6]
abspatializedSignal[ 7] = abspatializedSignal[ 7] + abdiffuseEarlyReflectionsSignal[ 7]
abspatializedSignal[ 8] = abspatializedSignal[ 8] + abdiffuseEarlyReflectionsSignal[ 8]
abspatializedSignal[ 9] = abspatializedSignal[ 9] + abdiffuseEarlyReflectionsSignal[ 9]
abspatializedSignal[10] = abspatializedSignal[10] + abdiffuseEarlyReflectionsSignal[10]
abspatializedSignal[11] = abspatializedSignal[11] + abdiffuseEarlyReflectionsSignal[11]
abspatializedSignal[12] = abspatializedSignal[12] + abdiffuseEarlyReflectionsSignal[12]
abspatializedSignal[13] = abspatializedSignal[13] + abdiffuseEarlyReflectionsSignal[13]
abspatializedSignal[14] = abspatializedSignal[14] + abdiffuseEarlyReflectionsSignal[14]
abspatializedSignal[15] = abspatializedSignal[15] + abdiffuseEarlyReflectionsSignal[15]
abspecularEarlyReflectionsSignal[] init 16
abspecularEarlyReflectionsSignal SpecularEarlyReflections afilteredSignal, kx, ky, kz
abspatializedSignal[ 0] = abspatializedSignal[ 0] + abspecularEarlyReflectionsSignal[ 0]
abspatializedSignal[ 1] = abspatializedSignal[ 1] + abspecularEarlyReflectionsSignal[ 1]
abspatializedSignal[ 2] = abspatializedSignal[ 2] + abspecularEarlyReflectionsSignal[ 2]
abspatializedSignal[ 3] = abspatializedSignal[ 3] + abspecularEarlyReflectionsSignal[ 3]
abspatializedSignal[ 4] = abspatializedSignal[ 4] + abspecularEarlyReflectionsSignal[ 4]
abspatializedSignal[ 5] = abspatializedSignal[ 5] + abspecularEarlyReflectionsSignal[ 5]
abspatializedSignal[ 6] = abspatializedSignal[ 6] + abspecularEarlyReflectionsSignal[ 6]
abspatializedSignal[ 7] = abspatializedSignal[ 7] + abspecularEarlyReflectionsSignal[ 7]
abspatializedSignal[ 8] = abspatializedSignal[ 8] + abspecularEarlyReflectionsSignal[ 8]
abspatializedSignal[ 9] = abspatializedSignal[ 9] + abspecularEarlyReflectionsSignal[ 9]
abspatializedSignal[10] = abspatializedSignal[10] + abspecularEarlyReflectionsSignal[10]
abspatializedSignal[11] = abspatializedSignal[11] + abspecularEarlyReflectionsSignal[11]
abspatializedSignal[12] = abspatializedSignal[12] + abspecularEarlyReflectionsSignal[12]
abspatializedSignal[13] = abspatializedSignal[13] + abspecularEarlyReflectionsSignal[13]
abspatializedSignal[14] = abspatializedSignal[14] + abspecularEarlyReflectionsSignal[14]
abspatializedSignal[15] = abspatializedSignal[15] + abspecularEarlyReflectionsSignal[15]
xout abspatializedSignal, aglobalReverbSend
endif
endop


THis is the decoder that receives all the spatial B-format signals, decodes them, and outputs them:

instr BformatDecoder
irig init i(gk_BformatDecoder_SpeakerRig)
asignal[] init nchnls
prints "%5.2f BformatDecoder irig: %d channels: %d\n", p1, irig, lenarray(asignal)
absignal[] init 16
absignal[] inletv "inbformat"
if irig == 0 then
asignal bformdec1 1, absignal
elseif irig == 1 then
asignal Bformat2DecodeBinaural, absignal, sr
else
asignal bformdec1 irig, absignal
endif
out asignal
endin


In the orchestra header things are connected like this:

; Connect up the instruments to create a signal flow graph.

connect "SimpleSine", "out", "SpatialReverb", "in"
connect "SimpleSine", "outbformat", "BformatDecoder", "inbformat"
connect "Moogy", "out", "SpatialReverb", "in"
connect "Moogy", "outbformat", "BformatDecoder", "inbformat"
connect "Harpsichord", "out", "SpatialReverb", "in"
connect "Harpsichord", "outbformat", "BformatDecoder", "inbformat"
connect "SpatialReverb", "outbformat", "BformatDecoder", "inbformat"

; Turn on the global units in the signal flow graph.

alwayson "SpatialReverb"
alwayson "BformatDecoder"





-----------------------------------------------------
Michael Gogins
Irreducible Productions
http://michaelgogins.tumblr.com
Michael dot Gogins at gmail dot com


On Wed, May 28, 2014 at 6:03 PM, Michael Gogins <michael.gogins@gmail.com> wrote:
Yes. You can also encode to, and decode from, a-rate array variables and send and receive these using the outletv and inletv signal flow graph opcodes. I am working on a spatialization system that works this way, it is almost ready to share.

Regards,
Mike


-----------------------------------------------------
Michael Gogins
Irreducible Productions
http://michaelgogins.tumblr.com
Michael dot Gogins at gmail dot com


On Wed, May 28, 2014 at 5:22 PM, David Worrall <david.worrall@iis.fraunhofer.de> wrote:
Hi all,

I have multiple sound instruments writing into ambisonic format (1st order) using the bformenc1 opcode. For example:

aw, ax, ay, az, ar, as, at, au, av bformenc1 asig, kloc, kbeta ; generate Bfmat

and decoding to a quad array:
a1, a2, a3, a4 bformdec1 2, aw, ax, ay, az ; decode Bfmat to 4chan speaker array
outo a1, a2, a3, a4 ; audio out

Given that multiple individual (w, x, y, z) channels of ambisonically-encoded signals can be
summed, does it makes sense to run a single global decode instrument, running much like a global reverb? It has to be more efficient than doing the decode in each instrument.

Perhaps the logic of this is flawed - or obvious - but I did a bit of a search but couldn’t find a demo illustration of this; Nor, anyone reporting on the effect of such an approach.


Before I cut and paste my code, does anyone have config. they’ve tried, or can report (dangers of etc) of - or even some example code they’d be willing to share?

thanks,

David


_____________________________________
Prof. Dr. David Worrall
Emerging Audio Research (EAR)
Audio Department
International Audio Laboratories Erlangen
Fraunhofer-Institut für Integrierte Schaltungen IIS
Am Wolfsmantel 33
91058 Erlangen
Telefon  +49 (0) 91 31 / 7 76-62 44
Fax      +49 (0) 91 31 / 7 76-20 99
E-Mail: david.worrall@iis.fraunhofer.de
Internet: www.iis.fraunhofer.de 
---
Adjunct Senior Research Fellow
School of Music, Australian National University



Date2014-05-30 19:30
FromDavid Worrall
SubjectRe: [Csnd] global ambisonic decode
HI Joachim,
I get no sound from this example - and I wonder
a) if you mean to run 
i "Clear" 0 10
at the same time as the other instruments
and if you do, 

b) when does it execute in relation to the others - last?

Thanks,
David

On 29.05.2014, at 12:56, joachim heintz <jh@joachimheintz.de> wrote:

hi david -

i think collecting the signals and then decoding all together is certainly a good idea. below is a simple example.

best -

joachim


<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>
sr = 44100
nchnls = 4
0dbfs = 1
ksmps=32

/*declare channels (not required but clearer)*/
chn_a "W", 3
chn_a "X", 3
chn_a "Y", 3
chn_a "Z", 3

/*instruments for encoding*/
instr Ambi_Enc_A
aSig poscil .2, 400
aW, aX, aY, aZ bformenc1 aSig, 90, 0
chnmix aW, "W"
chnmix aX, "X"
chnmix aY, "Y"
chnmix aZ, "Z"
endin

instr Ambi_Enc_B
aSig poscil .2, 600
aW, aX, aY, aZ bformenc1 aSig, -90, 0
chnmix aW, "W"
chnmix aX, "X"
chnmix aY, "Y"
chnmix aZ, "Z"
endin

/*instrument for decoding and output*/
instr Ambi_Dec
aW chnget "W"
aX chnget "X"
aY chnget "Y"
aZ chnget "Z"
a1, a2, a3, a4 bformdec1 2, aW, aX, aY, aZ
outch 1, a1, 2, a2, 3, a3, 4, a4
endin

/*clear channels*/
instr Clear
chnclear "W"
chnclear "X"
chnclear "Y"
chnclear "Z"
endin

</CsInstruments>
<CsScore>
i "Ambi_Enc_A" 0 10
i "Ambi_Enc_B" 0 10
i "Ambi_Dec" 0 10
i "Clear" 0 10
</CsScore>
</CsoundSynthesizer>


Send bugs reports to
      https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"


______________________________________
Prof. Dr. David Worrall
Emerging Audio Research (EAR)
Audio Department
International Audio Laboratories Erlangen
Fraunhofer-Institut für Integrierte Schaltungen IIS
Am Wolfsmantel 33
91058 Erlangen
Telefon  +49 (0) 91 31 / 7 76-62 44
Fax      +49 (0) 91 31 / 7 76-20 99
E-Mail: david.worrall@iis.fraunhofer.de
Internet: www.iis.fraunhofer.de 
---
Adjunct Senior Research Fellow
School of Music, Australian National University





Date2014-05-30 19:43
FromDavid Worrall
SubjectRe: [Csnd] global ambisonic decode
Cancel my first question - not awake yet - sorry!
But I don't understand the clearing the channel in the way you use it. -or the manual entry, for that matter.
D



On 30.05.2014, at 20:30, David Worrall <david.worrall@iis.fraunhofer.de> wrote:

HI Joachim,
I get no sound from this example - and I wonder
a) if you mean to run 
i "Clear" 0 10
at the same time as the other instruments
and if you do, 

b) when does it execute in relation to the others - last?

Thanks,
David

On 29.05.2014, at 12:56, joachim heintz <jh@joachimheintz.de> wrote:

hi david -

i think collecting the signals and then decoding all together is certainly a good idea. below is a simple example.

best -

joachim


<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>
sr = 44100
nchnls = 4
0dbfs = 1
ksmps=32

/*declare channels (not required but clearer)*/
chn_a "W", 3
chn_a "X", 3
chn_a "Y", 3
chn_a "Z", 3

/*instruments for encoding*/
instr Ambi_Enc_A
aSig poscil .2, 400
aW, aX, aY, aZ bformenc1 aSig, 90, 0
chnmix aW, "W"
chnmix aX, "X"
chnmix aY, "Y"
chnmix aZ, "Z"
endin

instr Ambi_Enc_B
aSig poscil .2, 600
aW, aX, aY, aZ bformenc1 aSig, -90, 0
chnmix aW, "W"
chnmix aX, "X"
chnmix aY, "Y"
chnmix aZ, "Z"
endin

/*instrument for decoding and output*/
instr Ambi_Dec
aW chnget "W"
aX chnget "X"
aY chnget "Y"
aZ chnget "Z"
a1, a2, a3, a4 bformdec1 2, aW, aX, aY, aZ
outch 1, a1, 2, a2, 3, a3, 4, a4
endin

/*clear channels*/
instr Clear
chnclear "W"
chnclear "X"
chnclear "Y"
chnclear "Z"
endin

</CsInstruments>
<CsScore>
i "Ambi_Enc_A" 0 10
i "Ambi_Enc_B" 0 10
i "Ambi_Dec" 0 10
i "Clear" 0 10
</CsScore>
</CsoundSynthesizer>


Send bugs reports to
      https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"


______________________________________
Prof. Dr. David Worrall
Emerging Audio Research (EAR)
Audio Department
International Audio Laboratories Erlangen
Fraunhofer-Institut für Integrierte Schaltungen IIS
Am Wolfsmantel 33
91058 Erlangen
Telefon  +49 (0) 91 31 / 7 76-62 44
Fax      +49 (0) 91 31 / 7 76-20 99
E-Mail: david.worrall@iis.fraunhofer.de
Internet: www.iis.fraunhofer.de 
---
Adjunct Senior Research Fellow
School of Music, Australian National University





Date2014-05-31 13:14
Fromjoachim heintz
SubjectRe: [Csnd] global ambisonic decode
hi david -

because the code uses chnmix, we have to clear the content either at the 
beginning, or at the end of a k-cycle. so i did the latter.

hope it works, all best -

	joachim


Am 30.05.2014 20:43, schrieb David Worrall:
> Cancel my first question - not awake yet - sorry!
> But I don't understand the clearing the channel in the way you use it.
> -or the manual entry, for that matter.
> D
>
>
>
> On 30.05.2014, at 20:30, David Worrall  > wrote:
>
>> HI Joachim,
>> I get no sound from this example - and I wonder
>> a) if you mean to run
>>> i "Clear" 0 10
>> at the same time as the other instruments
>> and if you do,
>>
>> b) when does it execute in relation to the others - last?
>>
>> Thanks,
>> David
>>
>> On 29.05.2014, at 12:56, joachim heintz > > wrote:
>>
>>> hi david -
>>>
>>> i think collecting the signals and then decoding all together is
>>> certainly a good idea. below is a simple example.
>>>
>>> best -
>>>
>>> joachim
>>>
>>>
>>> 
>>> 
>>> 
>>> 
>>> sr = 44100
>>> nchnls = 4
>>> 0dbfs = 1
>>> ksmps=32
>>>
>>> /*declare channels (not required but clearer)*/
>>> chn_a "W", 3
>>> chn_a "X", 3
>>> chn_a "Y", 3
>>> chn_a "Z", 3
>>>
>>> /*instruments for encoding*/
>>> instr Ambi_Enc_A
>>> aSig poscil .2, 400
>>> aW, aX, aY, aZ bformenc1 aSig, 90, 0
>>> chnmix aW, "W"
>>> chnmix aX, "X"
>>> chnmix aY, "Y"
>>> chnmix aZ, "Z"
>>> endin
>>>
>>> instr Ambi_Enc_B
>>> aSig poscil .2, 600
>>> aW, aX, aY, aZ bformenc1 aSig, -90, 0
>>> chnmix aW, "W"
>>> chnmix aX, "X"
>>> chnmix aY, "Y"
>>> chnmix aZ, "Z"
>>> endin
>>>
>>> /*instrument for decoding and output*/
>>> instr Ambi_Dec
>>> aW chnget "W"
>>> aX chnget "X"
>>> aY chnget "Y"
>>> aZ chnget "Z"
>>> a1, a2, a3, a4 bformdec1 2, aW, aX, aY, aZ
>>> outch 1, a1, 2, a2, 3, a3, 4, a4
>>> endin
>>>
>>> /*clear channels*/
>>> instr Clear
>>> chnclear "W"
>>> chnclear "X"
>>> chnclear "Y"
>>> chnclear "Z"
>>> endin
>>>
>>> 
>>> 
>>> i "Ambi_Enc_A" 0 10
>>> i "Ambi_Enc_B" 0 10
>>> i "Ambi_Dec" 0 10
>>> i "Clear" 0 10
>>> 
>>> 
>>>
>>>
>>> Send bugs reports to
>>> https://github.com/csound/csound/issues
>>> Discussions of bugs and features can be posted here
>>> To unsubscribe, send email sympa@lists.bath.ac.uk
>>>  with body "unsubscribe csound"
>>>
>>
>> ______________________________________
>> Prof. Dr. David Worrall
>> Emerging Audio Research (EAR)
>> Audio Department
>> International Audio Laboratories Erlangen
>> Fraunhofer-Institut für Integrierte Schaltungen IIS
>> Am Wolfsmantel 33
>> 91058 Erlangen
>> Telefon  +49 (0) 91 31 / 7 76-62 44
>> Fax      +49 (0) 91 31 / 7 76-20 99
>> E-Mail: david.worrall@iis.fraunhofer.de
>> 
>> Internet: www.iis.fraunhofer.de 
>> ---
>> Adjunct Senior Research Fellow
>> School of Music, Australian National University
>> david.worrall@anu.edu.au 
>>
>
>
>