First, I'm trying to do this without any proprietary libraries so that it is more portable, and I get a better/hands-dirty understanding of what's going on here. I'm ok writing my own classes and libraries to handle repetitive functionality (parsing headers, etc).
So I'm wondering how one could read a WAV/RIFF file through a stream in order that one can calculate information about said audio file (ie length of the audio in the file, how many samples, how many frames, etc). and then iterate through those frames or samples for other functionality.
I know it would be reading it in as a binary file through fstream
and allowing for the header (and getting some info from the header) as specified in the RIFF specs but how does one discern the bytes to frames or samples, and that to length?
I can find issues dealing with this in other languages, but haven't seen anything directly related to it in C++.
The WAV/RIFF header tells you the sampling size (8 bits, 16 bits, etc...); it also tells you the endian-ness, and whether each sample should be interpreted as a signed or an unsigned number (for 16 bits+); and also the number of channels.
Not sure what else you need. That's pretty much all that's needed to chew through the file. Reading the cited link, it seems to pretty much answer all your questions.
This happens to be the same link I used as a reference when throwing together a quick little hack to grab audio from my sound card which I attached to my radio. The aforementioned hack analyzed the audio it on the fly to find the silent spots, then split the audio stream, at the silent spots, into individual files. The resulting data passed enough for a .wav file to be acceptable to my .mp3 encoder, producing .mp3 files that I could dump onto my mp3 player, so that I could listen to my favorite radio shows later.