ActiveAE and bass management for 2 channel output
#1
My audio replay chain comprises a Linux PC running kodi outputting via optical to a standard 2-channel DAC which does not support any form of Dolby/DTS input. My complete audio replay chain is 2 channel analogue after the DAC and I don't want to replace the amp chain in any way.

I have setup kodi to downmix to 2 channels - which it does admirably - except it drops the LFE channel completely - which is the correct default thing to do. HOWEVER... if I had an external amp decoding the Dolby/DTS and didn't have a subwoofer attached, I'd be able to manage the bass signal and send the LFE into the 2 channel front speakers via the bass management feature. Given that I can't get at the LFE channel once kodi has downmixed to stereo, I'm pretty convinced that the bass management needs to be done by kodi itself. As ActiveAE runs on top of ffmpeg, I think all that is needed is setting the downmix coefficient using the
Code:
lfe_mix_level
appropriately.

Thoughts?
Reply
#2
Audio DSP addons can do this: http://forum.kodi.tv/showthread.php?tid=186857
Reply
#3
Thanks for the reply.

I read that thread yesterday before posting here and figured the bass management should be done as part of the 5.1/7.1 -> 2 channel mix process as you can ensure the normalisation gets done appropriately. Also, a DSP addon to do this seems a bit overkill when ffmpeg does it all for you. I've tested lfe_mix_level with ffmpeg using command line options and it seems to work correctly (you get everything slightly lower in the mix and LFE gets mixed into the 2 channel output as expected). I've got some Dolby multichannel test streams, cloned the git repo and compiled 15.2 so will have a play Smile
Reply
#4
We have designed DSP addon API for that purpose. An addon can do downmixing from 7.1/5.1 -> 2. An addon can also provide a UI dialog that can be accessed from the OSD. There won't be usage of ffmpeg for that purpose.
Reply
#5
OK.

But the code already exists in the ActiveAE to do all this downmixing to 2 channels before output and as I understand it, it uses the FFMPEG libraries to do this. I think I only have to add a couple of lines to get the LFE folded into the mix with something like:

Code:
av_opt_set_double(m_pContext, "lfe_mix_level", 1.0, 0);

somewhere in: xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResampleFFMPEG.cpp

Or am I misunderstanding how FFMPEG is used by ActiveAE to do the 5.1/7.1 -> 2 downmixing?

I'd have tried it by now, but there are people watching the TV (and have been all day!)....
Reply
#6
(2015-12-30, 20:39)arad85 Wrote: But the code already exists in the ActiveAE to do all this downmixing to 2 channels before output and as I understand it, it uses the FFMPEG libraries to do this. I think I only have to add a couple of lines to get the LFE folded into the mix with something like:

Code:
av_opt_set_double(m_pContext, "lfe_mix_level", 1.0, 0);

somewhere in: xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResampleFFMPEG.cpp

This appears to work for me and adds back in LFE to the 2 channel downmix here (although a value of 1.0 is not really noticeable and 10.0 is too much). Do you want me to try and code this up properly for inclusion into kodi or shall I just keep it on a local branch here? If integrating into kodi properly, ideally you'd need to have a boolean to say whether to enable or not and level value to say how much weight to give the LFE channel.

I've not looked at the Raspberry Pi (don't have one) resampling code, so don't know if the same would work there.
Reply
#7
My vision is that we use AudioDSP for all signal modications even for down mixes.
When I remember it correctly Alwinus defined an internal mode for that usecase. So you don't have to install an extra addon for it.
That should be the best place to add your FFMPEG function call.
When I'm at home I will try to find that place.
Latest news about AudioDSP and my libraries is available on Twitter.

Developers can follow me on Github.
Reply
#8
@wisler maybe you could create some simple DSP addon that can do LFE and center channel mixing. This could also serve as a template for others. What do you think?
Reply
#9
@wisler - thanks. @FernetMenta - yes, that is a good idea.
Reply
#10
(2015-12-31, 15:37)wisler Wrote: My vision is that we use AudioDSP for all signal modications even for down mixes...

Sorry I was wrong, there is an internal mode for upmixing.

I have found the right place, but I think that is not the way we should add more internal modes. Sorry I thought it's done in a different way.

It will introduce more spaghetti code. SadConfused
To integrate that nicely it will need more effort than I tought.

(2015-12-31, 16:46)FernetMenta Wrote: @wisler maybe you could create some simple DSP addon that can do LFE and center channel mixing. This could also serve as a template for others. What do you think?
I'm working on a template for AudioDSP addons see here. After my refactor is done, I will port adsp.basic to that template and a new pre-processing mode for volume correction. In the same step I will create a simple implementation to test the template, which will be a starting point for others.

