change ambisonic audio's channel position/layout

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

change ambisonic audio's channel position/layout

Liu Xin

hi,


I'm add an ambisonic microphone to my project to capture spatial sound, and I want to encode it into AAC and stream it. The only AAC encoder that supports 4 channels is FAAC. This plugin requires input's channel layout to be 0x107 ( FRONT_CENTER, REAR_CENTER, FRONT_LEFT, FRONT_RIGHT). While my mic's output is 0x33 (REAR_LEFT, REAR_RIGHT, FRONT_LEFT, FRONT_RIGHT), meaning conversion is needed. 


My question is how to do the conversion.


With gst-launch, I did 2 tests to simulate the entire data path, from capture to conversion to client side's playback (I use a proprietary player to listen to the captured sound. When everything is right, the final.wav should contain correct spatial cue when listening. Otherwise, the spatial cue is either wrong or doesn't exist). Result: TEST-1 is correct, while TEST-2 is not. 


TEST-1:

./gst-launch-1.0 -e \
alsasrc device=hw:2 ! foaa2b ! deinterleave name=d \
interleave name=i ! faac ! faad ! deinterleave name=dd \
interleave name=ii ! wavenc ! filesink location=final.wav \
d.src_0 ! queue ! audioconvert ! 'audio/x-raw,channels=1,channel-mask=(bitmask)0x1' ! queue ! i.sink_0 \
d.src_1 ! queue ! audioconvert ! 'audio/x-raw,channels=1,channel-mask=(bitmask)0x2' ! queue ! i.sink_1 \
d.src_2 ! queue ! audioconvert ! 'audio/x-raw,channels=1,channel-mask=(bitmask)0x4' ! queue ! i.sink_2 \
d.src_3 ! queue ! audioconvert ! 'audio/x-raw,channels=1,channel-mask=(bitmask)0x100' ! queue ! i.sink_3 \
dd.src_0 ! queue ! audioconvert ! 'audio/x-raw,channels=1,channel-mask=(bitmask)0x1' ! queue ! ii.sink_0 \
dd.src_1 ! queue ! audioconvert ! 'audio/x-raw,channels=1,channel-mask=(bitmask)0x2' ! queue ! ii.sink_1 \
dd.src_2 ! queue ! audioconvert ! 'audio/x-raw,channels=1,channel-mask=(bitmask)0x10' ! queue ! ii.sink_2 \
dd.src_3 ! queue ! audioconvert ! 'audio/x-raw,channels=1,channel-mask=(bitmask)0x20' ! queue ! ii.sink_3

TEST-2:

./gst-launch-1.0 -e \
alsasrc device=hw:2 ! foaa2b ! audioconvert ! 'audio/x-raw,channels=4,channel-mask=(bitmask)0x107' \
! faac ! faad ! audioconvert ! 'audio/x-raw,channels=4,channel-mask=(bitmask)0x33' ! wavenc ! filesink location=final.wav

It's easy to understand TEST-1, because it split 4 channels and give specific order to 4 sub-data-paths. Could someone tell me the why TEST-2 is different to TEST-1?

I really want to keep my pipeline simple. So I'm also concerning making foaa2b's output 0x107. Foaa2b is my self-written plugin that does ambisonic A-format to B-format conversion. So I can totally change its code. The problem is how put each channel to its correct position in the plugin code (which API to use?).

This is a long post. Thank you for your patience.

Best,

Xin


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

答复: change audio's channel position/layout

Liu Xin

hi,


This is the short version of my quetsion.


I have a microphone that captures 4 channels audio stream in channel layout of 0x33. I want to change some channels' position to make a stream of layout 0x107, but keeping the data in each channel untouched. How can I do that?


I already have a solution with using deinterleave/audioconvert/interleave, but want a simpler way, like doing it in one single element.


Best regards,
Xin


发件人: Liu Xin <[hidden email]>
发送时间: 2017年10月24日 20:27
收件人: [hidden email]
主题: change ambisonic audio's channel position/layout
 

hi,


I'm add an ambisonic microphone to my project to capture spatial sound, and I want to encode it into AAC and stream it. The only AAC encoder that supports 4 channels is FAAC. This plugin requires input's channel layout to be 0x107 ( FRONT_CENTER, REAR_CENTER, FRONT_LEFT, FRONT_RIGHT). While my mic's output is 0x33 (REAR_LEFT, REAR_RIGHT, FRONT_LEFT, FRONT_RIGHT), meaning conversion is needed. 


My question is how to do the conversion.


With gst-launch, I did 2 tests to simulate the entire data path, from capture to conversion to client side's playback (I use a proprietary player to listen to the captured sound. When everything is right, the final.wav should contain correct spatial cue when listening. Otherwise, the spatial cue is either wrong or doesn't exist). Result: TEST-1 is correct, while TEST-2 is not. 


TEST-1:

./gst-launch-1.0 -e \
alsasrc device=hw:2 ! foaa2b ! deinterleave name=d \
interleave name=i ! faac ! faad ! deinterleave name=dd \
interleave name=ii ! wavenc ! filesink location=final.wav \
d.src_0 ! queue ! audioconvert ! 'audio/x-raw,channels=1,channel-mask=(bitmask)0x1' ! queue ! i.sink_0 \
d.src_1 ! queue ! audioconvert ! 'audio/x-raw,channels=1,channel-mask=(bitmask)0x2' ! queue ! i.sink_1 \
d.src_2 ! queue ! audioconvert ! 'audio/x-raw,channels=1,channel-mask=(bitmask)0x4' ! queue ! i.sink_2 \
d.src_3 ! queue ! audioconvert ! 'audio/x-raw,channels=1,channel-mask=(bitmask)0x100' ! queue ! i.sink_3 \
dd.src_0 ! queue ! audioconvert ! 'audio/x-raw,channels=1,channel-mask=(bitmask)0x1' ! queue ! ii.sink_0 \
dd.src_1 ! queue ! audioconvert ! 'audio/x-raw,channels=1,channel-mask=(bitmask)0x2' ! queue ! ii.sink_1 \
dd.src_2 ! queue ! audioconvert ! 'audio/x-raw,channels=1,channel-mask=(bitmask)0x10' ! queue ! ii.sink_2 \
dd.src_3 ! queue ! audioconvert ! 'audio/x-raw,channels=1,channel-mask=(bitmask)0x20' ! queue ! ii.sink_3

TEST-2:

./gst-launch-1.0 -e \
alsasrc device=hw:2 ! foaa2b ! audioconvert ! 'audio/x-raw,channels=4,channel-mask=(bitmask)0x107' \
! faac ! faad ! audioconvert ! 'audio/x-raw,channels=4,channel-mask=(bitmask)0x33' ! wavenc ! filesink location=final.wav

It's easy to understand TEST-1, because it split 4 channels and give specific order to 4 sub-data-paths. Could someone tell me the why TEST-2 is different to TEST-1?

I really want to keep my pipeline simple. So I'm also concerning making foaa2b's output 0x107. Foaa2b is my self-written plugin that does ambisonic A-format to B-format conversion. So I can totally change its code. The problem is how put each channel to its correct position in the plugin code (which API to use?).

This is a long post. Thank you for your patience.

Best,

Xin


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel