Exemplo n.º 1
0
 /**
  * Set the source file for this WaveTab
  *
  * @param f The source file to set
  * @param waveForm The WaveForm corresponding to the file
  */
 protected void setInput(File f, AudioFileWaveForm waveForm) {
   tabItem.setText(f.getName());
   source = f;
   cutList.removeModificationListener(this);
   cutList = new CutList(new AudioFileSource(f, waveForm));
   cutList.addModificationListener(this);
   waveDisplay.redraw();
 }
Exemplo n.º 2
0
  /**
   * Create a new WaveTab
   *
   * @param editor The SampleEditor to which the WaveTab belongs
   * @param parent The TabFolder to be used as parent for the TabItem that will be created
   * @param style The style to be used for the TabItem
   * @param waveStyle The style to be used for the WaveFormDisplay
   * @param f The source file
   * @param wf The WaveForm corresponding to the file
   * @param format The AudioFormat to be used for recording or <code>null</code>, if not recording
   * @param rec true, if recording should be possible for this WaveTab, false otherwise
   * @throws UnsupportedAudioFileException If the AudioFileFormat of the given file can not be
   *     detected (only in case of not recording)
   * @throws IOException If an I/O error occured
   */
  WaveTab(
      SimpleSampleEditor editor,
      TabFolder parent,
      int style,
      int waveStyle,
      File f,
      AudioFileWaveForm wf,
      AudioFormat format,
      boolean rec)
      throws UnsupportedAudioFileException, IOException {
    this.editor = editor;
    afWF = wf;
    channels = wf.getChannels();
    afSource = new AudioFileSource(f, afWF);
    cutList = new CutList(afSource);
    cutList.addModificationListener(this);
    waveDisplay = new WaveFormDisplay(parent, waveStyle, false);
    waveDisplay.setChannelBackgroundColor(parent.getDisplay().getSystemColor(SWT.COLOR_BLACK));
    waveDisplay.addWaveDisplayListener(editor);
    waveDisplay.setSource(this);
    waveDisplay.setEditMarkers(true);
    waveDisplay.getComposite().addKeyListener(createKeyListener());
    waveDisplay.getComposite().addKeyListener(editor.keyListener);
    waveDisplay.addSelectableListener(
        new SelectableListener() {
          public void selectionPermanentChanged(Selectable s, Selection sel) {}

          public void selectionChanged(Selectable s, Selection sel) {
            WaveTab.this.editor.zoomSel.setEnabled(!sel.isEmpty());
          }

          public void positionChanged(Selectable s, int pos) {}

          public void positionWillChange(Selectable s) {}

          public void positionWontChange(Selectable s) {}
        });
    source = f;
    tabItem = new TabItem(parent, style);
    tabItem.setText(f.getName());
    tabItem.setControl(waveDisplay.getComposite());
    tabItem.setData(WaveTab.this);
    tabItem.addDisposeListener(
        new DisposeListener() {
          public void widgetDisposed(DisposeEvent e) {
            if (WaveTab.this.editor.player.getProvider() == WaveTab.this)
              WaveTab.this.editor.player.removeProvider();
          }
        });
    recording = rec;
    if (rec) {
      this.format = format;
      isNew = true;
      canRec = true;
    } else {
      fileFormat =
          AudioManager.getDefault().getAudioFileFormat(f, null, new String[] {"slices", "RLND"});
      format = fileFormat.getFormat();
      isNew = false;
      canRec = false;

      // For compatibility to 1.4...
      Map properties = AudioManager.getProperties(fileFormat);
      if (properties != null) {
        Object sl = properties.get("slices");
        if (sl != null && sl instanceof int[][]) {
          int[][] slices = (int[][]) sl;
          for (int i = 0; i < slices.length; i++) {
            waveDisplay.addMarker(slices[i][0], "");
          }
        }
      }
    }
  }