public void update() { if (currentItem == -1) { currentItem = 0; SequenceItem item = items.get(currentItem); changeItem(item); } if (musicSynced) { if (LEDCubeManager.getLEDCube().getSpectrumAnalyzer().isPlaying()) { int time = LEDCubeManager.getLEDCube().getSpectrumAnalyzer().getPositionMillis(); int lastItem = currentItem; for (int i = items.size() - 1; i >= 0; i--) { SequenceItem item = items.get(i); if (time >= item.time) { currentItem = i; break; } } if (currentItem != lastItem) { changeItem(items.get(currentItem)); } } } else { SequenceItem item = items.get(currentItem); if (timer.getMilliseconds() >= item.time) { timer.restart(); if (++currentItem >= items.size()) currentItem = 0; changeItem(items.get(currentItem)); } } }
public void start() { timer.restart(); currentItem = -1; if (musicFile != null) LEDCubeManager.getLEDCube().getSpectrumAnalyzer().loadFile(musicFile.getAbsolutePath()); }