Incorrect ChunkSize. Got[328044] Wanted[1765420]
Closed this issue · 4 comments
I was able to write a file and play it using another program, but when I tried to read the same file using this library I got the error: Incorrect ChunkSize. Got[328044] Wanted[1765420]
I wrote the file with:
file := wav.File{
SampleRate: 8000,
SignificantBits: 16,
Channels: 1,
}
I tried to read with:
f, err := os.Open("output.wav")
if err != nil {
fmt.Println(err)
os.Exit(1)
}
stat, err := f.Stat()
if err != nil {
fmt.Println(err)
os.Exit(1)
}
reader, err = wav.NewReader(f, stat.Size())
if err != nil {
fmt.Println(err)
os.Exit(1)
}
Oh, wow.. Sorry, I was sure, I had tests for this. I don't know when I'll come around to fix this but will take a look soon.
Hey @mateusbraga,
thanks for putting my nose back onto this. I used the writer mostly with GetDumbWriter()
which bypasses the sampleBuf *bufio.Writer
of WriterInt32(int32)
and WriteSample([]byte)
.
Please reopen if this isn't fixed now.
@cryptix
I am still getting the same error.
Playing it using aplay works but the audio is slower than it should.
Here is what I am doing: https://gist.github.com/mateusbraga/43387946de1a2df1d600
I suppose it is an error from my side related to using WriterInt32 assuming Significant bit set to 16 makes it right. Should I convert it to []byte myself and use WriteSample if I want to use samples of 16bits?
I suppose it is an error from my side related to using WriterInt32 assuming Significant bit set to 16 makes it right. Should I convert it to []byte myself and use WriteSample if I want to use samples of 16bits?
Yes, that sounds like a good workaround. I should add a check to see if the Writer
is setup for 32bit when calling WriteInt32()
and/or find a better way to define this helper for all sample sizes.