Ejemplo n.º 1
0
void AudioView::ImportMIDI()
{
  wxString fileName =
	wxFileSelector("Select a MIDI File...",
				   "", // Path
				   "", // Name
				   ".mid", // Extension
				   "*.mid", // Wildcard
				   0, // Flags
				   GetFrame()); // Parent

  if (fileName == "")
    return;

  NoteTrack *newTrack =
	new NoteTrack(&((AudioDoc *)GetDocument())->dirManager);
  
  if (::ImportMIDI(fileName, newTrack)) {

    SelectNone();
    GetTracks()->Add(newTrack);
	newTrack->selected = true;
    
    PushState();

    FixScrollbars();
    REDRAW(trackPanel);
    REDRAW(rulerPanel);
  }
}
Ejemplo n.º 2
0
void AudacityProject::OnImportMIDI(wxCommandEvent & event)
{
   wxString path = gPrefs->Read("/DefaultOpenPath",::wxGetCwd());

   wxString fileName = wxFileSelector(_("Select a MIDI file..."),
                                      path,     // Path
                                      "",       // Name
                                      "",       // Extension
                                      _("All files (*.*)|*.*|"
                                        "MIDI files (*.mid)|*.mid|"
                                        "Allegro files (*.gro)|*.gro"),
                                      0,        // Flags
                                      this);    // Parent

   if (fileName != "") {
      path =::wxPathOnly(fileName);
      gPrefs->Write("/DefaultOpenPath", path);

      NoteTrack *newTrack = new NoteTrack(&mDirManager);

      if (::ImportMIDI(fileName, newTrack)) {

         SelectNone();
         mTracks->Add(newTrack);
         newTrack->SetSelected(true);

         PushState(wxString::Format(_("Imported MIDI from '%s'"),
                                    fileName.c_str()));

         FixScrollbars();
         mTrackPanel->Refresh(false);
      }
   }
}
Ejemplo n.º 3
0
bool WindowStack::Remove(wxWindow* win)
{
    if(!Contains(win)) return false;
    m_windows.erase(win);

    if(win == m_selection) {
        SelectNone();
    }
}
Ejemplo n.º 4
0
void WindowStack::Clear()
{
    SelectNone();
    m_selection = NULL;

    std::set<wxWindow*>::iterator iter = m_windows.begin();
    for(; iter != m_windows.end(); iter++) {
        (*iter)->Destroy();
    }
    m_windows.clear();
}
Ejemplo n.º 5
0
void PtCloudGeom::HideSelection()
{
    for ( int j = 0; j < ( int ) m_Pts.size(); j++ )
    {
        if ( m_Selected[j] )
        {
            m_Hidden[j] = true;
            m_Selected[j] = false;
        }
    }
    SelectNone();
}
Ejemplo n.º 6
0
void WindowStack::Clear()
{
    SelectNone();
    m_selection = NULL;
    m_selectionKey.Clear();

	std::map<wxString,wxWindow*>::iterator iter = m_windows.begin();
	for (; iter != m_windows.end(); iter++) {
        iter->second->Destroy();
    }
    m_windows.clear();
}
Ejemplo n.º 7
0
void AudioView::ImportMP3()
{
  #if 0 // seems to be working better now!
    static bool warned=false;

    if (!warned) {
	wxMessageBox("Warning: This feature is not stable and may crash.  "
				 "Proceed at your own risk.");
	warned = true;
    }
  #endif // 0

  wxString fileName =
	wxFileSelector("Select a MP3 File...",
				   "", // Path
				   "", // Name
				   ".mp3", // Extension
				   "*.mp3", // Wildcard
				   0, // Flags
				   GetFrame()); // Parent
  
  if (fileName == "")
    return;

  WaveTrack *left = 0;
  WaveTrack *right = 0;

  if (::ImportMP3(fileName, &left, &right,
		  &((AudioDoc *)GetDocument())->dirManager)) {  
    if (left || right) {
      SelectNone();
    }
    
    if (left) {
      GetTracks()->Add(left);
      left->selected = true;
    }
    
    if (right) {
      GetTracks()->Add(right);
      right->selected = true;
    }
    
    PushState();
    
    FixScrollbars();
    REDRAW(trackPanel);
    REDRAW(rulerPanel);
  }
}
Ejemplo n.º 8
0
void AudacityProject::OnNewLabelTrack(wxCommandEvent & event)
{
   LabelTrack *t = new LabelTrack(&mDirManager);

   SelectNone();

   mTracks->Add(t);
   t->SetSelected(true);

   PushState(_("Created new label track"));

   FixScrollbars();
   mTrackPanel->Refresh(false);
}
Ejemplo n.º 9
0
void AudacityProject::OnNewWaveTrack(wxEvent & event)
{
   WaveTrack *t = new WaveTrack(&mDirManager);
   t->SetSampleFormat(mDefaultFormat);
   t->SetRate(mRate);
   SelectNone();

   mTracks->Add(t);
   t->SetSelected(true);

   PushState(_("Created new audio track"));

   FixScrollbars();
   mTrackPanel->Refresh(false);
}
Ejemplo n.º 10
0
void ChannelListctrl::FilterChannel( const wxString& partial )
{
    m_visible_idxs.clear();
    unsigned int idx = 0;
    for ( unsigned int i = 0; i < m_data.size() ; ++i ) {
        const ChannelInfo& data = m_data[i];
        if ( data.name.Find( partial ) != wxNOT_FOUND ) {
            m_visible_idxs[idx] = i;
            idx++;
        }
    }
    SelectNone();
    m_last_filter_value = partial;
    SetItemCount( m_visible_idxs.size() );
    RefreshVisibleItems( );
}
Ejemplo n.º 11
0
void AudioView::NewLabelTrack()
{
  LabelTrack *t = new LabelTrack(&((AudioDoc *)GetDocument())->dirManager);

  SelectNone();

  GetTracks()->Add(t);
  t->selected = true;

  PushState();

  FixScrollbars();
    
  REDRAW(trackPanel);
  REDRAW(rulerPanel);
}
Ejemplo n.º 12
0
void AudacityProject::Import(wxString fileName)
{
   WaveTrack **newTracks;
   int numTracks;

   numTracks =::Import(this, fileName, &newTracks);

   if (numTracks <= 0)
      return;

   SelectNone();

   bool initiallyEmpty = mTracks->IsEmpty();
   bool rateWarning = false;
   double newRate = newTracks[0]->GetRate();

   for (int i = 0; i < numTracks; i++) {
      if (newTracks[i]->GetRate() != mRate)
         rateWarning = true;
      mTracks->Add(newTracks[i]);
      newTracks[i]->SetSelected(true);
   }

   delete[]newTracks;

   if (initiallyEmpty) {
      mRate = newRate;
      mStatus->SetRate(mRate);
   } else if (rateWarning) {
      wxMessageBox(_("Warning: your file has multiple sampling rates.  "
                     "Audacity will ignore any track which is not at "
                     "the same sampling rate as the project."));
   }

   PushState(wxString::Format(_("Imported '%s'"), fileName.c_str()));
   ZoomFit();
   mTrackPanel->Refresh(false);

   if (initiallyEmpty) {
      wxString name =::TrackNameFromFileName(fileName);
      mFileName =::wxPathOnly(fileName) + wxFILE_SEP_PATH + name + ".aup";
      SetTitle(GetName());
   }

   HandleResize();
}
Ejemplo n.º 13
0
bool AudioView::ClickLabel(wxMouseEvent &event)
{
  VTrack *t = FindTrack(event.m_x, event.m_y, true);

  SelectNone();
  
  if (t) {
	t->selected = true;

	sel0 = 0.0;
	sel1 = t->GetMaxLen();
  }

  REDRAW(trackPanel);
  REDRAW(rulerPanel);
  
  return true;
}
Ejemplo n.º 14
0
void AudacityProject::OnImportRaw(wxCommandEvent & event)
{
   wxString path = gPrefs->Read("/DefaultOpenPath",::wxGetCwd());

   wxString fileName =
       wxFileSelector(_("Select any uncompressed audio file..."),
                      path,     // Path
                      "",       // Name
                      "",       // Extension
                      _("All files (*.*)|*.*"),
                      0,        // Flags
                      this);    // Parent

   if (fileName != "") {
      path =::wxPathOnly(fileName);
      gPrefs->Write("/DefaultOpenPath", path);

      WaveTrack *left = 0;
      WaveTrack *right = 0;

      if (::ImportRaw(this, fileName, &left, &right, &mDirManager)) {

         SelectNone();

         if (left) {
            mTracks->Add(left);
            left->SetSelected(true);
         }

         if (right) {
            mTracks->Add(right);
            right->SetSelected(true);
         }

         PushState(wxString::Format(_("Imported raw audio from '%s'"),
                                    fileName.c_str()));

         FixScrollbars();
         mTrackPanel->Refresh(false);
      }
   }
}
Ejemplo n.º 15
0
wxWindow* WindowStack::Remove(const wxString &key)
{
    std::map<wxString, wxWindow*>::iterator iter = m_windows.find(key);
    if(iter == m_windows.end()){
	return NULL;
    }

    wxWindow *win = iter->second;
    if(!win){
        return NULL;
    }

    if (m_selection == win) {
        SelectNone();
    }

    m_windows.erase(iter);

    return win;
}
Ejemplo n.º 16
0
void AudioView::Import()
{
  wxString fileName =
	wxFileSelector("Select an audio file...",
				   "", // Path
				   "", // Name
				   "", // Extension
				   "", // Wildcard
				   0, // Flags
				   GetFrame()); // Parent

  if (fileName == "")
    return;

  WaveTrack *left = 0;
  WaveTrack *right = 0;
  
  if (ImportWAV(fileName, &left, &right, &((AudioDoc *)GetDocument())->dirManager)) {

	if (left || right) {
	  SelectNone();
	}

    if (left) {
      GetTracks()->Add(left);
	  left->selected = true;
    }

    if (right) {
      GetTracks()->Add(right);
	  right->selected = true;
    }

    PushState();

    FixScrollbars();
    REDRAW(trackPanel);
    REDRAW(rulerPanel);
  }
  
}
Ejemplo n.º 17
0
void AudacityProject::OnImportLabels(wxCommandEvent & event)
{
   wxString path = gPrefs->Read("/DefaultOpenPath",::wxGetCwd());

   wxString fileName =
       wxFileSelector(_("Select a text file containing labels..."),
                      path,     // Path
                      "",       // Name
                      ".txt",   // Extension
                      _("Text files (*.txt)|*.txt|" "All files (*.*)|*.*"),
                      0,        // Flags
                      this);    // Parent

   if (fileName != "") {
      path =::wxPathOnly(fileName);
      gPrefs->Write("/DefaultOpenPath", path);

      wxTextFile f;

      f.Open(fileName);
      if (!f.IsOpened()) {
         wxMessageBox(_("Could not open file: ") + fileName);
         return;
      }

      LabelTrack *newTrack = new LabelTrack(&mDirManager);

      newTrack->Import(f);

      SelectNone();
      mTracks->Add(newTrack);
      newTrack->SetSelected(true);

      PushState(wxString::
                Format(_("Imported labels from '%s'"), fileName.c_str()));

      FixScrollbars();
      mTrackPanel->Refresh(false);
   }
}
Ejemplo n.º 18
0
BOOL LListCtrl::PreTranslateMessage(MSG* pMsg)
{
    // If edit control is visible in tree view control, sending a
    // WM_KEYDOWN message to the edit control will dismiss the edit
    // control.  When ENTER key was sent to the edit control, the parent
    // window of the tree view control is responsible for updating the
    // item's label in TVN_ENDLABELEDIT notification code.
    if ( pMsg->message == WM_KEYDOWN )
    {
        CHAR ckey=toupper( pMsg->wParam &0xFF );

        if ( VK_RETURN == pMsg->wParam )
            m_bEditNext = TRUE;
        if ( VK_ESCAPE == pMsg->wParam )
            m_bEditNext = FALSE;


        if( GetKeyState( VK_CONTROL )<-1 && (ckey== 'A') )
        {
            SelectAll();
            return TRUE;
        }
        if( GetKeyState( VK_CONTROL )<-1 && (ckey== 'N') )
        {
            SelectNone();
            return TRUE;
        }


        CEdit* edit = GetEditControl();
        if (edit)
        {
            //			LTRACE("Control key status = %d %d\n",LOBYTE(GetKeyState( VK_CONTROL )),HIWORD(GetKeyState( VK_CONTROL )));

            if( GetKeyState( VK_CONTROL )<-1 && (ckey== _T( 'C' ) ) )
            {
                edit->Copy();
                return TRUE;
            }
            if( GetKeyState( VK_CONTROL )<-1 && (ckey== _T( 'V' ) ) )
            {
                edit->Paste();
                return TRUE;
            }
            if( GetKeyState( VK_CONTROL )<-1 && (ckey== _T( 'X' ) ) )
            {
                edit->Cut();
                return TRUE;
            }
            if( GetKeyState( VK_CONTROL )<-1 && (ckey== _T( 'Z' ) ) )
            {
                edit->Undo();
                return TRUE;
            }
            if( pMsg->wParam == VK_RETURN || pMsg->wParam == VK_ESCAPE || pMsg->wParam == VK_CONTROL || pMsg->wParam == VK_INSERT || pMsg->wParam == VK_SHIFT )
            {
                edit->SendMessage(WM_KEYDOWN, pMsg->wParam, pMsg->lParam);
                return TRUE;
            }
        }
    }
    return CListCtrl::PreTranslateMessage(pMsg);
}
Ejemplo n.º 19
0
bool AudioView::ClickTrack(wxMouseEvent &event)
{
  wxRect r;
  int num;

  VTrack *t = FindTrack(event.m_x, event.m_y, false, &r, &num);

  if (t) {
	capturedTrack = t;
	capturedRect = r;
	capturedNum = num;
	
	mouseClickX = event.m_x;
	mouseClickY = event.m_y;

	mouseMostRecentX = event.m_x;
	mouseMostRecentY = event.m_y;

	if (mouseClickY >= r.y + r.height - 12 && mouseClickY < r.y + r.height) {
	  resizing = true;
	  initialTrackHeight = t->GetHeight();
	}
	else {
	  resizing = false;

	  if (event.ShiftDown()) { // Extend selection
		double selend = sinfo.h + ((event.m_x - r.x) / sinfo.zoom);
		
		if (selend > sel1) {
		  sel1 = selend;
		}
		else if (selend < sel0) {
		  sel0 = selend;
		} else {
		  // This is not ideal.  Fix???
		  sel1 = selend;
		  selstart = sel0;
		}
	  } 
	  else if (event.ControlDown()) {// Drag Track
		selstart = sinfo.h + ((event.m_x - r.x) / sinfo.zoom);

		dragging = true;
	  }
	  else { // Selecting
		dragging = false;

		selstart = sinfo.h + ((event.m_x - r.x) / sinfo.zoom);
		
		SelectNone();
		t->selected = true;
		
		sel0 = selstart;
		sel1 = selstart;
	  }
	}
	
    REDRAW(trackPanel);
  	REDRAW(rulerPanel);
	
	return true;
  }
  else {
	// No track was selected

	SelectNone();
	resizing = false;
	dragging = false;
    REDRAW(trackPanel);
  	REDRAW(rulerPanel);
    
    return true;
  }
}
Ejemplo n.º 20
0
void PtCloudGeom::HideAll()
{
    int n = m_Pts.size();
    m_Hidden.assign( n, true );
    SelectNone();
}
Ejemplo n.º 21
0
RipCD::RipCD(QWidget* parent)
    : QDialog(parent),
      transcoder_(new Transcoder(this)),
      queued_(0),
      finished_success_(0),
      finished_failed_(0),
      ui_(new Ui_RipCD) {

  // Init
  ui_->setupUi(this);

  // Set column widths in the QTableWidget.
  ui_->tableWidget->horizontalHeader()->setResizeMode(
      kCheckboxColumn, QHeaderView::ResizeToContents);
  ui_->tableWidget->horizontalHeader()->setResizeMode(
      kTrackNumberColumn, QHeaderView::ResizeToContents);
  ui_->tableWidget->horizontalHeader()->setResizeMode(kTrackTitleColumn,
                                                      QHeaderView::Stretch);

  // Add a rip button
  rip_button_ = ui_->button_box->addButton(tr("Start ripping"),
                                           QDialogButtonBox::ActionRole);
  cancel_button_ = ui_->button_box->button(QDialogButtonBox::Cancel);
  close_button_ = ui_->button_box->button(QDialogButtonBox::Close);

  // Hide elements
  cancel_button_->hide();
  ui_->progress_group->hide();

  connect(ui_->select_all_button, SIGNAL(clicked()), SLOT(SelectAll()));
  connect(ui_->select_none_button, SIGNAL(clicked()), SLOT(SelectNone()));
  connect(ui_->invert_selection_button, SIGNAL(clicked()),
          SLOT(InvertSelection()));
  connect(rip_button_, SIGNAL(clicked()), SLOT(ClickedRipButton()));
  connect(cancel_button_, SIGNAL(clicked()), SLOT(Cancel()));
  connect(close_button_, SIGNAL(clicked()), SLOT(hide()));

  connect(transcoder_, SIGNAL(JobComplete(QString, bool)),
          SLOT(JobComplete(QString, bool)));
  connect(transcoder_, SIGNAL(AllJobsComplete()), SLOT(AllJobsComplete()));
  connect(transcoder_, SIGNAL(JobOutputName(QString)),
          SLOT(AppendOutput(QString)));
  connect(this, SIGNAL(RippingComplete()), SLOT(ThreadedTranscoding()));
  connect(this, SIGNAL(SignalUpdateProgress()), SLOT(UpdateProgress()));

  connect(ui_->options, SIGNAL(clicked()), SLOT(Options()));
  connect(ui_->select, SIGNAL(clicked()), SLOT(AddDestination()));

  setWindowTitle(tr("Rip CD"));
  AddDestinationDirectory(QDir::homePath());

  cdio_ = cdio_open(nullptr, DRIVER_UNKNOWN);
  if (!cdio_) {
    qLog(Error) << "Failed to read CD drive";
    return;
  } else {
    i_tracks_ = cdio_get_num_tracks(cdio_);
    ui_->tableWidget->setRowCount(i_tracks_);
    for (int i = 1; i <= i_tracks_; i++) {
      QCheckBox* checkbox_i = new QCheckBox(ui_->tableWidget);
      checkbox_i->setCheckState(Qt::Checked);
      checkboxes_.append(checkbox_i);
      ui_->tableWidget->setCellWidget(i - 1, kCheckboxColumn, checkbox_i);
      ui_->tableWidget->setCellWidget(i - 1, kTrackNumberColumn,
                                      new QLabel(QString::number(i)));
      QString track_title = QString("Track %1").arg(i);
      QLineEdit* line_edit_track_title_i =
          new QLineEdit(track_title, ui_->tableWidget);
      track_names_.append(line_edit_track_title_i);
      ui_->tableWidget->setCellWidget(i - 1, kTrackTitleColumn,
                                      line_edit_track_title_i);
    }
  }
  // Get presets
  QList<TranscoderPreset> presets = Transcoder::GetAllPresets();
  qSort(presets.begin(), presets.end(), ComparePresetsByName);
  for (const TranscoderPreset& preset : presets) {
    ui_->format->addItem(
        QString("%1 (.%2)").arg(preset.name_, preset.extension_),
        QVariant::fromValue(preset));
  }

  // Load settings
  QSettings s;
  s.beginGroup(kSettingsGroup);
  last_add_dir_ = s.value("last_add_dir", QDir::homePath()).toString();

  QString last_output_format = s.value("last_output_format", "ogg").toString();
  for (int i = 0; i < ui_->format->count(); ++i) {
    if (last_output_format ==
        ui_->format->itemData(i).value<TranscoderPreset>().extension_) {
      ui_->format->setCurrentIndex(i);
      break;
    }
  }

  ui_->progress_bar->setValue(0);
  ui_->progress_bar->setMaximum(100);
}
Ejemplo n.º 22
0
RipCDDialog::RipCDDialog(QWidget* parent)
    : QDialog(parent),
      ui_(new Ui_RipCDDialog),
      ripper_(new Ripper(this)),
      working_(false) {
  // Init
  ui_->setupUi(this);

  // Set column widths in the QTableWidget.
  ui_->tableWidget->horizontalHeader()->setResizeMode(
      kCheckboxColumn, QHeaderView::ResizeToContents);
  ui_->tableWidget->horizontalHeader()->setResizeMode(
      kTrackNumberColumn, QHeaderView::ResizeToContents);
  ui_->tableWidget->horizontalHeader()->setResizeMode(kTrackTitleColumn,
                                                      QHeaderView::Stretch);

  // Add a rip button
  rip_button_ = ui_->button_box->addButton(tr("Start ripping"),
                                           QDialogButtonBox::ActionRole);
  cancel_button_ = ui_->button_box->button(QDialogButtonBox::Cancel);
  close_button_ = ui_->button_box->button(QDialogButtonBox::Close);

  // Hide elements
  cancel_button_->hide();
  ui_->progress_group->hide();

  connect(ui_->select_all_button, SIGNAL(clicked()), SLOT(SelectAll()));
  connect(ui_->select_none_button, SIGNAL(clicked()), SLOT(SelectNone()));
  connect(ui_->invert_selection_button, SIGNAL(clicked()),
          SLOT(InvertSelection()));
  connect(rip_button_, SIGNAL(clicked()), SLOT(ClickedRipButton()));
  connect(cancel_button_, SIGNAL(clicked()), ripper_, SLOT(Cancel()));
  connect(close_button_, SIGNAL(clicked()), SLOT(hide()));

  connect(ui_->options, SIGNAL(clicked()), SLOT(Options()));
  connect(ui_->select, SIGNAL(clicked()), SLOT(AddDestination()));

  connect(ripper_, SIGNAL(Finished()), SLOT(Finished()));
  connect(ripper_, SIGNAL(Cancelled()), SLOT(Cancelled()));
  connect(ripper_, SIGNAL(ProgressInterval(int, int)),
          SLOT(SetupProgressBarLimits(int, int)));
  connect(ripper_, SIGNAL(Progress(int)), SLOT(UpdateProgressBar(int)));

  setWindowTitle(tr("Rip CD"));
  AddDestinationDirectory(QDir::homePath());

  // Get presets
  QList<TranscoderPreset> presets = Transcoder::GetAllPresets();
  qSort(presets.begin(), presets.end(), ComparePresetsByName);
  for (const TranscoderPreset& preset : presets) {
    ui_->format->addItem(
        QString("%1 (.%2)").arg(preset.name_).arg(preset.extension_),
        QVariant::fromValue(preset));
  }

  // Load settings
  QSettings s;
  s.beginGroup(kSettingsGroup);
  last_add_dir_ = s.value("last_add_dir", QDir::homePath()).toString();

  QString last_output_format = s.value("last_output_format", "ogg").toString();
  for (int i = 0; i < ui_->format->count(); ++i) {
    if (last_output_format ==
        ui_->format->itemData(i).value<TranscoderPreset>().extension_) {
      ui_->format->setCurrentIndex(i);
      break;
    }
  }
}