Ejemplo n.º 1
0
SnapResults SnapManager::Snap
(Track *currentTrack, double t, bool rightEdge)
{

   SnapResults results;
   // Check to see if we need to reinitialize
   Reinit();

   results.timeSnappedTime = results.outTime = t;
   results.outCoord = mZoomInfo->TimeToPosition(t);

   // First snap to points in mSnapPoints
   results.snappedPoint =
      SnapToPoints(currentTrack, t, rightEdge, &results.outTime);

   if (mSnapToTime) {
      // Find where it would snap time to the grid
      mConverter.ValueToControls(t, GetActiveProject()->GetSnapTo() == SNAP_NEAREST);
      mConverter.ControlsToValue();
      results.timeSnappedTime = mConverter.GetValue();
   }

   results.snappedTime = false;
   if (mSnapToTime)
   {
      if (results.snappedPoint)
      {
         // Since mSnapPoints only contains points on the grid, we're done
         results.snappedTime = true;
      }
      else
      {
         results.outTime = results.timeSnappedTime;
         results.snappedTime = true;
      }
   }

   if (results.Snapped())
      results.outCoord = mZoomInfo->TimeToPosition(results.outTime);

   return results;
}
Ejemplo n.º 2
0
void TranscriptionToolBar::OnSelectSound(wxCommandEvent & WXUNUSED(event))
{

   //If IO is busy, abort immediately
   if (gAudioIO->IsBusy()){
      SetButton(false,mButtons[TTB_SelectSound]);
      return;
   }


   mVk->AdjustThreshold(GetSensitivity());
   AudacityProject *p = GetActiveProject();


   TrackList *tl = p->GetTracks();
   TrackListOfKindIterator iter(Track::Wave, tl);

   Track *t = iter.First();   //Make a track
   if(t)
      {
         auto wt = static_cast<const WaveTrack*>(t);
         sampleCount start, len;
         GetSamples(wt, &start, &len);

         //Adjust length to end if selection is null
         //if(len == 0)
         //len = wt->GetSequence()->GetNumSamples()-start;

         double rate =  wt->GetRate();
         auto newstart = mVk->OffBackward(*wt, start, start);
         auto newend   =
            mVk->OffForward(*wt, start + len, (int)(tl->GetEndTime() * rate));

         //reset the selection bounds.
         p->SetSel0(newstart.as_double() / rate);
         p->SetSel1(newend.as_double() /  rate);
         p->RedrawProject();

      }

   SetButton(false,mButtons[TTB_SelectSound]);
}
Ejemplo n.º 3
0
void LabelDialog::OnSelectCell(wxGridEvent &event)
{
   TrackListIterator iter(mTracks);
   Track *t = iter.First();
   while( t )
   {
      t->SetSelected( true );
      t = iter.Next();
   }

   if (!mData.empty())
   {
      RowData &rd = mData[event.GetRow()];
      mViewInfo->selectedRegion = rd.selectedRegion;

      GetActiveProject()->RedrawProject();
   }

   event.Skip();
}
Ejemplo n.º 4
0
void FileFormatPrefs::OnMP3FindButton(wxCommandEvent& evt)
{
   wxString oldPath = gPrefs->Read("/MP3/MP3LibPath", "");
 
   gPrefs->Write("/MP3/MP3LibPath", wxString(""));

   //Create dummy exporter to extract info from.
   MP3Exporter * tmpExporter = new PlatformMP3Exporter(GetActiveProject(),0.0,0.0,true,44100,2,0,0); 

   if (tmpExporter->FindLibrary(this))
      SetMP3VersionText();
   else {
      gPrefs->Write("/MP3/MP3LibPath", oldPath);
   }
   
   if(tmpExporter->GetConfigurationCaps() & MP3CONFIG_BITRATE)
     mMP3Bitrate->Enable(tmpExporter->ValidLibraryLoaded());

   delete tmpExporter;
}
Ejemplo n.º 5
0
void APalette::OnRecord()
{
   if (gAudioIO->IsBusy())
      return;

   AudacityProject *p = GetActiveProject();
   if (p) {
      TrackList *t = p->GetTracks();
      double t0 = p->GetSel0();
      double t1 = p->GetSel1();
      if (t1 == t0)
         t1 = 1000000000.0;  // record for a long, long time (tens of years)
      bool success = gAudioIO->StartRecord(p, t, t0, t1);
      if (!success) {
         SetPlay(false);
         SetStop(false);
         SetRecord(false);
      }
   }
}
Ejemplo n.º 6
0
static int rm_dash_rf_enumerate_prompt(wxString dirpath,
                                       wxArrayString &flist, 
                                       wxString dirspec,
                                       int files_p,int dirs_p,
                                       int progress_count,
                                       const wxChar *prompt){
   AudacityProject *p = GetActiveProject();

   if (p)
      p->ProgressShow(_("Progress"), prompt);

   int count=rm_dash_rf_enumerate_i(dirpath, flist, dirspec, files_p,dirs_p,
                                    progress_count,0,
                                    prompt);

   if (p)
      p->ProgressHide();

   return count;
}
Ejemplo n.º 7
0
void EffectRack::OnApply(wxCommandEvent & WXUNUSED(evt))
{
   AudacityProject *project = GetActiveProject();
   
   for (size_t i = 0, cnt = mEffects.GetCount(); i < cnt; i++)
   {
      if (mPowerState[i])
      {
         project->OnEffect(mEffects[i]->GetID(), true);

         mPowerState[i] = false;

         wxBitmapButton *btn = static_cast<wxBitmapButton *>(FindWindowById(ID_POWER + i));
         btn->SetBitmapLabel(mPowerRaised);
         btn->SetBitmapSelected(mPowerRaised);
      }
   }

   UpdateActive();
}
Ejemplo n.º 8
0
void ControlToolBar::PlayCurrentRegion(bool looped /* = false */,
                                       bool cutpreview /* = false */)
{
   AudacityProject *p = GetActiveProject();

   if (p)
   {
      if (looped)
         p->mLastPlayMode = loopedPlay;
      else
         p->mLastPlayMode = normalPlay;

      double playRegionStart, playRegionEnd;
      p->GetPlayRegion(&playRegionStart, &playRegionEnd);

      PlayPlayRegion(playRegionStart,
                     playRegionEnd,
                     looped, cutpreview);
   }
}
Ejemplo n.º 9
0
   // ModuleDispatch
   // is called by Audacity to initialize/terminmate the module,
   // and ask if it has anything for the menus.
   int ModuleDispatch(ModuleDispatchTypes type){
      switch (type){
         case AppQuiting: {
            //It is perfectly OK for gBench to be NULL.
            //Can happen if the menu item was never invoked.
            //wxASSERT(gBench != NULL);
            if (gBench) {
               gBench->Destroy();
               gBench = NULL;
            }
         }
         break;
         case ProjectInitialized:
         case MenusRebuilt:  {
            AudacityProject *p = GetActiveProject();
            wxASSERT(p != NULL);
            CommandManager *c = p->GetCommandManager();
            wxASSERT(c != NULL);

            wxMenuBar * pBar = p->GetMenuBar();
            wxASSERT(pBar != NULL );
            wxMenu * pMenu = pBar->GetMenu( 9 );  // Menu 9 is the Tools Menu.
            wxASSERT( pMenu != NULL );

            c->SetCurrentMenu(pMenu);
            c->AddSeparator();
            c->SetDefaultFlags(AudioIONotBusyFlag, AudioIONotBusyFlag);
            c->AddItem(wxT("NyqBench"),
               _("&Nyquist Workbench..."),
               true,
               findme,
               static_cast<CommandFunctorPointer>(&NyqBench::ShowNyqBench));

            c->ClearCurrentMenu();
         }
         break;
         default:
         break;
      }
      return 1;
   }
