Example code:

Is there a royalty-free library that reliably handles convoluted WAVE streams?

My incoming stream is generated by a third-party library and media players have no trouble with it. I need to adjust the stream. First effort was modifying (what I thought was) the data block in a na´ve for loop, using what I had understood from the specs above. My first attempt just made noise. I then tried using various GNU projects but those also destroyed the original content and returned noise.

After some hair-pulling I discovered WAVE streams can contain other chunks (i.e. INFO) that are not part of the spec. For example, when Audacity encounters an INFO block it will move it to the header. I checked my incoming stream for nefarious chunks and sure enough my single WAVE stream contains multiple chunks of every kind (RIFF, LMO, INFO, etc.) and the really annoying part is that they are out of order. My na´ve loop stood no chance.

Just to reiterate, media players make sense of this chatter-ridden stream, but its content does not seem to match the spec: RIFF-LMO-DATA-RIFF-INFO-RIFF-RIFF-LMO-INFO-INFO-DATA-RIFF... :/

Any tips or advice?