I have a not so simple question about Java Sound ( javax.sound package ).
I am implementing MP3 player with cross fade and smooth volume and seek controls.
I am reading sound as stream in 4096byte chunks and calculate the position in miliseconds manually.
When I want to seek() ( change base position from where the stream will be red ) I hear a really ugly "jump" in sound wave. I tried examining JLayer and other MP3 APIs but they don't have a seek() function at all or they have this "ugly sound jump" too.
My question is: How can I make this jump from one sound wave chunk to the other smoother? I tried interpolation but a reasonable ammount of time to "not-hear the jump" is 300ms and thats too long for seek() function.
Have you encountered this problem?
Do you know the solution?
I will paste a code sample here just to be sure.
public void seek( long pPosition )
{
sourceDataLine.flush();
seekIndex = ( sourceDataLine.getMicrosecondPosition() / 1000 ) - currentPositionInMilliseconds;
}
public long getPositionInMilliseconds()
{ return ( sourceDataLine.getMicrosecondPosition() / 1000 ) - seekIndex; }
the "position in milliseconds" is needed because of DataLine API of javax.sound
Thanks I'm frustrated...