Discussion:
[PATCH 2/2] mpc: fix replay gain calculation
Johannes Weißl
2011-02-23 01:23:00 UTC
Permalink
Replay Gain calculation seems to have changed from library version
SV7 -> SV8. The numbers are from mpcdec.c.

Otherwise gain values are ridiculously high, which screws audio
completely.
---
mpc.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/mpc.c b/mpc.c
index d34a9c5..0eec85c 100644
--- a/mpc.c
+++ b/mpc.c
@@ -279,6 +279,10 @@ static int mpc_seek(struct input_plugin_data *ip_data, double offset)
static const char *gain_to_str(int gain)
{
static char buf[16];
+#if MPC_SV8
+ float g = MPC_OLD_GAIN_REF - gain / 256.f;
+ sprintf(buf, "%.2f", g);
+#else
int b, a = gain / 100;

if (gain < 0) {
@@ -287,13 +291,18 @@ static const char *gain_to_str(int gain)
b = gain % 100;
}
sprintf(buf, "%d.%02d", a, b);
+#endif
return buf;
}

static const char *peak_to_str(unsigned int peak)
{
static char buf[16];
+#if MPC_SV8
+ sprintf(buf, "%.5f", peak / 256.f / 100.f);
+#else
sprintf(buf, "%d.%05d", peak / 32767, peak % 32767);
+#endif
return buf;
}
--
1.7.4.1
Gregory Petrosyan
2011-02-23 19:23:32 UTC
Permalink
Pushed both to master, and the second one to maint, thanks!

Gregory
Johannes Weißl
2011-02-24 15:48:29 UTC
Permalink
Post by Gregory Petrosyan
Pushed both to master, and the second one to maint, thanks!
Thanks! After assembling the list of replay gain support, I discovered
that .wav files can indeed store metadata and rg values! Patch is
attached! I think this makes cmus the only player that actually supports
this :-). I'm working on a scanner that can analyse all file formats
cmus understands, it will also support wav.


Johannes
Gregory Petrosyan
2011-02-26 00:01:06 UTC
Permalink
Post by Johannes Weißl
Post by Gregory Petrosyan
Pushed both to master, and the second one to maint, thanks!
Thanks! After assembling the list of replay gain support, I discovered
that .wav files can indeed store metadata and rg values! Patch is
attached! I think this makes cmus the only player that actually supports
this :-).
Hm, does this mean that .wav files with RG metadata are non-existent? In this
case, do we really need to support this specification?

Gregory
Johannes Weißl
2011-02-28 18:50:12 UTC
Permalink
Post by Gregory Petrosyan
Post by Johannes Weißl
Post by Gregory Petrosyan
Pushed both to master, and the second one to maint, thanks!
Thanks! After assembling the list of replay gain support, I discovered
that .wav files can indeed store metadata and rg values! Patch is
attached! I think this makes cmus the only player that actually supports
this :-).
Hm, does this mean that .wav files with RG metadata are non-existent? In this
case, do we really need to support this specification?
Hm, I think RG metadata is practically non-existent. But for other RIFF
metadata there exist implementations (e.g. reading: gstreamer, writing:
audacity). Reading .wav RG tags is marked as TODO in gstreamer code
though.

What do you think about the RIFF tag support? Should I strip the patch
to only include this?


Johannes
Gregory Petrosyan
2011-03-08 16:27:46 UTC
Permalink
Post by Johannes Weißl
Post by Gregory Petrosyan
Post by Johannes Weißl
Thanks! After assembling the list of replay gain support, I discovered
that .wav files can indeed store metadata and rg values! Patch is
attached! I think this makes cmus the only player that actually supports
this :-).
Hm, does this mean that .wav files with RG metadata are non-existent? In this
case, do we really need to support this specification?
Hm, I think RG metadata is practically non-existent. But for other RIFF
audacity). Reading .wav RG tags is marked as TODO in gstreamer code
though.
What do you think about the RIFF tag support? Should I strip the patch
to only include this?
Sorry for not replying for so long — this email got lost in the inbox :-(

Yes, IMHO it is better to not introduce "dead" code. So if you can strip the
patch, it'd be fantastic.

Gregory
Johannes Weißl
2011-03-08 22:30:59 UTC
Permalink
Post by Johannes Weißl
What do you think about the RIFF tag support? Should I strip the patch
to only include this?
Sorry for not replying for so long — this email got lost in the inbox :-(
Yes, IMHO it is better to not introduce "dead" code. So if you can strip the
patch, it'd be fantastic.
No problem, I stripped the patch (attached) and uploaded the RG stuff to:
http://gitorious.org/~jmuc/cmus/jw-cmus/commits/wavgain


Johannes
Gregory Petrosyan
2011-03-10 22:11:08 UTC
Permalink
Post by Johannes Weißl
Post by Gregory Petrosyan
Post by Johannes Weißl
What do you think about the RIFF tag support? Should I strip the patch
to only include this?
Sorry for not replying for so long — this email got lost in the inbox :-(
Yes, IMHO it is better to not introduce "dead" code. So if you can strip the
patch, it'd be fantastic.
http://gitorious.org/~jmuc/cmus/jw-cmus/commits/wavgain
Thanks, pushed it straight to master — the patch looks good, and for
sure will not break anybody's day-to-day cmus usage. If it does not do
what advertised, being in master will only help to find it quicker :-)

P.S. It is a bit unfortunate that there's no way to know how many
people pull from the official git repo regularly. The only countable
thing is source archive downloads for stable releases, which does not
give any clue how many people do test bleeding edge cmus on day-to-day
basis.

                Gregory

Loading...