Audacity  3.2.0
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
ProjectAudioManager Class Referencefinal

#include <ProjectAudioManager.h>

Inheritance diagram for ProjectAudioManager:
[legend]
Collaboration diagram for ProjectAudioManager:
[legend]

Public Member Functions

 ProjectAudioManager (AudacityProject &project)
 
 ProjectAudioManager (const ProjectAudioManager &) PROHIBITED
 
ProjectAudioManageroperator= (const ProjectAudioManager &) PROHIBITED
 
 ~ProjectAudioManager () override
 
bool IsTimerRecordCancelled ()
 
void SetTimerRecordCancelled ()
 
void ResetTimerRecordCancelled ()
 
bool Paused () const
 
bool Playing () const
 
bool Recording () const
 
bool Stopping () const
 
bool Appending () const
 
bool Looping () const
 
bool Cutting () const
 
bool CanStopAudioStream () const
 
void OnRecord (bool altAppearance)
 
bool DoRecord (AudacityProject &project, const TransportTracks &transportTracks, double t0, double t1, bool altAppearance, const AudioIOStartStreamOptions &options)
 
int PlayPlayRegion (const SelectedRegion &selectedRegion, const AudioIOStartStreamOptions &options, PlayMode playMode, bool backwards=false)
 
void PlayCurrentRegion (bool newDefault=false, bool cutpreview=false)
 
void OnPause ()
 
void Pause ()
 
void Stop (bool stopStream=true)
 
void StopIfPaused ()
 
bool DoPlayStopSelect (bool click, bool shift)
 
void DoPlayStopSelect ()
 
PlayMode GetLastPlayMode () const
 
- Public Member Functions inherited from ClientData::Base
virtual ~Base ()
 
- Public Member Functions inherited from AudioIOListener
 AudioIOListener ()
 
virtual ~AudioIOListener ()
 

Static Public Member Functions

static ProjectAudioManagerGet (AudacityProject &project)
 
static const ProjectAudioManagerGet (const AudacityProject &project)
 
static WaveTrackArray ChooseExistingRecordingTracks (AudacityProject &proj, bool selectedOnly, double targetRate=RATE_NOT_SELECTED)
 
static bool UseDuplex ()
 
static TransportTracks GetAllPlaybackTracks (TrackList &trackList, bool selectedOnly, bool nonWaveToo=false)
 

Private Member Functions

void SetPaused (bool value)
 
void SetAppending (bool value)
 
void SetLooping (bool value)
 
void SetCutting (bool value)
 
void SetStopping (bool value)
 
void CancelRecording ()
 
void OnAudioIORate (int rate) override
 
void OnAudioIOStartRecording () override
 
void OnAudioIOStopRecording () override
 
void OnAudioIONewBlocks (const WaveTrackArray *tracks) override
 
void OnCommitRecording () override
 
void OnSoundActivationThreshold () override
 
void OnCheckpointFailure (wxCommandEvent &evt)
 

Static Private Member Functions

static std::pair< TranslatableStrings, unsigned > StatusWidthFunction (const AudacityProject &project, StatusBarField field)
 

Private Attributes

AudacityProjectmProject
 
PlayMode mLastPlayMode { PlayMode::normalPlay }
 
bool mTimerRecordCanceled { false }
 
bool mPaused { false }
 
bool mAppending { false }
 
bool mLooping { false }
 
bool mCutting { false }
 
bool mStopping { false }
 
int mDisplayedRate { 0 }
 

Detailed Description

Definition at line 68 of file ProjectAudioManager.h.

Constructor & Destructor Documentation

◆ ProjectAudioManager() [1/2]

ProjectAudioManager::ProjectAudioManager ( AudacityProject project)
explicit

Definition at line 67 of file ProjectAudioManager.cpp.

