Skip to content

Commit d01c38a

Browse files
leafy7382devgianlu
authored andcommitted
Add a new option "loudness". When enabled, track_gain + normalisation… (#127)
* Add a new option "loudness". When enabled, track_gain + normalisationPregain will be applied to the incoming packet values. If disabled, incoming packet values will remain pristine. * Refactored code
1 parent a6e5935 commit d01c38a

4 files changed

Lines changed: 14 additions & 2 deletions

File tree

core/src/main/java/xyz/gianlu/librespot/FileConfiguration.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,11 @@ public boolean preloadEnabled() {
149149
return config.get("preload.enabled");
150150
}
151151

152+
@Override
153+
public boolean enableNormalisation() {
154+
return config.get("player.enableNormalisation");
155+
}
156+
152157
@Override
153158
public float normalisationPregain() {
154159
Object raw = config.get("player.normalisationPregain");

core/src/main/java/xyz/gianlu/librespot/player/Player.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,8 @@ public interface Configuration {
545545

546546
boolean preloadEnabled();
547547

548+
boolean enableNormalisation();
549+
548550
float normalisationPregain();
549551

550552
@Nullable

core/src/main/java/xyz/gianlu/librespot/player/codecs/Codec.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@ public abstract class Codec implements Runnable {
3535
this.listener = listener;
3636
this.lines = lines;
3737
this.duration = duration;
38-
this.normalizationFactor = normalizationData != null ? normalizationData.getFactor(conf) : 1;
3938
this.preloadEnabled = conf.preloadEnabled();
39+
40+
if (conf.enableNormalisation())
41+
this.normalizationFactor = normalizationData != null ? normalizationData.getFactor(conf) : 1;
42+
else
43+
this.normalizationFactor = 1;
4044
}
4145

4246
public final void play() {

core/src/main/resources/default.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ enabled = true # Preload enabled
2323
[player] ### Player ###
2424
autoplayEnabled = true # Autoplay similar songs when your music ends
2525
preferredAudioQuality = "VORBIS_160" # Preferred audio quality (VORBIS_96, VORBIS_160, VORBIS_320)
26+
enableNormalisation = true # Whether to apply the Spotify loudness normalisation
2627
normalisationPregain = 0.0 # Normalisation pregain
2728
initialVolume = 65536 # Initial volume (0-65536)
2829
logAvailableMixers = true # Log available mixers
@@ -33,4 +34,4 @@ enableLoadingState = true # Enable loading state (useful for slow connections)
3334
useCdn = true # Use CDN to download tracks
3435

3536
[player.episodes]
36-
useCdn = true # Use CDN to download episodes
37+
useCdn = true # Use CDN to download episodes

0 commit comments

Comments
 (0)