Thursday, 5 September 2013

JavaFX - Media player Bands display lag (AudioSpectrumInterval)

JavaFX - Media player Bands display lag (AudioSpectrumInterval)

I tried build some simple audio/video player wich shows audio spectrum so
i tried use buld in AudioSpectrumListener but when i change
AudioSpectrumInterval from default 0.1 to lower value for example 0.02 the
spectrumDataUpdate in float[] magnitudes array returns same values wich
cause strong visual laging
otput of magnitudes[0] + 60.0 :
25.30990982055664
25.30990982055664
25.30990982055664
16.35150146484375
16.35150146484375
16.35150146484375
13.008472442626953
27.34347915649414
27.34347915649414
0.0
0.0
29.151962280273438
23.044506072998047
31.829599380493164
31.829599380493164
31.829599380493164
i tried to find source code of AudioSpectrumListener but i cant find it in
openjfx 8 i tried to put it in another thread but still same result
piece of code
@Override
public void run() {
mediaPlayer.setAudioSpectrumInterval(0.02);
mediaPlayer.setAudioSpectrumNumBands(128);
new Thread() {
@Override
public void run() {
System.out.println("Threaddd");
audioSpectrumListener = new
AudioSpectrumListener() {
@Override
public void spectrumDataUpdate(double
timestamp, double duration, float[]
magnitudes, float[] phases)
{
for (int i = 0; i <
series1Data.length; i++)
{series1Data[i].setYValue(magnitudes[i]
+ 60);}
System.out.println(magnitudes[0] + 60.0);
}
};
mediaPlayer.setAudioSpectrumListener(audioSpectrumListener);
try {
Thread.sleep(100);
} catch (InterruptedException ex) {
}
}
}.start();
ty for any advice

No comments:

Post a Comment