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