Volume leveling working? [#11924, #8911]

Report bugs & feature requests for MediaMonkey for Android and learn about the newest beta build.

Moderator: Gurus

Aff
Posts: 307
Joined: Sun Oct 05, 2008 4:46 pm
Location: Switzerland

Re: Volume leveling working?

Post by Aff »

  1. MMA doesn't read or write file tags by itself, right?
  2. I've done a test with two tracks, one at normal level and one at -30dB, then sent a debug log: 3BM9H4ZC8S
  3. Where are the gain values stored?
    In mmstore.db I've seen a column "volume_leveling" in the media table, but the value is 1 for both tracks.
    In the log I see the same Volume coefficient 1.22 for both tracks.
  4. I've changed volume_leveling in the media table to 10. It had no effect on playback, but the volume coefficient in the log was now 100000.
  5. So possibly there is a bug for syncing the level via USB (WMDM) and another bug for the playback?
  6. How do you control the playback volume, maybe it depends on the device/ROM? I'm using CM 11 (4.4.2) on a i9000.
Lowlander
Posts: 56605
Joined: Sat Sep 06, 2003 5:53 pm
Location: MediaMonkey 5

Re: Volume leveling working?

Post by Lowlander »

MMA doesn't read tags from the files. It gets it from Android Media or from syncing with MMW. However you're not syncing with MMW (direct to device) thus MMA doesn't get updated with the metadata from MMW. This means in your setup MMA depends on metadata being picked up by Android Media which is lacking and may as said not pick up volume level tags.
Aff
Posts: 307
Joined: Sun Oct 05, 2008 4:46 pm
Location: Switzerland

Re: Volume leveling working?

Post by Aff »

The manual file copy was only an additional test and question.
Aff wrote:(...)
Test 1:
Auto-Sync incl. conversion to MP3.
Volume is not levelled (=increased) in MMA.
(...)
Test 3:
Redo Test 1 with some new files (FLAC and MP3) and a new playlist, so there can't be any pairing issue with existing files in MMA.
Volume is not levelled (=increased) in MMA.
(...)
For the last tests (incl. the debug log) the files were transferred by auto-sync as well.

So possibly this doesn't work well via USB? I'll do some tests via WiFi later on.
Lowlander
Posts: 56605
Joined: Sat Sep 06, 2003 5:53 pm
Location: MediaMonkey 5

Re: Volume leveling working?

Post by Lowlander »

Aff wrote:Additional question: does MMA level only auto-synced tracks, or manually copied audio files based on tag info as well?
Aff
Posts: 307
Joined: Sun Oct 05, 2008 4:46 pm
Location: Switzerland

Re: Volume leveling working?

Post by Aff »

I've done some more tests. Indeed there are two bugs.
  1. USB auto-sync (via WMDM in MSC mode) doesn't sync volume leveling values
  2. MMA can't change the playback volume in spite of correct volume leveling values in it's database
Details for Bug 1:
  • USB auto-sync creates mmstore.db.synced only if there is a mmstore.db (on the SD card).
    (When MMA is started, it merges mmstore.db.synced into mmstore.db, both on the sd card and internal memory)
  • MMA creates mmstore.db on the SD card only if it changed metadata.
  • So after a clean install and first run of MMA, MMW USB auto-sync thinks there is no MMA and doesn't write the metadata to the Android device. So MMA only gets its metadata from Android media storage, lacking rating and volume leveling tags.
  • If mmstore.db is present before, USB auto-sync writes mmstore.db.synced. In that database, ratings are transferred, but not volume leveling: the field volume_leveling remains 1.
Details for Bug 2:
  • After a Wi-fi sync from MMA and playing the tracks, mmstore.db was created with volume_leveling 21 and -9.
  • But still there was no effect at playback.
For every test run I wiped all MMA data, cache, relevant folders on the sd card and MMW devices (via SQL) and restarted MMW/MMA.

Maybe you could create a volume leveling test app to find out if there is a device/ROM specific problem with setting the volume by MMA?
Lowlander
Posts: 56605
Joined: Sat Sep 06, 2003 5:53 pm
Location: MediaMonkey 5

Re: Volume leveling working?

Post by Lowlander »

1) I believe this only works in MTP (I might be wrong).
2) Works fine for me on MMA.
Aff
Posts: 307
Joined: Sun Oct 05, 2008 4:46 pm
Location: Switzerland

Re: Volume leveling working?

