Hi!
Just signed up and can't help to notice what a good forum you got going here!! congratulations!
I am working on a project of educational software concerning sound editing and audio-video synchronization. I am researching the Java Sound API and it's been working pretty well but now I got stuck in a lower level detail.
I want to extract audio data from an audio file through a AudioInputStream and then work with it to create some sound visualizations.
The problem is that my function to extract the data is only comes out with all the values set to 1.
here is how I am trying to extrat it:
public int [] getSoundData()
{
int [] data = new int [soundSize];
int temp, count = 0;
try
{
AudioInputStream tempAudioStream;
tempAudioStream = AudioSystem.getAudioInputStream(new File(filename));
while((temp = tempAudioStream.read()) != -1)
{
data[count] = temp;
count++;
}
}catch (Exception e)
{
e.printStackTrace();
return null;
}
return data;
}
I wouldn't mind having a byte [] in the end if you know a better way, I just used int [] because AudioInputStream.read() returns an int.
The file is valid, the sound plays perfect in the application but data comes out with all 1's.
Any idea of what might be the problem?
Thanks in advance!!
David Jonas