void TranscriptionToolBar::OnEndOff(wxCommandEvent & WXUNUSED(event))
{

   //If IO is busy, abort immediately
   if (gAudioIO->IsBusy()){
      SetButton(false,mButtons[TTB_EndOff]);
      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) {
      sampleCount start,len;
      GetSamples((WaveTrack*)t, &start,&len);

      //Adjust length to end if selection is null
      if(len == 0) {
         len = start;
         start = 0;
      }
      sampleCount newEnd = mVk->OffBackward(*(WaveTrack*)t,start+ len,len);
      double newpos = newEnd / ((WaveTrack*)t)->GetRate();

      p->SetSel1(newpos);
      p->RedrawProject();

      SetButton(false, mButtons[TTB_EndOff]);
   }
}
void TranscriptionToolBar::OnEndOff(wxCommandEvent & WXUNUSED(event))
{

   //If IO is busy, abort immediately
   if (gAudioIO->IsBusy()){
      SetButton(false,mButtons[TTB_EndOff]);
      return;
   }
   mVk->AdjustThreshold(GetSensitivity());
   AudacityProject *p = GetActiveProject();

   auto t = *p->GetTracks()->Any< const WaveTrack >().begin();
   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 = start;
         start = 0;
      }
      auto newEnd = mVk->OffBackward(*wt, start + len, len);
      double newpos = newEnd.as_double() / wt->GetRate();

      p->SetSel1(newpos);
      p->RedrawProject();

      SetButton(false, mButtons[TTB_EndOff]);
   }
}
Пример #3
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]);
}
void TranscriptionToolBar::OnSelectSilence(wxCommandEvent & WXUNUSED(event))
{

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

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


   TrackList *tl = p->GetTracks();
   if(auto wt = *tl->Any<const WaveTrack>().begin()) {
      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->OnBackward(*wt, start, start);
      auto newend   =
      mVk->OnForward(*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_SelectSilence]);

}