Sorry I don't like quick hacks, consequently it will take some time.
Latest news about AudioDSP and my libraries is available on Twitter.

Developers can follow me on Github.
Reply
#11
Thanks for looking wisler Smile

My reason for choosing xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResampleFFMPEG.cpp was that this is where the quality setting is done. It seemed to me that this is where you setup the way the ffmpeg filter works, so adding the LFE at that point seemed logical. For the moment, I've settled on 6.0 as the value I use for mix level, but I'll need to see if that's too much after I've watched a few films.
Reply
#12
Hi arad85,

I stumbled upon this thread by looking at the lack of LFE in stereo downmixes issue. A major deficiency for people having a good stereo speaker set. Could you provide more details for less experienced people where and what code you inserted to get the LFE in the stereo downmix? What I see that you have done, i.e. a hard coded non configurable setting, is perfectly fine. Thanks a lot in advance.
Reply
#13
(2019-10-15, 22:11)gojkoo Wrote: Hi arad85,

I stumbled upon this thread by looking at the lack of LFE in stereo downmixes issue. A major deficiency for people having a good stereo speaker set. Could you provide more details for less experienced people where and what code you inserted to get the LFE in the stereo downmix? What I see that you have done, i.e. a hard coded non configurable setting, is perfectly fine. Thanks a lot in advance.

Hi gojkoo,

Yes, sure. I'll try and remember to do it tonight - I ended up coding it up using an unused setting in the menu (quality from memory) so I have 3 levels. I only used the mid level from memory. I'll attach a patch for the file. I'm still on a fairly old codebase though. I've also moved to surround which uses a unity gain input on the front amp and pre-out on a surround receiver to drive the front speakers. The surround now does all the bass management, folding the .1 channel into the main outputs as now all audio is set to passthrough. This is a great compromise between music (which just goes out via the main amp) and all video which goes out via HDMI to the surround sound processor. With room correction (I have a NAD amp with full Dirac) the sound is fabulous and I get to drive my main speakers with my main amplifier...

You can see my last post (about 7 months ago) showing how to duplicate audio out of both HDMI and optical (which I use to drive the DAC for music) on here somewhere if you want to go thatw ay.

If I've forgotten to reply in a couple of days, please ping me on the thread again (I have subscribed to replies so...)
Reply
#14
Here you go. I settled on 3, so I just apply it on each of the 3 quality levels.

Code:

xbmc@media:~/software/xbmc$ git diff xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResampleFFMPEG.cpp
diff --git a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResampleFFMPEG.cpp b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResampleFFMPEG.cpp
index af5bf93..48e06a3 100644
--- a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResampleFFMPEG.cpp
+++ b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResampleFFMPEG.cpp
@@ -76,17 +76,20 @@ bool CActiveAEResampleFFMPEG::Init(uint64_t dst_chan_layout, int dst_channels, i

   if(quality == AE_QUALITY_HIGH)
   {
+    av_opt_set_double(m_pContext, "lfe_mix_level", 3.0, 0);
     av_opt_set_double(m_pContext, "cutoff", 1.0, 0);
     av_opt_set_int(m_pContext,"filter_size", 256, 0);
   }
   else if(quality == AE_QUALITY_MID)
   {
     // 0.97 is default cutoff so use (1.0 - 0.97) / 2.0 + 0.97
+    av_opt_set_double(m_pContext, "lfe_mix_level", 3.0, 0);
     av_opt_set_double(m_pContext, "cutoff", 0.985, 0);
     av_opt_set_int(m_pContext,"filter_size", 64, 0);
   }
   else if(quality == AE_QUALITY_LOW)
   {
+    av_opt_set_double(m_pContext, "lfe_mix_level", 3.0, 0);
     av_opt_set_double(m_pContext, "cutoff", 0.97, 0);
     av_opt_set_int(m_pContext,"filter_size", 32, 0);
   }

I'm a ways back though on 17.5 (really must update, but everything I need works so...):

Code:

xbmc@media:~/software/xbmc$ git status
HEAD detached at 17.5-Krypton
Reply
#15
If you want more bass downmix, increment the 3.0 until you're happy (less and decrease the value).

As I say, I've now got a surround amp to do the downmix...
Reply

Logout Mark Read Team Forum Stats Members Help
ActiveAE and bass management for 2 channel output0