SWT "realtime" VU Meter Control [message #722344] |
Mon, 05 September 2011 12:59 |
Peter Dell Messages: 12 Registered: September 2011 |
Junior Member |
|
|
Hi,
I'm currently integrating a sound module player (asap.sourceforge.net) into my Eclipse based WUDSN IDE (www.wudsn.com). In fact it already works fine and has I have added a VU meter display which shows the current volume for each channel.
I've already learned that SWT requires widgets to be updated from the display thread. So whenever the player thread has rendered another chunk of music data, I trigger an asynchronous update as shown below. But the delay is really large (so the sound and the display are out of sync) and I'd like to have a more updates - maybe even couples with the actual audio.
Has anybody done something like this before and can provide tips?
Best regards, Peter
public void playerUpdated() {
String position;
final String text;
final int[] channelVolumnes;
channelVolumnes = player.getChannelVolumes();
if (player.isRunning()) {
position = (player.getPosition() + 999) / 1000 + "s";
if (player.isPaused()) {
text = position + " (paused)";
} else {
text = position;
}
} else {
text = "Stopped";
}
// Updates to widgets must be performed in the display thread.
Display.getDefault().asyncExec(new Runnable() {
// @Override
public void run() {
playerUpdatedWithValues(text, channelVolumnes);
}
});
}
void playerUpdatedWithValues(final String text, final int[] channelVolumnes) {
if (partControlCreated) {
if (positionField.getControl().isDisposed()) {
positionField.setValue(text);
}
vuMeterField.update(channelVolumnes);
}
}
-
Attachment: VUMeter.png
(Size: 12.01KB, Downloaded 1724 times)
[Updated on: Mon, 05 September 2011 13:00] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03513 seconds