go-audio / wav

Battle tested Wav decoder/encoder
Apache License 2.0
300 stars 46 forks source link

Encoded wav is entirely static noise #38

Open Jsewill opened 6 months ago

Jsewill commented 6 months ago

When using this library to transcode a wav file from pcm_s24le (as ffprobe reports), into a pcm_s16le wav file, the resulting file is just static noise. I based my attempts off of the wave to aiff example found here: https://github.com/go-audio/wav/blob/master/cmd/wavtoaiff/main.go . However, I got the same result using my own hackish, handwritten transcoder, prior to attempting to use this one. Yet, ffmpeg has no problem transcoding the same file from s24le to s16le, and produces a coherent wav file without noise. Do you have any idea why might this be?

Here's some output, regarding the wav file which I'm attempting to convert, from mplayer:

Clip info:
 encoder: FL Studio 21
[pcm] Uncompressed PCM audio decoder
AUDIO: 48000 Hz, 2 ch, s24le, 2304.0 kbit/100.00% (ratio: 288000->288000)
AO: [alsa] 48000Hz 2ch s24le (3 bytes per sample)

and from ffmpeg:

Stream #0:0: Audio: pcm_s24le ([1][0][0][0] / 0x0001), 48000 Hz, 2 channels, s32 (24 bit), 2304 kb/s

I've even tried using the audio.PCMBuffer type, with the SwitchPrimaryType function, to no avail. The only thing my program does with the decoder before calling PCMBuffer() with an audio.IntBuffer (as per the example), is to check IsValidFile(). I've noticed that if I read the metadata, the reader isn't reset, so I've avoided any calls which might prevent it from reading the PCM data.