Exemplo n.º 1
0
void ControlToolBar::PlayCurrentRegion(bool looped /* = false */,
                                       bool cutpreview /* = false */)
{
   if (!CanStopAudioStream())
      return;

   AudacityProject *p = GetActiveProject();

   if (p)
   {

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

      AudioIOStartStreamOptions options(p->GetDefaultPlayOptions());
      options.playLooped = looped;
      if (cutpreview)
         options.timeTrack = NULL;
      ControlToolBar::PlayAppearance appearance =
        cutpreview ? ControlToolBar::PlayAppearance::CutPreview
           : looped ? ControlToolBar::PlayAppearance::Looped
           : ControlToolBar::PlayAppearance::Straight;
      PlayPlayRegion(SelectedRegion(playRegionStart, playRegionEnd),
                     options,
                     (looped ? PlayMode::loopedPlay : PlayMode::normalPlay),
                     appearance);
   }
}
Exemplo n.º 2
0
// Come here from button clicks, or commands
void TranscriptionToolBar::PlayAtSpeed(bool looped, bool cutPreview)
{
   // Can't do anything without an active project
   AudacityProject * p = GetActiveProject();
   if (!p) {
      return;
   }

   // Create a TimeTrack if we haven't done so already
   if (!mTimeTrack) {
      mTimeTrack = p->GetTrackFactory()->NewTimeTrack();
      if (!mTimeTrack) {
         return;
      }
   }

   // Pop up the button
   SetButton(false, mButtons[TTB_PlaySpeed]);

   // If IO is busy, abort immediately
   if (gAudioIO->IsBusy()) {
      p->GetControlToolBar()->StopPlaying();
   }

   // Set the speed range
   //mTimeTrack->SetRangeUpper((double)mPlaySpeed / 100.0);
   //mTimeTrack->SetRangeLower((double)mPlaySpeed / 100.0);
   mTimeTrack->GetEnvelope()->Flatten((double)mPlaySpeed / 100.0);

   // Get the current play region
   double playRegionStart, playRegionEnd;
   p->GetPlayRegion(&playRegionStart, &playRegionEnd);

   // Start playing
   if (playRegionStart >= 0) {
//      playRegionEnd = playRegionStart + (playRegionEnd-playRegionStart)* 100.0/mPlaySpeed;
#ifdef EXPERIMENTAL_MIDI_OUT
      gAudioIO->SetMidiPlaySpeed(mPlaySpeed);
#endif
      AudioIOStartStreamOptions options(p->GetDefaultPlayOptions());
      options.playLooped = looped;
      options.timeTrack = mTimeTrack.get();
      ControlToolBar::PlayAppearance appearance =
         cutPreview ? ControlToolBar::PlayAppearance::CutPreview
         : looped ? ControlToolBar::PlayAppearance::Looped
         : ControlToolBar::PlayAppearance::Straight;
      p->GetControlToolBar()->PlayPlayRegion
         (SelectedRegion(playRegionStart, playRegionEnd),
          options,
          PlayMode::normalPlay,
          appearance);
   }
}
Exemplo n.º 3
0
void TranscriptionToolBar::OnPlaySpeed(wxCommandEvent & WXUNUSED(event))
{
   // Can't do anything without an active project
   AudacityProject * p = GetActiveProject();
   if (!p) {
      return;
   }

   // Create a TimeTrack if we haven't done so already
   if (!mTimeTrack) {
      mTimeTrack = new TimeTrack(p->GetDirManager());
      if (!mTimeTrack) {
         return;
      }
   }

   // Pop up the button
   SetButton(false, mButtons[TTB_PlaySpeed]);

   // If IO is busy, abort immediately
   if (gAudioIO->IsBusy()) {
      p->GetControlToolBar()->StopPlaying();
   }

   // Set the speed range
   //mTimeTrack->SetRangeUpper((double)mPlaySpeed / 100.0);
   //mTimeTrack->SetRangeLower((double)mPlaySpeed / 100.0);
   mTimeTrack->GetEnvelope()->Flatten((double)mPlaySpeed / 100.0);

   // Get the current play region
   double playRegionStart, playRegionEnd;
   p->GetPlayRegion(&playRegionStart, &playRegionEnd);

   // Start playing
   if (playRegionStart >= 0) {
//      playRegionEnd = playRegionStart + (playRegionEnd-playRegionStart)* 100.0/mPlaySpeed;
#ifdef EXPERIMENTAL_MIDI_OUT
      gAudioIO->SetMidiPlaySpeed(mPlaySpeed);
#endif
      p->GetControlToolBar()->PlayPlayRegion(playRegionStart,
                                             playRegionEnd,
                                             false,
                                             false,
                                             mTimeTrack);
   }
}
Exemplo n.º 4
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);
   }
}
// Come here from button clicks, or commands
void TranscriptionToolBar::PlayAtSpeed(bool looped, bool cutPreview)
{
   // Can't do anything without an active project
   AudacityProject * p = GetActiveProject();
   if (!p) {
      return;
   }

   // Fixed speed play is the old method, that uses a time track.
   // VariSpeed play reuses Scrubbing.
   bool bFixedSpeedPlay = !gPrefs->ReadBool(wxT("/AudioIO/VariSpeedPlay"), true);
   // Scrubbing doesn't support note tracks, but the fixed-speed method using time tracks does.
   if (p->GetTracks()->Any<NoteTrack>())
      bFixedSpeedPlay = true;

   // Scrubbing only supports straight through play.
   // So if looped or cutPreview, we have to fall back to fixed speed.
   bFixedSpeedPlay = bFixedSpeedPlay || looped || cutPreview;
   if (bFixedSpeedPlay)
   {
      // Create a TimeTrack if we haven't done so already
      if (!mTimeTrack) {
         mTimeTrack = p->GetTrackFactory()->NewTimeTrack();
         if (!mTimeTrack) {
            return;
         }
      }
      // Set the speed range
      //mTimeTrack->SetRangeUpper((double)mPlaySpeed / 100.0);
      //mTimeTrack->SetRangeLower((double)mPlaySpeed / 100.0);
      mTimeTrack->GetEnvelope()->Flatten((double)mPlaySpeed / 100.0);
   }

   // Pop up the button
   SetButton(false, mButtons[TTB_PlaySpeed]);

   // If IO is busy, abort immediately
   if (gAudioIO->IsBusy()) {
      p->GetControlToolBar()->StopPlaying();
   }

   // Get the current play region
   double playRegionStart, playRegionEnd;
   p->GetPlayRegion(&playRegionStart, &playRegionEnd);

   // Start playing
   if (playRegionStart < 0)
      return;
   if (bFixedSpeedPlay)
   {
      AudioIOStartStreamOptions options(p->GetDefaultPlayOptions());
      options.playLooped = looped;
      // No need to set cutPreview options.
      // Due to a rather hacky approach, the appearance is used
      // to signal use of cutpreview to code below.
      options.timeTrack = mTimeTrack.get();
      ControlToolBar::PlayAppearance appearance =
         cutPreview ? ControlToolBar::PlayAppearance::CutPreview
         : looped ? ControlToolBar::PlayAppearance::Looped
         : ControlToolBar::PlayAppearance::Straight;
      p->GetControlToolBar()->PlayPlayRegion
         (SelectedRegion(playRegionStart, playRegionEnd),
            options,
            PlayMode::normalPlay,
            appearance);
   }
   else
   {
      Scrubber &Scrubber = p->GetScrubber();
      Scrubber.StartSpeedPlay(GetPlaySpeed(), playRegionStart, playRegionEnd);
   }
}