[Csnd] Third order ambisonics rotation

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[Csnd] Third order ambisonics rotation

Ruben Sverre Gjertsen-2
Hello,

I have a question for the ambisonics experts on this list. I’m loooking for the algorithm for 3D rotation of third order ambisonics, roll, pitch, yaw(rotation). Blue ripple has an a solution up to second order:
The next step would be adding third order. 

For rotation/yaw (y to x): I found the solution in a text by Dave Malham (Higher order Ambisonic systems, 2003), where it is noted that the other 2 directions are complicated and have not been solved yet. I would assume lots of things have been happening since 2003, but I haven’t found sources describing roll and pitch in third order directly.
For pitch (z to x), I have guessed channel 9-11 would be a mirror of 6-8, as 4-5 is a mirror of 2-3, while 12-15 should be something even more complex. I’m stuck on those last 4 channels. It’s a guess, I could of course be wrong.
For roll  (y to z), I’m not able to see the continuation for 9-15 at all.

I include a part of my incomplete  csound instrument, applying the rotations to the audio signals.
Do you have some hints on where I could find the missing calculations?

It would of course be great to have an opcode for 3D rotation, but solving it this way would be a good start.

Best
Ruben Gjertsen


;------------------------------------------------
kroll=kazimuth   ;0-360!
kpitch=kelevation
kyaw=kdistance
;------------------------------------------------
;ROLL (y to z)

     ;0 order
awroll=a2ambW*1

    ;1st order (ACN order)
ayroll=(a2ambY*(cos(kroll)))-(a2ambZ*(sin(kroll)))
azroll=(a2ambY*(sin(kroll)))+(a2ambZ*(cos(kroll)))
axroll=a2ambZ*1

    ;2nd order (FuMa names in ACN order)
avroll=(a2ambV*(cos(kroll))) - (a2ambS *(sin(kroll)))       ;v or ACN 4
atroll=(a2ambT*(cos(2*kroll)))  -(a2ambR*((sqrt(3/4)*(sin(2*kroll)))))  - (a2ambU*((1/2)*sin(2*kroll)))   ;t or ACN 5
arroll=(a2ambT*(sqrt(3/4)*sin(2*kroll)))  +(a2ambR*((1/4)*(1+(3*(cos(2*kroll))))))  -(a2ambU*((sqrt(3/16))*(1-(cos(2*kroll)))))         ;r or ACN 6
asroll=(a2ambV*(sin(kroll)))  +(a2ambS*(cos(kroll)))         ;s or ACN 7
auroll=(a2ambT*((1/2)*sin(2*kroll)))   -(a2ambR*((sqrt(3/16))* (1 -(cos(2*kroll)))))  +(a2ambU*((1/4)*(3+(cos(2*kroll)))))  ;u or ACN 8   
 
       ;3rd order? ACN order
       ;unknown algorithm!
;aqroll= ?
;aoroll= ?
;amroll= ?
;akroll= ?
;alroll= ?
;anroll= ?
;aproll= ?    

;     0=w  1=y        2=z       3=x  4=v       5=t                 6=r                        7=s          8=u                       9=q        10=o       11=m       12=k      13=l     14=n       15=p
;0=w ;1    0
;1=y ;0    cos(roll) -sin(roll) 0
;2=z ;0    sin(roll) cos(roll)  0 
;3=x ;0    0          0         1
;4=v ;0    0          0         0    cos(roll) 0                   0                           -sin(roll)  0
;5=t ;0    0          0         0    0         cos(2roll)          -sqrt(3/4)sin(2roll)        0           -1/2 sin(2roll) 
;6=r ;0    0          0         0    0         sqrt(3/4)sin(2roll)  1/4(1+3cos(2roll))         0           -sqrt(3/16)(1- cos(2roll))
;7=s ;0    0          0         0    sin(roll) 0                   0                           cos(roll)    0
;8=u ;0    0          0         0    0         1/2 sin(2roll)      -sqrt(3/16)(1- cos(2roll))  0            1/4 (3+cos(2roll))
;9=q  ;0   0          0         0    0         0                   0                           0            0                           IQ-test!! 
;10=o ;0   0          0         0    0         0                   0                           0            0                           ? 
;11=m ;0   0          0         0    0         0                   0                           0            0                           ?  
;12=k ;0   0          0         0    0         0                   0                           0            0                           ?
;13=l ;0   0          0         0    0         0                   0                           0            0                           ?
;14=n ;0   0          0         0    0         0                   0                           0            0                           ?
;15=p ;0   0          0         0    0         0                   0                           0            0                           ?

  
;-----------------------------------------------       
;;PITCH (z to x)
     ;0 order
awpitch=awroll*1

     ;1st order
aypitch=ayroll*1
azpitch=  (azroll*(cos(kpitch)))   +(axroll*(sin(kpitch)))
axpitch=  (azroll*(cos(kpitch)))   -(axroll*(sin(kpitch)))

     ;2nd order (FuMa names in ACN order)