68  : mProject{ project }
69 {
71  registerStatusWidthFunction{ StatusWidthFunction };
72  project.Bind( EVT_CHECKPOINT_FAILURE,
74 }

◆ ProjectAudioManager() [2/2]

ProjectAudioManager::ProjectAudioManager ( const ProjectAudioManager )

◆ ~ProjectAudioManager()

ProjectAudioManager::~ProjectAudioManager ( )
overridedefault

Member Function Documentation

◆ Appending()

bool ProjectAudioManager::Appending ( ) const
inline

Definition at line 109 of file ProjectAudioManager.h.

109 { return mAppending; }

◆ CancelRecording()

void ProjectAudioManager::CancelRecording ( )
private

Definition at line 1016 of file ProjectAudioManager.cpp.

1017 {
1018  const auto project = &mProject;
1019  TrackList::Get( *project ).ClearPendingTracks();
1020 }

References TrackList::ClearPendingTracks(), and TrackList::Get().

Here is the call graph for this function:

◆ CanStopAudioStream()

bool ProjectAudioManager::CanStopAudioStream ( ) const

Definition at line 1126 of file ProjectAudioManager.cpp.

1127 {
1128  auto gAudioIO = AudioIO::Get();
1129  return (!gAudioIO->IsStreamActive() ||
1130  gAudioIO->IsMonitoring() ||
1131  gAudioIO->GetOwningProject().get() == &mProject );
1132 }

References AudioIO::Get().

Here is the call graph for this function:

◆ ChooseExistingRecordingTracks()

WaveTrackArray ProjectAudioManager::ChooseExistingRecordingTracks ( AudacityProject proj,
bool  selectedOnly,
double  targetRate = RATE_NOT_SELECTED 
)
static

Definition at line 576 of file ProjectAudioManager.cpp.

578 {
579  auto p = &proj;
580  size_t recordingChannels = std::max(0, AudioIORecordChannels.Read());
581  bool strictRules = (recordingChannels <= 2);
582 
583  // Iterate over all wave tracks, or over selected wave tracks only.
584  // If target rate was specified, ignore all tracks with other rates.
585  //
586  // In the usual cases of one or two recording channels, seek a first-fit
587  // unbroken sub-sequence for which the total number of channels matches the
588  // required number exactly. Never drop inputs or fill only some channels
589  // of a track.
590  //
591  // In case of more than two recording channels, choose tracks only among the
592  // selected. Simply take the earliest wave tracks, until the number of
593  // channels is enough. If there are fewer channels than inputs, but at least
594  // one channel, then some of the input channels will be dropped.
595  //
596  // Resulting tracks may be non-consecutive within the list of all tracks
597  // (there may be non-wave tracks between, or non-selected tracks when
598  // considering selected tracks only.)
599 
600  if (!strictRules && !selectedOnly)
601  return {};
602 
603  auto &trackList = TrackList::Get( *p );
604  std::vector<unsigned> channelCounts;
605  WaveTrackArray candidates;
606  const auto range = trackList.Leaders<WaveTrack>();
607  for ( auto candidate : selectedOnly ? range + &Track::IsSelected : range ) {
608  if (targetRate != RATE_NOT_SELECTED && candidate->GetRate() != targetRate)
609  continue;
610 
611  // count channels in this track
612  const auto channels = TrackList::Channels( candidate );
613  unsigned nChannels = channels.size();
614 
615  if (strictRules && nChannels > recordingChannels) {
616  // The recording would under-fill this track's channels
617  // Can't use any partial accumulated results
618  // either. Keep looking.
619  candidates.clear();
620  channelCounts.clear();
621  continue;
622  }
623  else {
624  // Might use this but may have to discard some of the accumulated
625  while(strictRules &&
626  nChannels + candidates.size() > recordingChannels) {
627  auto nOldChannels = channelCounts[0];
628  wxASSERT(nOldChannels > 0);
629  channelCounts.erase(channelCounts.begin());
630  candidates.erase(candidates.begin(),
631  candidates.begin() + nOldChannels);
632  }
633  channelCounts.push_back(nChannels);
634  for ( auto channel : channels ) {
635  candidates.push_back(channel->SharedPointer<WaveTrack>());
636  if(candidates.size() == recordingChannels)
637  // Done!
638  return candidates;
639  }
640  }
641  }
642 
643  if (!strictRules && !candidates.empty())
644  // good enough
645  return candidates;
646 
647  // If the loop didn't exit early, we could not find enough channels
648  return {};
649 }

References AudioIORecordChannels, TrackList::Channels(), TrackList::Get(), Track::IsSelected(), RATE_NOT_SELECTED, and Setting< T >::Read().

Referenced by TransportActions::Handler::OnTimerRecord().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Cutting()

bool ProjectAudioManager::Cutting ( ) const
inline

Definition at line 112 of file ProjectAudioManager.h.

112 { return mCutting; }

◆ DoPlayStopSelect() [1/2]

void ProjectAudioManager::DoPlayStopSelect ( )

Definition at line 1279 of file ProjectAudioManager.cpp.

1280 {
1281  auto gAudioIO = AudioIO::Get();
1282  if (DoPlayStopSelect(false, false))
1283  Stop();
1284  else if (!gAudioIO->IsBusy()) {
1285  //Otherwise, start playing (assuming audio I/O isn't busy)
1286 
1287  // Will automatically set mLastPlayMode
1288  PlayCurrentRegion(false);
1289  }
1290 }

References AudioIO::Get().

Here is the call graph for this function:

◆ DoPlayStopSelect() [2/2]

bool ProjectAudioManager::DoPlayStopSelect ( bool  click,
bool  shift 
)

Definition at line 1223 of file ProjectAudioManager.cpp.

1224 {
1225  auto &project = mProject;
1226  auto &scrubber = Scrubber::Get( project );
1227  auto token = ProjectAudioIO::Get( project ).GetAudioIOToken();
1228  auto &viewInfo = ViewInfo::Get( project );
1229  auto &selection = viewInfo.selectedRegion;
1230  auto gAudioIO = AudioIO::Get();
1231 
1232  //If busy, stop playing, make sure everything is unpaused.
1233  if (scrubber.HasMark() ||
1234  gAudioIO->IsStreamActive(token)) {
1235  // change the selection
1236  auto time = gAudioIO->GetStreamTime();
1237  // Test WasSpeedPlaying(), not IsSpeedPlaying()
1238  // as we could be stopped now. Similarly WasKeyboardScrubbing().
1239  if (click && (scrubber.WasSpeedPlaying() || scrubber.WasKeyboardScrubbing()))
1240  {
1241  ;// don't change the selection.
1242  }
1243  else if (shift && click) {
1244  // Change the region selection, as if by shift-click at the play head
1245  auto t0 = selection.t0(), t1 = selection.t1();
1246  if (time < t0)
1247  // Grow selection
1248  t0 = time;
1249  else if (time > t1)
1250  // Grow selection
1251  t1 = time;
1252  else {
1253  // Shrink selection, changing the nearer boundary
1254  if (fabs(t0 - time) < fabs(t1 - time))
1255  t0 = time;
1256  else
1257  t1 = time;
1258  }
1259  selection.setTimes(t0, t1);
1260  }
1261  else if (click){
1262  // avoid a point at negative time.
1263  time = wxMax( time, 0 );
1264  // Set a point selection, as if by a click at the play head
1265  selection.setTimes(time, time);
1266  } else
1267  // How stop and set cursor always worked
1268  // -- change t0, collapsing to point only if t1 was greater
1269  selection.setT0(time, false);
1270 
1271  ProjectHistory::Get( project ).ModifyState(false); // without bWantsAutoSave
1272  return true;
1273  }
1274  return false;
1275 }

References AudioIO::Get(), ViewInfo::Get(), ProjectAudioIO::Get(), ProjectHistory::Get(), Scrubber::Get(), ProjectAudioIO::GetAudioIOToken(), and ProjectHistory::ModifyState().

Referenced by TransportActions::Handler::OnPlayStopSelect().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoRecord()

bool ProjectAudioManager::DoRecord ( AudacityProject project,
const TransportTracks transportTracks,
double  t0,
double  t1,
bool  altAppearance,
const AudioIOStartStreamOptions options 
)

Definition at line 775 of file ProjectAudioManager.cpp.

780 {
781  auto &projectAudioManager = *this;
782 
783  CommandFlag flags = AlwaysEnabledFlag; // 0 means recalc flags.
784 
785  // NB: The call may have the side effect of changing flags.
786  bool allowed = MenuManager::Get(project).TryToMakeActionAllowed(
787  flags,
789 
790  if (!allowed)
791  return false;
792  // ...end of code from CommandHandler.
793 
794  auto gAudioIO = AudioIO::Get();
795  if (gAudioIO->IsBusy())
796  return false;
797 
798  projectAudioManager.SetAppending( !altAppearance );
799 
800  bool success = false;
801 
802  auto transportTracks = tracks;
803 
804  // Will replace any given capture tracks with temporaries
805  transportTracks.captureTracks.clear();
806 
807  const auto p = &project;
808 
809  bool appendRecord = !tracks.captureTracks.empty();
810 
811  auto makeNewClipName = [&](WaveTrack* track) {
812  for (auto i = 1;; ++i)
813  {
814  //i18n-hint a numerical suffix added to distinguish otherwise like-named clips when new record started
815  auto name = XC("%s #%d", "clip name template").Format(track->GetName(), i).Translation();
816  if (track->FindClipByName(name) == nullptr)
817  return name;
818  }
819  };
820 
821  {
822  if (appendRecord) {
823  // Append recording:
824  // Pad selected/all wave tracks to make them all the same length
825  for (const auto &wt : tracks.captureTracks)
826  {
827  auto endTime = wt->GetEndTime();
828 
829  // If the track was chosen for recording and playback both,
830  // remember the original in preroll tracks, before making the
831  // pending replacement.
832  bool prerollTrack = make_iterator_range(transportTracks.playbackTracks).contains(wt);
833  if (prerollTrack)
834  transportTracks.prerollTracks.push_back(wt);
835 
836  // A function that copies all the non-sample data between
837  // wave tracks; in case the track recorded to changes scale
838  // type (for instance), during the recording.
839  auto updater = [](Track &d, const Track &s){
840  auto &dst = static_cast<WaveTrack&>(d);
841  auto &src = static_cast<const WaveTrack&>(s);
842  dst.Reinit(src);
843  };
844 
845  // Get a copy of the track to be appended, to be pushed into
846  // undo history only later.
847  auto pending = std::static_pointer_cast<WaveTrack>(
849  updater, wt.get() ) );
850 
851  // End of current track is before or at recording start time.
852  // Less than or equal, not just less than, to ensure a clip boundary.
853  // when append recording.
854  if (endTime <= t0) {
855  pending->CreateClip(t0, makeNewClipName(pending.get()));
856  }
857  transportTracks.captureTracks.push_back(pending);
858  }
860  }
861 
862  if( transportTracks.captureTracks.empty() )
863  { // recording to NEW track(s).
864  bool recordingNameCustom, useTrackNumber, useDateStamp, useTimeStamp;
865  wxString defaultTrackName, defaultRecordingTrackName;
866 
867  // Count the tracks.
868  auto &trackList = TrackList::Get( *p );
869  auto numTracks = trackList.Leaders< const WaveTrack >().size();
870 
871  auto recordingChannels = std::max(1, AudioIORecordChannels.Read());
872 
873  gPrefs->Read(wxT("/GUI/TrackNames/RecordingNameCustom"), &recordingNameCustom, false);
874  gPrefs->Read(wxT("/GUI/TrackNames/TrackNumber"), &useTrackNumber, false);
875  gPrefs->Read(wxT("/GUI/TrackNames/DateStamp"), &useDateStamp, false);
876  gPrefs->Read(wxT("/GUI/TrackNames/TimeStamp"), &useTimeStamp, false);
878  gPrefs->Read(wxT("/GUI/TrackNames/RecodingTrackName"), &defaultRecordingTrackName, defaultTrackName);
879 
880  wxString baseTrackName = recordingNameCustom? defaultRecordingTrackName : defaultTrackName;
881 
882  Track *first {};
883  for (int c = 0; c < recordingChannels; c++) {
884  auto newTrack = WaveTrackFactory::Get( *p ).NewWaveTrack();
885  if (!first)
886  first = newTrack.get();
887 
888  // Quantize bounds to the rate of the new track.
889  if (c == 0) {
890  if (t0 < DBL_MAX)
891  t0 = newTrack->LongSamplesToTime(newTrack->TimeToLongSamples(t0));
892  if (t1 < DBL_MAX)
893  t1 = newTrack->LongSamplesToTime(newTrack->TimeToLongSamples(t1));
894  }
895 
896  newTrack->SetOffset(t0);
897  wxString nameSuffix = wxString(wxT(""));
898 
899  if (useTrackNumber) {
900  nameSuffix += wxString::Format(wxT("%d"), 1 + (int) numTracks + c);
901  }
902 
903  if (useDateStamp) {
904  if (!nameSuffix.empty()) {
905  nameSuffix += wxT("_");
906  }
907  nameSuffix += wxDateTime::Now().FormatISODate();
908  }
909 
910  if (useTimeStamp) {
911  if (!nameSuffix.empty()) {
912  nameSuffix += wxT("_");
913  }
914  nameSuffix += wxDateTime::Now().FormatISOTime();
915  }
916 
917  // ISO standard would be nice, but ":" is unsafe for file name.
918  nameSuffix.Replace(wxT(":"), wxT("-"));
919 
920  if (baseTrackName.empty()) {
921  newTrack->SetName(nameSuffix);
922  }
923  else if (nameSuffix.empty()) {
924  newTrack->SetName(baseTrackName);
925  }
926  else {
927  newTrack->SetName(baseTrackName + wxT("_") + nameSuffix);
928  }
929  //create a new clip with a proper name before recording is started
930  newTrack->CreateClip(t0, makeNewClipName(newTrack.get()));
931 
932  TrackList::Get( *p ).RegisterPendingNewTrack( newTrack );
933 
934  if ((recordingChannels > 2) &&
936  TrackView::Get( *newTrack ).SetMinimized(true);
937  }
938 
939  transportTracks.captureTracks.push_back(newTrack);
940  }
941  TrackList::Get( *p ).MakeMultiChannelTrack(*first, recordingChannels, true);
942  // Bug 1548. First of new tracks needs the focus.
943  TrackFocus::Get(*p).Set(first);
944  if (TrackList::Get(*p).back())
945  TrackList::Get(*p).back()->EnsureVisible();
946  }
947 
948  //Automated Input Level Adjustment Initialization
949  #ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
950  gAudioIO->AILAInitialize();
951  #endif
952 
953  int token = gAudioIO->StartStream(transportTracks, t0, t1, t1, options);
954 
955  success = (token != 0);
956 
957  if (success) {
959  }
960  else {
961  CancelRecording();
962 
963  // Show error message if stream could not be opened
964  auto msg = XO("Error opening recording device.\nError code: %s")
965  .Format( gAudioIO->LastPaErrorString() );
966  using namespace BasicUI;
968  XO("Error"), msg, wxT("Error_opening_sound_device"),
969  ErrorDialogOptions{ ErrorDialogType::ModalErrorReport } );
970  }
971  }
972 
973  return success;
974 }

