From dd10e00a2de5745c1f80f08326b1caf28a58648b Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Mon, 27 May 2019 10:17:16 -0400 Subject: [PATCH] New attached structure ProjectSettings stores rate, snap-to, et al. --- src/AudacityApp.cpp | 2 +- src/BatchCommands.cpp | 5 +- src/Dependencies.cpp | 6 +- src/LabelTrack.cpp | 7 +- src/Menus.cpp | 9 +- src/MixerBoard.cpp | 6 +- src/Project.cpp | 217 +++++++++++------- src/Project.h | 133 ++++++----- src/Snap.cpp | 12 +- src/TimeTrack.cpp | 4 +- src/Track.cpp | 2 +- src/WaveTrack.cpp | 15 +- src/effects/Contrast.cpp | 3 +- src/effects/Effect.cpp | 5 +- src/effects/Equalization.cpp | 6 +- src/effects/ScienFilter.cpp | 6 +- src/effects/ToneGen.cpp | 21 +- src/effects/TruncSilence.cpp | 3 +- src/effects/nyquist/Nyquist.cpp | 2 +- src/export/Export.cpp | 5 +- src/export/ExportCL.cpp | 2 +- src/export/ExportFFmpeg.cpp | 3 +- src/export/ExportFLAC.cpp | 3 +- src/export/ExportMP2.cpp | 3 +- src/export/ExportMP3.cpp | 2 +- src/export/ExportMultiple.cpp | 10 +- src/export/ExportOGG.cpp | 2 +- src/export/ExportPCM.cpp | 2 +- src/menus/ClipMenus.cpp | 3 +- src/menus/EditMenus.cpp | 8 +- src/menus/PluginMenus.cpp | 3 +- src/menus/SelectMenus.cpp | 31 ++- src/menus/TrackMenus.cpp | 38 +-- src/menus/TransportMenus.cpp | 3 +- src/toolbars/ControlToolBar.cpp | 3 +- .../notetrack/ui/StretchHandle.cpp | 3 +- .../ui/PlayableTrackButtonHandles.cpp | 4 +- src/tracks/ui/SelectHandle.cpp | 3 +- src/tracks/ui/TimeShiftHandle.cpp | 2 +- src/widgets/Meter.cpp | 2 +- 40 files changed, 371 insertions(+), 228 deletions(-) diff --git a/src/AudacityApp.cpp b/src/AudacityApp.cpp index d0411749b..9095c81f8 100644 --- a/src/AudacityApp.cpp +++ b/src/AudacityApp.cpp @@ -1522,7 +1522,7 @@ bool AudacityApp::OnInit() } } - if( project->mShowSplashScreen ){ + if( ProjectSettings::Get( *project ).GetShowSplashScreen() ){ // This may do a check-for-updates at every start up. // Mainly this is to tell users of ALPHAS who don't know that they have an ALPHA. // Disabled for now, after discussion. diff --git a/src/BatchCommands.cpp b/src/BatchCommands.cpp index 3291e6eb1..fcc4db34a 100644 --- a/src/BatchCommands.cpp +++ b/src/BatchCommands.cpp @@ -801,14 +801,15 @@ bool MacroCommands::ApplyCommandInBatchMode( const wxString &friendlyCommand, CommandContext const * pContext) { AudacityProject *project = GetActiveProject(); + auto &settings = ProjectSettings::Get( *project ); // Recalc flags and enable items that may have become enabled. MenuManager::Get(*project).UpdateMenus(*project, false); // enter batch mode... - bool prevShowMode = project->GetShowId3Dialog(); + bool prevShowMode = settings.GetShowId3Dialog(); project->mBatchMode++; auto cleanup = finally( [&] { // exit batch mode... - project->SetShowId3Dialog(prevShowMode); + settings.SetShowId3Dialog(prevShowMode); project->mBatchMode--; } ); diff --git a/src/Dependencies.cpp b/src/Dependencies.cpp index 9ec79db0f..a4ecd0422 100644 --- a/src/Dependencies.cpp +++ b/src/Dependencies.cpp @@ -107,7 +107,8 @@ static void ReplaceBlockFiles(BlockPtrArray &blocks, void FindDependencies(AudacityProject *project, AliasedFileArray &outAliasedFiles) { - sampleFormat format = project->GetDefaultFormat(); + const auto &settings = ProjectSettings::Get( *project ); + sampleFormat format = settings.GetDefaultFormat(); BlockPtrArray blocks; GetAllSeqBlocks(project, &blocks); @@ -164,6 +165,7 @@ static void RemoveDependencies(AudacityProject *project, // STRONG-GUARANTEE { auto &dirManager = DirManager::Get( *project ); + const auto &settings = ProjectSettings::Get( *project ); ProgressDialog progress (_("Removing Dependencies"), @@ -183,7 +185,7 @@ static void RemoveDependencies(AudacityProject *project, BlockPtrArray blocks; GetAllSeqBlocks(project, &blocks); - const sampleFormat format = project->GetDefaultFormat(); + const sampleFormat format = settings.GetDefaultFormat(); ReplacedBlockFileHash blockFileHash; wxLongLong completedBytes = 0; for (const auto blockFile : blocks) { diff --git a/src/LabelTrack.cpp b/src/LabelTrack.cpp index 7d97b9b87..31ac4ba42 100644 --- a/src/LabelTrack.cpp +++ b/src/LabelTrack.cpp @@ -3085,11 +3085,12 @@ int LabelTrack::FindNextLabel(const SelectedRegion& currentRegion) void LabelTrack::DoEditLabels (AudacityProject &project, LabelTrack *lt, int index) { - auto format = project.GetSelectionFormat(), - freqFormat = project.GetFrequencySelectionFormatName(); + const auto &settings = ProjectSettings::Get( project ); + auto format = settings.GetSelectionFormat(), + freqFormat = settings.GetFrequencySelectionFormatName(); auto &tracks = TrackList::Get( project ); auto &trackFactory = TrackFactory::Get( project ); - auto rate = project.GetRate(); + auto rate = ProjectSettings::Get( project ).GetRate(); auto &viewInfo = ViewInfo::Get( project ); auto &window = ProjectWindow::Get( project ); diff --git a/src/Menus.cpp b/src/Menus.cpp index 57b075d2f..095f73007 100644 --- a/src/Menus.cpp +++ b/src/Menus.cpp @@ -554,7 +554,8 @@ CommandFlag MenuManager::GetUpdateFlags if (FileHistory::Global().GetCount() > 0) flags |= HaveRecentFiles; - if (project.IsSyncLocked()) + const auto &settings = ProjectSettings::Get( project ); + if (settings.IsSyncLocked()) flags |= IsSyncLockedFlag; else flags |= IsNotSyncLockedFlag; @@ -589,6 +590,8 @@ void MenuManager::ModifyToolbarMenus(AudacityProject &project) auto &commandManager = CommandManager::Get( project ); + auto &settings = ProjectSettings::Get( project ); + commandManager.Check(wxT("ShowScrubbingTB"), toolManager.IsVisible(ScrubbingBarID)); commandManager.Check(wxT("ShowDeviceTB"), @@ -644,8 +647,10 @@ void MenuManager::ModifyToolbarMenus(AudacityProject &project) commandManager.Check(wxT("Overdub"), active); gPrefs->Read(wxT("/AudioIO/SWPlaythrough"),&active, false); commandManager.Check(wxT("SWPlaythrough"), active); + gPrefs->Read(wxT("/GUI/SyncLockTracks"), &active, false); - project.SetSyncLock(active); + settings.SetSyncLock(active); + commandManager.Check(wxT("SyncLock"), active); gPrefs->Read(wxT("/GUI/TypeToCreateLabel"),&active, false); commandManager.Check(wxT("TypeToCreateLabel"), active); diff --git a/src/MixerBoard.cpp b/src/MixerBoard.cpp index 8a450bce4..9769defc3 100644 --- a/src/MixerBoard.cpp +++ b/src/MixerBoard.cpp @@ -283,7 +283,7 @@ MixerTrackCluster::MixerTrackCluster(wxWindow* parent, *(mMixerBoard->mImageSoloDisabled), true); // toggle button mToggleButton_Solo->SetName(_("Solo")); - bool bSoloNone = mProject->IsSoloNone(); + bool bSoloNone = ProjectSettings::Get( *mProject ).IsSoloNone(); mToggleButton_Solo->Show(!bSoloNone); @@ -382,7 +382,7 @@ void MixerTrackCluster::HandleResize() // For wxSizeEvents, update gain slider a mSlider_Velocity->SetSize(-1, nGainSliderHeight); #endif - bool bSoloNone = mProject->IsSoloNone(); + bool bSoloNone = ProjectSettings::Get( *mProject ).IsSoloNone(); mToggleButton_Solo->Show(!bSoloNone); @@ -747,7 +747,7 @@ void MixerTrackCluster::OnButton_Mute(wxCommandEvent& WXUNUSED(event)) mToggleButton_Mute->SetAlternateIdx(mTrack->GetSolo() ? 1 : 0); // Update the TrackPanel correspondingly. - if (mProject->IsSoloSimple()) + if (ProjectSettings::Get(*mProject).IsSoloSimple()) ProjectWindow::Get( *mProject ).RedrawProject(); else // Update only the changed track. diff --git a/src/Project.cpp b/src/Project.cpp index d03ddacf4..854dff472 100644 --- a/src/Project.cpp +++ b/src/Project.cpp @@ -1061,32 +1061,13 @@ AudacityProject::AudacityProject(wxWindow * parent, wxWindowID id, const wxPoint & pos, const wxSize & size) : wxFrame(parent, id, _TS("Audacity"), pos, size), - mbLoadedFromAup( false ), - mDefaultFormat(QualityPrefs::SampleFormatChoice()), - mSnapTo(gPrefs->Read(wxT("/SnapTo"), SNAP_OFF)), - mSelectionFormat( NumericTextCtrl::LookupFormat( - NumericConverter::TIME, - gPrefs->Read(wxT("/SelectionFormat"), wxT("")) ) ), - mFrequencySelectionFormatName( NumericTextCtrl::LookupFormat( - NumericConverter::FREQUENCY, - gPrefs->Read(wxT("/FrequencySelectionFormatName"), wxT("")) ) ), - mBandwidthSelectionFormatName( NumericTextCtrl::LookupFormat( - NumericConverter::BANDWIDTH, - gPrefs->Read(wxT("/BandwidthSelectionFormatName"), wxT("")) ) ) + mbLoadedFromAup( false ) { auto &project = *this; auto &window = project; mNextWindowID = NextID; - if (!gPrefs->Read(wxT("/SamplingRate/DefaultProjectSampleRate"), &mRate, AudioIO::GetOptimalSupportedSampleRate())) { - // The default given above can vary with host/devices. So unless there is an entry for - // the default sample rate in audacity.cfg, Audacity can open with a rate which is different - // from the rate with which it closed. See bug 1879. - gPrefs->Write(wxT("/SamplingRate/DefaultProjectSampleRate"), mRate); - gPrefs->Flush(); - } - #ifdef EXPERIMENTAL_DA2 SetBackgroundColour(theTheme.Colour( clrMedium )); #endif @@ -1113,11 +1094,6 @@ AudacityProject::AudacityProject(wxWindow * parent, wxWindowID id, mLockPlayRegion = false; - // Make sure valgrind sees mIsSyncLocked is initialized, even - // though we're about to set it from prefs. - mIsSyncLocked = false; - gPrefs->Read(wxT("/GUI/SyncLockTracks"), &mIsSyncLocked, false); - // LLL: Read this!!! // // Until the time (and cpu) required to refresh the track panel is @@ -1378,7 +1354,8 @@ void AudacityProject::ApplyUpdatedTheme() AudioIOStartStreamOptions DefaultPlayOptions( AudacityProject &project ) { - AudioIOStartStreamOptions options { project.GetRate() }; + AudioIOStartStreamOptions options { + ProjectSettings::Get( project ).GetRate() }; options.timeTrack = TrackList::Get( project ).GetTimeTrack(); options.listener = &project; return options; @@ -1390,7 +1367,7 @@ DefaultSpeedPlayOptions( AudacityProject &project ) auto PlayAtSpeedRate = gAudioIO->GetBestRate( false, //not capturing true, //is playing - project.GetRate() //suggested rate + ProjectSettings::Get( project ).GetRate() //suggested rate ); AudioIOStartStreamOptions options{ PlayAtSpeedRate }; options.timeTrack = TrackList::Get( project ).GetTimeTrack(); @@ -1398,7 +1375,7 @@ DefaultSpeedPlayOptions( AudacityProject &project ) return options; } -void AudacityProject::UpdatePrefsVariables() +void ProjectSettings::UpdatePrefs() { gPrefs->Read(wxT("/AudioFiles/ShowId3Dialog"), &mShowId3Dialog, true); gPrefs->Read(wxT("/AudioFiles/NormalizeOnLoad"),&mNormalizeOnLoad, false); @@ -1430,8 +1407,6 @@ void AudacityProject::UpdatePrefsVariables() void AudacityProject::UpdatePrefs() { - UpdatePrefsVariables(); - SetProjectTitle(); } @@ -1532,12 +1507,15 @@ void AudacityProject::SetProjectTitle( int number) bool AudacityProject::SnapSelection() { - if (mSnapTo != SNAP_OFF) { - auto &project = *this; + auto &project = *this; + auto &settings = ProjectSettings::Get( project ); + auto snapTo = settings.GetSnapTo(); + if (snapTo != SNAP_OFF) { auto &viewInfo = ViewInfo::Get( project ); SelectedRegion &selectedRegion = viewInfo.selectedRegion; - NumericConverter nc(NumericConverter::TIME, GetSelectionFormat(), 0, GetRate()); - const bool nearest = (mSnapTo == SNAP_NEAREST); + NumericConverter nc(NumericConverter::TIME, + settings.GetSelectionFormat(), 0, settings.GetRate()); + const bool nearest = (snapTo == SNAP_NEAREST); const double oldt0 = selectedRegion.t0(); const double oldt1 = selectedRegion.t1(); @@ -1562,30 +1540,37 @@ bool AudacityProject::SnapSelection() double AudacityProject::AS_GetRate() { - return mRate; + auto &project = *this; + auto &settings = ProjectSettings::Get( project ); + return settings.GetRate(); } // Typically this came from the SelectionToolbar and does not need to // be communicated back to it. void AudacityProject::AS_SetRate(double rate) { - mRate = rate; + auto &project = *this; + auto &settings = ProjectSettings::Get( project ); + settings.SetRate( rate ); } int AudacityProject::AS_GetSnapTo() { - return GetSnapTo(); + auto &project = *this; + auto &settings = ProjectSettings::Get( project ); + return settings.GetSnapTo(); } void AudacityProject::AS_SetSnapTo(int snap) { auto &project = *this; + auto &settings = ProjectSettings::Get( project ); - SetSnapTo( snap ); + settings.SetSnapTo( snap ); // LLL: TODO - what should this be changed to??? // GetCommandManager()->Check(wxT("Snap"), mSnapTo); - gPrefs->Write(wxT("/SnapTo"), mSnapTo); + gPrefs->Write(wxT("/SnapTo"), snap); gPrefs->Flush(); SnapSelection(); @@ -1597,15 +1582,18 @@ void AudacityProject::AS_SetSnapTo(int snap) const NumericFormatSymbol & AudacityProject::AS_GetSelectionFormat() { - return GetSelectionFormat(); + auto &project = *this; + auto &settings = ProjectSettings::Get( project ); + return settings.GetSelectionFormat(); } void AudacityProject::AS_SetSelectionFormat(const NumericFormatSymbol & format) { auto &project = *this; - SetSelectionFormat( format ); + auto &settings = ProjectSettings::Get( project ); + settings.SetSelectionFormat( format ); - gPrefs->Write(wxT("/SelectionFormat"), mSelectionFormat.Internal()); + gPrefs->Write(wxT("/SelectionFormat"), format.Internal()); gPrefs->Flush(); if (SnapSelection()) @@ -1617,25 +1605,29 @@ void AudacityProject::AS_SetSelectionFormat(const NumericFormatSymbol & format) double AudacityProject::SSBL_GetRate() const { auto &project = *this; + auto &settings = ProjectSettings::Get( project ); auto &tracks = TrackList::Get( project ); // Return maximum of project rate and all track rates. - return std::max( mRate, + return std::max( settings.GetRate(), tracks.Any().max( &WaveTrack::GetRate ) ); } const NumericFormatSymbol & AudacityProject::SSBL_GetFrequencySelectionFormatName() { - return GetFrequencySelectionFormatName(); + auto &project = *this; + auto &settings = ProjectSettings::Get( project ); + return settings.GetFrequencySelectionFormatName(); } void AudacityProject::SSBL_SetFrequencySelectionFormatName(const NumericFormatSymbol & formatName) { auto &project = *this; + auto &settings = ProjectSettings::Get( project ); - SetFrequencySelectionFormatName( formatName ); + settings.SetFrequencySelectionFormatName( formatName ); gPrefs->Write(wxT("/FrequencySelectionFormatName"), - mFrequencySelectionFormatName.Internal()); + formatName.Internal()); gPrefs->Flush(); #ifdef EXPERIMENTAL_SPECTRAL_EDITING @@ -1645,17 +1637,20 @@ void AudacityProject::SSBL_SetFrequencySelectionFormatName(const NumericFormatSy const NumericFormatSymbol & AudacityProject::SSBL_GetBandwidthSelectionFormatName() { - return GetBandwidthSelectionFormatName(); + auto &project = *this; + auto &settings = ProjectSettings::Get( project ); + return settings.GetBandwidthSelectionFormatName(); } void AudacityProject::SSBL_SetBandwidthSelectionFormatName(const NumericFormatSymbol & formatName) { auto &project = *this; + auto &settings = ProjectSettings::Get( project ); - SetBandwidthSelectionFormatName( formatName ); + settings.SetBandwidthSelectionFormatName( formatName ); gPrefs->Write(wxT("/BandwidthSelectionFormatName"), - mBandwidthSelectionFormatName.Internal()); + formatName.Internal()); gPrefs->Flush(); #ifdef EXPERIMENTAL_SPECTRAL_EDITING @@ -1685,32 +1680,32 @@ void AudacityProject::SSBL_ModifySpectralSelection(double &bottom, double &top, #endif } -const NumericFormatSymbol & AudacityProject::GetFrequencySelectionFormatName() const +const NumericFormatSymbol & ProjectSettings::GetFrequencySelectionFormatName() const { return mFrequencySelectionFormatName; } -void AudacityProject::SetFrequencySelectionFormatName(const NumericFormatSymbol & formatName) +void ProjectSettings::SetFrequencySelectionFormatName(const NumericFormatSymbol & formatName) { mFrequencySelectionFormatName = formatName; } -const NumericFormatSymbol & AudacityProject::GetBandwidthSelectionFormatName() const +const NumericFormatSymbol & ProjectSettings::GetBandwidthSelectionFormatName() const { return mBandwidthSelectionFormatName; } -void AudacityProject::SetBandwidthSelectionFormatName(const NumericFormatSymbol & formatName) +void ProjectSettings::SetBandwidthSelectionFormatName(const NumericFormatSymbol & formatName) { mBandwidthSelectionFormatName = formatName; } -void AudacityProject::SetSelectionFormat(const NumericFormatSymbol & format) +void ProjectSettings::SetSelectionFormat(const NumericFormatSymbol & format) { mSelectionFormat = format; } -const NumericFormatSymbol & AudacityProject::GetSelectionFormat() const +const NumericFormatSymbol & ProjectSettings::GetSelectionFormat() const { return mSelectionFormat; } @@ -2463,6 +2458,7 @@ void AudacityProject::OnCloseWindow(wxCloseEvent & event) { auto &project = *this; auto &projectFileIO = project; + const auto &settings = ProjectSettings::Get( project ); auto &tracks = TrackList::Get( project ); auto &window = project; @@ -2510,7 +2506,7 @@ void AudacityProject::OnCloseWindow(wxCloseEvent & event) // We may not bother to prompt the user to save, if the // project is now empty. - if (event.CanVeto() && (mEmptyCanBeDirty || bHasTracks)) { + if (event.CanVeto() && (settings.EmptyCanBeDirty() || bHasTracks)) { if ( UndoManager::Get( project ).UnsavedChanges() ) { TitleRestorer Restorer( this );// RAII /* i18n-hint: The first %s numbers the project, the second %s is the project name.*/ @@ -3136,10 +3132,13 @@ void AudacityProject::OpenFile(const FilePath &fileNameArg, bool addtohistory) const bool err = results.trackError; if (bParseSuccess) { - AS_SetSnapTo(GetSnapTo()); - AS_SetSelectionFormat(GetSelectionFormat()); - SSBL_SetFrequencySelectionFormatName(GetFrequencySelectionFormatName()); - SSBL_SetBandwidthSelectionFormatName(GetBandwidthSelectionFormatName()); + auto &settings = ProjectSettings::Get( project ); + AS_SetSnapTo(settings.GetSnapTo()); + AS_SetSelectionFormat(settings.GetSelectionFormat()); + SSBL_SetFrequencySelectionFormatName( + settings.GetFrequencySelectionFormatName()); + SSBL_SetBandwidthSelectionFormatName( + settings.GetBandwidthSelectionFormatName()); InitialState(); trackPanel.SetFocusedTrack( *tracks.Any().begin() ); @@ -3395,6 +3394,7 @@ bool AudacityProject::HandleXMLTag(const wxChar *tag, const wxChar **attrs) auto &window = ProjectWindow::Get( project ); auto &viewInfo = ViewInfo::Get( project ); auto &dirManager = DirManager::Get( project ); + auto &settings = ProjectSettings::Get( project ); bool bFileVersionFound = false; wxString fileVersion = _(""); wxString audacityVersion = _(""); @@ -3511,24 +3511,26 @@ bool AudacityProject::HandleXMLTag(const wxChar *tag, const wxChar **attrs) } else if (!wxStrcmp(attr, wxT("rate"))) { - Internat::CompatibleToDouble(value, &mRate); - SelectionBar::Get( project ).SetRate( mRate ); + double rate; + Internat::CompatibleToDouble(value, &rate); + settings.SetRate( rate ); + SelectionBar::Get( project ).SetRate( rate ); } else if (!wxStrcmp(attr, wxT("snapto"))) { - SetSnapTo(wxString(value) == wxT("on") ? true : false); + settings.SetSnapTo(wxString(value) == wxT("on") ? true : false); } else if (!wxStrcmp(attr, wxT("selectionformat"))) - SetSelectionFormat( + settings.SetSelectionFormat( NumericConverter::LookupFormat( NumericConverter::TIME, value) ); else if (!wxStrcmp(attr, wxT("frequencyformat"))) - SetFrequencySelectionFormatName( + settings.SetFrequencySelectionFormatName( NumericConverter::LookupFormat( NumericConverter::FREQUENCY, value ) ); else if (!wxStrcmp(attr, wxT("bandwidthformat"))) - SetBandwidthSelectionFormatName( + settings.SetBandwidthSelectionFormatName( NumericConverter::LookupFormat( NumericConverter::BANDWIDTH, value ) ); } // while @@ -3645,6 +3647,7 @@ void AudacityProject::WriteXML(XMLWriter &xmlFile, bool bWantSaveCopy) auto &viewInfo = ViewInfo::Get( proj ); auto &dirManager = DirManager::Get( proj ); auto &tags = Tags::Get( proj ); + const auto &settings = ProjectSettings::Get( proj ); //TIMER_START( "AudacityProject::WriteXML", xml_writer_timer ); // Warning: This block of code is duplicated in Save, for now... @@ -3680,14 +3683,14 @@ void AudacityProject::WriteXML(XMLWriter &xmlFile, bool bWantSaveCopy) xmlFile.WriteAttr(wxT("audacityversion"), AUDACITY_VERSION_STRING); viewInfo.WriteXMLAttributes(xmlFile); - xmlFile.WriteAttr(wxT("rate"), mRate); - xmlFile.WriteAttr(wxT("snapto"), GetSnapTo() ? wxT("on") : wxT("off")); + xmlFile.WriteAttr(wxT("rate"), settings.GetRate()); + xmlFile.WriteAttr(wxT("snapto"), settings.GetSnapTo() ? wxT("on") : wxT("off")); xmlFile.WriteAttr(wxT("selectionformat"), - GetSelectionFormat().Internal()); + settings.GetSelectionFormat().Internal()); xmlFile.WriteAttr(wxT("frequencyformat"), - GetFrequencySelectionFormatName().Internal()); + settings.GetFrequencySelectionFormatName().Internal()); xmlFile.WriteAttr(wxT("bandwidthformat"), - GetBandwidthSelectionFormatName().Internal()); + settings.GetBandwidthSelectionFormatName().Internal()); tags.WriteXML(xmlFile); @@ -3796,6 +3799,7 @@ bool AudacityProject::DoSave (const bool fromSaveAs, auto &proj = *this; auto &window = GetProjectFrame( proj ); auto &dirManager = DirManager::Get( proj ); + const auto &settings = ProjectSettings::Get( proj ); wxASSERT_MSG(!bWantSaveCopy || fromSaveAs, "Copy Project SHOULD only be availabele from SaveAs"); @@ -3806,7 +3810,8 @@ bool AudacityProject::DoSave (const bool fromSaveAs, auto &tracks = TrackList::Get( project ); if ( ! tracks.Any() ) { - if ( UndoManager::Get( proj ).UnsavedChanges() && mEmptyCanBeDirty) { + if ( UndoManager::Get( proj ).UnsavedChanges() + && settings.EmptyCanBeDirty()) { int result = AudacityMessageBox(_("Your project is now empty.\nIf saved, the project will have no tracks.\n\nTo save any previously open tracks:\nClick 'No', Edit > Undo until all tracks\nare open, then File > Save Project.\n\nSave anyway?"), _("Warning - Empty Project"), wxYES_NO | wxICON_QUESTION, this); @@ -4232,7 +4237,8 @@ AudacityProject::AddImportedTracks(const FilePath &fileName, // Automatically assign rate of imported file to whole project, // if this is the first file that is imported if (initiallyEmpty && newRate > 0) { - mRate = newRate; + auto &settings = ProjectSettings::Get( project ); + settings.SetRate( newRate ); SelectionBar::Get( project ).SetRate( newRate ); } @@ -4630,6 +4636,7 @@ void AudacityProject::PushState(const wxString &desc, UndoPush flags ) { auto &project = *this; + const auto &settings = ProjectSettings::Get( project ); auto &tracks = TrackList::Get( project ); auto &viewInfo = ViewInfo::Get( project ); auto &undoManager = UndoManager::Get( project ); @@ -4644,8 +4651,8 @@ void AudacityProject::PushState(const wxString &desc, menuManager.ModifyUndoMenuItems( project ); menuManager.UpdateMenus( project ); - if (GetTracksFitVerticallyZoomed()) - ViewActions::DoZoomFitV(*this); + if (settings.GetTracksFitVerticallyZoomed()) + ViewActions::DoZoomFitV( project ); if((flags & UndoPush::AUTOSAVE) != UndoPush::MINIMAL) AutoSave(); @@ -5188,17 +5195,17 @@ void AudacityProject::OnAudioIONewBlockFiles(const AutoSaveFile & blockFileLog) } } -void AudacityProject::SetSnapTo(int snap) +void ProjectSettings::SetSnapTo(int snap) { mSnapTo = snap; } -int AudacityProject::GetSnapTo() const +int ProjectSettings::GetSnapTo() const { return mSnapTo; } -bool AudacityProject::IsSyncLocked() +bool ProjectSettings::IsSyncLocked() const { #ifdef EXPERIMENTAL_SYNC_LOCK return mIsSyncLocked; @@ -5207,9 +5214,9 @@ bool AudacityProject::IsSyncLocked() #endif } -void AudacityProject::SetSyncLock(bool flag) +void ProjectSettings::SetSyncLock(bool flag) { - auto &project = *this; + auto &project = mProject; if (flag != mIsSyncLocked) { mIsSyncLocked = flag; TrackPanel::Get( project ).Refresh(false); @@ -5350,7 +5357,7 @@ int AudacityProject::GetEstimatedRecordingMinsLeftOnDisk(long lCaptureChannels) dRecTime = lFreeSpace.GetHi() * 4294967296.0 + lFreeSpace.GetLo(); dRecTime /= bytesOnDiskPerSample; dRecTime /= lCaptureChannels; - dRecTime /= GetRate(); + dRecTime /= ProjectSettings::Get( project ).GetRate(); // Convert to minutes before returning int iRecMins = (int)round(dRecTime / 60.0); @@ -5530,3 +5537,51 @@ void AudacityProject::CloseLock() mLastSavedTracks.reset(); } } + +static const AudacityProject::AttachedObjects::RegisteredFactory sProjectSettingsKey{ + []( AudacityProject &project ){ + auto result = std::make_shared< ProjectSettings >( project ); + return result; + } +}; + +ProjectSettings &ProjectSettings::Get( AudacityProject &project ) +{ + return project.AttachedObjects::Get< ProjectSettings >( sProjectSettingsKey ); +} + +const ProjectSettings &ProjectSettings::Get( const AudacityProject &project ) +{ + return Get( const_cast< AudacityProject & >( project ) ); +} + +ProjectSettings::ProjectSettings( AudacityProject &project ) +: mProject{ project } +, mSelectionFormat{ NumericTextCtrl::LookupFormat( + NumericConverter::TIME, + gPrefs->Read(wxT("/SelectionFormat"), wxT("")) ) +} +, mFrequencySelectionFormatName{ NumericTextCtrl::LookupFormat( + NumericConverter::FREQUENCY, + gPrefs->Read(wxT("/FrequencySelectionFormatName"), wxT("")) ) +} +, mBandwidthSelectionFormatName{ NumericTextCtrl::LookupFormat( + NumericConverter::BANDWIDTH, + gPrefs->Read(wxT("/BandwidthSelectionFormatName"), wxT("")) ) +} +, mDefaultFormat{ QualityPrefs::SampleFormatChoice() } +, mSnapTo( gPrefs->Read(wxT("/SnapTo"), SNAP_OFF) ) +{ + if (!gPrefs->Read(wxT("/SamplingRate/DefaultProjectSampleRate"), &mRate, + AudioIO::GetOptimalSupportedSampleRate())) { + // The default given above can vary with host/devices. So unless there is + // an entry for the default sample rate in audacity.cfg, Audacity can open + // with a rate which is different from the rate with which it closed. + // See bug 1879. + gPrefs->Write(wxT("/SamplingRate/DefaultProjectSampleRate"), mRate); + gPrefs->Flush(); + } + gPrefs->Read(wxT("/GUI/SyncLockTracks"), &mIsSyncLocked, false); + + UpdatePrefs(); +} diff --git a/src/Project.h b/src/Project.h index 30ff21fb2..a61efe723 100644 --- a/src/Project.h +++ b/src/Project.h @@ -194,10 +194,6 @@ class AUDACITY_DLL_API AudacityProject final : public wxFrame, virtual void ApplyUpdatedTheme(); - sampleFormat GetDefaultFormat() { return mDefaultFormat; } - - double GetRate() const { return mRate; } - void GetPlayRegion(double* playRegionStart, double *playRegionEnd); bool IsPlayRegionLocked() { return mLockPlayRegion; } void SetPlayRegionLocked(bool value) { mLockPlayRegion = value; } @@ -298,15 +294,6 @@ public: wxWindow *GetMainPage() { return mMainPage; } wxPanel *GetTopPanel() { return mTopPanel; } - bool GetTracksFitVerticallyZoomed() { return mTracksFitVerticallyZoomed; } //lda - void SetTracksFitVerticallyZoomed(bool flag) { mTracksFitVerticallyZoomed = flag; } //lda - - bool GetShowId3Dialog() { return mShowId3Dialog; } //lda - void SetShowId3Dialog(bool flag) { mShowId3Dialog = flag; } //lda - - bool GetNormalizeOnLoad() { return mNormalizeOnLoad; } //lda - void SetNormalizeOnLoad(bool flag) { mNormalizeOnLoad = flag; } //lda - // Timer Record Auto Save/Export Routines bool SaveFromTimerRecording(wxFileName fnFile); bool IsProjectSaved(); @@ -348,7 +335,6 @@ public: int GetProjectNumber(){ return mProjectNo;}; void UpdatePrefs() override; - void UpdatePrefsVariables(); void RedrawProject(const bool bForceWaveTracks = false); void RefreshCursor(); void Zoom(double level); @@ -357,27 +343,6 @@ public: void SkipEnd(bool shift); - bool IsSyncLocked(); - void SetSyncLock(bool flag); - - // Snap To - - void SetSnapTo(int snap); - int GetSnapTo() const; - - // Selection Format - - void SetSelectionFormat(const NumericFormatSymbol & format); - const NumericFormatSymbol & GetSelectionFormat() const; - - // Spectral Selection Formats - - void SetFrequencySelectionFormatName(const NumericFormatSymbol & format); - const NumericFormatSymbol & GetFrequencySelectionFormatName() const; - - void SetBandwidthSelectionFormatName(const NumericFormatSymbol & format); - const NumericFormatSymbol & GetBandwidthSelectionFormatName() const; - // Scrollbars void OnScrollLeft(); @@ -481,10 +446,6 @@ public: void AutoSave(); void DeleteCurrentAutoSaveFile(); - public: - bool IsSoloSimple() const { return mSoloPref == wxT("Simple"); } - bool IsSoloNone() const { return mSoloPref == wxT("None"); } - private: // The project's name and file info @@ -494,14 +455,6 @@ public: static int mProjectCounter;// global counter. int mProjectNo; // count when this project was created. - double mRate; - sampleFormat mDefaultFormat; - - int mSnapTo; - NumericFormatSymbol mSelectionFormat; - NumericFormatSymbol mFrequencySelectionFormatName; - NumericFormatSymbol mBandwidthSelectionFormatName; - std::shared_ptr mLastSavedTracks; private: @@ -536,8 +489,6 @@ private: MeterPanel *mCaptureMeter{}; public: - bool mShowSplashScreen; - wxString mSoloPref; bool mbBusyImporting{ false }; // used to fix bug 584 int mBatchMode{ 0 };// 0 means not, >0 means in batch mode. @@ -552,19 +503,12 @@ private: int mAudioIOToken{ -1 }; bool mIsDeleting{ false }; - bool mTracksFitVerticallyZoomed{ false }; //lda - bool mNormalizeOnLoad; //lda - bool mShowId3Dialog{ true }; //lda - bool mEmptyCanBeDirty; public: - bool EmptyCanBeDirty() const { return mEmptyCanBeDirty; } bool IsBeingDeleted() const { return mIsDeleting; } void SetIsBeingDeleted() { mIsDeleting = true; } private: - bool mIsSyncLocked; - bool mLockPlayRegion; std::unique_ptr mImportXMLTagHandler; @@ -655,8 +599,83 @@ inline const wxFrame *FindProjectFrame( const AudacityProject *project ) { return project ? &GetProjectFrame( *project ) : nullptr; } +class ProjectSettings final + : public ClientData::Base + , private PrefsListener +{ +public: + static ProjectSettings &Get( AudacityProject &project ); + static const ProjectSettings &Get( const AudacityProject &project ); + + ProjectSettings( AudacityProject &project ); + + sampleFormat GetDefaultFormat() const { return mDefaultFormat; } + + double GetRate() const { return mRate; } + void SetRate( double value ) { mRate = value; } + + bool GetTracksFitVerticallyZoomed() const { return mTracksFitVerticallyZoomed; } //lda + void SetTracksFitVerticallyZoomed(bool flag) { mTracksFitVerticallyZoomed = flag; } //lda + + bool GetShowId3Dialog() const { return mShowId3Dialog; } //lda + void SetShowId3Dialog(bool flag) { mShowId3Dialog = flag; } //lda + + bool GetNormalizeOnLoad() const { return mNormalizeOnLoad; } //lda + void SetNormalizeOnLoad(bool flag) { mNormalizeOnLoad = flag; } //lda + + bool IsSyncLocked() const; + void SetSyncLock(bool flag); + + // Snap To + + void SetSnapTo(int snap); + int GetSnapTo() const; + + // Selection Format + + void SetSelectionFormat(const NumericFormatSymbol & format); + const NumericFormatSymbol & GetSelectionFormat() const; + + // Spectral Selection Formats + + void SetFrequencySelectionFormatName(const NumericFormatSymbol & format); + const NumericFormatSymbol & GetFrequencySelectionFormatName() const; + + void SetBandwidthSelectionFormatName(const NumericFormatSymbol & format); + const NumericFormatSymbol & GetBandwidthSelectionFormatName() const; + + bool IsSoloSimple() const { return mSoloPref == wxT("Simple"); } + bool IsSoloNone() const { return mSoloPref == wxT("None"); } + + bool EmptyCanBeDirty() const { return mEmptyCanBeDirty; } + + bool GetShowSplashScreen() const { return mShowSplashScreen; } + +private: + void UpdatePrefs() override; + + AudacityProject &mProject; + + NumericFormatSymbol mSelectionFormat; + NumericFormatSymbol mFrequencySelectionFormatName; + NumericFormatSymbol mBandwidthSelectionFormatName; + + wxString mSoloPref; + + double mRate; + + sampleFormat mDefaultFormat; + int mSnapTo; + + bool mTracksFitVerticallyZoomed{ false }; //lda + bool mShowId3Dialog{ true }; //lda + bool mNormalizeOnLoad; //lda + bool mIsSyncLocked{ false }; + bool mEmptyCanBeDirty; + bool mShowSplashScreen; +}; + AudioIOStartStreamOptions DefaultPlayOptions( AudacityProject &project ); AudioIOStartStreamOptions DefaultSpeedPlayOptions( AudacityProject &project ); #endif - diff --git a/src/Snap.cpp b/src/Snap.cpp index e41289202..ea19857e3 100644 --- a/src/Snap.cpp +++ b/src/Snap.cpp @@ -72,9 +72,10 @@ SnapManager::~SnapManager() void SnapManager::Reinit() { - int snapTo = mProject->GetSnapTo(); - double rate = mProject->GetRate(); - auto format = mProject->GetSelectionFormat(); + const auto &settings = ProjectSettings::Get( *mProject ); + int snapTo = settings.GetSnapTo(); + double rate = settings.GetRate(); + auto format = settings.GetSelectionFormat(); // No need to reinit if these are still the same if (snapTo == mSnapTo && rate == mRate && format == mFormat) @@ -329,7 +330,10 @@ SnapResults SnapManager::Snap if (mSnapToTime) { // Find where it would snap time to the grid - mConverter.ValueToControls(t, GetActiveProject()->GetSnapTo() == SNAP_NEAREST); + mConverter.ValueToControls( + t, + ProjectSettings::Get( *GetActiveProject() ).GetSnapTo() == SNAP_NEAREST + ); mConverter.ControlsToValue(); results.timeSnappedTime = mConverter.GetValue(); } diff --git a/src/TimeTrack.cpp b/src/TimeTrack.cpp index f2b85f7e1..d384afe55 100644 --- a/src/TimeTrack.cpp +++ b/src/TimeTrack.cpp @@ -125,14 +125,14 @@ Track::Holder TimeTrack::Copy( double t0, double t1, bool ) const void TimeTrack::Clear(double t0, double t1) { - auto sampleTime = 1.0 / GetActiveProject()->GetRate(); + auto sampleTime = 1.0 / ProjectSettings::Get( *GetActiveProject() ).GetRate(); mEnvelope->CollapseRegion( t0, t1, sampleTime ); } void TimeTrack::Paste(double t, const Track * src) { bool bOk = src && src->TypeSwitch< bool >( [&] (const TimeTrack *tt) { - auto sampleTime = 1.0 / GetActiveProject()->GetRate(); + auto sampleTime = 1.0 / ProjectSettings::Get( *GetActiveProject() ).GetRate(); mEnvelope->PasteEnvelope (t, tt->mEnvelope.get(), sampleTime); return true; diff --git a/src/Track.cpp b/src/Track.cpp index 5bce3bf32..65fa56340 100644 --- a/src/Track.cpp +++ b/src/Track.cpp @@ -323,7 +323,7 @@ bool Track::IsSyncLockSelected() const { #ifdef EXPERIMENTAL_SYNC_LOCK AudacityProject *p = GetActiveProject(); - if (!p || !p->IsSyncLocked()) + if (!p || !ProjectSettings::Get( *p ).IsSyncLocked()) return false; auto pList = mList.lock(); diff --git a/src/WaveTrack.cpp b/src/WaveTrack.cpp index bdc78448c..9e021b64d 100644 --- a/src/WaveTrack.cpp +++ b/src/WaveTrack.cpp @@ -93,13 +93,16 @@ WaveTrack::Holder TrackFactory::NewWaveTrack(sampleFormat format, double rate) WaveTrack::WaveTrack(const std::shared_ptr &projDirManager, sampleFormat format, double rate) : PlayableTrack(projDirManager) { - if (format == (sampleFormat)0) { - format = GetActiveProject()->GetDefaultFormat(); - } - if (rate == 0) - { - rate = GetActiveProject()->GetRate(); + const auto settings = ProjectSettings::Get( *GetActiveProject() ); + if (format == (sampleFormat)0) + { + format = settings.GetDefaultFormat(); + } + if (rate == 0) + { + rate = settings.GetRate(); + } } // Force creation always: diff --git a/src/effects/Contrast.cpp b/src/effects/Contrast.cpp index 74c682cdd..dbb32c78b 100644 --- a/src/effects/Contrast.cpp +++ b/src/effects/Contrast.cpp @@ -194,7 +194,8 @@ ContrastDialog::ContrastDialog(wxWindow * parent, wxWindowID id, wxString number; AudacityProject *p = GetActiveProject(); - mProjectRate = p->GetRate(); + const auto &settings = ProjectSettings::Get( *p ); + mProjectRate = settings.GetRate(); ShuttleGui S(this, eIsCreating); diff --git a/src/effects/Effect.cpp b/src/effects/Effect.cpp index dc9927646..2496073f9 100644 --- a/src/effects/Effect.cpp +++ b/src/effects/Effect.cpp @@ -163,8 +163,7 @@ Effect::Effect() mUIDebug = false; AudacityProject *p = GetActiveProject(); - mProjectRate = p ? p->GetRate() : 44100; - + mProjectRate = p ? ProjectSettings::Get( *p ).GetRate() : 44100; mIsBatch = false; } @@ -770,7 +769,7 @@ NumericFormatSymbol Effect::GetDurationFormat() NumericFormatSymbol Effect::GetSelectionFormat() { - return GetActiveProject()->GetSelectionFormat(); + return ProjectSettings( *GetActiveProject() ).GetSelectionFormat(); } void Effect::SetDuration(double seconds) diff --git a/src/effects/Equalization.cpp b/src/effects/Equalization.cpp index 1dd056594..21090a20d 100644 --- a/src/effects/Equalization.cpp +++ b/src/effects/Equalization.cpp @@ -620,7 +620,11 @@ void EffectEqualization::PopulateOrExchange(ShuttleGui & S) LoadCurves(); const auto t = *inputTracks()->Any< const WaveTrack >().first; - mHiFreq = (t ? t->GetRate() : GetActiveProject()->GetRate()) / 2.0; + mHiFreq = + (t + ? t->GetRate() + : ProjectSettings::Get( *GetActiveProject() ).GetRate()) + / 2.0; mLoFreq = loFreqI; S.SetBorder(0); diff --git a/src/effects/ScienFilter.cpp b/src/effects/ScienFilter.cpp index 922cc8f6e..b26ce1344 100644 --- a/src/effects/ScienFilter.cpp +++ b/src/effects/ScienFilter.cpp @@ -346,7 +346,11 @@ bool EffectScienFilter::Init() { auto t = *trackRange.begin(); - mNyquist = (t ? t->GetRate() : GetActiveProject()->GetRate()) / 2.0; + mNyquist = + (t + ? t->GetRate() + : ProjectSettings::Get( *GetActiveProject() ).GetRate()) + / 2.0; } for (auto t : trackRange) diff --git a/src/effects/ToneGen.cpp b/src/effects/ToneGen.cpp index 5b648076a..30b78c33c 100644 --- a/src/effects/ToneGen.cpp +++ b/src/effects/ToneGen.cpp @@ -321,7 +321,11 @@ bool EffectToneGen::SetAutomationParameters(CommandParameters & parms) mWaveform = Waveform; mInterpolation = Interp; - double freqMax = (GetActiveProject() ? GetActiveProject()->GetRate() : 44100.0) / 2.0; + double freqMax = + (GetActiveProject() + ? ProjectSettings::Get( *GetActiveProject() ).GetRate() + : 44100.0) + / 2.0; mFrequency[1] = TrapDouble(mFrequency[1], MIN_EndFreq, freqMax); return true; @@ -364,7 +368,10 @@ void EffectToneGen::PopulateOrExchange(ShuttleGui & S) S.StartHorizontalLay(wxLEFT, 50); { FloatingPointValidator vldStartFreq(6, &mFrequency[0], NumValidatorStyle::NO_TRAILING_ZEROES); - vldStartFreq.SetRange(MIN_StartFreq, GetActiveProject()->GetRate() / 2.0); + vldStartFreq.SetRange( + MIN_StartFreq, + ProjectSettings::Get( *GetActiveProject() ).GetRate() / 2.0 + ); t = S.AddTextBox( {}, wxT(""), 12); t->SetName(_("Frequency Hertz Start")); t->SetValidator(vldStartFreq); @@ -374,7 +381,10 @@ void EffectToneGen::PopulateOrExchange(ShuttleGui & S) S.StartHorizontalLay(wxLEFT, 50); { FloatingPointValidator vldEndFreq(6, &mFrequency[1], NumValidatorStyle::NO_TRAILING_ZEROES); - vldEndFreq.SetRange(MIN_EndFreq, GetActiveProject()->GetRate() / 2.0); + vldEndFreq.SetRange( + MIN_EndFreq, + ProjectSettings::Get( *GetActiveProject() ).GetRate() / 2.0 + ); t = S.AddTextBox( {}, wxT(""), 12); t->SetName(_("Frequency Hertz End")); t->SetValidator(vldEndFreq); @@ -415,7 +425,10 @@ void EffectToneGen::PopulateOrExchange(ShuttleGui & S) else { FloatingPointValidator vldFrequency(6, &mFrequency[0], NumValidatorStyle::NO_TRAILING_ZEROES); - vldFrequency.SetRange(MIN_Frequency, GetActiveProject()->GetRate() / 2.0); + vldFrequency.SetRange( + MIN_Frequency, + ProjectSettings::Get( *GetActiveProject() ).GetRate() / 2.0 + ); t = S.AddTextBox(_("Frequency (Hz):"), wxT(""), 12); t->SetValidator(vldFrequency); diff --git a/src/effects/TruncSilence.cpp b/src/effects/TruncSilence.cpp index a526aa4e4..41c974cc5 100644 --- a/src/effects/TruncSilence.cpp +++ b/src/effects/TruncSilence.cpp @@ -328,7 +328,8 @@ bool EffectTruncSilence::ProcessIndependently() { unsigned nGroups = 0; - const bool syncLock = ::GetActiveProject()->IsSyncLocked(); + const auto &settings = ProjectSettings::Get( *::GetActiveProject() ); + const bool syncLock = settings.IsSyncLocked(); // Check if it's permissible { diff --git a/src/effects/nyquist/Nyquist.cpp b/src/effects/nyquist/Nyquist.cpp index ce5745a31..9ee460e45 100644 --- a/src/effects/nyquist/Nyquist.cpp +++ b/src/effects/nyquist/Nyquist.cpp @@ -738,7 +738,7 @@ bool NyquistEffect::Process() // numbers to Nyquist, whereas using "%g" will use the user's // decimal separator which may be a comma in some countries. mProps += wxString::Format(wxT("(putprop '*PROJECT* (float %s) 'RATE)\n"), - Internat::ToString(project->GetRate())); + Internat::ToString(ProjectSettings::Get(*project).GetRate())); mProps += wxString::Format(wxT("(putprop '*PROJECT* %d 'TRACKS)\n"), numTracks); mProps += wxString::Format(wxT("(putprop '*PROJECT* %d 'WAVETRACKS)\n"), numWave); mProps += wxString::Format(wxT("(putprop '*PROJECT* %d 'LABELTRACKS)\n"), numLabel); diff --git a/src/export/Export.cpp b/src/export/Export.cpp index 219a10589..87464d3d2 100644 --- a/src/export/Export.cpp +++ b/src/export/Export.cpp @@ -395,7 +395,7 @@ bool Exporter::Process(AudacityProject *project, bool selectedOnly, double t0, d if (mPlugins[mFormat]->GetCanMetaData(mSubFormat)) { if (!(EditActions::DoEditMetadata( *project, _("Edit Metadata Tags"), _("Exported Tags"), - mProject->GetShowId3Dialog()))) { + ProjectSettings::Get( *mProject ).GetShowId3Dialog()))) { return false; } } @@ -1034,7 +1034,8 @@ bool Exporter::SetAutoExportOptions(AudacityProject *project) { if (mPlugins[mFormat]->GetCanMetaData(mSubFormat)) { if (!(EditActions::DoEditMetadata( *project, _("Edit Metadata Tags"), - _("Exported Tags"), mProject->GetShowId3Dialog()))) { + _("Exported Tags"), + ProjectSettings::Get(*mProject).GetShowId3Dialog()))) { return false; } } diff --git a/src/export/ExportCL.cpp b/src/export/ExportCL.cpp index 63595775d..25e130bbe 100644 --- a/src/export/ExportCL.cpp +++ b/src/export/ExportCL.cpp @@ -388,7 +388,7 @@ ProgressResult ExportCL::Export(AudacityProject *project, wxLogNull nolog; // establish parameters - int rate = lrint(project->GetRate()); + int rate = lrint( ProjectSettings::Get( *project ).GetRate()); const size_t maxBlockLen = 44100 * 5; unsigned long totalSamples = lrint((t1 - t0) * rate); unsigned long sampleBytes = totalSamples * channels * SAMPLE_SIZE(int16Sample); diff --git a/src/export/ExportFFmpeg.cpp b/src/export/ExportFFmpeg.cpp index 828b2d538..09daabfe2 100644 --- a/src/export/ExportFFmpeg.cpp +++ b/src/export/ExportFFmpeg.cpp @@ -382,6 +382,7 @@ static int set_dict_int(AVDictionary **dict, const char *key, int val) bool ExportFFmpeg::InitCodecs(AudacityProject *project) { + const auto &settings = ProjectSettings::Get( *project ); AVCodec *codec = NULL; AVDictionary *options = NULL; AVDictionaryCleanup cleanup{ &options }; @@ -391,7 +392,7 @@ bool ExportFFmpeg::InitCodecs(AudacityProject *project) mEncAudioCodecCtx->codec_id = ExportFFmpegOptions::fmts[mSubFormat].codecid; mEncAudioCodecCtx->codec_type = AVMEDIA_TYPE_AUDIO; mEncAudioCodecCtx->codec_tag = av_codec_get_tag(mEncFormatCtx->oformat->codec_tag,mEncAudioCodecCtx->codec_id); - mSampleRate = (int)project->GetRate(); + mSampleRate = (int)settings.GetRate(); mEncAudioCodecCtx->global_quality = -99999; //quality mode is off by default; // Each export type has its own settings diff --git a/src/export/ExportFLAC.cpp b/src/export/ExportFLAC.cpp index a90eff0b8..1a858fe96 100644 --- a/src/export/ExportFLAC.cpp +++ b/src/export/ExportFLAC.cpp @@ -252,7 +252,8 @@ ProgressResult ExportFLAC::Export(AudacityProject *project, const Tags *metadata, int WXUNUSED(subformat)) { - double rate = project->GetRate(); + const auto &settings = ProjectSettings::Get( *project ); + double rate = settings.GetRate(); const auto &tracks = TrackList::Get( *project ); wxLogNull logNo; // temporarily disable wxWidgets error messages diff --git a/src/export/ExportMP2.cpp b/src/export/ExportMP2.cpp index cd3dc4d7a..d6bbcbf1f 100644 --- a/src/export/ExportMP2.cpp +++ b/src/export/ExportMP2.cpp @@ -210,9 +210,10 @@ ProgressResult ExportMP2::Export(AudacityProject *project, bool selectionOnly, double t0, double t1, MixerSpec *mixerSpec, const Tags *metadata, int WXUNUSED(subformat)) { + const auto &settings = ProjectSettings::Get( *project ); bool stereo = (channels == 2); long bitrate = gPrefs->Read(wxT("/FileFormats/MP2Bitrate"), 160); - double rate = project->GetRate(); + double rate = settings.GetRate(); const auto &tracks = TrackList::Get( *project ); wxLogNull logNo; /* temporarily disable wxWidgets error messages */ diff --git a/src/export/ExportMP3.cpp b/src/export/ExportMP3.cpp index f702de175..237cb2ade 100644 --- a/src/export/ExportMP3.cpp +++ b/src/export/ExportMP3.cpp @@ -1753,7 +1753,7 @@ ProgressResult ExportMP3::Export(AudacityProject *project, const Tags *metadata, int WXUNUSED(subformat)) { - int rate = lrint(project->GetRate()); + int rate = lrint( ProjectSettings::Get( *project ).GetRate()); #ifndef DISABLE_DYNAMIC_LOADING_LAME wxWindow *parent = ProjectWindow::Find( project ); #endif // DISABLE_DYNAMIC_LOADING_LAME diff --git a/src/export/ExportMultiple.cpp b/src/export/ExportMultiple.cpp index c07c6a305..316f318ee 100644 --- a/src/export/ExportMultiple.cpp +++ b/src/export/ExportMultiple.cpp @@ -739,13 +739,14 @@ ProgressResult ExportMultiple::ExportMultipleByLabel(bool byName, setting.filetags.SetTag(TAG_TITLE, title); setting.filetags.SetTag(TAG_TRACK, l+1); // let the user have a crack at editing it, exit if cancelled - bool bShowTagsDialog = mProject->GetShowId3Dialog(); + auto &settings = ProjectSettings::Get( *mProject ); + bool bShowTagsDialog = settings.GetShowId3Dialog(); if( bShowTagsDialog ){ bool bCancelled = !setting.filetags.ShowEditDialog( ProjectWindow::Find( mProject ), _("Edit Metadata Tags"), bShowTagsDialog); gPrefs->Read(wxT("/AudioFiles/ShowId3Dialog"), &bShowTagsDialog, true); - mProject->SetShowId3Dialog( bShowTagsDialog ); + settings.SetShowId3Dialog( bShowTagsDialog ); if( bCancelled ) return ProgressResult::Cancelled; } @@ -858,13 +859,14 @@ ProgressResult ExportMultiple::ExportMultipleByTrack(bool byName, setting.filetags.SetTag(TAG_TITLE, title); setting.filetags.SetTag(TAG_TRACK, l+1); // let the user have a crack at editing it, exit if cancelled - bool bShowTagsDialog = mProject->GetShowId3Dialog(); + auto &settings = ProjectSettings::Get( *mProject ); + bool bShowTagsDialog = settings.GetShowId3Dialog(); if( bShowTagsDialog ){ bool bCancelled = !setting.filetags.ShowEditDialog( ProjectWindow::Find( mProject ), _("Edit Metadata Tags"), bShowTagsDialog); gPrefs->Read(wxT("/AudioFiles/ShowId3Dialog"), &bShowTagsDialog, true); - mProject->SetShowId3Dialog( bShowTagsDialog ); + settings.SetShowId3Dialog( bShowTagsDialog ); if( bCancelled ) return ProgressResult::Cancelled; } diff --git a/src/export/ExportOGG.cpp b/src/export/ExportOGG.cpp index 80801153f..fa112e1da 100644 --- a/src/export/ExportOGG.cpp +++ b/src/export/ExportOGG.cpp @@ -170,7 +170,7 @@ ProgressResult ExportOGG::Export(AudacityProject *project, const Tags *metadata, int WXUNUSED(subformat)) { - double rate = project->GetRate(); + double rate = ProjectSettings::Get( *project ).GetRate(); const auto &tracks = TrackList::Get( *project ); double quality = (gPrefs->Read(wxT("/FileFormats/OggExportQuality"), 50)/(float)100.0); diff --git a/src/export/ExportPCM.cpp b/src/export/ExportPCM.cpp index 814742ed0..174f99eee 100644 --- a/src/export/ExportPCM.cpp +++ b/src/export/ExportPCM.cpp @@ -442,7 +442,7 @@ ProgressResult ExportPCM::Export(AudacityProject *project, const Tags *metadata, int subformat) { - double rate = project->GetRate(); + double rate = ProjectSettings::Get( *project ).GetRate(); const auto &tracks = TrackList::Get( *project ); int sf_format; diff --git a/src/menus/ClipMenus.cpp b/src/menus/ClipMenus.cpp index 610d80aff..367f92207 100644 --- a/src/menus/ClipMenus.cpp +++ b/src/menus/ClipMenus.cpp @@ -701,8 +701,9 @@ void DoClipLeftOrRight auto &trackPanel = TrackPanel::Get( project ); auto &viewInfo = ViewInfo::Get( project ); auto &selectedRegion = viewInfo.selectedRegion; + const auto &settings = ProjectSettings::Get( project ); auto &tracks = TrackList::Get( project ); - auto isSyncLocked = project.IsSyncLocked(); + auto isSyncLocked = settings.IsSyncLocked(); auto amount = DoClipMove( viewInfo, trackPanel.GetFocusedTrack(), tracks, isSyncLocked, right ); diff --git a/src/menus/EditMenus.cpp b/src/menus/EditMenus.cpp index 95db28354..f1be7646c 100644 --- a/src/menus/EditMenus.cpp +++ b/src/menus/EditMenus.cpp @@ -139,7 +139,7 @@ bool DoPasteNothingSelected(AudacityProject &project) // with various project and track sample rates. // So do it at the sample rate of the project AudacityProject *p = GetActiveProject(); - double projRate = p->GetRate(); + double projRate = ProjectSettings::Get( *p ).GetRate(); double quantT0 = QUANTIZED_TIME(clipboard.T0(), projRate); double quantT1 = QUANTIZED_TIME(clipboard.T1(), projRate); selectedRegion.setTimes( @@ -201,6 +201,7 @@ bool DoEditMetadata (AudacityProject &project, const wxString &title, const wxString &shortUndoDescription, bool force) { + auto &settings = ProjectSettings::Get( project ); auto &tags = Tags::Get( project ); // Back up my tags @@ -218,7 +219,7 @@ bool DoEditMetadata } bool bShowInFuture; gPrefs->Read(wxT("/AudioFiles/ShowId3Dialog"), &bShowInFuture, true); - project.SetShowId3Dialog( bShowInFuture ); + settings.SetShowId3Dialog( bShowInFuture ); return true; } @@ -440,9 +441,10 @@ void OnPaste(const CommandContext &context) auto &trackPanel = TrackPanel::Get( project ); auto &trackFactory = TrackFactory::Get( project ); auto &selectedRegion = ViewInfo::Get( project ).selectedRegion; + const auto &settings = ProjectSettings::Get( project ); auto &window = ProjectWindow::Get( project ); - auto isSyncLocked = project.IsSyncLocked(); + auto isSyncLocked = settings.IsSyncLocked(); // Handle text paste (into active label) first. if (DoPasteText(project)) diff --git a/src/menus/PluginMenus.cpp b/src/menus/PluginMenus.cpp index 605bf1e53..6fb4ee77e 100644 --- a/src/menus/PluginMenus.cpp +++ b/src/menus/PluginMenus.cpp @@ -423,10 +423,11 @@ bool DoEffect( const PluginID & ID, const CommandContext &context, unsigned flags ) { AudacityProject &project = context.project; + const auto &settings = ProjectSettings::Get( project ); auto &tracks = TrackList::Get( project ); auto &trackPanel = TrackPanel::Get( project ); auto &trackFactory = TrackFactory::Get( project ); - auto rate = project.GetRate(); + auto rate = settings.GetRate(); auto &selectedRegion = ViewInfo::Get( project ).selectedRegion; auto &commandManager = CommandManager::Get( project ); auto &window = ProjectWindow::Get( project ); diff --git a/src/menus/SelectMenus.cpp b/src/menus/SelectMenus.cpp index acadc8255..4b875f6a4 100644 --- a/src/menus/SelectMenus.cpp +++ b/src/menus/SelectMenus.cpp @@ -93,7 +93,8 @@ void DoNextPeakFrequency(AudacityProject &project, bool up) double NearestZeroCrossing (AudacityProject &project, double t0) { - auto rate = project.GetRate(); + const auto &settings = ProjectSettings::Get( project ); + auto rate = settings.GetRate(); auto &tracks = TrackList::Get( project ); // Window is 1/100th of a second. @@ -226,9 +227,10 @@ void SeekWhenAudioActive(double seekStep, wxLongLong &lastSelectionAdjustment) double GridMove (AudacityProject &project, double t, int minPix) { - auto rate = project.GetRate(); + const auto &settings = ProjectSettings::Get( project ); + auto rate = settings.GetRate(); auto &viewInfo = ViewInfo::Get( project ); - auto format = project.GetSelectionFormat(); + auto format = settings.GetSelectionFormat(); NumericConverter nc(NumericConverter::TIME, format, t, rate); @@ -271,10 +273,11 @@ void MoveWhenAudioInactive auto &trackPanel = TrackPanel::Get( project ); auto &tracks = TrackList::Get( project ); auto &ruler = AdornedRulerPanel::Get( project ); + const auto &settings = ProjectSettings::Get( project ); auto &window = ProjectWindow::Get( project ); // If TIME_UNIT_SECONDS, snap-to will be off. - int snapToTime = project.GetSnapTo(); + int snapToTime = settings.GetSnapTo(); const double t0 = viewInfo.selectedRegion.t0(); const double end = std::max( tracks.GetEndTime(), @@ -324,6 +327,7 @@ SelectionOperation operation) auto &viewInfo = ViewInfo::Get( project ); auto &trackPanel = TrackPanel::Get( project ); auto &tracks = TrackList::Get( project ); + const auto &settings = ProjectSettings::Get( project ); if( operation == CURSOR_MOVE ) { @@ -331,7 +335,7 @@ SelectionOperation operation) return; } - int snapToTime = project.GetSnapTo(); + int snapToTime = settings.GetSnapTo(); const double t0 = viewInfo.selectedRegion.t0(); const double t1 = viewInfo.selectedRegion.t1(); const double end = std::max( @@ -513,10 +517,12 @@ void DoListSelection auto &tracks = TrackList::Get( project ); auto &trackPanel = TrackPanel::Get( project ); auto &selectionState = SelectionState::Get( project ); + const auto &settings = ProjectSettings::Get( project ); auto &viewInfo = ViewInfo::Get( project ); auto &window = GetProjectFrame( project ); - auto isSyncLocked = project.IsSyncLocked(); + auto isSyncLocked = settings.IsSyncLocked(); + selectionState.HandleListSelection( tracks, viewInfo, *t, shift, ctrl, isSyncLocked ); @@ -611,6 +617,7 @@ void OnSetLeftSelection(const CommandContext &context) auto &project = context.project; auto token = project.GetAudioIOToken(); auto &selectedRegion = ViewInfo::Get( project ).selectedRegion; + const auto &settings = ProjectSettings::Get( project ); auto &trackPanel = TrackPanel::Get( project ); auto &window = GetProjectFrame( project ); @@ -623,8 +630,8 @@ void OnSetLeftSelection(const CommandContext &context) } else { - auto fmt = project.GetSelectionFormat(); - auto rate = project.GetRate(); + auto fmt = settings.GetSelectionFormat(); + auto rate = settings.GetRate(); TimeDialog dlg(&window, _("Set Left Selection Boundary"), fmt, rate, selectedRegion.t0(), _("Position")); @@ -650,6 +657,7 @@ void OnSetRightSelection(const CommandContext &context) auto &project = context.project; auto token = project.GetAudioIOToken(); auto &selectedRegion = ViewInfo::Get( project ).selectedRegion; + const auto &settings = ProjectSettings::Get( project ); auto &trackPanel = TrackPanel::Get( project ); auto &window = GetProjectFrame( project ); @@ -662,8 +670,8 @@ void OnSetRightSelection(const CommandContext &context) } else { - auto fmt = project.GetSelectionFormat(); - auto rate = project.GetRate(); + auto fmt = settings.GetSelectionFormat(); + auto rate = settings.GetRate(); TimeDialog dlg(&window, _("Set Right Selection Boundary"), fmt, rate, selectedRegion.t1(), _("Position")); @@ -867,6 +875,7 @@ void OnZeroCrossing(const CommandContext &context) { auto &project = context.project; auto &selectedRegion = ViewInfo::Get( project ).selectedRegion; + const auto &settings = ProjectSettings::Get( project ); auto &trackPanel = TrackPanel::Get( project ); const double t0 = NearestZeroCrossing(project, selectedRegion.t0()); @@ -875,7 +884,7 @@ void OnZeroCrossing(const CommandContext &context) else { const double t1 = NearestZeroCrossing(project, selectedRegion.t1()); // Empty selection is generally not much use, so do not make it if empty. - if( fabs( t1 - t0 ) * project.GetRate() > 1.5 ) + if( fabs( t1 - t0 ) * settings.GetRate() > 1.5 ) selectedRegion.setTimes(t0, t1); } diff --git a/src/menus/TrackMenus.cpp b/src/menus/TrackMenus.cpp index e3d7432f7..b8e63373a 100644 --- a/src/menus/TrackMenus.cpp +++ b/src/menus/TrackMenus.cpp @@ -38,10 +38,11 @@ namespace { void DoMixAndRender (AudacityProject &project, bool toNewTrack) { + const auto &settings = ProjectSettings::Get( project ); auto &tracks = TrackList::Get( project ); auto &trackFactory = TrackFactory::Get( project ); - auto rate = project.GetRate(); - auto defaultFormat = project.GetDefaultFormat(); + auto rate = settings.GetRate(); + auto defaultFormat = settings.GetDefaultFormat(); auto &trackPanel = TrackPanel::Get( project ); auto &window = ProjectWindow::Get( project ); @@ -600,6 +601,7 @@ void DoRemoveTracks( AudacityProject &project ) void DoTrackMute(AudacityProject &project, Track *t, bool exclusive) { + const auto &settings = ProjectSettings::Get( project ); auto &tracks = TrackList::Get( project ); auto &trackPanel = TrackPanel::Get( project ); @@ -626,7 +628,7 @@ void DoTrackMute(AudacityProject &project, Track *t, bool exclusive) for (auto channel : TrackList::Channels(pt)) channel->SetMute( !wasMute ); - if (project.IsSoloSimple() || project.IsSoloNone()) + if (settings.IsSoloSimple() || settings.IsSoloNone()) { // We also set a solo indicator if we have just one track / stereo pair playing. // in a group of more than one playable tracks. @@ -649,6 +651,7 @@ void DoTrackMute(AudacityProject &project, Track *t, bool exclusive) void DoTrackSolo(AudacityProject &project, Track *t, bool exclusive) { + const auto &settings = ProjectSettings::Get( project ); auto &tracks = TrackList::Get( project ); auto &trackPanel = TrackPanel::Get( project ); @@ -660,7 +663,7 @@ void DoTrackSolo(AudacityProject &project, Track *t, bool exclusive) return; bool bWasSolo = pt->GetSolo(); - bool bSoloMultiple = !project.IsSoloSimple() ^ exclusive; + bool bSoloMultiple = !settings.IsSoloSimple() ^ exclusive; // Standard and Simple solo have opposite defaults: // Standard - Behaves as individual buttons, shift=radio buttons @@ -682,12 +685,12 @@ void DoTrackSolo(AudacityProject &project, Track *t, bool exclusive) for (auto channel : group) { if (chosen) { channel->SetSolo( !bWasSolo ); - if( project.IsSoloSimple() ) + if( settings.IsSoloSimple() ) channel->SetMute( false ); } else { channel->SetSolo( false ); - if( project.IsSoloSimple() ) + if( settings.IsSoloSimple() ) channel->SetMute( !bWasSolo ); } } @@ -799,13 +802,14 @@ struct Handler : CommandHandlerObject { void OnNewWaveTrack(const CommandContext &context) { auto &project = context.project; + const auto &settings = ProjectSettings::Get( project ); auto &tracks = TrackList::Get( project ); auto &trackFactory = TrackFactory::Get( project ); auto &trackPanel = TrackPanel::Get( project ); auto &window = ProjectWindow::Get( project ); - auto defaultFormat = project.GetDefaultFormat(); - auto rate = project.GetRate(); + auto defaultFormat = settings.GetDefaultFormat(); + auto rate = settings.GetRate(); auto t = tracks.Add( trackFactory.NewWaveTrack( defaultFormat, rate ) ); SelectActions::SelectNone( project ); @@ -821,13 +825,14 @@ void OnNewWaveTrack(const CommandContext &context) void OnNewStereoTrack(const CommandContext &context) { auto &project = context.project; + const auto &settings = ProjectSettings::Get( project ); auto &tracks = TrackList::Get( project ); auto &trackFactory = TrackFactory::Get( project ); auto &trackPanel = TrackPanel::Get( project ); auto &window = ProjectWindow::Get( project ); - auto defaultFormat = project.GetDefaultFormat(); - auto rate = project.GetRate(); + auto defaultFormat = settings.GetDefaultFormat(); + auto rate = settings.GetRate(); SelectActions::SelectNone( project ); @@ -913,7 +918,8 @@ void OnMixAndRenderToNewTrack(const CommandContext &context) void OnResample(const CommandContext &context) { auto &project = context.project; - auto projectRate = project.GetRate(); + const auto &settings = ProjectSettings::Get( project ); + auto projectRate = settings.GetRate(); auto &tracks = TrackList::Get( project ); auto &undoManager = UndoManager::Get( project ); auto &window = ProjectWindow::Get( project ); @@ -1025,11 +1031,12 @@ void OnRemoveTracks(const CommandContext &context) void OnMuteAllTracks(const CommandContext &context) { auto &project = context.project; + const auto &settings = ProjectSettings::Get( project ); auto &tracks = TrackList::Get( project ); auto &window = ProjectWindow::Get( project ); - auto soloSimple = project.IsSoloSimple(); - auto soloNone = project.IsSoloNone(); + auto soloSimple = settings.IsSoloSimple(); + auto soloNone = settings.IsSoloNone(); for (auto pt : tracks.Any()) { @@ -1045,11 +1052,12 @@ void OnMuteAllTracks(const CommandContext &context) void OnUnmuteAllTracks(const CommandContext &context) { auto &project = context.project; + const auto &settings = ProjectSettings::Get( project ); auto &tracks = TrackList::Get( project ); auto &window = ProjectWindow::Get( project ); - auto soloSimple = project.IsSoloSimple(); - auto soloNone = project.IsSoloNone(); + auto soloSimple = settings.IsSoloSimple(); + auto soloNone = settings.IsSoloNone(); for (auto pt : tracks.Any()) { diff --git a/src/menus/TransportMenus.cpp b/src/menus/TransportMenus.cpp index b899c3459..40ffe0aa7 100644 --- a/src/menus/TransportMenus.cpp +++ b/src/menus/TransportMenus.cpp @@ -399,6 +399,7 @@ void OnRecord2ndChoice(const CommandContext &context) void OnTimerRecord(const CommandContext &context) { auto &project = context.project; + const auto &settings = ProjectSettings::Get( project ); auto &undoManager = UndoManager::Get( project ); auto &window = ProjectWindow::Get( project ); @@ -417,7 +418,7 @@ void OnTimerRecord(const CommandContext &context) // preventing issues surrounding "dirty" projects when Automatic Save/Export // is used in Timer Recording. if ((undoManager.UnsavedChanges()) && - (TrackList::Get( project ).Any() || project.EmptyCanBeDirty())) { + (TrackList::Get( project ).Any() || settings.EmptyCanBeDirty())) { AudacityMessageBox(_("Timer Recording cannot be used while you have unsaved changes.\n\nPlease save or close this project and try again."), _("Timer Recording"), wxICON_INFORMATION | wxOK); diff --git a/src/toolbars/ControlToolBar.cpp b/src/toolbars/ControlToolBar.cpp index 5a230340a..0c13a9397 100644 --- a/src/toolbars/ControlToolBar.cpp +++ b/src/toolbars/ControlToolBar.cpp @@ -1242,7 +1242,8 @@ bool ControlToolBar::DoRecord(AudacityProject &project, newTrack->SetName(baseTrackName + wxT("_") + nameSuffix); } - if ((recordingChannels > 2) && !(p->GetTracksFitVerticallyZoomed())) { + if ((recordingChannels > 2) && + !(ProjectSettings::Get(*p).GetTracksFitVerticallyZoomed())) { newTrack->SetMinimized(true); } diff --git a/src/tracks/playabletrack/notetrack/ui/StretchHandle.cpp b/src/tracks/playabletrack/notetrack/ui/StretchHandle.cpp index 0b9c68ae6..ab3e1a720 100644 --- a/src/tracks/playabletrack/notetrack/ui/StretchHandle.cpp +++ b/src/tracks/playabletrack/notetrack/ui/StretchHandle.cpp @@ -224,8 +224,9 @@ UIHandle::Result StretchHandle::Release bool left = mStretchState.mMode == stretchLeft; bool right = mStretchState.mMode == stretchRight; + const auto &settings = ProjectSettings::Get( *pProject ); auto &viewInfo = ViewInfo::Get( *pProject ); - if ( pProject->IsSyncLocked() && ( left || right ) ) { + if ( settings.IsSyncLocked() && ( left || right ) ) { for ( auto track : TrackList::SyncLockGroup( mpTrack.get() ) ) { if ( track != mpTrack.get() ) { diff --git a/src/tracks/playabletrack/ui/PlayableTrackButtonHandles.cpp b/src/tracks/playabletrack/ui/PlayableTrackButtonHandles.cpp index f5e2bc620..4eec49a23 100644 --- a/src/tracks/playabletrack/ui/PlayableTrackButtonHandles.cpp +++ b/src/tracks/playabletrack/ui/PlayableTrackButtonHandles.cpp @@ -60,7 +60,7 @@ UIHandlePtr MuteButtonHandle::HitTest wxRect buttonRect; if ( pTrack ) TrackInfo::GetMuteSoloRect(rect, buttonRect, false, - !pProject->IsSoloNone(), pTrack.get()); + !ProjectSettings::Get( *pProject ).IsSoloNone(), pTrack.get()); if ( TrackInfo::HideTopItem( rect, buttonRect ) ) return {}; @@ -116,7 +116,7 @@ UIHandlePtr SoloButtonHandle::HitTest wxRect buttonRect; if ( pTrack ) TrackInfo::GetMuteSoloRect(rect, buttonRect, true, - !pProject->IsSoloNone(), pTrack.get()); + !ProjectSettings::Get( *pProject ).IsSoloNone(), pTrack.get()); if ( TrackInfo::HideTopItem( rect, buttonRect ) ) return {}; diff --git a/src/tracks/ui/SelectHandle.cpp b/src/tracks/ui/SelectHandle.cpp index e8983efa9..3807b4917 100644 --- a/src/tracks/ui/SelectHandle.cpp +++ b/src/tracks/ui/SelectHandle.cpp @@ -554,6 +554,7 @@ UIHandle::Result SelectHandle::Click return RefreshAll | Cancelled; auto &selectionState = SelectionState::Get( *pProject ); + const auto &settings = ProjectSettings::Get( *pProject ); if (event.LeftDClick() && !event.ShiftDown()) { auto &trackList = TrackList::Get( *pProject ); @@ -564,7 +565,7 @@ UIHandle::Result SelectHandle::Click // Default behavior: select whole track SelectionState::SelectTrackLength - ( viewInfo, *pTrack, pProject->IsSyncLocked() ); + ( viewInfo, *pTrack, settings.IsSyncLocked() ); // Special case: if we're over a clip in a WaveTrack, // select just that clip diff --git a/src/tracks/ui/TimeShiftHandle.cpp b/src/tracks/ui/TimeShiftHandle.cpp index f1ffdf0f2..d8a44a593 100644 --- a/src/tracks/ui/TimeShiftHandle.cpp +++ b/src/tracks/ui/TimeShiftHandle.cpp @@ -407,7 +407,7 @@ UIHandle::Result TimeShiftHandle::Click else if ( captureClips ) CreateListOfCapturedClips( mClipMoveState, viewInfo, *pTrack, trackList, - pProject->IsSyncLocked(), clickTime ); + ProjectSettings::Get( *pProject ).IsSyncLocked(), clickTime ); mSlideUpDownOnly = event.CmdDown() && !multiToolModeActive; mRect = rect; diff --git a/src/widgets/Meter.cpp b/src/widgets/Meter.cpp index d38e6c20c..1934f1573 100644 --- a/src/widgets/Meter.cpp +++ b/src/widgets/Meter.cpp @@ -1871,7 +1871,7 @@ void MeterPanel::StartMonitoring() if (start && !gAudioIO->IsBusy()){ AudacityProject *p = GetActiveProject(); if (p){ - gAudioIO->StartMonitoring(p->GetRate()); + gAudioIO->StartMonitoring( ProjectSettings::Get( *p ).GetRate()); } mLayoutValid = false;