avpitch=  (avroll*(cos(kpitch)))   -(atroll*(sin(kpitch)))     ;v or ACN 4
atpitch= (avroll*(sin(kpitch)))   +(atroll*(cos(kpitch))) ;t or ACN 5
arpitch= (arroll*((1/4)*(1+(3*cos(2*kpitch)))))  +(asroll*((sqrt(3/4))*(sin(2*kpitch))))  +(auroll*((sqrt(3/16))*(1-(cos(2*kpitch)))))  ;r or ACN 6
aspitch= -(arroll*((sqrt(3/4))*sin(2*kpitch))) +(asroll*(cos(2*kpitch)))  +(auroll*((1/2)*sin(2*kpitch)))       ;s or ACN 7
aupitch= (arroll*((sqrt(3/16))*(1-(cos(2*kpitch)))))  -(asroll *((1/2)*sin(2*kpitch)))  +(auroll*((1/4)*(3+cos(2*kpitch))))   ;u or ACN 8 

       ;3rd order   ACN order
;aqpitch= (aqroll*((1/4)*cos(2*kpitch))) -(aoroll*((1/2)*sin(2*kpitch)))  +(amroll* ((sqrt(3/16))*(1-cos(2*kpitch))))  
;aopitch= (aqroll*((1/2)*sin(2*kpitch))) +(aoroll*(cos(2*kpitch)))    -(amroll*((sqrt(3/4))*sin(2*kpitch)))    
;ampitch= (aqroll*((sqrt(3/16))*(1-(cos(2*kpitch))))) +(aoroll*((sqrt(3/4))*sin(2*kpitch)))  +(amroll*((1/4)*(1+(3*(cos(2*kpitch))))))   
    ;4x4 of unknown more complex calculations    
;akpitch= ?
;alpitch= ?
;anpitch= ?

;appitch= ?

;     0=w  1=y        2=z         3=x        4=v          5=t         6=r                        7=s                  8=u                         9=q                         10=o                 11=m                           12=k       13=l          14=n       15=p
;0=w ;1    0          0           0     
;1=y ;0    1          0           0 
;2=z ;0    0          cos(pitch)  sin(pitch)
;3=x ;0    0          -sin(pitch) cos(pitch) 
;4=v ;0    0          0           0          cos(pitch)  -sin(pitch)  0                          0                    0
;5=t ;0    0          0           0          sin(pitch)  cos(pitch)   0                          0                    0
;6=r ;0    0          0           0          0           0            1/4(1+3cos(2pitch))        sqrt(3/4)sin(2pitch) sqrt(3/16)(1- cos(2pitch))
;7=s ;0    0          0           0          0           0            -sqrt(3/4)sin(2pitch)      cos(2pitch)          1/2 sin(2pitch) 
;8=u ;0    0          0           0          0           0            sqrt(3/16)(1- cos(2pitch)) -1/2 sin(2pitch)     1/4 (3+cos(2pitch))          
;9=q  ;0   0          0           0          0           0            0                          0                     0                            1/4 (3+cos(2pitch))        -1/2 sin(2pitch)     sqrt(3/16)(1- cos(2pitch))    0           0           0          0
;10=o ;0   0          0           0          0           0            0                          0                     0                            1/2 sin(2pitch)            cos(2pitch)          -sqrt(3/4)sin(2pitch)         0           0           0          0
;11=m ;0   0          0           0          0           0            0                          0                     0                            sqrt(3/16)(1- cos(2pitch)) sqrt(3/4)sin(2pitch)  1/4(1+3cos(2pitch))          0           0           0          0
;12=k ;0   0          0           0          0           0            0                          0                     0                            0                           0                    0                            ?cos(3pitch)   ?sin(3pitch)  ?cos(3pitch)  ?sin(3pitch)
;13=l ;0   0          0           0          0           0            0                          0                     0                            0                           0                    0                            -?sin(3pitch)   ?cos(3pitch)  ?sin(3pitch)  ?cos(3pitch)
;14=n ;0   0          0           0          0           0            0                          0                     0                            0                           0                    0                            ?cos(3pitch)   -?sin(3pitch)  ?cos(3pitch)  ?sin(3pitch)
;15=p ;0   0          0           0          0           0            0                          0                     0                            0                           0                    0                            ?sin(3pitch)   ?cos(3pitch)  -?sin(3pitch)  ?cos(3pitch) 


