Closed emmx closed 10 years ago
If you add writer.close
at the end of the second example, does it work? That is:
reader = WaveFile::Reader.new "test.wav"
writer = WaveFile::Writer.new("output2.wav", reader.format)
reader.each_buffer(4096) do |buffer|
writer.write WaveFile::Buffer.new(buffer.samples, reader.format)
end
writer.close
The file won't be valid until close
is called. When using a block as in the first example, the WaveFile will automatically be closed when the block exits, which is why you don't need to call close
there.
It makes sense, now it works!
If I'm not wrong, both examples below are supposed to work just as well. However, the second test produces a WAV file with the correct size, but somehow it's corrupted.