Player implementation of ReplayGain (Android) |
Player implementation of ReplayGain (Android) |
Oct 8 2012, 11:53
Post
#1
|
|
|
Group: Members Posts: 6 Joined: 7-October 12 Member No.: 103677 |
Hello,
I'm hoping some folks here can help me get my head around the task of adding ReplayGain functionality to the stock Android music player app. My lack of training in maths and audio science is making it hard for me to ask the right questions probably, so please bear with me if you can. I've read through the replaygain spec (original proposal on your minisite and the updated version in the wiki) but there's still a lot that I'm unclear on. A sound engineeer friend helped me along a little further, but I think I exhausted his patience :( Now I understand that all replaygain adjustments start from -14 dBFS, and RG treats this as equivalent to 89 dB (SPL). Where I get lost is how I'd translate that to the logarithmic scale used by the volume control function I have to work with, which takes a float value (0-1 = mute-max) to attenuate the playback volume for the app (normally it stays at 1 and is used mainly for fading; it's independent of the master volume controls for the device). It can be abstracted to a linear scale (of the type that a physical volume control would use, I believe) of 0-<number of your choice>. The value is calculated from a linear-scale value like this: CODE #Example to set volume to 50/100 on the linear scale int maxvol = 100; int newvol = 50; float ratio = (float) (1 - (Math.log(maxvol - newvol) / Math.log(maxvol))); But to get to that point, I need somehow to abstract that starting-point of -14 dBFS / 89 dB SPL onto that linear scale. From what I've read so far, I get the feeling there is no "pure" way to do this and I'll be required to make some educated guesses. So that's where being uneducated lets me down :( I'd just be grateful for any suggestions, help or references in how I might understand the task better and construct a *reasonably* accurate equation for it. |
|
|
|
![]() |
Oct 9 2012, 01:38
Post
#2
|
|
|
Group: Members Posts: 6 Joined: 7-October 12 Member No.: 103677 |
Right, I see. The only open-source implementation that I've looked at so far that I actually comprehended the final stage of the process was the old Amarok script, which did basically adjust the UI volume slider, so I assumed this was the approach other implementations were following.
This certainly means the task's more challenging than I anticipated; the Android MediaPlayer API (for which the stock music player app I intended to build on is basically a wrapper) doesn't expose anything as low-level as PCM sample levels. In fact so far I can't see anything in the Java APIs that does, which probably means native code will be required (bit more of a learning curve for me!) though I've only started familiarising myself with it so I could be wrong. Thanks for piercing my misapprehension anyway; hopefully this'll be the biggest one I'll make and the rest will be a little more straightforward ;) |
|
|
|
Oct 9 2012, 01:46
Post
#3
|
|
|
Group: Members Posts: 4129 Joined: 2-September 02 Member No.: 3264 |
This certainly means the task's more challenging than I anticipated; the Android MediaPlayer API (for which the stock music player app I intended to build on is basically a wrapper) doesn't expose anything as low-level as PCM sample levels. If you don't have access to the actual audio, then its going to be hard to implement DSP effects. I guess if you don't have the ability to increase volume (which seems odd to me), you could try applying some constant volume reduction and make that 0 dB, then implement positive gain as less reduction. Depending on how the API is implemented, this might actually be equivalent to scaling the audio directly, or it might not. |
|
|
|
Havin_it Player implementation of ReplayGain (Android) Oct 8 2012, 11:53
Lear You could take a look at the Vorbis plugin in XMMS... Oct 8 2012, 12:40
saratoga QUOTE (Havin_it @ Oct 8 2012, 06:53) But ... Oct 8 2012, 16:03
[JAZ] @saratoga: Since we're talking about volume, s... Oct 8 2012, 18:57
Havin_it Hi, thanks all for replying :)
@Lear, I actually ... Oct 8 2012, 22:05
[JAZ] No, you don't need to substract 14.
Usually, ... Oct 8 2012, 22:30
Havin_it Well, the collection I have comprises a couple of ... Oct 9 2012, 00:21
saratoga QUOTE (Havin_it @ Oct 8 2012, 19:21) The ... Oct 9 2012, 00:44
Havin_it It's not exactly that I can't increase it,... Oct 9 2012, 03:24
Havin_it Pleased to report that the Equalizer route worked ... Oct 14 2012, 11:32
lvqcl QUOTE (Havin_it @ Oct 14 2012, 14:32) if ... Oct 14 2012, 11:40![]() ![]() |
|
Lo-Fi Version | Time is now: 19th May 2013 - 09:36 |