References AlwaysEnabledFlag, AudioIONotBusyFlag(), AudioIORecordChannels, CanStopAudioStreamFlag(), TransportTracks::captureTracks, AudioIO::Get(), TrackFocus::Get(), TrackList::Get(), MenuManager::Get(), ProjectAudioIO::Get(), ProjectSettings::Get(), WaveTrackFactory::Get(), TrackView::Get(), WaveTrack::GetDefaultAudioTrackNamePreference(), ProjectSettings::GetTracksFitVerticallyZoomed(), gPrefs, make_iterator_range(), TrackList::MakeMultiChannelTrack(), name, WaveTrackFactory::NewWaveTrack(), ProjectFramePlacement(), Setting< T >::Read(), TrackList::RegisterPendingChangedTrack(), TrackList::RegisterPendingNewTrack(), WaveTrack::Reinit(), ProjectAudioIO::SetAudioIOToken(), TrackView::SetMinimized(), BasicUI::ShowErrorDialog(), size, MenuManager::TryToMakeActionAllowed(), TrackList::UpdatePendingTracks(), XC, and XO.

Here is the call graph for this function:

◆ Get() [1/2]

ProjectAudioManager & ProjectAudioManager::Get ( AudacityProject project)
static

Definition at line 55 of file ProjectAudioManager.cpp.

