From d96942bef96e79ed3d327638bfee1d8190ea2e4f Mon Sep 17 00:00:00 2001 From: braheezy Date: Sat, 13 Apr 2024 11:13:31 -0700 Subject: [PATCH] Warn about high bitrates for lossless encodings --- cmd/convert.go | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/cmd/convert.go b/cmd/convert.go index a950004..cab67e8 100644 --- a/cmd/convert.go +++ b/cmd/convert.go @@ -131,7 +131,16 @@ func convertAudio(inputFile, outputFile string) { numSamples, ) - logger.Debug(inputFile, "channels", pcmBuffer.Format.NumChannels, "samplerate(hz)", pcmBuffer.Format.SampleRate, "samples/channel", numSamples, "size", formatSize(len(inputData))) + logger.Debug( + inputFile, + "channels", pcmBuffer.Format.NumChannels, + "samplerate(hz)", pcmBuffer.Format.SampleRate, + "samples/channel", numSamples, + "bit depth", wavDecoder.SampleBitDepth(), + "size", formatSize(len(inputData))) + if wavDecoder.SampleBitDepth() > 16 { + logger.Warn("Bit depth is greater than 16, this may result in loss of precision and sound quality!") + } case ".mp3": decodedData, q = decodeMp3(&inputData, inputFile) case ".ogg": @@ -192,7 +201,17 @@ func convertAudio(inputFile, outputFile string) { uint32(numSamples), ) - logger.Debug(inputFile, "channels", flacMetadata.NChannels, "samplerate(hz)", flacMetadata.SampleRate, "samples/channel", numSamples, "size", formatSize(len(inputData))) + logger.Debug( + inputFile, + "channels", flacMetadata.NChannels, + "samplerate(hz)", flacMetadata.SampleRate, + "samples/channel", numSamples, + "bit depth", flacMetadata.BitsPerSample, + "size", formatSize(len(inputData)), + ) + if flacMetadata.BitsPerSample > 16 { + logger.Warn("Bit depth is greater than 16, this may result in loss of precision and sound quality!") + } } outExt := filepath.Ext(outputFile)