Skip to main content
Topic: Writing into existing WavPack files (Read 3730 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Writing into existing WavPack files

So without too much trouble, I was able to write some code where I could encode an audio file that was being recorded into WavPack and then decode it on playback.  But, what if I want to seek to some position in that recorded WavPack file and record over the data that's there?  There's no read and write WavpackContext*.  If I open an existing file with WavpackOpenFileOutput(), can I seek to some position in the WavpackContext* and pack samples from there?

Any input would be appreciated.

Thanks,

Hayden



Writing into existing WavPack files

Reply #1
Hi Hayden,

Unfortunately, there is no way to open a WavPack file for both reading and writing using the current library. This is quite a bit more complicated with lossless files because the new data might take more space than the old data and you would overwrite more samples than intended. Also, the block that you started overwriting would have to be rewritten in a truncated form. I have thought about adding full editing like this to the library, but it’s a significant task.

That said, the WavPack format itself is somewhat suited for limited editing like this because blocks can be any length and so there would never be any need to re-encode any audio data except for a tiny amount at the edit endpoints. It would be possible, though not really easy, to use the WavPack library in a sort of “raw” mode to accomplish this. The calling code would have to handle manipulating the WavPack headers while the library would be used to blindly encode and decode individual blocks (the Windows DirectShow and Linux Gstreamer filters work like this). Let me know if you are interested in pursuing this further.

Thanks for the question!

David

 
SimplePortal 1.0.0 RC1 © 2008-2018