<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<p>hi,</p>
<p><br>
</p>
<p>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. </p>
<p><br>
</p>
<p>My question is how to do the conversion.</p>
<p><br>
</p>
<p>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. </p>
<p><br>
</p>
<p>TEST-1:</p>
<p></p>
<div></div>
<div>./gst-launch-1.0 -e \</div>
<div>alsasrc device=hw:2 ! foaa2b ! deinterleave name=d \</div>
<div>interleave name=i ! faac ! faad ! deinterleave name=dd \</div>
<div>interleave name=ii ! wavenc ! filesink location=final.wav \</div>
<div>d.src_0 ! queue ! audioconvert ! 'audio/x-raw,channels=1,channel-mask=(bitmask)0x1' ! queue ! i.sink_0 \</div>
<div>d.src_1 ! queue ! audioconvert ! 'audio/x-raw,channels=1,channel-mask=(bitmask)0x2' ! queue ! i.sink_1 \</div>
<div>d.src_2 ! queue ! audioconvert ! 'audio/x-raw,channels=1,channel-mask=(bitmask)0x4' ! queue ! i.sink_2 \</div>
<div>d.src_3 ! queue ! audioconvert ! 'audio/x-raw,channels=1,channel-mask=(bitmask)0x100' ! queue ! i.sink_3 \</div>
<div>dd.src_0 ! queue ! audioconvert ! 'audio/x-raw,channels=1,channel-mask=(bitmask)0x1' ! queue ! ii.sink_0 \</div>
<div>dd.src_1 ! queue ! audioconvert ! 'audio/x-raw,channels=1,channel-mask=(bitmask)0x2' ! queue ! ii.sink_1 \</div>
<div>dd.src_2 ! queue ! audioconvert ! 'audio/x-raw,channels=1,channel-mask=(bitmask)0x10' ! queue ! ii.sink_2 \</div>
<div>dd.src_3 ! queue ! audioconvert ! 'audio/x-raw,channels=1,channel-mask=(bitmask)0x20' ! queue ! ii.sink_3</div>
<div></div>
<div></div>
<div id="divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<br>
</div>
TEST-2:<br>
<p></p>
<p></p>
<div>./gst-launch-1.0 -e \</div>
<div>alsasrc device=hw:2 ! foaa2b ! audioconvert ! 'audio/x-raw,channels=4,channel-mask=(bitmask)0x107' \</div>
<div>! faac ! faad ! audioconvert ! 'audio/x-raw,channels=4,channel-mask=(bitmask)0x33' ! wavenc ! filesink location=final.wav</div>
<div id="divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<br>
</div>
<div id="divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
It's easy to understand TEST-1, because it split 4 channels and give specific order to 4 sub-data-paths. <span style="font-size: 12pt;">Could someone tell me the why TEST-2 is different to TEST-1?</span></div>
<div id="divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<span style="font-size: 12pt;"><br>
</span></div>
<div id="divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<span style="font-size: 12pt;">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?).</span></div>
<div id="divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<br>
</div>
<div id="divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
This is a long post. Thank you for your patience.</div>
<div id="divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<br>
</div>
<p>Best,</p>
<p>Xin</p>
</div>
</body>
</html>