56 {
57  return project.AttachedObjects::Get< ProjectAudioManager >(
59 }

References sProjectAudioManagerKey.

Referenced by AdornedRulerPanel::ScrubbingHandle::Cancel(), CanStopAudioStreamFlag(), AdornedRulerPanel::ClearPlayRegion(), CloseButtonHandle::CommitChanges(), DefaultPlayOptions(), MacroCommands::DoAudacityCommand(), EffectUI::DoEffect(), anonymous_namespace{TransportMenus.cpp}::DoMoveToLabel(), TransportUtilities::DoStartPlaying(), TransportUtilities::DoStopPlaying(), ControlToolBar::EnableDisableButtons(), Get(), Scrubber::MarkScrubStart(), ProjectManager::New(), ProjectManager::OnCloseWindow(), ControlToolBar::OnFF(), ControlToolBar::OnIdle(), AudacityApp::OnKeyDown(), ControlToolBar::OnKeyEvent(), TransportActions::Handler::OnPause(), ControlToolBar::OnPause(), EffectUIHost::OnPlay(), ControlToolBar::OnPlay(), TransportActions::Handler::OnPlayStopSelect(), ControlToolBar::OnRecord(), ControlToolBar::OnRewind(), TransportActions::Handler::OnStop(), ControlToolBar::OnStop(), MixerBoard::OnTimer(), PlayIndicatorOverlay::OnTimer(), TrackPanel::OnTimer(), TransportActions::Handler::OnTimerRecord(), TranscriptionToolBar::PlayAtSpeed(), TransportUtilities::PlayCurrentRegionAndWait(), ControlToolBar::PlayDefault(), TransportUtilities::PlayPlayRegionAndWait(), TransportUtilities::RecordAndWait(), TimerRecordDialog::RunWaitDialog(), AdornedRulerPanel::StartQPPlay(), ControlToolBar::StateForStatusBar(), and StatusWidthFunction().

Here is the caller graph for this function:

◆ Get() [2/2]

const ProjectAudioManager & ProjectAudioManager::Get ( const AudacityProject project)
static

Definition at line 61 of file ProjectAudioManager.cpp.

63 {
64  return Get( const_cast< AudacityProject & >( project ) );
65 }

References Get().

Here is the call graph for this function:

◆ GetAllPlaybackTracks()

TransportTracks ProjectAudioManager::GetAllPlaybackTracks ( TrackList trackList,
bool  selectedOnly,
bool  nonWaveToo = false 
)
static
Parameters
nonWaveTooif true, collect all PlayableTracks

Definition at line 1190 of file ProjectAudioManager.cpp.

1192 {
1193  TransportTracks result;
1194  {
1195  auto range = trackList.Any< WaveTrack >()
1196  + (selectedOnly ? &Track::IsSelected : &Track::Any );
1197  for (auto pTrack: range)
1198  result.playbackTracks.push_back(
1199  pTrack->SharedPointer< WaveTrack >() );
1200  }
1201 #ifdef EXPERIMENTAL_MIDI_OUT
1202  if (nonWaveToo) {
1203  auto range = trackList.Any< const PlayableTrack >() +
1204  (selectedOnly ? &Track::IsSelected : &Track::Any );
1205  for (auto pTrack: range)
1206  if (!track_cast<const WaveTrack *>(pTrack))
1207  result.otherPlayableTracks.push_back(
1208  pTrack->SharedPointer< const PlayableTrack >() );
1209  }
1210 #else
1211  WXUNUSED(useMidi);
1212 #endif
1213  return result;
1214 }

References TrackList::Any(), Track::Any(), Track::IsSelected(), TransportTracks::otherPlayableTracks, and TransportTracks::playbackTracks.

Referenced by Effect::Preview().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetLastPlayMode()

PlayMode ProjectAudioManager::GetLastPlayMode ( ) const
inline

Definition at line 149 of file ProjectAudioManager.h.

149 { return mLastPlayMode; }

Referenced by MixerBoard::OnTimer(), and PlayIndicatorOverlay::OnTimer().

Here is the caller graph for this function:

◆ IsTimerRecordCancelled()

bool ProjectAudioManager::IsTimerRecordCancelled ( )
inline

Definition at line 94 of file ProjectAudioManager.h.

94 { return mTimerRecordCanceled; }

◆ Looping()

bool ProjectAudioManager::Looping ( ) const
inline

Definition at line 111 of file ProjectAudioManager.h.

111 { return mLooping; }

◆ OnAudioIONewBlocks()

void ProjectAudioManager::OnAudioIONewBlocks ( const WaveTrackArray tracks)
overrideprivatevirtual

Implements AudioIOListener.

Definition at line 1077 of file ProjectAudioManager.cpp.

1078 {
1079  auto &project = mProject;
1080  auto &projectFileIO = ProjectFileIO::Get( project );
1081  projectFileIO.AutoSave(true);
1082 }

References ProjectFileIO::Get().

Here is the call graph for this function:

◆ OnAudioIORate()

void ProjectAudioManager::OnAudioIORate ( int  rate)
overrideprivatevirtual

Implements AudioIOListener.

Definition at line 1022 of file ProjectAudioManager.cpp.

1023 {
1024  auto &project = mProject;
1025 
1026  mDisplayedRate = rate;
1027 
1028  auto display = FormatRate( rate );
1029 
1030  ProjectStatus::Get( project ).Set( display, rateStatusBarField );
1031 }

References FormatRate(), ProjectStatus::Get(), rateStatusBarField, and ProjectStatus::Set().

Here is the call graph for this function:

◆ OnAudioIOStartRecording()

void ProjectAudioManager::OnAudioIOStartRecording ( )
overrideprivatevirtual

Implements AudioIOListener.

Definition at line 1033 of file ProjectAudioManager.cpp.

1034 {
1035  // Auto-save was done here before, but it is unnecessary, provided there
1036  // are sufficient autosaves when pushing or modifying undo states.
1037 }

◆ OnAudioIOStopRecording()

void ProjectAudioManager::OnAudioIOStopRecording ( )
overrideprivatevirtual

Implements AudioIOListener.

Definition at line 1040 of file ProjectAudioManager.cpp.

1041 {
1042  auto &project = mProject;
1043  auto &projectAudioIO = ProjectAudioIO::Get( project );
1044  auto &projectFileIO = ProjectFileIO::Get( project );
1045 
1046  // Only push state if we were capturing and not monitoring
1047  if (projectAudioIO.GetAudioIOToken() > 0)
1048  {
1049  auto &history = ProjectHistory::Get( project );
1050 
1051  if (IsTimerRecordCancelled()) {
1052  // discard recording
1053  history.RollbackState();
1054  // Reset timer record
1056  }
1057  else {
1058  // Add to history
1059  // We want this to have No-fail-guarantee if we get here from exception
1060  // handling of recording, and that means we rely on the last autosave
1061  // successfully committed to the database, not risking a failure
1062  history.PushState(XO("Recorded Audio"), XO("Record"),
1064 
1065  // Now, we may add a label track to give information about
1066  // dropouts. We allow failure of this.
1067  auto gAudioIO = AudioIO::Get();
1068  auto &intervals = gAudioIO->LostCaptureIntervals();
1069  if (intervals.size()) {
1070  RecordingDropoutEvent evt{ intervals };
1071  mProject.ProcessEvent(evt);
1072  }
1073  }
1074  }
1075 }

References AudioIO::Get(), ProjectAudioIO::Get(), ProjectFileIO::Get(), ProjectHistory::Get(), NOAUTOSAVE, and XO.

Here is the call graph for this function:

◆ OnCheckpointFailure()

void ProjectAudioManager::OnCheckpointFailure ( wxCommandEvent &  evt)
private

Definition at line 1099 of file ProjectAudioManager.cpp.

1100 {
1101  evt.Skip();
1102  Stop();
1103 }

◆ OnCommitRecording()

void ProjectAudioManager::OnCommitRecording ( )
overrideprivatevirtual

Implements AudioIOListener.

Definition at line 1084 of file ProjectAudioManager.cpp.

1085 {
1086  const auto project = &mProject;
1087  TrackList::Get( *project ).ApplyPendingTracks();
1088 }

References TrackList::ApplyPendingTracks(), and TrackList::Get().

Here is the call graph for this function:

◆ OnPause()

void ProjectAudioManager::OnPause ( )

Definition at line 976 of file ProjectAudioManager.cpp.

977 {
978  auto &projectAudioManager = *this;
979  bool canStop = projectAudioManager.CanStopAudioStream();
980 
981  if ( !canStop ) {
982  return;
983  }
984 
985  bool paused = !projectAudioManager.Paused();
986  projectAudioManager.SetPaused( paused );
987 
988  auto gAudioIO = AudioIO::Get();
989 
990 #ifdef EXPERIMENTAL_SCRUBBING_SUPPORT
991 
992  auto project = &mProject;
993  auto &scrubber = Scrubber::Get( *project );
994 
995  // Bug 1494 - Pausing a seek or scrub should just STOP as
996  // it is confusing to be in a paused scrub state.
997  bool bStopInstead = paused &&
999  !scrubber.IsSpeedPlaying() &&
1000  !scrubber.IsKeyboardScrubbing();
1001 
1002  if (bStopInstead) {
1003  Stop();
1004  return;
1005  }
1006 
1008  scrubber.Pause(paused);
1009  else
1010 #endif
1011  {
1012  gAudioIO->SetPaused(paused);
1013  }
1014 }

References AudioIO::Get(), Scrubber::Get(), and ScrubState::IsScrubbing().

Referenced by TransportActions::Handler::OnPause(), and ControlToolBar::OnPause().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnRecord()

void ProjectAudioManager::OnRecord ( bool  altAppearance)
Exception safety guarantee:
Strong – For state of current project's tracks

Definition at line 652 of file ProjectAudioManager.cpp.

653 {
654  bool bPreferNewTrack;
655  gPrefs->Read("/GUI/PreferNewTrackRecord", &bPreferNewTrack, false);
656  const bool appendRecord = (altAppearance == bPreferNewTrack);
657 
658  // Code from CommandHandler start...
660 
661  if (p) {
662  const auto &selectedRegion = ViewInfo::Get( *p ).selectedRegion;
663  double t0 = selectedRegion.t0();
664  double t1 = selectedRegion.t1();
665  // When no time selection, recording duration is 'unlimited'.
666  if (t1 == t0)
667  t1 = DBL_MAX;
668 
669  auto options = DefaultPlayOptions(*p);
670  WaveTrackArray existingTracks;
671 
672  // Checking the selected tracks: counting them and
673  // making sure they all have the same rate
674  const auto selectedTracks{ GetPropertiesOfSelected(*p) };
675  const int rateOfSelected{ selectedTracks.rateOfSelected };
676  const int numberOfSelected{ selectedTracks.numberOfSelected };
677  const bool allSameRate{ selectedTracks.allSameRate };
678 
679  if (!allSameRate) {
680  AudacityMessageBox(XO("The tracks selected "
681  "for recording must all have the same sampling rate"),
682  XO("Mismatched Sampling Rates"),
683  wxICON_ERROR | wxCENTRE);
684 
685  return;
686  }
687 
688  if (appendRecord) {
689  const auto trackRange = TrackList::Get( *p ).Any< const WaveTrack >();
690 
691  // Try to find wave tracks to record into. (If any are selected,
692  // try to choose only from them; else if wave tracks exist, may record into any.)
693  existingTracks = ChooseExistingRecordingTracks(*p, true, rateOfSelected);
694  if (!existingTracks.empty()) {
695  t0 = std::max(t0,
696  (trackRange + &Track::IsSelected).max(&Track::GetEndTime));
697  }
698  else {
699  if (numberOfSelected > 0 && rateOfSelected != options.rate) {
701  "Too few tracks are selected for recording at this sample rate.\n"
702  "(Audacity requires two channels at the same sample rate for\n"
703  "each stereo track)"),
704  XO("Too Few Compatible Tracks Selected"),
705  wxICON_ERROR | wxCENTRE);
706 
707  return;
708  }
709 
710  existingTracks = ChooseExistingRecordingTracks(*p, false, options.rate);
711  if (!existingTracks.empty())
712  {
713  auto endTime = std::max_element(
714  existingTracks.begin(),
715  existingTracks.end(),
716  [](const auto& a, const auto& b) {
717  return a->GetEndTime() < b->GetEndTime();
718  }
719  )->get()->GetEndTime();
720 
721  //If there is a suitable track, then adjust t0 so
722  //that recording not starts before the end of that track
723  t0 = std::max(t0, endTime);
724  }
725  // If suitable tracks still not found, will record into NEW ones,
726  // starting with t0
727  }
728 
729  // Whether we decided on NEW tracks or not:
730  if (t1 <= selectedRegion.t0() && selectedRegion.t1() > selectedRegion.t0()) {
731  t1 = selectedRegion.t1(); // record within the selection
732  }
733  else {
734  t1 = DBL_MAX; // record for a long, long time
735  }
736  }
737 
738  TransportTracks transportTracks;
739  if (UseDuplex()) {
740  // Remove recording tracks from the list of tracks for duplex ("overdub")
741  // playback.
742  /* TODO: set up stereo tracks if that is how the user has set up
743  * their preferences, and choose sample format based on prefs */
744  transportTracks = GetAllPlaybackTracks(TrackList::Get( *p ), false, true);
745  for (const auto &wt : existingTracks) {
746  auto end = transportTracks.playbackTracks.end();
747  auto it = std::find(transportTracks.playbackTracks.begin(), end, wt);
748  if (it != end)
749  transportTracks.playbackTracks.erase(it);
750  }
751  }
752 
753  transportTracks.captureTracks = existingTracks;
754 
755  if (rateOfSelected != RATE_NOT_SELECTED)
756  options.rate = rateOfSelected;
757 
758  DoRecord(*p, transportTracks, t0, t1, altAppearance, options);
759  }
760 }

