go-audio / wav

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

How to create a wave file from PCM data #2

Closed dstotijn closed 7 years ago

dstotijn commented 7 years ago

Hi Matt,

I've been experimenting with go-audio/audio and go-audio/wav, trying to parse PCM data (signed, 8 kHz, 16 bit, 1 channel) coming from Amazon Polly into a .wav file. Is this possible? The PCM data I have from Amazon is in a io.ReadCloser. I've tried writing it to a file and decoding that with FullPCMBuffer but then I encounter a "PCM chunk not found" error.

Any help/pointers are welcome. Thanks! :)

dstotijn commented 7 years ago

Finally did get it working. I just manually filled an audio.IntBuffer with sample data and passed that to Encoder.Write. For anybody interested, here is the code: https://gist.github.com/dstotijn/9741aecb2ecccf4786939cb534a6f49a

vinniyo commented 2 years ago

Thanks buddy!

shearn89 commented 2 years ago

This is exactly what I was looking for - it would be great to have an example in the docs of how to take the contents of a bytes.Buffer in a known format and just dump it to a file with a header...