IPB

Welcome Guest ( Log In | Register )

Player implementation of ReplayGain (Android)
Havin_it
post 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.
Go to the top of the page
+Quote Post
 
Start new topic
Replies
Havin_it
post Oct 14 2012, 11:32
Post #2





Group: Members
Posts: 6
Joined: 7-October 12
Member No.: 103677



Pleased to report that the Equalizer route worked out nicely. I'm able to access a 5-band equalizer for the media playback stream, each band having a -15 - 15 dB range. So for each new track I just read the tags, and add the (+/-) track gain to the default level for each band (which are +3, 0, 0, 0, +3 on my test phone).

The results sound good so far, just wondering if my logic's sound or whether I ought to be bringing all bands to zero before adding the replaygain? Also, in the above case, if I had a RG value of +15 dB would you recommend pushing all bands to +15, or to (+15, +12, +12, +12, +15) to preserve the original relative levels? I don't think I can chain multiple equalizers on the one output, so trying to complement existing settings rather than ride rough-shod over them seems the preferred approach if I were to take the app public.
Go to the top of the page
+Quote Post
lvqcl
post Oct 14 2012, 11:40
Post #3





Group: Developer
Posts: 3469
Joined: 2-December 07
Member No.: 49183



QUOTE (Havin_it @ Oct 14 2012, 14:32) *
if I had a RG value of +15 dB would you recommend pushing all bands to +15, or to (+15, +12, +12, +12, +15) to preserve the original relative levels?


Neither the former nor the latter. It's usually not a good idea to use EQ for replaygain.

This post has been edited by lvqcl: Oct 14 2012, 11:40
Go to the top of the page
+Quote Post

Posts in this topic


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 29th December 2014 - 03:00