;----------------------------------------------- 
;SKIP ROLL(tilt) PITCH(tumble) until it can be solved completely in third order!
awpitch=a2ambW ;TEMPORARY
axpitch=a2ambX ;TEMPORARY
aypitch=a2ambY ;TEMPORARY
azpitch=a2ambZ ;TEMPORARY
arpitch=a2ambR ;TEMPORARY
aspitch=a2ambS ;TEMPORARY
atpitch=a2ambT ;TEMPORARY
aupitch=a2ambU ;TEMPORARY
avpitch=a2ambV ;TEMPORARY
akpitch=a2ambK ;TEMPORARY
alpitch=a2ambL ;TEMPORARY
ampitch=a2ambM ;TEMPORARY
anpitch=a2ambN;TEMPORARY
aopitch=a2ambO ;TEMPORARY
appitch=a2ambP ;TEMPORARY
aqpitch=a2ambQ;TEMPORARY
;-----------------------------------------------       

;YAW (y to x, horisontal)
; USE ONLY YAW (ROTATE!) until high order solutions of roll and pitch have been found!
   ;In a 2D setup, this is the most efficient direction
     ;0 order
awyaw=awpitch*1

      ;1st order 
ayyaw=  (aypitch*(cos(kyaw)))   +(axpitch*(sin(kyaw)))
azyaw=    azpitch*1
axyaw=  -(aypitch*(sin(kyaw)))  +(axpitch*(cos(kyaw)))

      ;2nd order (FuMa names in ACN order)
avyaw=   (avpitch*(cos(2*kyaw)))   +(aupitch*(sin(2*kyaw)))     ;v or ACN 4
atyaw=  (atpitch*(cos(kyaw)))    +(aspitch*(sin(kyaw)))    ;t or ACN 5
aryaw=      arpitch*1      ;r or ACN 6
asyaw=  -(atpitch*(sin(kyaw)))  + (aspitch*(cos(kyaw)))       ;s or ACN 7
auyaw=  -(avpitch*(sin(2*kyaw))) +(aupitch*(cos(2*kyaw)))     ;u or ACN 8 

      ;3rd order ACN order   
aqyaw= (aqpitch*(cos(3*kyaw)))   + (appitch*(sin(3*kyaw)))   
aoyaw= (aopitch*(cos(2*kyaw)))   + (anpitch*(sin(2*kyaw)))   
amyaw= (ampitch*(cos(kyaw)))     + (alpitch*(sin(kyaw)))  
akyaw=       akpitch*1
alyaw=  -(ampitch*(sin(kyaw)))   + (alpitch*(cos(kyaw)))     
anyaw=  -(aopitch*(sin(2*kyaw)))  +(anpitch*(cos(2*kyaw)))   
apyaw=  -(aqpitch*(sin(3*kyaw)))  + (appitch*(cos(3*kyaw)))  
      
;     0=w  1=y      2=z      3=x          4=v          5=t      6=r   7=s      8=u         9=q        10=o       11=m       12=k      13=l     14=n       15=p
;0=w ;1    0          0       0
;1=y ;0    cos(yaw)   0       sin(yaw)
;2=z ;0    0          1       0
;3=x ;0    -sin(yaw)  0       cos(yaw)
;4=v ;0    0          0        0           cos(2yaw)   0         0    0        sin(2yaw)
;5=t ;0    0          0        0           0           cos(yaw)  0    sin(yaw) 0
;6=r ;0    0          0        0           0           0         1    0        0
;7=s ;0    0          0        0           0           -sin(yaw) 0    cos(yaw) 0
;8=u ;0    0          0        0           -sin(2yaw)  0         0    0        cos(2yaw)
;9=q  ;0    0          0        0           0           0         0    0        0           cos(3yaw)  0          0          0         0        0          sin(3yaw) 
;10=o ;0    0          0        0           0           0         0    0        0           0          cos(2yaw)  0          0         0        sin(2yaw)  0  
;11=m ;0    0          0        0           0           0         0    0        0           0          0          cos(yaw)   0         sin(yaw) 0          0
;12=k ;0    0          0        0           0           0         0    0        0           0          0          0          1         0        0          0
;13=l ;0    0          0        0           0           0         0    0        0           0          0          -sin(yaw)  0         cos(yaw) 0          0
;14=n ;0    0          0        0           0           0         0    0        0           0          -sin(2yaw) 0          0         0        cos(2yaw)  0
;15=p ;0    0          0        0           0           0         0    0        0           -sin(3yaw) 0          0          0         0        0          cos(3yaw)

;roll and pitch is more difficult
;Zotter: 90 degree rotation around y-axis, read Zotter!
;     Not much clearer yet.....

;Back to FuMa Order: 
aw=awyaw ;multiplier here?
ax=axyaw
ay=ayyaw
az=azyaw
ar=aryaw
as=asyaw
at=atyaw
au=auyaw
av=avyaw
ak=akyaw
al=alyaw
am=amyaw
an=anyaw
ao=aoyaw
ap=apyaw
aq=aqyaw

;------------------------------------------------
outch 1, aw,2, ax,3, ay,4, az ,5, ar , 6 ,as, 7,at ,8,au ,9, av  ,10, ak, 11, al, 12, am, 13, an, 14, ao, 15, ap, 16, aq
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here