I was curious if there is a way to extract metadata from wav files. For instance, can you get bpm, key, instrument, etc. from a .wav file on upload?


closed as off-topic by MBaz, lennon310, Marcus Müller, Matt L., Stanley Pawlukiewicz Sep 2 '18 at 16:57

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "General programming questions are off-topic here, but can be asked on Stack Overflow." – MBaz, lennon310, Marcus Müller, Matt L., Stanley Pawlukiewicz
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ I think your question is not really about signal processing, but about the details of a particular file format (which, by the way, is well documented; I'd start in Wikipedia). As such, the question may be more appropriate in stackoverflow. $\endgroup$ – MBaz Aug 30 '18 at 22:21
  • $\begingroup$ i don't think it's such a bad question. but maybe the Stack Overflow people would know better than us DSP people. .wav files use this RIFF format. data is stored in "chunks". dunno, other than writing your own C program (with fopen(), fread(), fseek(), and fclose()) to scan each formatted block for the data. otherwise i dunno. $\endgroup$ – robert bristow-johnson Aug 31 '18 at 0:16

As mentioned already, it is incredibly easy to read metadata off of WAV files as it is a tag based format and there are already implementations of readers for this information out there (e.g. tinytag in Python).

Having said this though, "bpm, key, instrument" are not part of typical information you would find in a WAV file. If the creator of the file put them there, you will be able to read it, but "bpm" is not essential for playing back an audio file. What you are more likely to be able to retrieve is things like Sampling Frequency, Bits per sample, number of channels and of course anything to do with any compression method used. Building an automatic "recogniser" which could be populating these fields given some WAV file, is possible but not exactly straightforward.

Bpm, key and instrument however are essential for playing back MIDI files. Perhaps these are more useful to you (?)

Hope this helps.

  • $\begingroup$ That is very helpful. I need to find a way to get the bpm, key, etc. from .wav as I am building a platform to rival Splice.com. If you go to their site you can see that they have streamlined this process quite well. $\endgroup$ – Cody Rutscher Aug 31 '18 at 11:42
  • $\begingroup$ I have also read that JUCE might have some functionality in regards to metadata extraction using their .h or .cpp files. $\endgroup$ – Cody Rutscher Aug 31 '18 at 11:44
  • $\begingroup$ @CodyRutscher Thanks. I was not aware of "Splice" but you could get some similar functionality from WAV files via librosa. I suppose that they extract various features (tempo, timbre) and then try to group them depending on the way the content gets tagged. $\endgroup$ – A_A Aug 31 '18 at 11:56

Not the answer you're looking for? Browse other questions tagged or ask your own question.