Skip to content

Commit

Permalink
Export: fixed invalid JSON for empty ReplayGain information
Browse files Browse the repository at this point in the history
  • Loading branch information
mail@gausi.de authored and mail@gausi.de committed Dec 4, 2022
1 parent 00e9a36 commit 10aaea8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/AudioDisplayUtils.pas
Original file line number Diff line number Diff line change
Expand Up @@ -397,10 +397,10 @@ function GetAudioProperty(aAudioFile: TAudioFile; aProp: TEAudioProperty): strin
cpLyrics : result := aAudioFile.Lyrics;
cpLyricsExist : if aAudioFile.LyricsExisting then result := '1' else result := '0';
cpBPM : result := aAudioFile.BPM;
cpTrackGain : result := GainValueToNumberString(aAudioFile.TrackGain);
cpAlbumGain : result := GainValueToNumberString(aAudioFile.AlbumGain);
cpTrackPeak : result := PeakValueToString(aAudioFile.TrackPeak);
cpAlbumPeak : result := PeakValueToString(aAudioFile.AlbumPeak);
cpTrackGain : result := ReplayGainValueToNumberString(aAudioFile.TrackGain);
cpAlbumGain : result := ReplayGainValueToNumberString(aAudioFile.AlbumGain);
cpTrackPeak : result := ReplayGainValueToNumberString(aAudioFile.TrackPeak);
cpAlbumPeak : result := ReplayGainValueToNumberString(aAudioFile.AlbumPeak);
cpCoverID : result := aAudioFile.CoverID;
else
result := '';
Expand Down
14 changes: 7 additions & 7 deletions src/Hilfsfunktionen.pas
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function GainStringToSingle(aGainString: String): Single;
function PeakStringToSingle(aPeakString: String): Single;

function GainValueToString(aGainValue: Single): String;
function GainValueToNumberString(aGainValue: Single): String;
function ReplayGainValueToNumberString(aGainValue: Single): String;
function PeakValueToString(aPeakValue: Single): String;

function AnsiCompareText_Nemp(const S1, S2: string): Integer;
Expand Down Expand Up @@ -764,19 +764,19 @@ function GainValueToString(aGainValue: Single): String;
end;
end;

function GainValueToNumberString(aGainValue: Single): String;
function ReplayGainValueToNumberString(aGainValue: Single): String;
var formatSettings: TFormatSettings;
begin
if isZero(aGainValue) then
result := ''
result := '0'
else
if SameValue(aGainValue, 1) then
result := '1'
else
begin
formatSettings := TFormatSettings.Create(GetThreadLocale);
formatSettings.DecimalSeparator := '.';
if aGainValue > 0 then
result := Format('+%.6f', [aGainValue], formatSettings)
else
result := Format('%.6f', [aGainValue], formatSettings);
result := Format('%.6f', [aGainValue], formatSettings);
end;
end;

Expand Down

0 comments on commit 10aaea8

Please sign in to comment.