Ejemplo n.º 10
0
void TranscriptionToolBar::OnCalibrate(wxCommandEvent & WXUNUSED(event))
{
   //If IO is busy, abort immediately
   if (gAudioIO->IsBusy()){
      SetButton(false,mButtons[TTB_Calibrate]);
      return;
   }


   AudacityProject *p = GetActiveProject();

   TrackList *tl = p->GetTracks();
   if(auto wt = *tl->Any<const WaveTrack>().begin()) {
      sampleCount start, len;
      GetSamples(wt, &start, &len);

      mVk->CalibrateNoise(*wt, start, len);
      mVk->AdjustThreshold(3);

      mButtons[TTB_StartOn]->Enable();
      mButtons[TTB_StartOff]->Enable();
      mButtons[TTB_EndOn]->Enable();
      mButtons[TTB_EndOff]->Enable();
      //mThresholdSensitivity->Set(3);

      SetButton(false,mButtons[TTB_Calibrate]);
   }

   mButtons[TTB_StartOn]->Enable();
   mButtons[TTB_StartOff]->Enable();
   mButtons[TTB_EndOn]->Enable();
   mButtons[TTB_EndOff]->Enable();
   mButtons[TTB_SelectSound]->Enable();
   mButtons[TTB_SelectSilence]->Enable();
   mButtons[TTB_AutomateSelection]->Enable();

   //Make the sensititivy slider set the sensitivity by processing an event.
   wxCommandEvent dummy;
   OnSensitivitySlider(dummy);

}
Ejemplo n.º 11
0
void ControlToolBar::EnableDisableButtons()
{
   //TIDY-ME: Button logic could be neater.
   AudacityProject *p = GetActiveProject();
   bool tracks = false;
   bool playing = mPlay->IsDown();
   bool recording = mRecord->IsDown();
   bool busy = gAudioIO->IsBusy() || playing || recording;

   // Only interested in audio type tracks
   if (p) {
      TrackListIterator iter( p->GetTracks() );
      for (Track *t = iter.First(); t; t = iter.Next()) {
         if (t->GetKind() == Track::Wave
#if defined(USE_MIDI)
         || t->GetKind() == Track::Note
#endif
         ) {
            tracks = true;
            break;
         }
      }
   }

   const bool enablePlay = (!recording) || (tracks && !busy);
   mPlay->SetEnabled(enablePlay);
   // Enable and disable the other play button 
   if (p)
   {
      TranscriptionToolBar *const pttb = p->GetTranscriptionToolBar();
      if (pttb)
         pttb->SetEnabled(enablePlay);
   }

   mRecord->SetEnabled(!busy && !playing);

   mStop->SetEnabled(busy);
   mRewind->SetEnabled(!busy);
   mFF->SetEnabled(tracks && !busy);
   mPause->SetEnabled(true);
}
Ejemplo n.º 12
0
   // ModuleDispatch
   // is called by Audacity to initialize/terminmate the module,
   // and ask if it has anything for the menus.
   int ModuleDispatch(ModuleDispatchTypes type){
      switch (type){
         case AppInitialized:{
            wxASSERT(gBench == NULL);
            gBench = new NyqBench(NULL);
         }
         break;
         case AppQuiting: {
            wxASSERT(gBench != NULL);
            if (gBench) {
               delete gBench;
               gBench = NULL;
            }
         }
         break;
         case ProjectInitialized:
         case MenusRebuilt:  {
            AudacityProject *p = GetActiveProject();
            wxASSERT(p != NULL);
            CommandManager *c = p->GetCommandManager();
            wxASSERT(c != NULL);

            wxMenuBar * pBar = p->GetMenuBar();
            wxASSERT(pBar != NULL );
            wxMenu * pMenu = pBar->GetMenu( 2 );  // Menu 2 is the View Menu.
            wxASSERT( pMenu != NULL );

            c->SetToMenu( pMenu );
            c->AddSeparator();
            // c->BeginMenu(_("T&ools"));
            c->SetDefaultFlags(AudioIONotBusyFlag, AudioIONotBusyFlag);
            c->AddItem(wxT("NyqBench"),
                       _("&Nyquist Workbench..."),
                       new ModNyqBenchCommandFunctor());
         }
         break;
         default:
         break;
      }
      return 1;
   }