References TrackList::Any(), AudacityMessageBox(), TransportTracks::captureTracks, DefaultPlayOptions(), ViewInfo::Get(), TrackList::Get(), Track::GetEndTime(), GetPropertiesOfSelected(), gPrefs, Track::IsSelected(), TransportTracks::playbackTracks, RATE_NOT_SELECTED, PropertiesOfSelected::rateOfSelected, ViewInfo::selectedRegion, NotifyingSelectedRegion::t0(), and XO.

Referenced by ControlToolBar::OnRecord(), and TimerRecordDialog::RunWaitDialog().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnSoundActivationThreshold()

void ProjectAudioManager::OnSoundActivationThreshold ( )
overrideprivatevirtual

Implements AudioIOListener.

Definition at line 1090 of file ProjectAudioManager.cpp.

1091 {
1092  auto &project = mProject;
1093  auto gAudioIO = AudioIO::Get();
1094  if ( gAudioIO && &project == gAudioIO->GetOwningProject().get() ) {
1095  wxTheApp->CallAfter( [this]{ Pause(); } );
1096  }
1097 }

References AudioIO::Get().

Here is the call graph for this function:

◆ operator=()

ProjectAudioManager& ProjectAudioManager::operator= ( const ProjectAudioManager )

◆ Pause()

void ProjectAudioManager::Pause ( )

Definition at line 562 of file ProjectAudioManager.cpp.

563 {
564  auto &projectAudioManager = *this;
565  bool canStop = projectAudioManager.CanStopAudioStream();
566 
567  if ( !canStop ) {
568  auto gAudioIO = AudioIO::Get();
569  gAudioIO->SetPaused(!gAudioIO->IsPaused());
570  }
571  else {
572  OnPause();
573  }
574 }

References AudioIO::Get().

Here is the call graph for this function:

◆ Paused()

bool ProjectAudioManager::Paused ( ) const
inline

Definition at line 98 of file ProjectAudioManager.h.

98 { return mPaused; }

◆ PlayCurrentRegion()

void ProjectAudioManager::PlayCurrentRegion ( bool  newDefault = false,
bool  cutpreview = false 
)
Parameters
newDefaultSee DefaultPlayOptions

Definition at line 469 of file ProjectAudioManager.cpp.

471 {
472  auto &projectAudioManager = *this;
473  bool canStop = projectAudioManager.CanStopAudioStream();
474 
475  if ( !canStop )
476  return;
477 
479 
480  {
481 
482  const auto &playRegion = ViewInfo::Get( *p ).playRegion;
483 
484  if (newDefault)
485  cutpreview = false;
486  auto options = DefaultPlayOptions( *p, newDefault );
487  if (cutpreview)
488  options.envelope = nullptr;
489  auto mode =
490  cutpreview ? PlayMode::cutPreviewPlay
491  : newDefault ? PlayMode::loopedPlay
493  PlayPlayRegion(SelectedRegion(playRegion.GetStart(), playRegion.GetEnd()),
494  options,
495  mode);
496  }
497 }

References cutPreviewPlay, DefaultPlayOptions(), ViewInfo::Get(), loopedPlay, normalPlay, and ViewInfo::playRegion.

Referenced by ControlToolBar::PlayDefault().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Playing()

bool ProjectAudioManager::Playing ( ) const

Definition at line 1105 of file ProjectAudioManager.cpp.

1106 {
1107  auto gAudioIO = AudioIO::Get();
1108  return
1109  gAudioIO->IsBusy() &&
1110  CanStopAudioStream() &&
1111  // ... and not merely monitoring
1112  !gAudioIO->IsMonitoring() &&
1113  // ... and not punch-and-roll recording
1114  gAudioIO->GetNumCaptureChannels() == 0;
1115 }

References AudioIO::Get().

Here is the call graph for this function:

◆ PlayPlayRegion()

int ProjectAudioManager::PlayPlayRegion ( const SelectedRegion selectedRegion,
const AudioIOStartStreamOptions options,
PlayMode  playMode,
bool  backwards = false 
)

Definition at line 291 of file ProjectAudioManager.cpp.

295 {
296  auto &projectAudioManager = *this;
297  bool canStop = projectAudioManager.CanStopAudioStream();
298 
299  if ( !canStop )
300  return -1;
301 
302  auto &pStartTime = options.pStartTime;
303 
304  bool nonWaveToo = options.playNonWaveTracks;
305 
306  // Uncomment this for laughs!
307  // backwards = true;
308 
309  double t0 = selectedRegion.t0();
310  double t1 = selectedRegion.t1();
311  // SelectedRegion guarantees t0 <= t1, so we need another boolean argument
312  // to indicate backwards play.
313  const bool newDefault = (mode == PlayMode::loopedPlay);
314 
315  if (backwards)
316  std::swap(t0, t1);
317 
318  projectAudioManager.SetLooping( mode == PlayMode::loopedPlay );
319  projectAudioManager.SetCutting( mode == PlayMode::cutPreviewPlay );
320 
321  bool success = false;
322 
323  auto gAudioIO = AudioIO::Get();
324  if (gAudioIO->IsBusy())
325  return -1;
326 
327  const bool cutpreview = mode == PlayMode::cutPreviewPlay;
328  if (cutpreview && t0==t1)
329  return -1; /* msmeyer: makes no sense */
330 
332 
333  auto &tracks = TrackList::Get( *p );
334 
335  mLastPlayMode = mode;
336 
337  bool hasaudio;
338  if (nonWaveToo)
339  hasaudio = ! tracks.Any<PlayableTrack>().empty();
340  else
341  hasaudio = ! tracks.Any<WaveTrack>().empty();
342 
343  double latestEnd = tracks.GetEndTime();
344 
345  if (!hasaudio)
346  return -1; // No need to continue without audio tracks
347 
348 #if defined(EXPERIMENTAL_SEEK_BEHIND_CURSOR)
349  double initSeek = 0.0;
350 #endif
351  double loopOffset = 0.0;
352 
353  if (t1 == t0) {
354  if (newDefault) {
355  const auto &selectedRegion = ViewInfo::Get( *p ).selectedRegion;
356  // play selection if there is one, otherwise
357  // set start of play region to project start,
358  // and loop the project from current play position.
359 
360  if ((t0 > selectedRegion.t0()) && (t0 < selectedRegion.t1())) {
361  t0 = selectedRegion.t0();
362  t1 = selectedRegion.t1();
363  }
364  else {
365  // loop the entire project
366  // Bug2347, loop playback from cursor position instead of project start
367  loopOffset = t0 - tracks.GetStartTime();
368  if (!pStartTime)
369  // TODO move this reassignment elsewhere so we don't need an
370  // ugly mutable member
371  pStartTime.emplace(loopOffset);
372  t0 = tracks.GetStartTime();
373  t1 = tracks.GetEndTime();
374  }
375  } else {
376  // move t0 to valid range
377  if (t0 < 0) {
378  t0 = tracks.GetStartTime();
379  }
380  else if (t0 > tracks.GetEndTime()) {
381  t0 = tracks.GetEndTime();
382  }
383 #if defined(EXPERIMENTAL_SEEK_BEHIND_CURSOR)
384  else {
385  initSeek = t0; //AC: initSeek is where playback will 'start'
386  if (!pStartTime)
387  pStartTime.emplace(initSeek);
388  t0 = tracks.GetStartTime();
389  }
390 #endif
391  }
392  t1 = tracks.GetEndTime();
393  }
394  else {
395  // maybe t1 < t0, with backwards scrubbing for instance
396  if (backwards)
397  std::swap(t0, t1);
398 
399  t0 = std::max(0.0, std::min(t0, latestEnd));
400  t1 = std::max(0.0, std::min(t1, latestEnd));
401 
402  if (backwards)
403  std::swap(t0, t1);
404  }
405 
406  int token = -1;
407 
408  if (t1 != t0) {
409  if (cutpreview) {
410  const double tless = std::min(t0, t1);
411  const double tgreater = std::max(t0, t1);
412  double beforeLen, afterLen;
413  gPrefs->Read(wxT("/AudioIO/CutPreviewBeforeLen"), &beforeLen, 2.0);
414  gPrefs->Read(wxT("/AudioIO/CutPreviewAfterLen"), &afterLen, 1.0);
415  double tcp0 = tless-beforeLen;
416  const double diff = tgreater - tless;
417  double tcp1 = tgreater+afterLen;
418  if (backwards)
419  std::swap(tcp0, tcp1);
420  AudioIOStartStreamOptions myOptions = options;
421  myOptions.policyFactory =
422  [tless, diff](auto&) -> std::unique_ptr<PlaybackPolicy> {
423  return std::make_unique<CutPreviewPlaybackPolicy>(tless, diff);
424  };
425  token = gAudioIO->StartStream(
426  GetAllPlaybackTracks(TrackList::Get(*p), false, nonWaveToo),
427  tcp0, tcp1, tcp1, myOptions);
428  }
429  else {
430  double mixerLimit = t1;
431  if (newDefault) {
432  mixerLimit = latestEnd;
433  if (pStartTime && *pStartTime >= t1)
434  t1 = latestEnd;
435  }
436  token = gAudioIO->StartStream(
437  GetAllPlaybackTracks( tracks, false, nonWaveToo ),
438  t0, t1, mixerLimit, options);
439  }
440  if (token != 0) {
441  success = true;
443  }
444  else {
445  // Bug1627 (part of it):
446  // infinite error spew when trying to start scrub:
447  // Problem was that the error dialog yields to events,
448  // causing recursion to this function in the scrub timer
449  // handler! Easy fix, just delay the user alert instead.
450  auto &window = GetProjectFrame( mProject );
451  window.CallAfter( [&]{
452  using namespace BasicUI;
453  // Show error message if stream could not be opened
455  XO("Error"),
456  XO("Error opening sound device.\nTry changing the audio host, playback device and the project sample rate."),
457  wxT("Error_opening_sound_device"),
458  ErrorDialogOptions{ ErrorDialogType::ModalErrorReport } );
459  });
460  }
461  }
462 
463  if (!success)
464  return -1;
465 
466  return token;
467 }

