Audacity  2.2.2
Project.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  Project.h
6 
7  Dominic Mazzoni
8 
9  In Audacity, the main window you work in is called a project.
10  Projects can contain an arbitrary number of tracks of many
11  different types, but if a project contains just one or two
12  tracks then it can be saved in standard formats like WAV or AIFF.
13  This window is the one that contains the menu bar (except on
14  the Mac).
15 
16 **********************************************************************/
17 
18 #ifndef __AUDACITY_PROJECT__
19 #define __AUDACITY_PROJECT__
20 
21 #include "Audacity.h"
22 #include "Experimental.h"
23 
24 #include "widgets/OverlayPanel.h"
25 
26 #include "DirManager.h"
27 #include "SelectionState.h"
28 #include "ViewInfo.h"
29 #include "TrackPanelListener.h"
30 #include "AudioIOListener.h"
33 #include "xml/XMLTagHandler.h"
36 
37 #include "MemoryX.h"
38 #include <wx/defs.h>
39 #include <wx/event.h>
40 #include <wx/log.h>
41 #include <wx/dragimag.h>
42 #include <wx/generic/dragimgg.h>
43 #include <wx/frame.h>
44 #include <wx/intl.h>
45 #include <wx/dcclient.h>
46 
47 #include "import/ImportRaw.h" // defines TrackHolders
48 
49 const int AudacityProjectTimerID = 5200;
50 
51 class wxWindow;
52 class wxDialog;
53 class wxBoxSizer;
54 class wxScrollEvent;
55 class wxScrollBar;
56 class wxPanel;
57 class wxTimerEvent;
58 
59 class AudacityProject;
61 class Importer;
62 class ODLock;
64 class TrackList;
65 class Tags;
66 
67 class TrackPanel;
68 class FreqWindow;
69 class ContrastDialog;
70 class MeterPanel;
71 
72 // toolbar classes
74 class DeviceToolBar;
75 class EditToolBar;
76 class MeterToolBar;
78 class Scrubber;
79 class ScrubbingToolBar;
80 class SelectionBar;
82 class ToolManager;
85 
86 // windows and frames
87 class AdornedRulerPanel;
88 class HistoryWindow;
89 class MacrosWindow;
91 class MixerBoard;
92 class MixerBoardFrame;
93 
95 struct UndoState;
96 
97 class Regions;
98 
99 class LWSlider;
100 class UndoManager;
101 enum class UndoPush : unsigned char;
102 
103 class Track;
104 class WaveClip;
105 class BackgroundCell;
106 
107 
109 AUDACITY_DLL_API AudacityProject *GetActiveProject();
110 void RedrawAllProjects();
112 AUDACITY_DLL_API void CloseAllProjects();
113 
114 void GetDefaultWindowRect(wxRect *defRect);
115 void GetNextWindowPlacement(wxRect *nextRect, bool *pMaximized, bool *pIconized);
116 bool IsWindowAccessible(wxRect *requestedRect);
117 
118 // Use shared_ptr to projects, because elsewhere we need weak_ptr
119 using AProjectHolder = std::shared_ptr< AudacityProject >;
120 using AProjectArray = std::vector< AProjectHolder >;
121 
123 
124 
125 enum class PlayMode : int {
126  normalPlay,
127  oneSecondPlay, // Disables auto-scrolling
128  loopedPlay // Disables auto-scrolling
129 };
130 
135 };
136 
140 DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, EVT_CAPTURE_KEY, -1);
141 
142 // XML handler for <import> tag
143 class ImportXMLTagHandler final : public XMLTagHandler
144 {
145  public:
146  ImportXMLTagHandler(AudacityProject* pProject) { mProject = pProject; }
147 
148  bool HandleXMLTag(const wxChar *tag, const wxChar **attrs) override;
149  XMLTagHandler *HandleXMLChild(const wxChar * WXUNUSED(tag)) override
150  { return NULL; }
151 
152  // Don't want a WriteXML method because ImportXMLTagHandler is not a WaveTrack.
153  // <import> tags are instead written by AudacityProject::WriteXML.
154  // void WriteXML(XMLWriter &xmlFile) /* not override */ { wxASSERT(false); }
155 
156  private:
158 };
159 
160 class EffectPlugs;
161 typedef wxArrayString PluginIDList;
162 class CommandContext;
163 class CommandManager;
164 class Track;
165 class TrackHolder;
166 class TrackList;
167 class WaveClip;
168 class WaveTrack;
169 
170 #include "./commands/CommandFlag.h"
171 #include "../include/audacity/EffectInterface.h"
172 
174 
175 
176 class AUDACITY_DLL_API AudacityProject final : public wxFrame,
177  public TrackPanelListener,
178  public SelectionBarListener,
180  public XMLTagHandler,
181  public AudioIOListener
182 {
183  public:
184  AudacityProject(wxWindow * parent, wxWindowID id,
185  const wxPoint & pos, const wxSize & size);
186  virtual ~AudacityProject();
187 
188  virtual void ApplyUpdatedTheme();
189 
190  AudioIOStartStreamOptions GetDefaultPlayOptions();
191 
192  TrackList *GetTracks() { return mTracks.get(); }
193  const TrackList *GetTracks() const { return mTracks.get(); }
194  size_t GetTrackCount() const { return GetTracks()->size(); }
195  UndoManager *GetUndoManager() { return mUndoManager.get(); }
196 
197  sampleFormat GetDefaultFormat() { return mDefaultFormat; }
198 
199  double GetRate() const { return mRate; }
200  bool ZoomInAvailable() const { return mViewInfo.ZoomInAvailable(); }
201  bool ZoomOutAvailable() const { return mViewInfo.ZoomOutAvailable(); }
202  const SelectedRegion &GetSelection() const { return mViewInfo.selectedRegion; }
203  SelectedRegion &GetSelection() { return mViewInfo.selectedRegion; }
204  double GetSel0() const { return mViewInfo.selectedRegion.t0(); }
205  double GetSel1() const { return mViewInfo.selectedRegion.t1(); }
206  const ZoomInfo &GetZoomInfo() const { return mViewInfo; }
207  const ViewInfo &GetViewInfo() const { return mViewInfo; }
208  ViewInfo &GetViewInfo() { return mViewInfo; }
209 
210  std::shared_ptr<Track> GetFirstVisible();
211 
212  void GetPlayRegion(double* playRegionStart, double *playRegionEnd);
213  bool IsPlayRegionLocked() { return mLockPlayRegion; }
215  void SetSel0(double); //Added by STM
216  void SetSel1(double); //Added by STM
217 
218  bool Clipboard() { return (msClipT1 - msClipT0) > 0.0; }
220  wxString GetName();
221  const std::shared_ptr<DirManager> &GetDirManager();
222  TrackFactory *GetTrackFactory();
223  AdornedRulerPanel *GetRulerPanel();
224  const Tags *GetTags();
225  int GetAudioIOToken() const;
226  bool IsAudioActive() const;
227  void SetAudioIOToken(int token);
228 
229  bool IsActive() override;
230 
231  // File I/O
232 
260  static wxArrayString ShowOpenDialog(const wxString &extraformat = wxEmptyString,
261  const wxString &extrafilter = wxEmptyString);
262  static bool IsAlreadyOpen(const wxString & projPathName);
263  static void OpenFiles(AudacityProject *proj);
264 
265  // Return the given project if that is not NULL, else create a project.
266  // Then open the given project path.
267  // But if an exception escapes this function, create no NEW project.
268  static AudacityProject *OpenProject(
269  AudacityProject *pProject,
270  const wxString &fileNameArg, bool addtohistory = true);
271 
272  void OpenFile(const wxString &fileName, bool addtohistory = true);
273 
274 private:
275  void EnqueueODTasks();
276 
277 public:
278  bool WarnOfLegacyFile( );
279 
280  // If pNewTrackList is passed in non-NULL, it gets filled with the pointers to NEW tracks.
281  bool Import(const wxString &fileName, WaveTrackArray *pTrackArray = NULL);
282 
283  void ZoomAfterImport(Track *pTrack);
284 
285  // Takes array of unique pointers; returns array of shared
286  std::vector< std::shared_ptr<Track> >
287  AddImportedTracks(const wxString &fileName,
288  TrackHolders &&newTracks);
289 
290  bool Save();
291  bool SaveAs(bool bWantSaveCopy = false, bool bLossless = false);
292  bool SaveAs(const wxString & newFileName, bool bWantSaveCopy = false, bool addToHistory = true);
293  // strProjectPathName is full path for aup except extension
294  bool SaveCopyWaveTracks(const wxString & strProjectPathName, bool bLossless = false);
295 
296 private:
297  bool DoSave(bool fromSaveAs, bool bWantSaveCopy, bool bLossless = false);
298 public:
299 
300  void Clear();// clears a selection
301 
302  const wxString &GetFileName() { return mFileName; }
303  bool GetDirty() { return mDirty; }
304  void SetProjectTitle( int number =-1);
305 
306  wxPanel *GetTopPanel() { return mTopPanel; }
307  TrackPanel * GetTrackPanel() {return mTrackPanel;}
308  const TrackPanel * GetTrackPanel() const {return mTrackPanel;}
309  SelectionState &GetSelectionState() { return mSelectionState; }
310 
311  bool GetIsEmpty();
312 
313  bool GetTracksFitVerticallyZoomed() { return mTracksFitVerticallyZoomed; } //lda
314  void SetTracksFitVerticallyZoomed(bool flag) { mTracksFitVerticallyZoomed = flag; } //lda
315 
316  bool GetShowId3Dialog() { return mShowId3Dialog; } //lda
317  void SetShowId3Dialog(bool flag) { mShowId3Dialog = flag; } //lda
318 
319  bool GetNormalizeOnLoad() { return mNormalizeOnLoad; } //lda
320  void SetNormalizeOnLoad(bool flag) { mNormalizeOnLoad = flag; } //lda
325  void SetMissingAliasFileDialog(wxDialog *dialog);
329  wxDialog *GetMissingAliasFileDialog();
331  // Timer Record Auto Save/Export Routines
332  bool SaveFromTimerRecording(wxFileName fnFile);
333  bool ExportFromTimerRecording(wxFileName fnFile, int iFormat, int iSubFormat, int iFilterIndex);
334  int GetOpenProjectCount();
335  bool IsProjectSaved();
336  void ResetProjectToEmpty();
337 
338  bool ProjectHasTracks();
339 
340  // Routine to estimate how many minutes of recording time are left on disk
341  int GetEstimatedRecordingMinsLeftOnDisk(long lCaptureChannels = 0);
342  // Converts number of minutes to human readable format
343  wxString GetHoursMinsString(int iMinutes);
344 
345 #include "Menus.h"
346 
347  CommandManager *GetCommandManager() { return &mCommandManager; }
348  const CommandManager *GetCommandManager() const { return &mCommandManager; }
349 
350  // Keyboard capture
351  static bool HasKeyboardCapture(const wxWindow *handler);
352  static wxWindow *GetKeyboardCaptureHandler();
353  static void CaptureKeyboard(wxWindow *handler);
354  static void ReleaseKeyboard(wxWindow *handler);
355 
356  void RebuildMenuBar();
357  void RebuildOtherMenus();
358  void MayStartMonitoring();
359 
360 
361  // Message Handlers
362 
363  void OnMenu(wxCommandEvent & event);
364  void OnUpdateUI(wxUpdateUIEvent & event);
365 
366  void MacShowUndockedToolbars(bool show);
367  void OnActivate(wxActivateEvent & event);
368 
369  void OnMouseEvent(wxMouseEvent & event);
370  void OnIconize(wxIconizeEvent &event);
371  void OnSize(wxSizeEvent & event);
372  void OnShow(wxShowEvent & event);
373  void OnMove(wxMoveEvent & event);
374  void DoScroll();
375  void OnScroll(wxScrollEvent & event);
376  void OnCloseWindow(wxCloseEvent & event);
377  void OnTimer(wxTimerEvent & event);
378  void OnToolBarUpdate(wxCommandEvent & event);
379  void OnOpenAudioFile(wxCommandEvent & event);
380  void OnODTaskUpdate(wxCommandEvent & event);
381  void OnODTaskComplete(wxCommandEvent & event);
382 
383  void HandleResize();
384  void UpdateLayout();
385  double GetScreenEndTime() const;
386  void ZoomInByFactor( double ZoomFactor );
387  void ZoomOutByFactor( double ZoomFactor );
388 
389  // Other commands
390  static TrackList *GetClipboardTracks();
391  static void ClearClipboard();
392  static void DeleteClipboard();
393 
394  int GetProjectNumber(){ return mProjectNo;};
395  static int CountUnnamed();
396  static void RefreshAllTitles(bool bShowProjectNumbers );
397  // checkActive is a temporary hack that should be removed as soon as we
398  // get multiple effect preview working
399  void UpdateMenus(bool checkActive = true);
400  void UpdatePrefs();
401  void UpdatePrefsVariables();
402  void RedrawProject(const bool bForceWaveTracks = false);
403  void RefreshCursor();
404  void SelectNone();
405  void SelectAllIfNone();
406  void StopIfPaused();
407  void Zoom(double level);
408  void ZoomBy(double multiplier);
409  void Rewind(bool shift);
410  void SkipEnd(bool shift);
411 
412 
413  typedef void (WaveTrack::* EditFunction)(double, double);
414  typedef std::unique_ptr<Track> (WaveTrack::* EditDestFunction)(double, double);
415 
416  void EditByLabel(EditFunction action, bool bSyncLockedTracks);
417  void EditClipboardByLabel(EditDestFunction action );
418 
419  bool IsSyncLocked();
420  void SetSyncLock(bool flag);
421 
422  void DoTrackMute(Track *pTrack, bool exclusive);
423  void DoTrackSolo(Track *pTrack, bool exclusive);
424  void SetTrackGain(WaveTrack * track, LWSlider * slider);
425  void SetTrackPan(WaveTrack * track, LWSlider * slider);
426 
427  void RemoveTrack(Track * toRemove);
428 
429  // "exclusive" mute means mute the chosen track and unmute all others.
430  void HandleTrackMute(Track *t, const bool exclusive);
432  // Type of solo (standard or simple) follows the set preference, unless
433  // alternate == true, which causes the opposite behavior.
434  void HandleTrackSolo(Track *t, const bool alternate);
435 
436  // Snap To
437 
438  void SetSnapTo(int snap);
439  int GetSnapTo() const;
440 
441  // Selection Format
442 
443  void SetSelectionFormat(const NumericFormatId & format);
444  const NumericFormatId & GetSelectionFormat() const;
446  // Spectral Selection Formats
448  void SetFrequencySelectionFormatName(const NumericFormatId & format);
449  const NumericFormatId & GetFrequencySelectionFormatName() const;
450 
451  void SetBandwidthSelectionFormatName(const NumericFormatId & format);
452  const NumericFormatId & GetBandwidthSelectionFormatName() const;
453 
454  // Scrollbars
455 
456  void OnScrollLeft();
457  void OnScrollRight();
458 
459  void OnScrollLeftButton(wxScrollEvent & event);
460  void OnScrollRightButton(wxScrollEvent & event);
461 
462  void FinishAutoScroll();
463  void FixScrollbars();
464 
465  bool MayScrollBeyondZero() const;
466  double ScrollingLowerBoundTime() const;
467  // How many pixels are covered by the period from lowermost scrollable time, to the given time:
468  // PRL: Bug1197: we seem to need to compute all in double, to avoid differing results on Mac
469  double PixelWidthBeforeTime(double scrollto) const;
470  void SetHorizontalThumb(double scrollto);
471 
472  // PRL: old and incorrect comment below, these functions are used elsewhere than TrackPanel
473  // TrackPanel access
474  wxSize GetTPTracksUsableArea() /* not override */;
475  void RefreshTPTrack(Track* pTrk, bool refreshbacking = true) /* not override */;
476 
477  // TrackPanel callback methods, overrides of TrackPanelListener
478  void TP_DisplaySelection() override;
479  void TP_DisplayStatusMessage(const wxString &msg) override;
480 
481  ToolsToolBar * TP_GetToolsToolBar() override;
482 
483  void TP_PushState(const wxString &longDesc, const wxString &shortDesc,
484  UndoPush flags) override;
485  void TP_ModifyState(bool bWantsAutoSave) override; // if true, writes auto-save file. Should set only if you really want the state change restored after
486  // a crash, as it can take many seconds for large (eg. 10 track-hours) projects
487  void TP_RedrawScrollbars() override;
488  void TP_ScrollLeft() override;
489  void TP_ScrollRight() override;
490  void TP_ScrollWindow(double scrollto) override;
491  bool TP_ScrollUpDown(int delta) override;
492  void TP_HandleResize() override;
493 
494  // ToolBar
495 
496  // In the GUI, ControlToolBar appears as the "Transport Toolbar". "Control Toolbar" is historic.
497  ControlToolBar *GetControlToolBar();
499  DeviceToolBar *GetDeviceToolBar();
500  EditToolBar *GetEditToolBar();
501  MixerToolBar *GetMixerToolBar();
502  ScrubbingToolBar *GetScrubbingToolBar();
503  SelectionBar *GetSelectionBar();
504 #ifdef EXPERIMENTAL_SPECTRAL_EDITING
505  SpectralSelectionBar *GetSpectralSelectionBar();
506 #endif
507  ToolsToolBar *GetToolsToolBar();
508  const ToolsToolBar *GetToolsToolBar() const;
509  TranscriptionToolBar *GetTranscriptionToolBar();
510 
511  MeterPanel *GetPlaybackMeter();
512  void SetPlaybackMeter(MeterPanel *playback);
513  MeterPanel *GetCaptureMeter();
514  void SetCaptureMeter(MeterPanel *capture);
515 
516  LyricsWindow* GetLyricsWindow() { return mLyricsWindow; }
517  MixerBoard* GetMixerBoard() { return mMixerBoard; }
518 
519  wxStatusBar* GetStatusBar() { return mStatusBar; }
520 
521 private:
522  bool SnapSelection();
523 
524 public:
525  // SelectionBarListener callback methods
526 
527  double AS_GetRate() override;
528  void AS_SetRate(double rate) override;
529  int AS_GetSnapTo() override;
530  void AS_SetSnapTo(int snap) override;
531  const NumericFormatId & AS_GetSelectionFormat() override;
532  void AS_SetSelectionFormat(const NumericFormatId & format) override;
533  void AS_ModifySelection(double &start, double &end, bool done) override;
534 
535  // SpectralSelectionBarListener callback methods
536 
537  double SSBL_GetRate() const override;
538 
540  void SSBL_SetFrequencySelectionFormatName(const NumericFormatId & formatName) override;
541 
543  void SSBL_SetBandwidthSelectionFormatName(const NumericFormatId & formatName) override;
544 
545  void SSBL_ModifySpectralSelection(double &bottom, double &top, bool done) override;
546 
547  void SetStateTo(unsigned int n);
548 
549  // XMLTagHandler callback methods
550 
551  bool HandleXMLTag(const wxChar *tag, const wxChar **attrs) override;
552  XMLTagHandler *HandleXMLChild(const wxChar *tag) override;
553  void WriteXML(
554  XMLWriter &xmlFile, bool bWantSaveCopy) /* not override */;
555 
556  void WriteXMLHeader(XMLWriter &xmlFile) const;
558  PlayMode mLastPlayMode{ PlayMode::normalPlay };
560 
561  // Audio IO callback methods
562  void OnAudioIORate(int rate) override;
563  void OnAudioIOStartRecording() override;
564  void OnAudioIOStopRecording() override;
565  void OnAudioIONewBlockFiles(const AutoSaveFile & blockFileLog) override;
566 
567  // Command Handling
568  bool ReportIfActionNotAllowed
569  ( const wxString & Name, CommandFlag & flags, CommandFlag flagsRqd, CommandFlag mask );
570  bool TryToMakeActionAllowed
571  ( CommandFlag & flags, CommandFlag flagsRqd, CommandFlag mask );
572 
573  bool UndoAvailable();
574  bool RedoAvailable();
575 
576  void PushState(const wxString &desc, const wxString &shortDesc); // use UndoPush::AUTOSAVE
577  void PushState(const wxString &desc, const wxString &shortDesc, UndoPush flags);
578  void RollbackState();
579 
580 
581  private:
582 
583  void OnCapture(wxCommandEvent & evt);
584  void InitialState();
585 
586  public:
587  void ModifyState(bool bWantsAutoSave); // if true, writes auto-save file. Should set only if you really want the state change restored after
588  // a crash, as it can take many seconds for large (eg. 10 track-hours) projects
589  void RecreateMixerBoard();
590 
591  private:
592  void PopState(const UndoState &state);
593 
594  void UpdateLyrics();
595  void UpdateMixerBoard();
596 
597  void GetRegionsByLabel( Regions &regions );
598 
599  void AutoSave();
600  void DeleteCurrentAutoSaveFile();
601 
602  double GetZoomOfToFit();
603  double GetZoomOfSelection();
604  double GetZoomOfPreset(int preset );
605 
606  public:
607  bool IsSoloSimple() const { return mSoloPref == wxT("Simple"); }
608  bool IsSoloNone() const { return mSoloPref == wxT("None"); }
609 
610  private:
611 
612  // The project's name and file info
613  wxString mFileName;
615  std::shared_ptr<DirManager> mDirManager; // MM: DirManager now created dynamically
616 
617  static int mProjectCounter;// global counter.
618  int mProjectNo; // count when this project was created.
619 
620  double mRate;
622 
623  // Recent files
625 
626  // Tags (artist name, song properties, MP3 ID3 info, etc.)
627  // The structure may be shared with undo history entries
628  // To keep undo working correctly, always replace this with a NEW duplicate
629  // BEFORE doing any editing of it!
630  std::shared_ptr<Tags> mTags;
631 
632  // List of tracks and display info
633  std::shared_ptr<TrackList> mTracks;
634 
635  int mSnapTo;
639 
640  std::shared_ptr<TrackList> mLastSavedTracks;
641 
642  // Clipboard (static because it is shared by all projects)
643  static std::shared_ptr<TrackList> msClipboard;
645  static double msClipT0;
646  static double msClipT1;
647 
648 public:
650  //shared by all projects
651  static ODLock &AllProjectDeleteMutex();
652 
653 private:
654  // History/Undo manager
655  std::unique_ptr<UndoManager> mUndoManager;
656  bool mDirty{ false };
657 
658  // Commands
659 
661 
663 
664  // Window elements
665 
667  std::unique_ptr<wxTimer> mTimer;
668  void RestartTimer();
669 
670  wxStatusBar *mStatusBar;
671 
672  AdornedRulerPanel *mRuler{};
673  wxPanel *mTopPanel{};
674  TrackPanel *mTrackPanel{};
675  SelectionState mSelectionState{};
676  bool mCircularTrackNavigation{};
677  std::unique_ptr<TrackFactory> mTrackFactory{};
678  wxPanel * mMainPanel;
679  wxScrollBar *mHsbar;
680  wxScrollBar *mVsbar;
681  bool mAutoScrolling{ false };
682  bool mActive{ true };
683  bool mIconized;
684 
685  MacrosWindow *mMacrosWindow{};
686  HistoryWindow *mHistoryWindow{};
687  LyricsWindow* mLyricsWindow{};
688  MixerBoardFrame* mMixerBoardFrame{};
689  MixerBoard* mMixerBoard{};
690 
693 
694  // dialog for missing alias warnings
695  wxDialog *mAliasMissingWarningDialog{};
696 
697  bool mShownOnce{ false };
698 
699  // Project owned meters
700  MeterPanel *mPlaybackMeter{};
701  MeterPanel *mCaptureMeter{};
702 
703  std::unique_ptr<ToolManager> mToolManager;
704 
705  public:
706  ToolManager *GetToolManager() { return mToolManager.get(); }
708  wxString mHelpPref;
709  wxString mSoloPref;
710  bool mbBusyImporting{ false }; // used to fix bug 584
711  int mBatchMode{ 0 };// 0 menas not, >0 means in batch mode.
712 
713  void SetNormalizedWindowState(wxRect pSizeAndLocation) { mNormalizedWindowState = pSizeAndLocation; }
714  wxRect GetNormalizedWindowState() const { return mNormalizedWindowState; }
715 
716  bool IsTimerRecordCancelled(){return mTimerRecordCanceled;}
717  void ResetTimerRecordFlag(){mTimerRecordCanceled=false;}
718  private:
719  //sort method used by OnSortName and OnSortTime
720  //currently only supported flags are kAudacitySortByName and kAudacitySortByName
721  //in the future we might have 0x01 as sort ascending and we can bit or it
722 #define kAudacitySortByTime (1 << 1)
723 #define kAudacitySortByName (1 << 2)
724  void SortTracks(int flags);
725 
726  int mAudioIOToken{ -1 };
727 
728  bool mIsDeleting{ false };
729  bool mTracksFitVerticallyZoomed{ false }; //lda
730  bool mNormalizeOnLoad; //lda
731  bool mShowId3Dialog{ true }; //lda
733 
734  // 0 is grey out, 1 is Autoselect, 2 is Give warnings.
737 
739 
741 
742  std::unique_ptr<ImportXMLTagHandler> mImportXMLTagHandler;
743 
744  // Last auto-save file name and path (empty if none)
746 
747  // Are we currently auto-saving or not?
748  bool mAutoSaving{ false };
749 
750  // Has this project been recovered from an auto-saved version
751  bool mIsRecovered{ false };
752 
753  // The auto-save data dir the project has been recovered from
755 
756  // The handler that handles recovery of <recordingrecovery> tags
757  std::unique_ptr<RecordingRecoveryHandler> mRecordingRecoveryHandler;
758 
759  // Dependencies have been imported and a warning should be shown on save
760  bool mImportedDependencies{ false };
761 
762  wxArrayString mStrOtherNamesArray; // used to make sure compressed file names are unique
763 
764  // Last effect applied to this project
765  PluginID mLastEffect{};
766 
768 
769  //flag for cancellation of timer record.
770  bool mTimerRecordCanceled{ false };
771 
772  // Are we currently closing as the result of a menu command?
773  bool mMenuClose{ false };
774 
775  bool mbInitializingScrollbar{ false };
776 
777  // Flag that we're recoding.
778  bool mIsCapturing{ false };
779 
780  // Keyboard capture
781  wxWindow *mKeyboardCaptureHandler{};
782 
783  double mSeekShort;
784  double mSeekLong;
785 
787 
788  // See explanation in OnCloseWindow
789  bool mIsBeingDeleted{ false };
790 
791  // CommandManager needs to use private methods
792  friend class CommandManager;
793 
794  // TrackPanelOverlay objects
795  std::unique_ptr<Overlay>
796  mIndicatorOverlay, mCursorOverlay;
797 
798  std::shared_ptr<BackgroundCell> mBackgroundCell;
799 
800 #ifdef EXPERIMENTAL_SCRUBBING_BASIC
801  std::unique_ptr<Overlay> mScrubOverlay;
802  std::unique_ptr<Scrubber> mScrubber;
803 public:
804  Scrubber &GetScrubber() { return *mScrubber; }
805  const Scrubber &GetScrubber() const { return *mScrubber; }
806 #endif
807 
808  class PlaybackScroller final : public wxEvtHandler
809  {
810  public:
811  explicit PlaybackScroller(AudacityProject *project);
812 
813  enum class Mode {
814  Off,
815  Refresh,
816  Pinned,
817  Right,
818  };
819 
820  Mode GetMode() const { return mMode; }
821  void Activate(Mode mode)
822  {
823  mMode = mode;
824  }
825 
826  private:
827  void OnTimer(wxCommandEvent &event);
828 
830  Mode mMode { Mode::Off };
831  };
832  std::unique_ptr<PlaybackScroller> mPlaybackScroller;
833 
834 public:
835  PlaybackScroller &GetPlaybackScroller() { return *mPlaybackScroller; }
836  std::shared_ptr<BackgroundCell> GetBackgroundCell() const
837  { return mBackgroundCell; }
838 
839  wxWindowRef mFocusLender;
840 
841  // Return true if the window is really focused, or if focus was borrowed
842  // from it
843  bool IsFocused( const wxWindow *window ) const;
844 
845  DECLARE_EVENT_TABLE()
846 };
847 
848 #endif
849 
virtual void OnAudioIOStartRecording()=0
virtual void AS_SetSnapTo(int snap)=0
std::unique_ptr< Overlay > mIndicatorOverlay
Definition: Project.h:796
A ToolBar that has the main Transport buttons.
std::unique_ptr< ImportXMLTagHandler > mImportXMLTagHandler
Definition: Project.h:742
A ToolBar that holds the VU Meter.
Definition: MeterToolBar.h:32
A list of TrackListNode items.
Definition: Track.h:623
bool mbLoadedFromAup
Definition: Project.h:614
Class which actulaly imports the auido, using functions defined in ImportPCM.cpp, ImportMP3...
Definition: Import.h:88
wxMenu * mRecentFilesMenu
Definition: Project.h:624
double t0() const
virtual double SSBL_GetRate() const =0
std::unique_ptr< PlaybackScroller > mPlaybackScroller
Definition: Project.h:832
virtual void SSBL_SetBandwidthSelectionFormatName(const NumericFormatId &formatName)=0
ViewInfo is used mainly to hold the zooming, selection and scroll information. It also has some statu...
Definition: ViewInfo.h:141
Works with UndoManager to allow user to see descriptions of and undo previous commands. Also allows you to selectively clear the undo memory so as to free up space.
Definition: HistoryWindow.h:27
virtual void SSBL_ModifySpectralSelection(double &bottom, double &top, bool done)=0
bool GetDirty()
Definition: Project.h:303
bool ZoomInAvailable() const
Definition: Project.h:200
Scrubber & GetScrubber()
Definition: Project.h:804
wxString mRecoveryAutoSaveDataDir
Definition: Project.h:754
SelectedRegion & GetSelection()
Definition: Project.h:203
A now badly named class which is used to give access to a subset of the TrackPanel methods from all o...
bool mIsSyncLocked
Definition: Project.h:738
virtual int AS_GetSnapTo()=0
void RedrawAllProjects()
Definition: Project.cpp:598
bool mIconized
Definition: Project.h:683
std::unique_ptr< wxTimer > mTimer
Definition: Project.h:667
AudacityProject * CreateNewAudacityProject()
Definition: Project.cpp:550
(not quite a Toolbar) at foot of screen for setting and viewing the selection range.
Definition: SelectionBar.h:42
virtual void TP_PushState(const wxString &shortDesc, const wxString &longDesc, UndoPush flags)=0
const wxChar * desc
Definition: ExportPCM.cpp:58
bool IsTimerRecordCancelled()
Definition: Project.h:716
virtual void TP_ModifyState(bool bWantsAutoSave)=0
void GetNextWindowPlacement(wxRect *nextRect, bool *pMaximized, bool *pIconized)
Definition: Project.cpp:719
wxScrollBar * mVsbar
Definition: Project.h:680
virtual void AS_SetSelectionFormat(const NumericFormatId &format)=0
wxArrayString PluginIDList
Definition: Project.h:160
AudacityProject * mProject
Definition: Project.h:157
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:309
A parent class of SelectionBar, used to forward events to do with changes in the SelectionBar.
virtual void AS_SetRate(double rate)=0
AProjectArray gAudacityProjects
Definition: Project.cpp:304
virtual XMLTagHandler * HandleXMLChild(const wxChar *tag)=0
bool mLockPlayRegion
Definition: Project.h:740
virtual void TP_HandleResize()=0
double mSeekShort
Definition: Project.h:783
A ToolBar that has the edit buttons on it.
Definition: EditToolBar.h:73
wxString mSoloPref
Definition: Project.h:709
std::unique_ptr< Scrubber > mScrubber
Definition: Project.h:802
bool mShowSplashScreen
Definition: Project.h:707
const CommandManager * GetCommandManager() const
Definition: Project.h:348
PlayMode
Definition: Project.h:125
sampleFormat mDefaultFormat
Definition: Project.h:621
wxString mLastMainStatusMessage
Definition: Project.h:666
wxString PluginID
Definition: Types.h:209
const Scrubber & GetScrubber() const
Definition: Project.h:805
void SetShowId3Dialog(bool flag)
Definition: Project.h:317
std::shared_ptr< DirManager > mDirManager
Definition: Project.h:615
bool mEmptyCanBeDirty
Definition: Project.h:732
bool IsWindowAccessible(wxRect *requestedRect)
Definition: Project.cpp:668
bool GetNormalizeOnLoad()
Definition: Project.h:319
CommandContext provides addiitonal information to an 'Apply()' command. It provides the project...
CommandManager mCommandManager
Definition: Project.h:660
virtual void TP_ScrollWindow(double scrollto)=0
CommandManager * GetCommandManager()
Definition: Project.h:347
virtual void OnAudioIOStopRecording()=0
MeterPanel is a panel that paints the meter used for monitoring or playback.
Definition: Meter.h:97
wxString mFileName
Definition: Project.h:613
const TrackPanel * GetTrackPanel() const
Definition: Project.h:308
std::shared_ptr< AudacityProject > AProjectHolder
Definition: Project.h:119
MixerBoard * GetMixerBoard()
Definition: Project.h:517
StatusBarField
Definition: Project.h:131
bool HandleXMLTag(const wxChar *tag, const wxChar **attrs) override
Definition: Project.cpp:491
void ResetTimerRecordFlag()
Definition: Project.h:717
Used to create a WaveTrack, or a LabelTrack.. Implementation of the functions of this class are dispe...
Definition: Track.h:867
std::unique_ptr< RecordingRecoveryHandler > mRecordingRecoveryHandler
Definition: Project.h:757
std::shared_ptr< Tags > mTags
Definition: Project.h:630
virtual const NumericFormatId & SSBL_GetFrequencySelectionFormatName()=0
DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, EVT_CAPTURE_KEY,-1)
Custom events.
wxWindowRef mFocusLender
Definition: Project.h:839
XMLTagHandler * HandleXMLChild(const wxChar *WXUNUSED(tag)) override
Definition: Project.h:149
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
size_t size() const
Definition: Track.cpp:1234
int format
Definition: ExportPCM.cpp:56
std::shared_ptr< TrackList > mLastSavedTracks
Definition: Project.h:640
void GetDefaultWindowRect(wxRect *defRect)
Definition: Project.cpp:624
wxRect mNormalizedWindowState
Definition: Project.h:767
std::shared_ptr< BackgroundCell > mBackgroundCell
Definition: Project.h:798
Defines a selected portion of a project.
double mRate
Definition: Project.h:620
The TrackPanel class coordinates updates and operations on the main part of the screen which contains...
Definition: TrackPanel.h:237
std::vector< std::shared_ptr< WaveTrack > > WaveTrackArray
Definition: AudioIO.h:67
ViewInfo & GetViewInfo()
Definition: Project.h:208
Lightweight version of ASlider. In other words it does not have a window permanently associated with ...
Definition: ASlider.h:73
NumericFormatId mSelectionFormat
Definition: Project.h:636
struct holding stream options, including a pointer to the TimeTrack and AudioIOListener and whether t...
Definition: AudioIO.h:124
This allows multiple clips to be a part of one WaveTrack.
Definition: WaveClip.h:176
virtual void SSBL_SetFrequencySelectionFormatName(const NumericFormatId &formatName)=0
UndoPush
Definition: UndoManager.h:82
(not quite a Toolbar) at foot of screen for setting and viewing the frequency selection range...
double mSeekLong
Definition: Project.h:784
A toobar to allow easier changing of input and output devices .
Definition: DeviceToolBar.h:25
const SelectedRegion & GetSelection() const
Definition: Project.h:202
virtual void TP_DisplayStatusMessage(const wxString &msg)=0
static double msClipT0
Definition: Project.h:645
static double msClipT1
Definition: Project.h:646
CommandFlag mLastFlags
Definition: Project.h:662
sampleFormat
Definition: Types.h:188
virtual bool HandleXMLTag(const wxChar *tag, const wxChar **attrs)=0
bool GetShowId3Dialog()
Definition: Project.h:316
const TrackList * GetTracks() const
Definition: Project.h:193
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
ToolManager * GetToolManager()
Definition: Project.h:706
virtual void TP_ScrollLeft()=0
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
virtual const NumericFormatId & SSBL_GetBandwidthSelectionFormatName()=0
std::unique_ptr< UndoManager > mUndoManager
Definition: Project.h:655
CommandManager implements a system for organizing all user-callable commands.
This class is an interface which should be implemented by classes which wish to be able to load and s...
Definition: XMLTagHandler.h:72
AudacityProject * mProject
Definition: Project.h:829
AUDACITY_DLL_API void CloseAllProjects()
Definition: Project.cpp:612
ViewInfo mViewInfo
Definition: Project.h:559
virtual const NumericFormatId & AS_GetSelectionFormat()=0
const int AudacityProjectTimerID
Definition: Project.h:49
std::unique_ptr< Track >(WaveTrack::* EditDestFunction)(double, double)
Definition: Project.h:414
wxArrayString mStrOtherNamesArray
Definition: Project.h:762
SelectionState & GetSelectionState()
Definition: Project.h:309
virtual double AS_GetRate()=0
virtual void TP_RedrawScrollbars()=0
bool Clipboard()
Definition: Project.h:218
std::shared_ptr< BackgroundCell > GetBackgroundCell() const
Definition: Project.h:836
IdentInterfaceSymbol pairs a persistent string identifier used internally with an optional...
std::unique_ptr< Overlay > mScrubOverlay
Definition: Project.h:801
ImportXMLTagHandler(AudacityProject *pProject)
Definition: Project.h:146
virtual void TP_ScrollRight()=0
wxString mAutoSaveFileName
Definition: Project.h:745
bool mNormalizeOnLoad
Definition: Project.h:730
ID3 Tags (for MP3)
Definition: Tags.h:70
int mWhatIfNoSelection
Definition: Project.h:735
bool IsSoloNone() const
Definition: Project.h:608
bool IsSoloSimple() const
Definition: Project.h:607
NumericFormatId mFrequencySelectionFormatName
Definition: Project.h:637
std::vector< AProjectHolder > AProjectArray
Definition: Project.h:120
virtual void OnAudioIONewBlockFiles(const AutoSaveFile &blockFileLog)=0
Destroy_ptr< ContrastDialog > mContrastDialog
Definition: Project.h:692
Monitors record play start/stop and new blockfiles. Has callbacks for these events.
wxStatusBar * GetStatusBar()
Definition: Project.h:519
wxStatusBar * mStatusBar
Definition: Project.h:670
CommandFlag
Definition: CommandFlag.h:16
bool mStopIfWasPaused
Definition: Project.h:736
UndoManager * GetUndoManager()
Definition: Project.h:195
PlaybackScroller & GetPlaybackScroller()
Definition: Project.h:835
wxString mHelpPref
Definition: Project.h:708
wxScrollBar * mHsbar
Definition: Project.h:679
std::unique_ptr< ToolManager > mToolManager
Definition: Project.h:703
LyricsWindow * GetLyricsWindow()
Definition: Project.h:516
Displays a spectrum plot of the waveform. Has options for selecting parameters of the plot...
Definition: FreqWindow.h:125
A kind of ToolBar with Tools on it.
Definition: ToolsToolBar.h:49
int GetProjectNumber()
Definition: Project.h:394
bool GetTracksFitVerticallyZoomed()
Definition: Project.h:313
Works with HistoryWindow to provide the Undo functionality.
Definition: UndoManager.h:93
static int mProjectCounter
Definition: Project.h:617
virtual void OnAudioIORate(int rate)=0
virtual bool TP_ScrollUpDown(int delta)=0
void RefreshCursorForAllProjects()
Definition: Project.cpp:605
wxRect GetNormalizedWindowState() const
Definition: Project.h:714
std::unique_ptr< T, Destroyer< T >> Destroy_ptr
Definition: MemoryX.h:433
This is an Audacity Specific ruler panel which additionally has border, selection markers...
Definition: Ruler.h:313
A class used to forward events to do with changes in the SpectralSelectionBar.
double GetRate() const
Definition: Project.h:199
double GetSel1() const
Definition: Project.h:205
static std::shared_ptr< TrackList > msClipboard
Definition: Project.h:643
void SetNormalizedWindowState(wxRect pSizeAndLocation)
Definition: Project.h:713
TrackList * GetTracks()
Definition: Project.h:192
Base class for XMLFileWriter and XMLStringWriter that provides the general functionality for creating...
Definition: XMLWriter.h:22
bool IsPlayRegionLocked()
Definition: Project.h:213
std::vector< std::unique_ptr< WaveTrack >> TrackHolders
Definition: ImportRaw.h:24
const ViewInfo & GetViewInfo() const
Definition: Project.h:207
static AudacityProject * msClipProject
Definition: Project.h:644
class ToolManager
Definition: ToolManager.h:45
const wxString & GetFileName()
Definition: Project.h:302
A kind of ToolBar used to help with analysing voice recordings.
void SetTracksFitVerticallyZoomed(bool flag)
Definition: Project.h:314
virtual void TP_DisplaySelection()=0
std::shared_ptr< TrackList > mTracks
Definition: Project.h:633
A ToolBar that provides the record and playback volume settings.
Definition: MixerToolBar.h:25
wxLongLong mLastSelectionAdjustment
Definition: Project.h:786
virtual ToolsToolBar * TP_GetToolsToolBar()=0
virtual void AS_ModifySelection(double &start, double &end, bool done)=0
wxPanel * mMainPanel
Definition: Project.h:678
NumericFormatId mBandwidthSelectionFormatName
Definition: Project.h:638
a class wrapping reading and writing of arbitrary data in text or binary format to a file...
Definition: AutoRecovery.h:76
Destroy_ptr< FreqWindow > mFreqWindow
Definition: Project.h:691