Skip to content

Commit a961d98

Browse files
committed
Do not divide by zero when normalizing audio waveforms full of 0.0 values
1 parent c472a24 commit a961d98

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/AudioWaveformer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ AudioWaveformData AudioWaveformer::ExtractSamples(int channel, int num_per_secon
120120

121121
// Scale all values to the -1 to +1 range (regardless of how small or how large the
122122
// original audio sample values are)
123-
if (normalize) {
123+
if (normalize && samples_max > 0.0) {
124124
float scale = 1.0f / samples_max;
125125
data.scale(total_samples, scale);
126126
}

0 commit comments

Comments
 (0)