I have been using mp3spi, tritonus and JLayer to process mp3 files. I am stuck up at one point where I need mp3 input stream / mp3 audio signal as floating point array. Please help!
Thanks
Have you tried using or sub-classing java.io.DataInputStream? Perhaps the readFloat() method is what you are looking for.
Related
I want to read wav files in Java and I am going to classify them with K-means.
How can I read wav files in Java and assign them into an array or something like that(you can suggest ideas for it) to classify them?
EDIT: I want to use APIs for reading wav files and for K-means.
The official Java Sound Programmer Guide walks through reading and writing audio files.
This article by A Greensted: Reading and Writing Wav Files in java should be helpful. The WavFile class is very useful and it can be tweaked to return the entire data array instead of buffered fragments.
Equivalent to matlab's wavread function:
http://web.archive.org/web/20120531113946/http://www.builogic.com/java/javasound-read-write.html
You could read the sound files using javax sound library and FileInputStream
(found a nice example here)
and treat the wave files as a vector of bits (0,1) or bytes.. using multiple sequence alignment (Wiki) create a distance matrix between every stream of bits/bytes, and from there, the clustering should be straight forward.
The Problem is, that this method is very sensitive to noise, etc, but it is worth a shot...
Not sure if this will help someone. Java JDK already provides AudioSystem class.
I used this as part of my tests to check generated WAV properties,
AudioFileFormat audioFileFormat = AudioSystem.getAudioFileFormat(new File(response.get()));
assertEquals(1, audioFileFormat.getFormat().getChannels());
assertEquals(8000.0, audioFileFormat.getFormat().getSampleRate(), 0.0f);
assertEquals(8, audioFileFormat.getFormat().getSampleSizeInBits());
I'd like to modify the audio input stream, the stream that would come
from my microphone.
I have looked through the java.sound package API, but did not entirely understand it,
nor how to modify direct sound input.
Does anyone here know how to do that, or know an API that is capable of doing it?
You want a mixture of things:
The Java Sound system: http://www.oracle.com/technetwork/java/index-139508.html
A trail for it: http://docs.oracle.com/javase/tutorial/sound/index.html
Using audio controls: http://docs.oracle.com/javase/1.5.0/docs/guide/sound/programmer_guide/chapter6.html (part of a wider set of documentation)
If you are able to give more information about what you want to do to the audio stream, it's likely we'll be able to give you more specific advice.
I need to extract the audio stream from a movie and eventually convert it to a certain format, let's say MP3 at 192 kbps, for later processing, more exactly to detect the voices.
Are there any libraries for extracting the audio stream from a movie?
you could use mplayer to extract audio to a seperate file:
mplayer yourmovie.mov -vo null -vc null -ao pcm:fast
http://www.mplayerhq.hu/DOCS/man/en/mplayer.1.html
Assuming you have a DVD it can be as simple as stripping the audio track, which you can do with various bits of DVD ripping software.
It it has a standard Dolby Digital audio track (up to 48kHz 16bit) or possibly TrueHD in the case of Blu-Ray (up to 96kHz, 24bit) you should be able to decode either using either mplayer or ffmpeg.
If it's Java you're interested in check out FMJ:
http://fmj-sf.net/index.php
This provides a Java wrapper to ffmpeg.
I'm developing applications for Android. I need to have some kind of audio mixing effect.
How can I combine 2 or more audio tracks into 1 audio track?
Or adding an audio track into a certain stream of an audio?
Can anyone give me samples where I can head start?
Maybe you could try to port this code to Android?
Mixing of multiple AudioInputStreams to one AudioInputStream.
This class takes a collection of AudioInputStreams and mixes
them together. Being a subclass of AudioInputStream itself,
reading from instances of this class behaves as if the mixdown
result of the input streams is read
.
I want to change the volume of an audio file
and save the new file using java.sound.sampled.
I tried to use the mixer to create a source line
from the file given and a target line to the new file.
So that I can change the mixer settings to change the volume.
But the sound is being played to the system speaker.
Am I thinking along correct way or not?
Is there any other way to record a file from a line?
The code is available here
A solution I got is www.jsresources.org/examples/AmplitudeConverter.html.
But can the same be done within java.sound.sampled
without using external libraries.
To change the volume, if you don't use a "Control" (see the Java Sound Tutorials), there is the option of directly modifying the samples themselves.
In your innermost loop, convert the bytes in the innermost buffer into a sample (if it is WAV 16-bit encoding, then you need to put the two bytes together to make the single SHORT value), then multiply that value by a float that ranges from 0 to 1, where 0 is the quietest and 1 leaves the sound at full volume. Then take the result and break it back down into two bytes and pass it along.
Do you need the code to do this? There are several other posts here where folks convert from bytes to INTs or Float and back.
Hmmm. This question is pretty old. Well maybe my answer will help someone new to the same problem.