1
|
|
2
|
---------------------------------------------------------------------
|
3
|
audacious-3.9/src/libaudcore/audio.h
|
4
|
|
5
|
### BEFORE ###
|
6
|
struct ReplayGainInfo {
|
7
|
float track_gain; /* dB */
|
8
|
float track_peak; /* 0-1 */
|
9
|
float album_gain; /* dB */
|
10
|
float album_peak; /* 0-1 */
|
11
|
};
|
12
|
|
13
|
### AFTER ###
|
14
|
struct ReplayGainInfo {
|
15
|
float track_gain; /* dB */
|
16
|
float track_peak; /* 0-1 */
|
17
|
float album_gain; /* dB */
|
18
|
float album_peak; /* 0-1 */
|
19
|
int track_gain_is_set; /* true or false */
|
20
|
int album_gain_is_set; /* true or false */
|
21
|
};
|
22
|
|
23
|
---------------------------------------------------------------------
|
24
|
audacious-3.9/src/libaudcore/tuple.cc
|
25
|
|
26
|
### BEFORE ###
|
27
|
EXPORT ReplayGainInfo Tuple::get_replay_gain () const
|
28
|
{
|
29
|
ReplayGainInfo gain {};
|
30
|
[…]
|
31
|
return gain;
|
32
|
}
|
33
|
|
34
|
### AFTER ###
|
35
|
EXPORT ReplayGainInfo Tuple::get_replay_gain () const
|
36
|
{
|
37
|
ReplayGainInfo gain {};
|
38
|
[…]
|
39
|
gain.album_gain_is_set = (data->is_set (AlbumGain)) ? 1 : 0;
|
40
|
gain.track_gain_is_set = (data->is_set (TrackGain)) ? 1 : 0;
|
41
|
|
42
|
return gain;
|
43
|
}
|
44
|
|
45
|
---------------------------------------------------------------------
|
46
|
audacious-3.9/src/libaudcore/output.cc
|
47
|
|
48
|
### BEFORE ###
|
49
|
static bool s_gain; /* replay gain info set */
|
50
|
|
51
|
### AFTER ###
|
52
|
// line removed
|
53
|
|
54
|
|
55
|
### BEFORE ###
|
56
|
static void apply_replay_gain (Index<float> & data)
|
57
|
{
|
58
|
if (! aud_get_bool (0, "enable_replay_gain"))
|
59
|
return;
|
60
|
|
61
|
float factor = powf (10, aud_get_double (0, "replay_gain_preamp") / 20);
|
62
|
|
63
|
if (s_gain)
|
64
|
{
|
65
|
float peak;
|
66
|
|
67
|
auto mode = (ReplayGainMode) aud_get_int (0, "replay_gain_mode");
|
68
|
if ((mode == ReplayGainMode::Album) ||
|
69
|
(mode == ReplayGainMode::Automatic &&
|
70
|
(! aud_get_bool (0, "shuffle") || aud_get_bool (0, "album_shuffle"))))
|
71
|
{
|
72
|
factor *= powf (10, gain_info.album_gain / 20);
|
73
|
peak = gain_info.album_peak;
|
74
|
}
|
75
|
else
|
76
|
{
|
77
|
factor *= powf (10, gain_info.track_gain / 20);
|
78
|
peak = gain_info.track_peak;
|
79
|
}
|
80
|
|
81
|
if (aud_get_bool (0, "enable_clipping_prevention") && peak * factor > 1)
|
82
|
factor = 1 / peak;
|
83
|
}
|
84
|
else
|
85
|
factor *= powf (10, aud_get_double (0, "default_gain") / 20);
|
86
|
|
87
|
if (factor < 0.99 || factor > 1.01)
|
88
|
audio_amplify (data.begin (), 1, data.len (), & factor);
|
89
|
}
|
90
|
|
91
|
### AFTER ###
|
92
|
static void apply_replay_gain (Index<float> & data)
|
93
|
{
|
94
|
if (! aud_get_bool (0, "enable_replay_gain"))
|
95
|
return;
|
96
|
|
97
|
float factor = powf (10, aud_get_double (0, "replay_gain_preamp") / 20);
|
98
|
float peak;
|
99
|
auto mode = (ReplayGainMode) aud_get_int (0, "replay_gain_mode");
|
100
|
if (
|
101
|
((mode == ReplayGainMode::Album) ||
|
102
|
(mode == ReplayGainMode::Automatic &&
|
103
|
(! aud_get_bool (0, "shuffle") || aud_get_bool (0, "album_shuffle")))) &&
|
104
|
(gain_info.album_gain_is_set))
|
105
|
{
|
106
|
factor *= powf (10, gain_info.album_gain / 20);
|
107
|
peak = gain_info.album_peak;
|
108
|
if (aud_get_bool (0, "enable_clipping_prevention") && peak * factor > 1)
|
109
|
factor = 1 / peak;
|
110
|
}
|
111
|
else
|
112
|
{
|
113
|
if (gain_info.track_gain_is_set)
|
114
|
{
|
115
|
factor *= powf (10, gain_info.track_gain / 20);
|
116
|
peak = gain_info.track_peak;
|
117
|
if (aud_get_bool (0, "enable_clipping_prevention") && peak * factor > 1)
|
118
|
factor = 1 / peak;
|
119
|
}
|
120
|
else
|
121
|
factor *= powf (10, aud_get_double (0, "default_gain") / 20);
|
122
|
}
|
123
|
|
124
|
if (factor < 0.99 || factor > 1.01)
|
125
|
audio_amplify (data.begin (), 1, data.len (), & factor);
|
126
|
}
|
127
|
|
128
|
|
129
|
### BEFORE ###
|
130
|
s_gain = s_paused = s_flushed = false;
|
131
|
|
132
|
### AFTER ###
|
133
|
s_paused = s_flushed = false;
|
134
|
|
135
|
### BEFORE ###
|
136
|
s_gain = true;
|
137
|
|
138
|
### AFTER ###
|
139
|
// line removed
|
140
|
|
141
|
---------------------------------------------------------------------
|
142
|
src/vorbis/vorbis.cc
|
143
|
|
144
|
### BEFORE ###
|
145
|
static bool update_replay_gain (OggVorbis_File * vf, ReplayGainInfo * rg_info)
|
146
|
{
|
147
|
const char *rg_gain, *rg_peak;
|
148
|
|
149
|
vorbis_comment * comment = ov_comment (vf, -1);
|
150
|
if (! comment)
|
151
|
return false;
|
152
|
|
153
|
rg_gain = vorbis_comment_query(comment, "REPLAYGAIN_ALBUM_GAIN", 0);
|
154
|
if (!rg_gain) rg_gain = vorbis_comment_query(comment, "RG_AUDIOPHILE", 0); /* Old */
|
155
|
rg_info->album_gain = (rg_gain != nullptr) ? str_to_double (rg_gain) : 0.0;
|
156
|
AUDDBG ("Album gain: %s (%f)\n", rg_gain, rg_info->album_gain);
|
157
|
|
158
|
rg_gain = vorbis_comment_query(comment, "REPLAYGAIN_TRACK_GAIN", 0);
|
159
|
if (!rg_gain) rg_gain = vorbis_comment_query(comment, "RG_RADIO", 0); /* Old */
|
160
|
rg_info->track_gain = (rg_gain != nullptr) ? str_to_double (rg_gain) : 0.0;
|
161
|
AUDDBG ("Track gain: %s (%f)\n", rg_gain, rg_info->track_gain);
|
162
|
|
163
|
rg_peak = vorbis_comment_query(comment, "REPLAYGAIN_ALBUM_PEAK", 0);
|
164
|
rg_info->album_peak = rg_peak != nullptr ? str_to_double (rg_peak) : 0.0;
|
165
|
AUDDBG ("Album peak: %s (%f)\n", rg_peak, rg_info->album_peak);
|
166
|
|
167
|
rg_peak = vorbis_comment_query(comment, "REPLAYGAIN_TRACK_PEAK", 0);
|
168
|
if (!rg_peak) rg_peak = vorbis_comment_query(comment, "RG_PEAK", 0); /* Old */
|
169
|
rg_info->track_peak = rg_peak != nullptr ? str_to_double (rg_peak) : 0.0;
|
170
|
AUDDBG ("Track peak: %s (%f)\n", rg_peak, rg_info->track_peak);
|
171
|
|
172
|
|
173
|
return true;
|
174
|
}
|
175
|
|
176
|
### AFTER ###
|
177
|
static bool update_replay_gain (OggVorbis_File * vf, ReplayGainInfo * rg_info)
|
178
|
{
|
179
|
const char *rg_gain, *rg_peak;
|
180
|
|
181
|
vorbis_comment * comment = ov_comment (vf, -1);
|
182
|
if (! comment)
|
183
|
return false;
|
184
|
|
185
|
rg_gain = vorbis_comment_query(comment, "REPLAYGAIN_ALBUM_GAIN", 0);
|
186
|
if (!rg_gain) rg_gain = vorbis_comment_query(comment, "RG_AUDIOPHILE", 0); /* Old */
|
187
|
rg_info->album_gain = (rg_gain != nullptr) ? str_to_double (rg_gain) : 0.0;
|
188
|
AUDDBG ("Album gain: %s (%f)\n", rg_gain, rg_info->album_gain);
|
189
|
rg_info->album_gain_is_set = (rg_gain != nullptr) ? 1 : 0;
|
190
|
|
191
|
rg_gain = vorbis_comment_query(comment, "REPLAYGAIN_TRACK_GAIN", 0);
|
192
|
if (!rg_gain) rg_gain = vorbis_comment_query(comment, "RG_RADIO", 0); /* Old */
|
193
|
rg_info->track_gain = (rg_gain != nullptr) ? str_to_double (rg_gain) : 0.0;
|
194
|
AUDDBG ("Track gain: %s (%f)\n", rg_gain, rg_info->track_gain);
|
195
|
rg_info->track_gain_is_set = (rg_gain != nullptr) ? 1 : 0;
|
196
|
|
197
|
rg_peak = vorbis_comment_query(comment, "REPLAYGAIN_ALBUM_PEAK", 0);
|
198
|
rg_info->album_peak = rg_peak != nullptr ? str_to_double (rg_peak) : 0.0;
|
199
|
AUDDBG ("Album peak: %s (%f)\n", rg_peak, rg_info->album_peak);
|
200
|
|
201
|
rg_peak = vorbis_comment_query(comment, "REPLAYGAIN_TRACK_PEAK", 0);
|
202
|
if (!rg_peak) rg_peak = vorbis_comment_query(comment, "RG_PEAK", 0); /* Old */
|
203
|
rg_info->track_peak = rg_peak != nullptr ? str_to_double (rg_peak) : 0.0;
|
204
|
AUDDBG ("Track peak: %s (%f)\n", rg_peak, rg_info->track_peak);
|
205
|
|
206
|
|
207
|
return true;
|
208
|
}
|
209
|
---------------------------------------------------------------------
|
210
|
|
211
|
|
212
|
|
213
|
|
214
|
|
215
|
|