@Override
  public void actionPerformed(ActionEvent e) {
    super.actionPerformed(e);
    long curFrame = CurAudio.getAudioProgress();
    long frameShift = CurAudio.getMaster().millisToFrames(shift);
    long naivePosition = curFrame + frameShift;
    long frameLength = CurAudio.getMaster().durationInFrames();

    long finalPosition = naivePosition;

    if (naivePosition < 0) {
      finalPosition = 0;
    } else if (naivePosition > frameLength) {
      finalPosition = frameLength;
    }

    CurAudio.setAudioProgressWithoutUpdatingActions(
        finalPosition); // not using setAudioProgressAndUpdateActions() because we don't want to
    // slow down start of playback
    CurAudio.getPlayer().queuePlayAt(finalPosition);

    replayer.actionPerformed(
        new ActionEvent(
            MyMenu.getInstance(),
            ActionEvent.ACTION_PERFORMED,
            null,
            System.currentTimeMillis(),
            0));

    MyMenu.updateActions();
  }
Пример #2
0
 /**
  * Performs the zoom, increasing/decreasing the pixelsPerSecond by calling {@link
  * components.waveform.WaveformDisplay#zoomX(boolean)}.
  *
  * <p>Since the waveform display autonomously decides when to paint itself, this action may not
  * result in an instant visual change.
  *
  * @param e The <code>ActionEvent</code> provided by the trigger
  */
 @Override
 public void actionPerformed(ActionEvent e) {
   super.actionPerformed(e);
   if (dir == Direction.IN) {
     WaveformDisplay.zoomX(true);
   } else {
     WaveformDisplay.zoomX(false);
   }
 }