References cutPreviewPlay, AudioIO::Get(), ViewInfo::Get(), TrackList::Get(), ProjectAudioIO::Get(), GetProjectFrame(), gPrefs, loopedPlay, min(), AudioIOStartStreamOptions::playNonWaveTracks, AudioIOStartStreamOptions::policyFactory, ProjectFramePlacement(), AudioIOStartStreamOptions::pStartTime, ViewInfo::selectedRegion, ProjectAudioIO::SetAudioIOToken(), BasicUI::ShowErrorDialog(), anonymous_namespace{NoteTrack.cpp}::swap(), SelectedRegion::t0(), SelectedRegion::t1(), and XO.

Here is the call graph for this function:

◆ Recording()

bool ProjectAudioManager::Recording ( ) const

Definition at line 1117 of file ProjectAudioManager.cpp.

1118 {
1119  auto gAudioIO = AudioIO::Get();
1120  return
1121  gAudioIO->IsBusy() &&
1122  CanStopAudioStream() &&
1123  gAudioIO->GetNumCaptureChannels() > 0;
1124 }

References AudioIO::Get().

Here is the call graph for this function:

◆ ResetTimerRecordCancelled()

void ProjectAudioManager::ResetTimerRecordCancelled ( )
inline

Definition at line 96 of file ProjectAudioManager.h.

96 { mTimerRecordCanceled = false; }

◆ SetAppending()

void ProjectAudioManager::SetAppending ( bool  value)
inlineprivate

Definition at line 153 of file ProjectAudioManager.h.

153 { mAppending = value; }

◆ SetCutting()

void ProjectAudioManager::SetCutting ( bool  value)
inlineprivate

Definition at line 155 of file ProjectAudioManager.h.

155 { mCutting = value; }

◆ SetLooping()

void ProjectAudioManager::SetLooping ( bool  value)
inlineprivate

Definition at line 154 of file ProjectAudioManager.h.

154 { mLooping = value; }

◆ SetPaused()

void ProjectAudioManager::SetPaused ( bool  value)
inlineprivate

Definition at line 152 of file ProjectAudioManager.h.

152 { mPaused = value; }

◆ SetStopping()

void ProjectAudioManager::SetStopping ( bool  value)
inlineprivate

Definition at line 156 of file ProjectAudioManager.h.

156 { mStopping = value; }

◆ SetTimerRecordCancelled()

void ProjectAudioManager::SetTimerRecordCancelled ( )
inline

Definition at line 95 of file ProjectAudioManager.h.

95 { mTimerRecordCanceled = true; }

Referenced by TransportActions::Handler::OnTimerRecord().

Here is the caller graph for this function:

◆ StatusWidthFunction()

auto ProjectAudioManager::StatusWidthFunction ( const AudacityProject project,
StatusBarField  field 
)
staticprivate

Definition at line 88 of file ProjectAudioManager.cpp.

91 {
92  if ( field == rateStatusBarField ) {
93  auto &audioManager = ProjectAudioManager::Get( project );
94  int rate = audioManager.mDisplayedRate;
95  return {
96  { { FormatRate( rate ) } },
97  50
98  };
99  }
100  return {};
101 }

References field, FormatRate(), Get(), and rateStatusBarField.

Here is the call graph for this function:

◆ Stop()

void ProjectAudioManager::Stop ( bool  stopStream = true)

Definition at line 499 of file ProjectAudioManager.cpp.

500 {
501  AudacityProject *project = &mProject;
502  auto &projectAudioManager = *this;
503  bool canStop = projectAudioManager.CanStopAudioStream();
504 
505  if ( !canStop )
506  return;
507 
508  if(project) {
509  // Let scrubbing code do some appearance change
510  auto &scrubber = Scrubber::Get( *project );
511  scrubber.StopScrubbing();
512  }
513 
514  auto gAudioIO = AudioIO::Get();
515 
516  auto cleanup = finally( [&]{
517  projectAudioManager.SetStopping( false );
518  } );
519 
520  if (stopStream && gAudioIO->IsBusy()) {
521  // flag that we are stopping
522  projectAudioManager.SetStopping( true );
523  // Allow UI to update for that
524  while( wxTheApp->ProcessIdle() )
525  ;
526  }
527 
528  if(stopStream)
529  gAudioIO->StopStream();
530 
531  projectAudioManager.SetLooping( false );
532  projectAudioManager.SetCutting( false );
533 
534  #ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
535  gAudioIO->AILADisable();
536  #endif
537 
538  projectAudioManager.SetPaused( false );
539  //Make sure you tell gAudioIO to unpause
540  gAudioIO->SetPaused( false );
541 
542  // So that we continue monitoring after playing or recording.
543  // also clean the MeterQueues
544  if( project ) {
545  auto &projectAudioIO = ProjectAudioIO::Get( *project );
546  auto meter = projectAudioIO.GetPlaybackMeter();
547  if( meter ) {
548  meter->Clear();
549  }
550 
551  meter = projectAudioIO.GetCaptureMeter();
552  if( meter ) {
553  meter->Clear();
554  }
555  }
556 
557  const auto toolbar = ToolManager::Get( *project ).GetToolBar(ScrubbingBarID);
558  if (toolbar)
559  toolbar->EnableDisableButtons();
560 }

References ToolBar::EnableDisableButtons(), AudioIO::Get(), ProjectAudioIO::Get(), ToolManager::Get(), Scrubber::Get(), ToolManager::GetToolBar(), and ScrubbingBarID.

Referenced by AdornedRulerPanel::ScrubbingHandle::Cancel(), AdornedRulerPanel::ClearPlayRegion(), MacroCommands::DoAudacityCommand(), EffectUI::DoEffect(), ProjectManager::OnCloseWindow(), AudacityApp::OnKeyDown(), TransportActions::Handler::OnStop(), and TimerRecordDialog::RunWaitDialog().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ StopIfPaused()

