0

I have tons of ripped .wav files (I'm ready to convert them into flacs if it's easier) which details I want to insert in a MySQL database. When I right click the .wav files in Windows Explorer (not the browser) and select Properties -> Details I can see some details about the song. For example the artist, genre and duration. How can I read and edit these details in Java?

MikkoP
  • 4,864
  • 16
  • 58
  • 106
  • possible duplicate of [Java - reading, manipulating and writing WAV files](http://stackoverflow.com/questions/3297749/java-reading-manipulating-and-writing-wav-files) –  Jul 26 '12 at 09:53
  • Please find an old post which may help you. http://stackoverflow.com/questions/3297749/java-reading-manipulating-and-writing-wav-files – Pramod Kumar Jul 26 '12 at 09:59
  • Doesn't seem the same. Or is that able to read the artist and year etc details? – MikkoP Jul 26 '12 at 13:08
  • By doing a bit research it seems that wavs doesn't support tagging. Who does Windows do it then? Might the question be a bit easier to answer, if the files were flacs? – MikkoP Jul 26 '12 at 17:16

2 Answers2

0

To get durration information, see this link: Java - reading, manipulating and writing WAV files

Essentially, a WAV file is broken up into chunks, which either contain audio data, or describe the audio data in some way, or provide information about it. If the reader doesn't understand one of those chunks it is able to skip it, which allows placing a lot of different kinds of information in the file. One of those chunks contains information like the samplerate, number of channels and total number of sample frames, from which you can calculate the length.

For artist, genre and so on... well there's no standard chunk for that, so if that's really in the file, and not in the windows db somewhere, it's probably stored in ID3 tags embedded in the WAV. I don't know for sure what the chunkID is for ID3, but it's probably "id3 ", or "ID3 " (including the space). You coud probably figure this out by searching for strings of length 4 or more in the file -- usually data chunks are in the beginning and audio is at the end. (on unix/macos I would use the "strings" command, maybe with "head") ID3 tags are standard for MP3, and you can figure out how to parse them by googling. To get to them, you'll need to understand WAV files first, at least enough to know what chunks are, chunkIds, how to skip chunks you don't care about, and so on.

I don't know of a library that will read ID3 tags in WAV files in Java, so you'll either have to write one, or wrap one written in another language. I suspect libsndfile will work, but it doesn't have an MP3 reader, so maybe not. You could also try SOX. You can also check out http://javamusictag.sourceforge.net/ which I've never used, but it came up in a search.

good luck!

Community
  • 1
  • 1
Bjorn Roche
  • 11,279
  • 6
  • 36
  • 58
  • Thanks for the response, but I'm not really interested to learn how to manipulate files like that :) – MikkoP Jul 27 '12 at 15:51
0

I ended up converting them into flac files and using JAudiotagger. Thanks for the responses, this time I ended up this way.

http://www.jthink.net/jaudiotagger/

MikkoP
  • 4,864
  • 16
  • 58
  • 106