.wav class

From Jeskola Buzz Wiki
Revision as of 10:02, 29 June 2010 by JoaCHIP (Talk | contribs) (Methods)

Jump to: navigation, search

Design proposition of a lean and mean .wav file handler class

General design goals

  • Should not be bloated and support obscure unused features like ADPCM and such. Just PCM.
  • Should be object oriented (C++), so that handling several files is a breeze
  • Should handle both mono and stereo
  • Should handle up to 192 KHz samplerate
  • Should handle the following input formats: 8-bit int, 16-bit int, 24-bit int, 32-bit float
  • Should handle the following output formats: 16-bit int, 24-bit int (optionally 8-bit int and 32-bit float)
  • Remember to use unsigned int for file sizes. No reason to limit ourselves at 2GB when 4GB is the actual limit.


  • Should it support files larger than 4 GB? How does this even work?
  • What should happen to unknown chunks such as markers, weird beat info. It would be super nice to be able to maintain these, but this would take memory.
  • Maybe it should handle IFF AIFF files (as they are 95% identical to .wav it should be fairly simple)


  • Open(filename)
Opens the file and reads meta data (samplerate etc.) into the class, so that various parameters can be known up front.
  • ReadData(chunksize, convert_to_float)
  • Close
Streams in a block of data from the file
  • Save(output file bitdepth)
  • WriteData(data)
  • UpdateAndClose()
Udpate header information (such as file length) and closes file

Internal data field

  • Length (in samples)
  • Samplerate
  • Channels
  • Bits per sample