void ProjectAudioManager::StopIfPaused ( )

Definition at line 1217 of file ProjectAudioManager.cpp.

1218 {
1219  if( AudioIOBase::Get()->IsPaused() )
1220  Stop();
1221 }

References AudioIOBase::Get().

Referenced by CloseButtonHandle::CommitChanges(), ControlToolBar::OnFF(), and ControlToolBar::OnRewind().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Stopping()

bool ProjectAudioManager::Stopping ( ) const
inline

Definition at line 106 of file ProjectAudioManager.h.

106 { return mStopping; }

◆ UseDuplex()

bool ProjectAudioManager::UseDuplex ( )
static

Definition at line 762 of file ProjectAudioManager.cpp.

763 {
764  bool duplex;
765  gPrefs->Read(wxT("/AudioIO/Duplex"), &duplex,
766 #ifdef EXPERIMENTAL_DA
767  false
768 #else
769  true
770 #endif
771  );
772  return duplex;
773 }

References gPrefs.

Member Data Documentation

◆ mAppending

bool ProjectAudioManager::mAppending { false }
private

Definition at line 179 of file ProjectAudioManager.h.

◆ mCutting

bool ProjectAudioManager::mCutting { false }
private

Definition at line 181 of file ProjectAudioManager.h.

◆ mDisplayedRate

int ProjectAudioManager::mDisplayedRate { 0 }
private

Definition at line 184 of file ProjectAudioManager.h.

◆ mLastPlayMode

PlayMode ProjectAudioManager::mLastPlayMode { PlayMode::normalPlay }
private

Definition at line 173 of file ProjectAudioManager.h.

◆ mLooping

bool ProjectAudioManager::mLooping { false }
private

Definition at line 180 of file ProjectAudioManager.h.

◆ mPaused

bool ProjectAudioManager::mPaused { false }
private

Definition at line 178 of file ProjectAudioManager.h.

◆ mProject

AudacityProject& ProjectAudioManager::mProject
private

Definition at line 171 of file ProjectAudioManager.h.

◆ mStopping

bool ProjectAudioManager::mStopping { false }
private

Definition at line 182 of file ProjectAudioManager.h.

◆ mTimerRecordCanceled

bool ProjectAudioManager::mTimerRecordCanceled { false }
private

Definition at line 176 of file ProjectAudioManager.h.


