Esempio n. 1
0
 /**
  * Try to save the peak file
  *
  * @return true, if the operation succeeded and the file was saved, false otherwise
  */
 protected boolean savePeak() {
   // Save peak File
   File p = FileManager.getParallelFile(source, "gmpk");
   OutputStream out;
   try {
     out = new FileOutputStream(p);
   } catch (FileNotFoundException e1) {
     e1.printStackTrace();
     return false;
   }
   WaveForm peak = afWF.getPeakWaveForm();
   ProgressThread saver =
       new SavePeakWaveFormThread(peak, peak.getIntervallSize(), out, source.lastModified());
   ProgressMonitor progress =
       new ProgressMonitor(
           getShell(), saver, "Saving Peak File...", "Saving Peak File " + p.getAbsolutePath());
   try {
     progress.start();
   } catch (NotFinishedException ex) {
     try {
       out.close();
     } catch (IOException e) {
       e.printStackTrace();
     }
     return false;
   }
   try {
     out.close();
   } catch (IOException e4) {
     e4.printStackTrace();
     return false;
   }
   return true;
 }
Esempio n. 2
0
  /**
   * @see
   *     com.groovemanager.sampled.waveform.WaveFormProvider#getWaveForm(com.groovemanager.sampled.waveform.AbstractWaveFormDisplay,
   *     int, int, int)
   */
  public WaveForm getWaveForm(AbstractWaveFormDisplay display, int start, int length, int width) {
    if (display == waveDisplay) {
      // Can we use the last WaveForm?
      if (lastWaveForm != null
          && lastWaveForm.canProvide(
              (int) Math.round((start - lastWaveFormPos) / lastWaveForm.getZoomFactor()),
              (int) Math.round(length / lastWaveForm.getZoomFactor()),
              width))
        lastWaveForm =
            lastWaveForm.subWaveForm(
                (int) Math.round((start - lastWaveFormPos) / lastWaveForm.getZoomFactor()),
                (int) Math.round(length / lastWaveForm.getZoomFactor()),
                width);
      else lastWaveForm = cutList.getWaveForm(start, length, width);

      lastWaveFormPos = start;

      return lastWaveForm;
    } else {
      // Can we use the last WaveForm?
      if (lastZoomWaveForm != null
          && lastZoomWaveForm.canProvide(
              (int) Math.round((start - lastZoomWaveFormPos) / lastZoomWaveForm.getZoomFactor()),
              (int) Math.round(length / lastZoomWaveForm.getZoomFactor()),
              width))
        lastZoomWaveForm =
            lastZoomWaveForm.subWaveForm(
                (int) Math.round((start - lastZoomWaveFormPos) / lastZoomWaveForm.getZoomFactor()),
                (int) Math.round(length / lastZoomWaveForm.getZoomFactor()),
                width);
      else lastZoomWaveForm = cutList.getWaveForm(start, length, width);

      lastZoomWaveFormPos = start;

      return lastZoomWaveForm;
    }
  }