Post by Aff »

    1. Wouldn't make any sense if the volume_leveling value only was correctly updated in MTP. Would be a strange bug. I don't have any time to test that at the moment.
    2. Either should MMA write mmstore.db on the SD card at the very first start or MMW should recognize MMA by something else (e.g. MediaMonkey/files/storageinfo.xml)
  1. How can we proceed? What about a test app?
rusty
Posts: 8423
Joined: Tue Apr 29, 2003 3:39 am
Location: Montreal, Canada

Re: Volume leveling working?

Post by rusty »

1) Thanks--I'm able to replicate the problem. Tracked at http://www.ventismedia.com/mantis/view.php?id=11924

2) I'm not seeing this issue either. Could it be that:
- Volume leveling wasn't enabled in the options menu (just to be sure)
- You didn't pause playback and switch tracks to verify that it works (it seems that enabling volume leveling doesn't have an immediate effect--it changes a setting, I'm not 100% certain, but it seems to me that it only become active after playback has stopped and the track has switched).

-Rusty
Aff
Posts: 307
Joined: Sun Oct 05, 2008 4:46 pm
Location: Switzerland

Re: Volume leveling working?

Post by Aff »

Tested again with other volumes: it works, but only by reducing volumes!

A track with volume leveling -10.9 dB plays at the same loudness as a track with volume leveling 0 dB.
But a track with +3 dB plays lower than a track with 0 dB.

Regarding the previously used test tracks, the one with +21 dB plays much quieter than the one with -9 dB.
Target/playback volume in MMW is 89 dB.

I've tested with another music app as well (Vanilla Music). There is a hint that on Android the volume can not be set above 100%. The app allows to select the preamp volume for replay gain. Indeed it has to be set to a lower volume in order to be able to increase the playback volume of tracks with positive leveling.

So maybe MMA suffers from the same strange Android limitation that limits amplification irrespective of the tracks original volume?

What were the volumes for your tests?
rusty
Posts: 8423
Joined: Tue Apr 29, 2003 3:39 am
Location: Montreal, Canada

Re: Volume leveling working?

Post by rusty »

Hi,

Thanks for the additional info. I'm also seeing some anomalies--but opposite to yours. i.e. if the co-efficient is -13db then enabling volume leveling seems to have an effect of reducing the volume. But if the co-efficient is -13db, I don't notice a change in volume when leveling is enabled.

I've re-opened http://www.ventismedia.com/mantis/view.php?id=8911 to track this.

-Rusty
Aff
Posts: 307
Joined: Sun Oct 05, 2008 4:46 pm
Location: Switzerland

