TarsosDSP
TarsosDSP copied to clipboard
AudioPlayer, when reading file : loosing audio data and can't read properly?
Hello after many trials, I was not able to get the AudioPlayer working normally. The sound is jerky , clipped , it is like the audio processor dont read the whole audio file but jump to a next step.
I tried this without any transformation on the audio stream : just one AudioProcessor is added. See the example :
File audioFile = new File(fileName);
AudioFormat format=null;
try {
dispatcher = AudioDispatcherFactory.fromFile(audioFile, 4096*100, 0);
format = AudioSystem.getAudioFileFormat(audioFile).getFormat();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
new Thread(dispatcher,"Audio dispatching").start();
I put here a enormous value of 4096*100 to show the problem. The problem is the same with values of : 2048 , 0 1024 , 0 2048 , 1024 etc The is still a loss of audio : we can't hear the original music
Is this normal and due to the dsp implementation?
The classes in the "examples" folder does not help, like Spectrogram.java that is not working using a AudioPlayer that play no sound at all, certainly due to bufferSize and overlap values.
I have this need because i want exactly what the Spectrogram.java is supposed to do : get a frequency visual with the sound played at the same time, with smoothness
Hi,
Could you give some details on the system you are using? Android? Windows? JRE?
Regards
Joren
hello standart version (not android), Tarsos DSP 2.3, Windows, JDK 8, Netbeans 8.1
Same here, jerky sound like every period of some time some bytes are missing. Also as chris282 mentioned when buffer size is big enough, the sound is normal, and I suppose the 'stops' in sound are between buffers.
I have a strange behavior, when using microphone input and setting values like
AudioDispatcher dispatcher = AudioDispatcherFactory.fromDefaultMicrophone(22050,2048,0);
It plays normal.
Also I found that this issue happens only with stereo(2 channels) input.
I had the same problem here, but I think I guess the magic numbers:
int audioBufferSize = format.getFrameSize() - 2;
int bufferOverlap = 0;
I don't know why...
I think you should change the documentation of those numbers to something more meaningful 👍
@celsogg How did you get AudioFormat instance?