Java Media Framework: extract audio information from mp3 file

I analyze mp3 music files. What I'm doing is extracting audio data from a file and counting the musical similarity.

I use javazoom to process mp3 files. Using audioFormat, I extract raw data from an mp3 file:

byte[] audioBytes = new byte[numBytes];
in_format_init = AudioSystem.getAudioInputStream(musicFile);
AudioFormat formatInit = in_format_init.getFormat(); 
AudioFormat formatFinal = new AudioFormat(
            AudioFormat.Encoding.PCM_SIGNED,
            formatInit.getSampleRate(),
            16,
            formatInit.getChannels(),
            formatInit.getChannels()*2,
            formatInit.getSampleRate(),
            false);
AudioInputStream streamIn = AudioSystem.getAudioInputStream(formatFinal,     in_format_init);
while (((numBytesRead = streamIn.read(audioBytes)) != -1))
{...}

By doing this, I save the audio data (without headers or tags) in audioBytes, and then the information stored in the array is processed.

My question is: is it possible to extract audio information from an mp3 audio file and save it, as I do in my example? I read about JMF, but it baffles me.

Thank.

+3
source share
1 answer

JMF API, , 100% , - :

try {
  File f = new File ("/path/to/my/audio.mp3");
  DataSource ds = Manager.createDataSource(f.toURI().toURL());
  ds.connect();
  ds.start();
  ...
} catch (java.io.IOException e) {
  ...
} catch (NoDataSourceException e) {
  ...
}

DataSource: ds.getControls() , - .

, , , , ds.disconnect(), , .

, JMF MP3 plugin

-

+3

Source: https://habr.com/ru/post/1727310/


All Articles