change ambisonic audio's channel position/layout

Liu Xin liuxin8166 at hotmail.com
Tue Oct 24 12:27:24 UTC 2017


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20171024/5ec78388/attachment-0001.html>


More information about the gstreamer-devel mailing list