[banshee/gapless-ng: 831/836] [libbanshee] Re-add ReplayGain history fallback
- From: Christopher James Halse Rogers <chrishr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee/gapless-ng: 831/836] [libbanshee] Re-add ReplayGain history fallback
- Date: Thu, 25 Feb 2010 22:45:44 +0000 (UTC)
commit da603e287016c65b0db73b7c291f6491ebe83a5d
Author: Christopher James Halse Rogers <raof ubuntu com>
Date: Thu Feb 25 13:12:22 2010 +1100
[libbanshee] Re-add ReplayGain history fallback
libbanshee/banshee-player-private.h | 11 ++---------
libbanshee/banshee-player-replaygain.c | 30 ++++++++++++++++++++++++++++++
2 files changed, 32 insertions(+), 9 deletions(-)
---
diff --git a/libbanshee/banshee-player-private.h b/libbanshee/banshee-player-private.h
index 3c7a3d9..104dc5d 100644
--- a/libbanshee/banshee-player-private.h
+++ b/libbanshee/banshee-player-private.h
@@ -153,15 +153,8 @@ struct BansheePlayer {
// and the oldest at index 10. History is used to compute
// gain on a track where no adjustment information is present.
// http://replaygain.hydrogenaudio.org/player_scale.html
- gdouble volume_scale_history[11];
- gboolean volume_scale_history_shift;
- gboolean current_scale_from_history;
-
- // ReplayGain cache
- gdouble album_gain;
- gdouble album_peak;
- gdouble track_gain;
- gdouble track_peak;
+ gdouble rg_gain_history[10];
+ gint history_size;
};
#endif /* _BANSHEE_PLAYER_PRIVATE_H */
diff --git a/libbanshee/banshee-player-replaygain.c b/libbanshee/banshee-player-replaygain.c
index d0dac85..7dade14 100644
--- a/libbanshee/banshee-player-replaygain.c
+++ b/libbanshee/banshee-player-replaygain.c
@@ -40,10 +40,40 @@ bp_replaygain_db_to_linear(gdouble value)
return pow(10, value / 20.0);
}
+static gdouble bp_rg_calc_history_avg (BansheePlayer *player)
+{
+ gdouble sum = 0.0;
+ int i;
+ for (i = 0; i < player->history_size; ++i) {
+ sum += player->rg_gain_history[i];
+ }
+ return sum / player->history_size;
+}
+
+static void bp_replaygain_update_history (BansheePlayer *player)
+{
+ g_return_if_fail (player->history_size <= 10);
+
+ if (player->history_size == 10) {
+ memmove (player->rg_gain_history + 1, player->rg_gain_history, sizeof (gdouble) * 9);
+ } else {
+ memmove (player->rg_gain_history + 1, player->rg_gain_history, sizeof (gdouble) * player->history_size);
+ player->history_size++;
+ }
+
+ gdouble gain;
+ g_object_get (G_OBJECT (player->rgvolume), "target-gain", &gain, NULL);
+ player->rg_gain_history[0] = gain;
+ bp_debug ("[ReplayGain] Added gain: %.2f to history.", gain);
+
+ g_object_set (G_OBJECT (player->rgvolume), "fallback-gain", bp_rg_calc_history_avg (player), NULL);
+}
+
static void on_target_gain_changed (GstElement *rgvolume, GParamSpec *pspec, BansheePlayer *player)
{
g_return_if_fail (IS_BANSHEE_PLAYER (player));
+ bp_replaygain_update_history (player);
_bp_rgvolume_print_volume (player);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]