I have a problem with playing a sound using OpenAL in Java (LWJGL). Whats worse is I have no idea what the error is telling me.
AL lib: ReleaseALC: 1 device not closed
Now I'm sure that the file location is correct but waveFile is returning a null, So the error is on line 8; when it's trying to get data from the waveFile.
FileInputStream fin = null;
try {
fin = new FileInputStream("res/FancyPants.wav");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
WaveData waveFile = WaveData.create(fin);
AL10.alBufferData(buffer.get(0), waveFile.format, waveFile.data, waveFile.samplerate);
waveFile.dispose();
Many Thanks.
try wrapping the FileInputStream in a BufferedInputStream. Like this.
FileInputStream fin = null;
BufferedInputStream bin = null;
try
{
fin = new FileInputStream("res/FancyPants.wav");
bin = new BufferedInputStream(fin);
}
catch(FileNotFoundException e)
{
e.printStackTrace();
}
WaveData waveFile = WaveData.create(bin);
AL10.alBufferData(buffer.get(0), waveFile.format, waveFile.data, waveFile.samplerate);
waveFile.dispose();