Re: Volume leveling working? [#11924, #8911]

Post by Aff »

Thanks.
I think there are several possible solutions/workarounds for the 100% limitation of Android MediaPlayer setVolume:
  • Add a user preference in MMA for the ReplayGain playback level, so 100% can be set to less than 89 dB.
    E.g. the user could set it to 83 dB, so tracks with volume leveling 0 dB would have a factor of 50%, tracks with +6 dB would have 100%.
    (+) easy to implement
    (-) not that easy to understand for some users
    (-) reduces the volume for most of the tracks below the maximum. There may be quite some unused headroom taking into account that the user didn't set the music stream volume to the maximum.
  • Use setStreamVolume with getStreamMaxVolume from Android AudioManager, so if the user didn't set the music volume to the maximum, MMA can use this headroom to increase the volume of a track.
    (+) seems to be relatively easy to implement (but needs careful handling of events)
    (+) easy for the user if he set the music volume well below the maximum
    (-) still can't really increase the volume of tracks with peak <0dBFS (compared to tracks with peak 0dBFS)
    (-) useless if the user has set the volume to the maximum
  • Pre-process the tracks (sample values) in order to increase the volume.
    (+) tracks with peaks < 0dBFS can really be made louder
    (-) needs some more programming, ev. some kind of a DSP plug in
  • Same as above, but combined. So if there is headroom because the user didn't set the stream volume to the maximum, MMA would use it and set the stream volume to the maximum where needed.
  • Hope that Google cares. There is a feature request where you may add a comment: MediaPlayer setVolume to more than 100%
ColdZro

Re: Volume leveling working? [#11924, #8911]

Post by ColdZro »

Hi,
Just wanted to jump in with a quick question: I use a program called MP3Gain to level out all my mp3 files, which I like because it tags it and it can be easily undone if I want to. I've been using it for years, so maybe it's just outdated or something. I used to be into the technical stuff more than I am now, so maybe I'm just behind. lol. But anyway, it has always worked just fine for me... on the hard drive, all my music is level already (well, within a range of 1.5 dB). If I play the files on my computer, on any media player, or if I burn a disc of any type, it always plays nice and level. Even playing on other Android media players, I've never had to adjust my volume between songs. But playing on MMA, I notice major differences in volumes. Now, I didn't have all of the volumes analyzed in MMW, which I'm now in the process of doing... and I see the volumes displayed there are covering a wide range... not even close to level. So, my question is, does MediaMonkey just ignore the tags and volume adjustments made by MP3Gain? I mean, they still sound the same volume when I'm PLAYING them on MMW, but when they're analyzed, they display... I dunno, I guess it's the original volume maybe? Anyway, I LOVE MediaMonkey, so I'm sticking with it, but is my MP3Gain going to be a waste of time now that I've just gotten hold of MMA as my primary portable player. Or is there a better volume leveler that will change the actual file, like MP3Gain does? I mean, I'd be happy to just let MMW analyze the volume and tag it, but does MediaMonkey just analyze the volume, so that IT knows how to play everything level, or does it actually change the file for the benefit of other players, too, like MP3Gain does? Because if it doesn't change the file, itself, then what if I burn a disc, or heaven forbid, have to play my music on some other program or app besides MMA... will they play level on some other player?

Anyway, quick note to you MediaMonkey guys, while I've got ya: you've made my life so much easier and better. MediaMonkey is awesome... there are a couple things which are not ABSOLUTELY perfect, but man it's like THIS><CLOSE! And that's what's awesome, because there's no way to please everybody 100%, but MM does so much right that it kinda shocks me when I run across something that isn't EXACTLY how I want it. lol. So, thanks very much. :D
rusty
Posts: 8423
Joined: Tue Apr 29, 2003 3:39 am
Location: Montreal, Canada

Re: Volume leveling working? [#11924, #8911]

Post by rusty »

Cold Zro,

Re. the technical stuff: MP3Gain actually _modifies_the_volume_ of your MP3 files in a lossless fashion, so theoretically, when MMW analyzes the volume of tracks that have been levelled by MP3Gain, they should all be within a few dB of each other. If they aren't then it means that something is amiss re. the volume leveling that was performed (or with MMW's calculation).

As far as real world usage: If you've levelled your tracks with MP3 gain, since the tracks are already level there's no need to enable volume leveling at playback either in MMW or MMA--the tracks are already level so there's no need to dynamically adjust volume based on leveling coefficients.

Hope that clarifies.

-Rusty
ColdZro

Re: Volume leveling working? [#11924, #8911]

Post by ColdZro »

Hi, Rusty,
Thanks for the response. That actually did fix the problem for me, but in a way I didn't expect. I knew that MP3Gain modified the volume and that I shouldn't need to enable leveling in MMA since MOST of my tracks are level already, but I enabled it anyway thinking it would level that odd track that I had put on my phone before I remembered to MP3Gain it. So, what I didn't realize was that MMA was still going to do an adjustment based on the tags... I figured it just wouldn't do anything most of the time, until it played one of those odd tracks. But what I was finding was, although I had volume leveling enabled in MMA, it was playing my already leveled tracks at varying volumes! So after what you told me, I DISabled leveling, and found that now they DO play level. I guess MMA was reading the original recorded volume, and applying what should have been the appropriate volume adjustment... however because MP3Gain had already leveled them, it was now sort of reversing it? And that's something that hadn't occurred to me before. So, anyway, they all seem to be playing just fine now. Thank you! :)

And I don't know if this is of any help or any curiosity to anyone else, but I'm gonna throw it out there... all my files which have been modified by MP3Gain to be level (within about plus or minus 1.5 dB), when I analyze the volume in MMW, they show a wide range of volumes! Much more than a few dB difference. But when I play them... in MMW or pretty much anywhere... they ARE pretty level. So, what is MMW calculating? The original volume, before MP3Gain modified it? Anyway, this isn't a problem to me, I'm just curious... so you guys can ignore this if you want. lol. :D

Thanks again,
Dave
rusty
Posts: 8423
Joined: Tue Apr 29, 2003 3:39 am
Location: Montreal, Canada

Re: Volume leveling working? [#11924, #8911]

Post by rusty »

Dave,

Can you send me a link (e.g. via mediafire) to 2 tracks that you've leveled with MP3 gain that have the greatest discrepancy in volumes according to MMW (i.e. one should be +x dB and the other should be -x dB where x in both cases is the furthest from 0 dB).

Thanks.

-Rusty
Post Reply