Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add metadata to WAV file?

Tags:

metadata

wav

I'm looking for some sample code to show me how to add metadata to the wav files we create. Anyone?

like image 671
Curtis Avatar asked Aug 09 '10 21:08

Curtis


1 Answers

One option is to add your own chunk with a unique id. Most WAV players will ignore it.

Another idea would to be use a labl chunk, associated with a que set at the beginning or end of the file. You'd also need a que chunk. See here for a reference

How to write the data is simple

  1. Write "RIFF".
  2. save the file position.
  3. Write 4 bytes of 0's
  4. Write all the existing chunks. Keep count of bytes written.
  5. Add your chunk. Be sure to get the chunksize right. Keep count of bytes written.
  6. rewind to the saved position. Write the new size (as a 32-bit number).
  7. Close the file.

It's slightly more complicated if you are adding things to an existing list chunk, but the same principle applies.

like image 182
AShelly Avatar answered Sep 25 '22 07:09

AShelly