The documentation for this class was generated from the following files:
size
size_t size
Definition: ffmpeg-2.3.6-single-header.h:412
ProjectAudioManager::mLooping
bool mLooping
Definition: ProjectAudioManager.h:180
WaveTrackArray
std::vector< std::shared_ptr< WaveTrack > > WaveTrackArray
Definition: AudioIO.h:46
PlayMode::cutPreviewPlay
@ cutPreviewPlay
ProjectHistory::ModifyState
void ModifyState(bool bWantsAutoSave)
Definition: ProjectHistory.cpp:124
ViewInfo::Get
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235
field
#define field(n, t)
Definition: ImportAUP.cpp:167
TransportTracks::playbackTracks
WaveTrackArray playbackTracks
Definition: AudioIO.h:70
ProjectAudioIO::GetAudioIOToken
int GetAudioIOToken() const
Definition: ProjectAudioIO.cpp:43
CanStopAudioStreamFlag
const ReservedCommandFlag & CanStopAudioStreamFlag()
Definition: ProjectAudioManager.cpp:1135
ProjectFramePlacement
std::unique_ptr< const BasicUI::WindowPlacement > ProjectFramePlacement(AudacityProject *project)
Make a WindowPlacement object suitable for project (which may be null)
Definition: ProjectWindows.cpp:101
WaveTrackFactory::Get
static WaveTrackFactory & Get(AudacityProject &project)
Definition: WaveTrack.cpp:2799
Scrubber::Get
static Scrubber & Get(AudacityProject &project)
Definition: Scrubbing.cpp:202
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:75
make_iterator_range
IteratorRange< Iterator > make_iterator_range(const Iterator &i1, const Iterator &i2)
Definition: MemoryX.h:423
ProjectAudioManager::Get
static ProjectAudioManager & Get(AudacityProject &project)
Definition: ProjectAudioManager.cpp:55
AudacityMessageBox
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
Definition: AudacityMessageBox.cpp:17
TrackView::Get
static TrackView & Get(Track &)
Definition: TrackView.cpp:69
TrackView::SetMinimized
void SetMinimized(bool minimized)
Definition: TrackView.cpp:93
gPrefs
FileConfig * gPrefs
Definition: Prefs.cpp:71
Track::GetEndTime
virtual double GetEndTime() const =0
SelectedRegion::t1
double t1() const
Definition: SelectedRegion.h:95
ProjectAudioManager::GetAllPlaybackTracks
static TransportTracks GetAllPlaybackTracks(TrackList &trackList, bool selectedOnly, bool nonWaveToo=false)
Definition: ProjectAudioManager.cpp:1190
BasicUI::ShowErrorDialog
void ShowErrorDialog(const WindowPlacement &placement, const TranslatableString &dlogTitle, const TranslatableString &message, const ManualPageID &helpPage, const ErrorDialogOptions &options={})
Show an error dialog with a link to the manual for further help.
Definition: BasicUI.h:241
TransportTracks::captureTracks
WaveTrackArray captureTracks
Definition: AudioIO.h:71
ProjectAudioManager::DoPlayStopSelect
void DoPlayStopSelect()
Definition: ProjectAudioManager.cpp:1279
ProjectAudioManager::Pause
void Pause()
Definition: ProjectAudioManager.cpp:562
ViewInfo::playRegion
PlayRegion playRegion
Definition: ViewInfo.h:216
AudioIONotBusyFlag
const ReservedCommandFlag & AudioIONotBusyFlag()
Definition: CommonCommandFlags.cpp:128
sProjectAudioManagerKey
static AudacityProject::AttachedObjects::RegisteredFactory sProjectAudioManagerKey
Definition: ProjectAudioManager.cpp:49
TrackList::Channels
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1483
ProjectAudioManager::ChooseExistingRecordingTracks
static WaveTrackArray ChooseExistingRecordingTracks(AudacityProject &proj, bool selectedOnly, double targetRate=RATE_NOT_SELECTED)
Definition: ProjectAudioManager.cpp:576
ProjectAudioManager::mDisplayedRate
int mDisplayedRate
Definition: ProjectAudioManager.h:184
ToolManager::Get
static ToolManager & Get(AudacityProject &project)
Definition: ToolManager.cpp:341
ProjectAudioManager::OnCheckpointFailure
void OnCheckpointFailure(wxCommandEvent &evt)
Definition: ProjectAudioManager.cpp:1099
ToolBar::EnableDisableButtons
virtual void EnableDisableButtons()=0
DefaultPlayOptions
AudioIOStartStreamOptions DefaultPlayOptions(AudacityProject &project, bool newDefault)
Definition: ProjectAudioManager.cpp:1144
XO
#define XO(s)
Definition: Internat.h:31
XC
#define XC(s, c)
Definition: Internat.h:37
ProjectFileIO::Get
static ProjectFileIO & Get(AudacityProject &project)
Definition: ProjectFileIO.cpp:480
ProjectSettings::Get
static ProjectSettings & Get(AudacityProject &project)
Definition: ProjectSettings.cpp:45
AudioIOStartStreamOptions::policyFactory
PolicyFactory policyFactory
Definition: AudioIOBase.h:73
ProjectAudioManager::CancelRecording
void CancelRecording()
Definition: ProjectAudioManager.cpp:1016
Track::Any
bool Any() const
Definition: Track.cpp:292
AlwaysEnabledFlag
constexpr CommandFlag AlwaysEnabledFlag
Definition: CommandFlag.h:35
CommandFlag
std::bitset< NCommandFlags > CommandFlag
Definition: CommandFlag.h:31
ProjectAudioIO::Get
static ProjectAudioIO & Get(AudacityProject &project)
Definition: ProjectAudioIO.cpp:24
ProjectAudioManager::PlayCurrentRegion
void PlayCurrentRegion(bool newDefault=false, bool cutpreview=false)
Definition: ProjectAudioManager.cpp:469
TransportTracks::otherPlayableTracks
PlayableTrackConstArray otherPlayableTracks
Definition: AudioIO.h:72
ProjectAudioManager::mLastPlayMode
PlayMode mLastPlayMode
Definition: ProjectAudioManager.h:173
WaveTrack::Reinit
void Reinit(const WaveTrack &orig)
Definition: WaveTrack.cpp:216
ProjectAudioManager::ResetTimerRecordCancelled
void ResetTimerRecordCancelled()
Definition: ProjectAudioManager.h:96
Setting::Read
bool Read(T *pVar) const
overload of Read returning a boolean that is true if the value was previously defined *‍/
Definition: Prefs.h:127
PlayMode::normalPlay
@ normalPlay
TrackList::RegisterPendingChangedTrack
std::shared_ptr< Track > RegisterPendingChangedTrack(Updater updater, Track *src)
Definition: Track.cpp:903
ProjectAudioManager::CanStopAudioStream
bool CanStopAudioStream() const
Definition: ProjectAudioManager.cpp:1126
UndoPush::NOAUTOSAVE
@ NOAUTOSAVE
ProjectAudioManager::IsTimerRecordCancelled
bool IsTimerRecordCancelled()
Definition: ProjectAudioManager.h:94
ProjectStatus::Set
void Set(const TranslatableString &msg, StatusBarField field=mainStatusBarField)
Definition: ProjectStatus.cpp:63
ViewInfo::selectedRegion
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:215
ToolManager::GetToolBar
ToolBar * GetToolBar(int type) const
Definition: ToolManager.cpp:1015
TrackList::ClearPendingTracks
void ClearPendingTracks(ListOfTracks *pAdded=nullptr)
Definition: Track.cpp:948
ScrubbingBarID
@ ScrubbingBarID
Definition: ToolBar.h:80
TrackList::MakeMultiChannelTrack
bool MakeMultiChannelTrack(Track &first, int nChannels, bool aligned)
Converts channels to a multichannel track.
Definition: Track.cpp:615
name
const TranslatableString name
Definition: Distortion.cpp:98
ProjectAudioManager::mTimerRecordCanceled
bool mTimerRecordCanceled
Definition: ProjectAudioManager.h:176
WaveTrack::GetDefaultAudioTrackNamePreference
static wxString GetDefaultAudioTrackNamePreference()
Definition: WaveTrack.cpp:100
rateStatusBarField
@ rateStatusBarField
Definition: ProjectStatus.h:27
ProjectAudioManager::UseDuplex
static bool UseDuplex()
Definition: ProjectAudioManager.cpp:762
Track::IsSelected
bool IsSelected() const
Definition: Track.cpp:295
AudioIOBase::Get
static AudioIOBase * Get()
Definition: AudioIOBase.cpp:89
TrackFocus::Get
Track * Get()
Definition: TrackPanelAx.cpp:760
AudioIOStartStreamOptions
struct holding stream options, including a pointer to the time warp info and AudioIOListener and whet...
Definition: AudioIOBase.h:43
anonymous_namespace{NoteTrack.cpp}::swap
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)
Definition: NoteTrack.cpp:753
ProjectAudioManager::mAppending
bool mAppending
Definition: ProjectAudioManager.h:179
TrackList::RegisterPendingNewTrack
void RegisterPendingNewTrack(const std::shared_ptr< Track > &pTrack)
Definition: Track.cpp:924
ProjectAudioManager::Stop
void Stop(bool stopStream=true)
Definition: ProjectAudioManager.cpp:499
PlayableTrack
AudioTrack subclass that can also be audibly replayed by the program.
Definition: Track.h:875
AudioIOStartStreamOptions::playNonWaveTracks
bool playNonWaveTracks
Definition: AudioIOBase.h:61
MenuManager::TryToMakeActionAllowed
bool TryToMakeActionAllowed(CommandFlag &flags, CommandFlag flagsRqd)
Definition: Menus.cpp:714
ScrubState::IsScrubbing
static bool IsScrubbing()
Definition: ScrubState.cpp:482
BasicUI::ErrorDialogOptions
Options for variations of error dialogs; the default is for modal dialogs.
Definition: BasicUI.h:49
TransportTracks
Definition: AudioIO.h:69
AudioIOStartStreamOptions::pStartTime
std::optional< double > pStartTime
Definition: AudioIOBase.h:58
ProjectAudioManager::mPaused
bool mPaused
Definition: ProjectAudioManager.h:178
TrackList::UpdatePendingTracks
void UpdatePendingTracks()
Definition: Track.cpp:930
ProjectAudioIO::SetAudioIOToken
void SetAudioIOToken(int token)
Definition: ProjectAudioIO.cpp:48
min
int min(int a, int b)
Definition: CompareAudioCommand.cpp:106
RATE_NOT_SELECTED
constexpr int RATE_NOT_SELECTED
Definition: ProjectAudioManager.h:21
SelectedRegion::t0
double t0() const
Definition: SelectedRegion.h:94
BasicUI
Definition: Effect.h:47
TrackList::Get
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:377
TrackList::ApplyPendingTracks
bool ApplyPendingTracks()
Definition: Track.cpp:989
Track
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:224
ProjectAudioManager::mProject
AudacityProject & mProject
Definition: ProjectAudioManager.h:171
ProjectSettings::GetTracksFitVerticallyZoomed
bool GetTracksFitVerticallyZoomed() const
Definition: ProjectSettings.h:76
ProjectAudioManager::mCutting
bool mCutting
Definition: ProjectAudioManager.h:181
RecordingDropoutEvent
Notification, posted on the project, after recording has stopped, when dropouts have been detected.
Definition: ProjectAudioManager.h:48
ProjectStatus::Get
static ProjectStatus & Get(AudacityProject &project)
Definition: ProjectStatus.cpp:21
ProjectStatus::RegisteredStatusWidthFunction
Definition: ProjectStatus.h:57
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:89
ProjectAudioManager
Definition: ProjectAudioManager.h:72
GetProjectFrame
AUDACITY_DLL_API wxFrame & GetProjectFrame(AudacityProject &project)
Get the top-level window associated with the project (as a wxFrame only, when you do not need to use ...
Definition: ProjectWindows.cpp:72
MenuManager::Get
static MenuManager & Get(AudacityProject &project)
Definition: Menus.cpp:70
ProjectAudioManager::PlayPlayRegion
int PlayPlayRegion(const SelectedRegion &selectedRegion, const AudioIOStartStreamOptions &options, PlayMode playMode, bool backwards=false)
Definition: ProjectAudioManager.cpp:291
NotifyingSelectedRegion::t0
double t0() const
Definition: ViewInfo.h:34
ProjectAudioManager::DoRecord
bool DoRecord(AudacityProject &project, const TransportTracks &transportTracks, double t0, double t1, bool altAppearance, const AudioIOStartStreamOptions &options)
Definition: ProjectAudioManager.cpp:775
GetPropertiesOfSelected
PropertiesOfSelected GetPropertiesOfSelected(const AudacityProject &proj)
Definition: ProjectAudioManager.cpp:1308
TrackList::Any
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:1379
AudioIO::Get
static AudioIO * Get()
Definition: AudioIO.cpp:140
PlayMode::loopedPlay
@ loopedPlay
TransportTracks::prerollTracks
WaveTrackConstArray prerollTracks
Definition: AudioIO.h:75
ProjectAudioManager::mStopping
bool mStopping
Definition: ProjectAudioManager.h:182
WaveTrackFactory::NewWaveTrack
std::shared_ptr< WaveTrack > NewWaveTrack(sampleFormat format=(sampleFormat) 0, double rate=0)
Definition: WaveTrack.cpp:126
PropertiesOfSelected::rateOfSelected
int rateOfSelected
Definition: ProjectAudioManager.h:201
ProjectHistory::Get
static ProjectHistory & Get(AudacityProject &project)
Definition: ProjectHistory.cpp:26
AudioIORecordChannels
IntSetting AudioIORecordChannels
Definition: AudioIOBase.cpp:943
ProjectAudioManager::StatusWidthFunction
static std::pair< TranslatableStrings, unsigned > StatusWidthFunction(const AudacityProject &project, StatusBarField field)
Definition: ProjectAudioManager.cpp:88
FormatRate
static TranslatableString FormatRate(int rate)
Definition: ProjectAudioManager.cpp:78
SelectedRegion
Defines a selected portion of a project.
Definition: SelectedRegion.h:38
ProjectAudioManager::OnPause
void OnPause()
Definition: ProjectAudioManager.cpp:976