src/toolbars/TranscriptionToolBar.cpp
// Come here from button clicks, or commands
Come here from button clicks, or commands
Come here from button clicks or commands
void TranscriptionToolBar::PlayAtSpeed(bool looped, bool cutPreview)
{
   AudacityProject *p = &mProject;
   if (!p) {
      return;
   }
   auto &projectAudioManager = ProjectAudioManager::Get( mProject );
   bool bFixedSpeedPlay = !gPrefs->ReadBool(wxT("/AudioIO/VariSpeedPlay"), true);
   if ( TrackList::Get( *p ).Any< NoteTrack >() )
      bFixedSpeedPlay = true;
   if (looped)
      cutPreview = false;
   bFixedSpeedPlay = bFixedSpeedPlay || looped || cutPreview;
   if (bFixedSpeedPlay)
   {
      if (!mEnvelope) {
         mEnvelope =
            std::make_unique<BoundedEnvelope>(
               true, TIMETRACK_MIN, TIMETRACK_MAX, 1.0);
         mEnvelope->SetRangeLower( 0.9 );
         mEnvelope->SetRangeUpper( 1.1 );
      }
      mEnvelope->Flatten((double)mPlaySpeed / 100.0);
   }
   SetButton(false, mButtons[TTB_PlaySpeed]);
   auto gAudioIO = AudioIOBase::Get();
   if (gAudioIO->IsBusy())
      projectAudioManager.Stop();
   const auto &viewInfo = ViewInfo::Get( *p );
   const auto &playRegion = viewInfo.playRegion;
   if (playRegion.GetStart() < 0)
      return;
   if (bFixedSpeedPlay)
   {
      auto options = DefaultPlayOptions( *p, looped );
      options.envelope = mEnvelope.get();
      auto mode =
         cutPreview ? PlayMode::cutPreviewPlay
         : looped ? PlayMode::loopedPlay
         : PlayMode::normalPlay;
      projectAudioManager.PlayPlayRegion(
         SelectedRegion(playRegion.GetStart(), playRegion.GetEnd()),
            options,
            mode);
   }
   else
   {
      auto &scrubber = Scrubber::Get( *p );
      scrubber.StartSpeedPlay(GetPlaySpeed(),
         playRegion.GetStart(), playRegion.GetEnd());
   }
}
void TranscriptionToolBar :: PlayAtSpeed ( bool looped , bool cutPreview ) { AudacityProject * p = & mProject ; if ( ! p ) { return ; } auto & projectAudioManager = ProjectAudioManager :: Get ( mProject ) ; bool bFixedSpeedPlay = ! gPrefs -> ReadBool ( wxT ( " " ) , true ) ; if ( TrackList :: Get ( * p ) . Any < NoteTrack > ( ) ) bFixedSpeedPlay = true ; if ( looped ) cutPreview = false ; bFixedSpeedPlay = bFixedSpeedPlay || looped || cutPreview ; if ( bFixedSpeedPlay ) { if ( ! mEnvelope ) { mEnvelope = std :: make_unique < BoundedEnvelope > ( true , TIMETRACK_MIN , TIMETRACK_MAX , 1.0 ) ; mEnvelope -> SetRangeLower ( 0.9 ) ; mEnvelope -> SetRangeUpper ( 1.1 ) ; } mEnvelope -> Flatten ( ( double ) mPlaySpeed / 100.0 ) ; } SetButton ( false , mButtons [ TTB_PlaySpeed ] ) ; auto gAudioIO = AudioIOBase :: Get ( ) ; if ( gAudioIO -> IsBusy ( ) ) projectAudioManager . Stop ( ) ; const auto & viewInfo = ViewInfo :: Get ( * p ) ; const auto & playRegion = viewInfo . playRegion ; if ( playRegion . GetStart ( ) < 0 ) return ; if ( bFixedSpeedPlay ) { auto options = DefaultPlayOptions ( * p , looped ) ; options . envelope = mEnvelope . get ( ) ; auto mode = cutPreview ? PlayMode :: cutPreviewPlay : looped ? PlayMode :: loopedPlay : PlayMode :: normalPlay ; projectAudioManager . PlayPlayRegion ( SelectedRegion ( playRegion . GetStart ( ) , playRegion . GetEnd ( ) ) , options , mode ) ; } else { auto & scrubber = Scrubber :: Get ( * p ) ; scrubber . StartSpeedPlay ( GetPlaySpeed ( ) , playRegion . GetStart ( ) , playRegion . GetEnd ( ) ) ; } }
Come here from button clicks, or commands
Come here from button clicks or commands
// Can't do anything without an active project // Fixed speed play is the old method, that uses a time track. // VariSpeed play reuses Scrubbing. // Scrubbing doesn't support note tracks, but the fixed-speed method using time tracks does. // Scrubbing only supports straight through play. // So if looped or cutPreview, we have to fall back to fixed speed. // Create a BoundedEnvelope if we haven't done so already // values as in the constructor for TimeTrack // Set the speed range //mTimeTrack->SetRangeUpper((double)mPlaySpeed / 100.0); //mTimeTrack->SetRangeLower((double)mPlaySpeed / 100.0); // Pop up the button // If IO is busy, abort immediately // Get the current play region // Start playing // No need to set cutPreview options.