Ejemplo n.º 13
0
void ControlToolBar::OnPlay(wxCommandEvent & WXUNUSED(evt))
{
   auto doubleClicked = mPlay->IsDoubleClicked();
   mPlay->ClearDoubleClicked();

   auto p = GetActiveProject();

   if (doubleClicked)
      p->GetPlaybackScroller().Activate(true);
   else {
      if (!CanStopAudioStream())
         return;

      StopPlaying();

      if (p) p->TP_DisplaySelection();

      PlayDefault();
      UpdateStatusBar(p);
   }
}
Ejemplo n.º 14
0
void InitFreqWindow(wxWindow * parent)
{
   AudacityProject* p = GetActiveProject();
   if (!p)
      return;

   if(!p->mFreqWindow)
   {
      wxPoint where;

      where.x = 150;
      where.y = 150;

      p->mFreqWindow = new FreqWindow(parent, -1, _("Frequency Analysis"), where);
   }
   wxCommandEvent dummy;
   p->mFreqWindow->OnReplot(dummy);
   p->mFreqWindow->Show(true);
   p->mFreqWindow->Raise();
   p->mFreqWindow->SetFocus();
}
Ejemplo n.º 15
0
void NyqBench::OnRunUpdate(wxUpdateUIEvent & e)
{
   AudacityProject *p = GetActiveProject();
   wxToolBar *tbar = GetToolBar();
   wxMenuBar *mbar = GetMenuBar();

   if (p && gAudioIO->IsBusy()) {
      mbar->Enable(ID_GO, false);
      mbar->Enable(ID_STOP, false);

      tbar->EnableTool(ID_GO, false);
      tbar->EnableTool(ID_STOP, false);
   }
   else {
      mbar->Enable(ID_GO, (mScript->GetLastPosition() > 0) && !mRunning);
      mbar->Enable(ID_STOP, (mScript->GetLastPosition() > 0) && mRunning);

      tbar->EnableTool(ID_GO, (mScript->GetLastPosition() > 0) && !mRunning);
      tbar->EnableTool(ID_STOP, (mScript->GetLastPosition() > 0) && mRunning);
   }
}
Ejemplo n.º 16
0
// Gets all commands that are valid for this mode.
wxArrayString BatchCommands::GetAllCommands()
{
   wxArrayString commands;
   wxString command;
   commands.Clear();

   AudacityProject *project = GetActiveProject();
   if (!project)
      return commands;

   EffectArray * effects;
   unsigned int i;

   for(i=0;i<sizeof(SpecialCommands)/sizeof(SpecialCommands[0]);i++)
   {
      commands.Add( SpecialCommands[i] );
   }
   
   int additionalEffects=ADVANCED_EFFECT;
   if( project->GetCleanSpeechMode() )
       additionalEffects = 0;
   effects = Effect::GetEffects(PROCESS_EFFECT | BUILTIN_EFFECT | additionalEffects);
   for(i=0; i<effects->GetCount(); i++) {
      command=(*effects)[i]->GetEffectName();
      command.Replace( wxT("..."), wxT(""));
      commands.Add( command);
   }
   delete effects;

/* This is for later in development: include the menu commands.
   CommandManager * mManager = project->GetCommandManager();
   wxArrayString mNames;
   mNames.Clear();
   mManager->GetAllCommandNames(mNames, false);
   for(i=0; i<mNames.GetCount(); i++) {
      commands.Add( mNames[i] );
   }
*/
   return commands;
}
Ejemplo n.º 17
0
void EffectNoiseRemoval::CleanSpeechMayReadNoisegate()
{
   int halfWindowSize = mWindowSize / 2;

   //lda-131a always try to get noisegate.nrp if in CleanSpeechMode
   // and it exists
   AudacityProject * project = GetActiveProject();
   if (project == NULL) {
      int mode = gPrefs->Read(wxT("/Batch/CleanSpeechMode"), 0L);
      if (mode == 0) {
         return;
      }
   }

   // Try to open the file.
   if( !wxDirExists( FileNames::NRPDir() ))
      return;

   // if file doesn't exist, return quietly.
   wxString fileName = FileNames::NRPFile();
   if( !wxFileExists( fileName ))
      return;

   wxFFile noiseGateFile(fileName, wxT("rb"));
   bool flag = noiseGateFile.IsOpened();
   if (flag != true)
      return;

   // Now get its data.
   int expectedCount = halfWindowSize * sizeof(float);
   int count = noiseGateFile.Read(mNoiseThreshold, expectedCount);
   noiseGateFile.Close();
   if (count == expectedCount) {
      for (int i = halfWindowSize; i < mSpectrumSize; ++i) {
         mNoiseThreshold[i] = float(0.0);  // only partly filled by Read?
      }
      mHasProfile = true;
      mDoProfile = false;
   }
}
Ejemplo n.º 18
0
int AudacityApp::OnAllKeys(wxKeyEvent& event)
{
   AudacityProject *audacityPrj = GetActiveProject();

   if (!audacityPrj) {
      return -1;
   }

   if(audacityPrj->IsActive())
   {
      if (event.GetEventType() == wxEVT_KEY_DOWN) {
         if (audacityPrj->HandleKeyDown(event))
            return true;
      }
      if (event.GetEventType() == wxEVT_KEY_UP) {
         if (audacityPrj->HandleKeyUp(event))
            return true;
      }
   }

   return -1;
}
Ejemplo n.º 19
0
const char * vsnet_addin::get_project_path()
{
	EnvDTE::ProjectPtr pProj;
	if (GetActiveProject(pProj) == S_FALSE || pProj == NULL)
	{
		return "";
	}
	EnvDTE::DocumentPtr pDoc;
	EnvDTE::TextDocumentPtr doc;
	EnvDTE::TextSelectionPtr p;
	CComBSTR name;
	pProj->get_FullName(&name);
	static CString s_path;
	s_path = name;
	int pos = s_path.ReverseFind(_T('\\'));
	if (pos)
	{
		s_path = s_path.Left(pos);
		return (char*)(const char*)s_path;
	}
	return "";
}
Ejemplo n.º 20
0
void TranscriptionToolBar::GetSamples(
   const WaveTrack *t, sampleCount *s0, sampleCount *slen)
{
   // GetSamples attempts to translate the start and end selection markers into sample indices
   // These selection numbers are doubles.

   AudacityProject *p = GetActiveProject();
   if (!p) {
      return;
   }

   //First, get the current selection. It is part of the mViewInfo, which is
   //part of the project

   const auto &selectedRegion = p->GetViewInfo().selectedRegion;
   double start = selectedRegion.t0();
   double end = selectedRegion.t1();

   auto ss0 = sampleCount( (start - t->GetOffset()) * t->GetRate() );
   auto ss1 = sampleCount( (end - t->GetOffset()) * t->GetRate() );

   if (start < t->GetOffset()) {
      ss0 = 0;
   }

#if 0
   //This adjusts the right samplecount to the maximum sample.
   if (ss1 >= t->GetNumSamples()) {
      ss1 = t->GetNumSamples();
   }
#endif

   if (ss1 < ss0) {
      ss1 = ss0;
   }

   *s0 = ss0;
   *slen = ss1 - ss0;
}
Ejemplo n.º 21
0
void NyqBench::OnGo(wxCommandEvent & e)
{
    mEffect->SetCommand(mScript->GetValue());

    AudacityProject *p = GetActiveProject();
    wxASSERT(p != NULL);

    if (p) {
        wxWindowDisabler disable(this);
        NyqRedirector redir((NyqTextCtrl *)mOutput);

        mRunning = true;
        UpdateWindowUI();

        p->OnEffect(ALL_EFFECTS, mEffect->GetID());

        mRunning = false;
        UpdateWindowUI();
    }

    Raise();
}
Ejemplo n.º 22
0
void Lyrics::Update(double t)
{
   if (t < 0.0)
   {
      // TrackPanel::OnTimer passes gAudioIO->GetStreamTime(), which is -1000000000 if !IsStreamActive().
      // In that case, use the selection start time.
      AudacityProject* pProj = GetActiveProject();
      mT = pProj->GetSel0();
   }
   else
      mT = t;

   if (mLyricsStyle == kBouncingBallLyrics)
   {
      wxRect karaokeRect(0, 0, mWidth, mKaraokeHeight);
      this->Refresh(false, &karaokeRect);
   }

   int i = FindSyllable(mT);
   if (i == mCurrentSyllable)
      return;

   mCurrentSyllable = i;

   if (mLyricsStyle == kHighlightLyrics)
   {
      mHighlightTextCtrl->SetSelection(mSyllables[i].char0, mSyllables[i].char1);

      //v No trail for now.
      //// Leave a trail behind the selection, by highlighting.
      //if (i == I_FIRST_REAL_SYLLABLE)
      //   // Reset the trail to zero.
      //   mHighlightTextCtrl->SetStyle(0, mHighlightTextCtrl->GetLastPosition(), wxTextAttr(wxNullColour, *wxWHITE));
      //// Mark the trail for mSyllables[i].
      //mHighlightTextCtrl->SetStyle(mSyllables[i].char0, mSyllables[i].char1, wxTextAttr(wxNullColour, *wxLIGHT_GREY));

      //v Too much flicker:   mHighlightTextCtrl->ShowPosition(mSyllables[i].char0);
   }
}
Ejemplo n.º 23
0
void APalette::OnPlay()
{
   if (gAudioIO->IsBusy())
      return;

   AudacityProject *p = GetActiveProject();
   if (p) {
      TrackList *t = p->GetTracks();
      double t0 = p->GetSel0();
      double t1 = p->GetSel1();
      if (t1 == t0)
         t1 = t->GetMaxLen();
      bool success = gAudioIO->StartPlay(p, t, t0, t1);

      if (!success) {
         SetPlay(false);
         SetStop(false);
         SetRecord(false);
      }

   }
}
Ejemplo n.º 24
0
void FileFormatPrefs::SetMP3VersionText()
{
   wxString versionString;
   bool doMP3 = true;
   
   //Create dummy exporter to extract info from.
   MP3Exporter * tmpExporter = new PlatformMP3Exporter(GetActiveProject(),0.0,0.0,true,44100,2,0,0); 

   doMP3 = tmpExporter->LoadLibrary();

   if (doMP3)
      doMP3 = tmpExporter->ValidLibraryLoaded();

   if(doMP3)
      versionString = tmpExporter->GetLibraryVersion();
   else
      versionString = _("MP3 exporting plugin not found");
   
   delete tmpExporter;

   mMP3Version->SetLabel(versionString);
}
Ejemplo n.º 25
0
void LabelDialog::OnSelectCell(wxGridEvent &event)
{
   TrackListIterator iter(mTracks);
   Track *t = iter.First();
   RowData *rd;

   rd = mData[event.GetRow()];

   t = iter.First();
   while( t )
   {
      t->SetSelected( true );
      t = iter.Next();
   }

   mViewInfo->sel0 = rd->stime;
   mViewInfo->sel1 = rd->etime;

   GetActiveProject()->RedrawProject();

   event.Skip();
}
Ejemplo n.º 26
0
// This is the function that connects us to Audacity.
MOD_TRACK_PANEL_DLL_API int ModuleDispatch(ModuleDispatchTypes type)
{
   switch (type)
   {
   case AppInitialized:
      Registrar::Start();
      // Demand that all track panels be created using the TrackPanel2Factory.
      TrackPanel::FactoryFunction = TrackPanel2Factory;
      break;
   case AppQuiting:
      Registrar::Finish();
      break;
   case ProjectInitialized:
   case MenusRebuilt:
      {
         AudacityProject *p = GetActiveProject();
         if( p== NULL )
            return 0;

         wxMenuBar * pBar = p->GetMenuBar();
         wxMenu * pMenu = pBar->GetMenu( 7 );  // Menu 7 is the Analyze Menu.
         CommandManager * c = p->GetCommandManager();

         c->SetToMenu( pMenu );
         c->AddSeparator();
         // We add two new commands into the Analyze menu.
         c->AddItem( _T("Extra Dialog..."), _T("Experimental Extra Dialog for whatever you want."),
            ModTrackPanelFN( OnFuncShowAudioExplorer ) );
         //Second menu tweak no longer needed as we always make TrackPanel2's.
         //c->AddItem( _T("Replace TrackPanel..."), _T("Replace Current TrackPanel with TrackPanel2"),
         //   ModTrackPanelFN( OnFuncReplaceTrackPanel ) );
      }
      break;
   default:
      break;
   }

   return 1;
}
Ejemplo n.º 27
0
void ControlToolBar::StopPlaying(bool stopStream /* = true*/)
{
   mStop->PushDown();

   SetStop(false);
   if(stopStream)
      gAudioIO->StopStream();
   SetPlay(false);
   SetRecord(false);

   #ifdef AUTOMATED_INPUT_LEVEL_ADJUSTMENT
      gAudioIO->AILADisable();
   #endif

   mPause->PopUp();
   mPaused=false;
   //Make sure you tell gAudioIO to unpause
   gAudioIO->SetPaused(mPaused);

   ClearCutPreviewTracks();

   mBusyProject = NULL;
   // So that we continue monitoring after playing or recording.
   // also clean the MeterQueues
   AudacityProject *project = GetActiveProject();
   if( project ) {
      project->MayStartMonitoring();

      Meter *meter = project->GetPlaybackMeter();
      if( meter ) {
         meter->Clear();
      }
      
      meter = project->GetCaptureMeter();
      if( meter ) {
         meter->Clear();
      }
   }
}
Ejemplo n.º 28
0
void ControlToolBar::OnKeyEvent(wxKeyEvent & event)
{
   if (event.ControlDown() || event.AltDown()) {
      event.Skip();
      return;
   }

   if (event.GetKeyCode() == WXK_SPACE) {
      if (gAudioIO->IsStreamActive(GetActiveProject()->GetAudioIOToken())) {
         SetPlay(false);
         SetStop(true);
         StopPlaying();
      }
      else if (!gAudioIO->IsBusy()) {
         //SetPlay(true);// Not needed as done in PlayPlayRegion
         SetStop(false);
         PlayCurrentRegion();
      }
      return;
   }
   event.Skip();
}
Ejemplo n.º 29
0
void ControlToolBar::SetupCutPreviewTracks(double WXUNUSED(playStart), double cutStart,
                                           double cutEnd, double  WXUNUSED(playEnd))
{
   ClearCutPreviewTracks();
   AudacityProject *p = GetActiveProject();
   if (p) {
      // Find first selected track (stereo or mono) and duplicate it
      Track *track1 = NULL, *track2 = NULL;
      TrackListIterator it(p->GetTracks());
      for (Track *t = it.First(); t; t = it.Next())
      {
         if (t->GetKind() == Track::Wave && t->GetSelected())
         {
            track1 = t;
            track2 = t->GetLink();
            break;
         }
      }

      if (track1)
      {
         // Duplicate and change tracks
         auto new1 = track1->Duplicate();
         new1->Clear(cutStart, cutEnd);
         decltype(new1) new2{};
         if (track2)
         {
            new2 = track2->Duplicate();
            new2->Clear(cutStart, cutEnd);
         }

         mCutPreviewTracks = new TrackList();
         mCutPreviewTracks->Add(std::move(new1));
         if (track2)
            mCutPreviewTracks->Add(std::move(new2));
      }
   }
}
Ejemplo n.º 30
0
/// HandleTextualCommand() allows us a limitted version of script/batch
/// behavior, since we can get from a string command name to the actual
/// code to run.
bool CommandManager::HandleTextualCommand(wxString & Str, wxUint32 flags, wxUint32 mask)
{
   unsigned int i;

   // Linear search for now...
   for (i = 0; i < mCommandList.GetCount(); i++)
   {
      if (!mCommandList[i]->multi)
      {
         if( Str.IsSameAs( mCommandList[i]->name ))
         {
            return HandleCommandEntry( mCommandList[i], flags, mask);
         }
      }
   }
   // Not one of the singleton commands.
   // We could/should try all the list-style commands.
   // instead we only try the effects.
   AudacityProject * proj = GetActiveProject();
   if( !proj )
   {
      return false;
   }

   PluginManager & pm = PluginManager::Get();
   EffectManager & em = EffectManager::Get();
   const PluginDescriptor *plug = pm.GetFirstPlugin(PluginTypeEffect);
   while (plug)
         {
      if (em.GetEffectName(plug->GetID()).IsSameAs(Str))
      {
         return proj->OnEffect( ALL_EFFECTS | CONFIGURED_EFFECT, plug->GetID()); 
      }
      plug = pm.GetNextPlugin(PluginTypeEffect);
   }

   return false;
}