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();
301 
302  const wxString &GetFileName() { return mFileName; }
303  bool GetDirty() { return mDirty; }
304  void SetProjectTitle( int number =-1);
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
319  bool GetNormalizeOnLoad() { return mNormalizeOnLoad; } //lda
320  void SetNormalizeOnLoad(bool flag) { mNormalizeOnLoad = flag; } //lda
325  void SetMissingAliasFileDialog(wxDialog *dialog);
329  wxDialog *GetMissingAliasFileDialog();
330 
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 
337  bool ProjectHasTracks();
338 
339  // Routine to estimate how many minutes of recording time are left on disk
340  int GetEstimatedRecordingMinsLeftOnDisk(long lCaptureChannels = 0);
341  // Converts number of minutes to human readable format
342  wxString GetHoursMinsString(int iMinutes);
343 
344 #include "Menus.h"
345 
346  CommandManager *GetCommandManager() { return &mCommandManager; }
347  const CommandManager *GetCommandManager() const { return &mCommandManager; }
348 
349  // Keyboard capture
350  static bool HasKeyboardCapture(const wxWindow *handler);
351  static wxWindow *GetKeyboardCaptureHandler();
352  static void CaptureKeyboard(wxWindow *handler);
353  static void ReleaseKeyboard(wxWindow *handler);
354 
355  void RebuildMenuBar();
356  void RebuildOtherMenus();
357  void MayStartMonitoring();
358 
359 
360  // Message Handlers
361 
362  void OnMenu(wxCommandEvent & event);
363  void OnUpdateUI(wxUpdateUIEvent & event);
364 
365  void MacShowUndockedToolbars(bool show);
366  void OnActivate(wxActivateEvent & event);
367 
368  void OnMouseEvent(wxMouseEvent & event);
369  void OnIconize(wxIconizeEvent &event);
370  void OnSize(wxSizeEvent & event);
371  void OnShow(wxShowEvent & event);
372  void OnMove(wxMoveEvent & event);
373  void DoScroll();
374  void OnScroll(wxScrollEvent & event);
375  void OnCloseWindow(wxCloseEvent & event);
376  void OnTimer(wxTimerEvent & event);
377  void OnToolBarUpdate(wxCommandEvent & event);
378  void OnOpenAudioFile(wxCommandEvent & event);
379  void OnODTaskUpdate(wxCommandEvent & event);
380  void OnODTaskComplete(wxCommandEvent & event);
381 
382  void HandleResize();
383  void UpdateLayout();
384  double GetScreenEndTime() const;
385  void ZoomInByFactor( double ZoomFactor );
386  void ZoomOutByFactor( double ZoomFactor );
387 
388  // Other commands
389  static TrackList *GetClipboardTracks();
390  static void ClearClipboard();
391  static void DeleteClipboard();
392 
393  int GetProjectNumber(){ return mProjectNo;};
394  static int CountUnnamed();
395  static void RefreshAllTitles(bool bShowProjectNumbers );
396  // checkActive is a temporary hack that should be removed as soon as we
397  // get multiple effect preview working
398  void UpdateMenus(bool checkActive = true);
399  void UpdatePrefs();
400  void UpdatePrefsVariables();
401  void RedrawProject(const bool bForceWaveTracks = false);
402  void RefreshCursor();
403  void SelectNone();
404  void SelectAllIfNone();
405  void StopIfPaused();
406  void Zoom(double level);
407  void ZoomBy(double multiplier);
408  void Rewind(bool shift);
409  void SkipEnd(bool shift);
410 
411 
412  typedef void (WaveTrack::* EditFunction)(double, double);
413  typedef std::unique_ptr<Track> (WaveTrack::* EditDestFunction)(double, double);
414 
415  void EditByLabel(EditFunction action, bool bSyncLockedTracks);
416  void EditClipboardByLabel(EditDestFunction action );
417 
418  bool IsSyncLocked();
419  void SetSyncLock(bool flag);
420 
421  void DoTrackMute(Track *pTrack, bool exclusive);
422  void DoTrackSolo(Track *pTrack, bool exclusive);
423  void SetTrackGain(WaveTrack * track, LWSlider * slider);
424  void SetTrackPan(WaveTrack * track, LWSlider * slider);
425 
426  void RemoveTrack(Track * toRemove);
427 
428  // "exclusive" mute means mute the chosen track and unmute all others.
429  void HandleTrackMute(Track *t, const bool exclusive);
431  // Type of solo (standard or simple) follows the set preference, unless
432  // alternate == true, which causes the opposite behavior.
433  void HandleTrackSolo(Track *t, const bool alternate);
434 
435  // Snap To
436 
437  void SetSnapTo(int snap);
438  int GetSnapTo() const;
439 
440  // Selection Format
441 
442  void SetSelectionFormat(const NumericFormatId & format);
443  const NumericFormatId & GetSelectionFormat() const;
445  // Spectral Selection Formats
447  void SetFrequencySelectionFormatName(const NumericFormatId & format);
448  const NumericFormatId & GetFrequencySelectionFormatName() const;
449 
450  void SetBandwidthSelectionFormatName(const NumericFormatId & format);
451  const NumericFormatId & GetBandwidthSelectionFormatName() const;
452 
453  // Scrollbars
454 
455  void OnScrollLeft();
456  void OnScrollRight();
457 
458  void OnScrollLeftButton(wxScrollEvent & event);
459  void OnScrollRightButton(wxScrollEvent & event);
460 
461  void FinishAutoScroll();
462  void FixScrollbars();
463 
464  bool MayScrollBeyondZero() const;
465  double ScrollingLowerBoundTime() const;
466  // How many pixels are covered by the period from lowermost scrollable time, to the given time:
467  // PRL: Bug1197: we seem to need to compute all in double, to avoid differing results on Mac
468  double PixelWidthBeforeTime(double scrollto) const;
469  void SetHorizontalThumb(double scrollto);
470 
471  // PRL: old and incorrect comment below, these functions are used elsewhere than TrackPanel
472  // TrackPanel access
473  wxSize GetTPTracksUsableArea() /* not override */;
474  void RefreshTPTrack(Track* pTrk, bool refreshbacking = true) /* not override */;
475 
476  // TrackPanel callback methods, overrides of TrackPanelListener
477  void TP_DisplaySelection() override;
478  void TP_DisplayStatusMessage(const wxString &msg) override;
479 
480  ToolsToolBar * TP_GetToolsToolBar() override;
481 
482  void TP_PushState(const wxString &longDesc, const wxString &shortDesc,
483  UndoPush flags) override;
484  void TP_ModifyState(bool bWantsAutoSave) override; // if true, writes auto-save file. Should set only if you really want the state change restored after
485  // a crash, as it can take many seconds for large (eg. 10 track-hours) projects
486  void TP_RedrawScrollbars() override;
487  void TP_ScrollLeft() override;
488  void TP_ScrollRight() override;
489  void TP_ScrollWindow(double scrollto) override;
490  bool TP_ScrollUpDown(int delta) override;
491  void TP_HandleResize() override;
492 
493  // ToolBar
494 
495  // In the GUI, ControlToolBar appears as the "Transport Toolbar". "Control Toolbar" is historic.
496  ControlToolBar *GetControlToolBar();
498  DeviceToolBar *GetDeviceToolBar();
499  EditToolBar *GetEditToolBar();
500  MixerToolBar *GetMixerToolBar();
501  ScrubbingToolBar *GetScrubbingToolBar();
502  SelectionBar *GetSelectionBar();
503 #ifdef EXPERIMENTAL_SPECTRAL_EDITING
504  SpectralSelectionBar *GetSpectralSelectionBar();
505 #endif
506  ToolsToolBar *GetToolsToolBar();
507  const ToolsToolBar *GetToolsToolBar() const;
508  TranscriptionToolBar *GetTranscriptionToolBar();
509 
510  MeterPanel *GetPlaybackMeter();
511  void SetPlaybackMeter(MeterPanel *playback);
512  MeterPanel *GetCaptureMeter();
513  void SetCaptureMeter(MeterPanel *capture);
514 
515  LyricsWindow* GetLyricsWindow() { return mLyricsWindow; }
516  MixerBoard* GetMixerBoard() { return mMixerBoard; }
517 
518  wxStatusBar* GetStatusBar() { return mStatusBar; }
519 
520 private:
521  bool SnapSelection();
522 
523 public:
524  // SelectionBarListener callback methods
525 
526  double AS_GetRate() override;
527  void AS_SetRate(double rate) override;
528  int AS_GetSnapTo() override;
529  void AS_SetSnapTo(int snap) override;
530  const NumericFormatId & AS_GetSelectionFormat() override;
531  void AS_SetSelectionFormat(const NumericFormatId & format) override;
532  void AS_ModifySelection(double &start, double &end, bool done) override;
533 
534  // SpectralSelectionBarListener callback methods
535 
536  double SSBL_GetRate() const override;
537 
539  void SSBL_SetFrequencySelectionFormatName(const NumericFormatId & formatName) override;
540 
542  void SSBL_SetBandwidthSelectionFormatName(const NumericFormatId & formatName) override;
543 
544  void SSBL_ModifySpectralSelection(double &bottom, double &top, bool done) override;
545 
546  void SetStateTo(unsigned int n);
547 
548  // XMLTagHandler callback methods
549 
550  bool HandleXMLTag(const wxChar *tag, const wxChar **attrs) override;
551  XMLTagHandler *HandleXMLChild(const wxChar *tag) override;
552  void WriteXML(
553  XMLWriter &xmlFile, bool bWantSaveCopy) /* not override */;
554 
555  void WriteXMLHeader(XMLWriter &xmlFile) const;
557  PlayMode mLastPlayMode{ PlayMode::normalPlay };
559 
560  // Audio IO callback methods
561  void OnAudioIORate(int rate) override;
562  void OnAudioIOStartRecording() override;
563  void OnAudioIOStopRecording() override;
564  void OnAudioIONewBlockFiles(const AutoSaveFile & blockFileLog) override;
565 
566  // Command Handling
567  bool ReportIfActionNotAllowed
568  ( const wxString & Name, CommandFlag & flags, CommandFlag flagsRqd, CommandFlag mask );
569  bool TryToMakeActionAllowed
570  ( CommandFlag & flags, CommandFlag flagsRqd, CommandFlag mask );
571 
572  bool UndoAvailable();
573  bool RedoAvailable();
574 
575  void PushState(const wxString &desc, const wxString &shortDesc); // use UndoPush::AUTOSAVE
576  void PushState(const wxString &desc, const wxString &shortDesc, UndoPush flags);
577  void RollbackState();
578 
579 
580  private:
581 
582  void OnCapture(wxCommandEvent & evt);
583  void InitialState();
584 
585  public:
586  void ModifyState(bool bWantsAutoSave); // if true, writes auto-save file. Should set only if you really want the state change restored after
587  // a crash, as it can take many seconds for large (eg. 10 track-hours) projects
588  void RecreateMixerBoard();
589 
590  private:
591  void PopState(const UndoState &state);
592 
593  void UpdateLyrics();
594  void UpdateMixerBoard();
595 
596  void GetRegionsByLabel( Regions &regions );
597 
598  void AutoSave();
599  void DeleteCurrentAutoSaveFile();
600 
601  double GetZoomOfToFit();
602  double GetZoomOfSelection();
603  double GetZoomOfPreset(int preset );
604 
605  public:
606  bool IsSoloSimple() const { return mSoloPref == wxT("Simple"); }
607  bool IsSoloNone() const { return mSoloPref == wxT("None"); }
608 
609  private:
610 
611  // The project's name and file info
612  wxString mFileName;
614  std::shared_ptr<DirManager> mDirManager; // MM: DirManager now created dynamically
615 
616  static int mProjectCounter;// global counter.
617  int mProjectNo; // count when this project was created.
618 
619  double mRate;
621 
622  // Recent files
624 
625  // Tags (artist name, song properties, MP3 ID3 info, etc.)
626  // The structure may be shared with undo history entries
627  // To keep undo working correctly, always replace this with a NEW duplicate
628  // BEFORE doing any editing of it!
629  std::shared_ptr<Tags> mTags;
630 
631  // List of tracks and display info
632  std::shared_ptr<TrackList> mTracks;
633 
634  int mSnapTo;
638 
639  std::shared_ptr<TrackList> mLastSavedTracks;
640 
641  // Clipboard (static because it is shared by all projects)
642  static std::shared_ptr<TrackList> msClipboard;
644  static double msClipT0;
645  static double msClipT1;
646 
647 public:
649  //shared by all projects
650  static ODLock &AllProjectDeleteMutex();
651 
652 private:
653  // History/Undo manager
654  std::unique_ptr<UndoManager> mUndoManager;
655  bool mDirty{ false };
656 
657  // Commands
658 
660 
662 
663  // Window elements
664 
665  std::unique_ptr<wxTimer> mTimer;
667 
668  wxStatusBar *mStatusBar;
669 
670  AdornedRulerPanel *mRuler{};
671  wxPanel *mTopPanel{};
672  TrackPanel *mTrackPanel{};
673  SelectionState mSelectionState{};
674  bool mCircularTrackNavigation{};
675  std::unique_ptr<TrackFactory> mTrackFactory{};
676  wxPanel * mMainPanel;
677  wxScrollBar *mHsbar;
678  wxScrollBar *mVsbar;
679  bool mAutoScrolling{ false };
680  bool mActive{ true };
681  bool mIconized;
682 
683  MacrosWindow *mMacrosWindow{};
684  HistoryWindow *mHistoryWindow{};
685  LyricsWindow* mLyricsWindow{};
686  MixerBoardFrame* mMixerBoardFrame{};
687  MixerBoard* mMixerBoard{};
688 
691 
692  // dialog for missing alias warnings
693  wxDialog *mAliasMissingWarningDialog{};
694 
695  bool mShownOnce{ false };
696 
697  // Project owned meters
698  MeterPanel *mPlaybackMeter{};
699  MeterPanel *mCaptureMeter{};
700 
701  std::unique_ptr<ToolManager> mToolManager;
702 
703  public:
704  ToolManager *GetToolManager() { return mToolManager.get(); }
706  wxString mHelpPref;
707  wxString mSoloPref;
708  bool mbBusyImporting{ false }; // used to fix bug 584
709 
710  void SetNormalizedWindowState(wxRect pSizeAndLocation) { mNormalizedWindowState = pSizeAndLocation; }
711  wxRect GetNormalizedWindowState() const { return mNormalizedWindowState; }
712 
713  bool IsTimerRecordCancelled(){return mTimerRecordCanceled;}
714  void ResetTimerRecordFlag(){mTimerRecordCanceled=false;}
715  private:
716  //sort method used by OnSortName and OnSortTime
717  //currently only supported flags are kAudacitySortByName and kAudacitySortByName
718  //in the future we might have 0x01 as sort ascending and we can bit or it
719 #define kAudacitySortByTime (1 << 1)
720 #define kAudacitySortByName (1 << 2)
721  void SortTracks(int flags);
722 
723  int mAudioIOToken{ -1 };
724 
725  bool mIsDeleting{ false };
726  bool mTracksFitVerticallyZoomed{ false }; //lda
727  bool mNormalizeOnLoad; //lda
728  bool mShowId3Dialog{ true }; //lda
730 
731  // 0 is grey out, 1 is Autoselect, 2 is Give warnings.
734 
736 
738 
739  std::unique_ptr<ImportXMLTagHandler> mImportXMLTagHandler;
740 
741  // Last auto-save file name and path (empty if none)
743 
744  // Are we currently auto-saving or not?
745  bool mAutoSaving{ false };
746 
747  // Has this project been recovered from an auto-saved version
748  bool mIsRecovered{ false };
749 
750  // The auto-save data dir the project has been recovered from
752 
753  // The handler that handles recovery of <recordingrecovery> tags
754  std::unique_ptr<RecordingRecoveryHandler> mRecordingRecoveryHandler;
755 
756  // Dependencies have been imported and a warning should be shown on save
757  bool mImportedDependencies{ false };
758 
759  wxArrayString mStrOtherNamesArray; // used to make sure compressed file names are unique
760 
761  // Last effect applied to this project
762  PluginID mLastEffect{};
763 
765 
766  //flag for cancellation of timer record.
767  bool mTimerRecordCanceled{ false };
768 
769  // Are we currently closing as the result of a menu command?
770  bool mMenuClose{ false };
771 
772  bool mbInitializingScrollbar{ false };
773 
774  // Flag that we're recoding.
775  bool mIsCapturing{ false };
776 
777  // Keyboard capture
778  wxWindow *mKeyboardCaptureHandler{};
779 
780  double mSeekShort;
781  double mSeekLong;
782 
784 
785  // See explanation in OnCloseWindow
786  bool mIsBeingDeleted{ false };
787 
788  // CommandManager needs to use private methods
789  friend class CommandManager;
790 
791  // TrackPanelOverlay objects
792  std::unique_ptr<Overlay>
793  mIndicatorOverlay, mCursorOverlay;
794 
795  std::shared_ptr<BackgroundCell> mBackgroundCell;
796 
797 #ifdef EXPERIMENTAL_SCRUBBING_BASIC
798  std::unique_ptr<Overlay> mScrubOverlay;
799  std::unique_ptr<Scrubber> mScrubber;
800 public:
801  Scrubber &GetScrubber() { return *mScrubber; }
802  const Scrubber &GetScrubber() const { return *mScrubber; }
803 #endif
804 
805  class PlaybackScroller final : public wxEvtHandler
806  {
807  public:
808  explicit PlaybackScroller(AudacityProject *project);
809 
810  enum class Mode {
811  Off,
812  Refresh,
813  Centered,
814  Right,
815  };
816 
817  Mode GetMode() const { return mMode; }
818  void Activate(Mode mode)
819  {
820  mMode = mode;
821  }
822 
823  private:
824  void OnTimer(wxCommandEvent &event);
825 
827  Mode mMode { Mode::Off };
828  };
829  std::unique_ptr<PlaybackScroller> mPlaybackScroller;
830 
831 public:
832  PlaybackScroller &GetPlaybackScroller() { return *mPlaybackScroller; }
833  std::shared_ptr<BackgroundCell> GetBackgroundCell() const
834  { return mBackgroundCell; }
835 
836  DECLARE_EVENT_TABLE()
837 };
838 
839 #endif
840 
virtual void OnAudioIOStartRecording()=0
virtual void AS_SetSnapTo(int snap)=0
std::unique_ptr< Overlay > mIndicatorOverlay
Definition: Project.h:793
A ToolBar that has the main Transport buttons.
std::unique_ptr< ImportXMLTagHandler > mImportXMLTagHandler
Definition: Project.h:739
A ToolBar that holds the VU Meter.
Definition: MeterToolBar.h:32
A list of TrackListNode items.
Definition: Track.h:619
bool mbLoadedFromAup
Definition: Project.h:613
Class which actulaly imports the auido, using functions defined in ImportPCM.cpp, ImportMP3...
Definition: Import.h:88
wxMenu * mRecentFilesMenu
Definition: Project.h:623
double t0() const
virtual double SSBL_GetRate() const =0
std::unique_ptr< PlaybackScroller > mPlaybackScroller
Definition: Project.h:829
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:801
wxString mRecoveryAutoSaveDataDir
Definition: Project.h:751
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:735
virtual int AS_GetSnapTo()=0
void RedrawAllProjects()
Definition: Project.cpp:597
bool mIconized
Definition: Project.h:681
std::unique_ptr< wxTimer > mTimer
Definition: Project.h:665
AudacityProject * CreateNewAudacityProject()
Definition: Project.cpp:549
(not quite a Toolbar) at foot of screen for setting and viewing the selection range.
Definition: SelectionBar.h:42
long mLastStatusUpdateTime
Definition: Project.h:666
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:713
virtual void TP_ModifyState(bool bWantsAutoSave)=0
void GetNextWindowPlacement(wxRect *nextRect, bool *pMaximized, bool *pIconized)
Definition: Project.cpp:718
wxScrollBar * mVsbar
Definition: Project.h:678
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:308
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:303
virtual XMLTagHandler * HandleXMLChild(const wxChar *tag)=0
bool mLockPlayRegion
Definition: Project.h:737
virtual void TP_HandleResize()=0
double mSeekShort
Definition: Project.h:780
A ToolBar that has the edit buttons on it.
Definition: EditToolBar.h:73
wxString mSoloPref
Definition: Project.h:707
std::unique_ptr< Scrubber > mScrubber
Definition: Project.h:799
bool mShowSplashScreen
Definition: Project.h:705
const CommandManager * GetCommandManager() const
Definition: Project.h:347
PlayMode
Definition: Project.h:125
sampleFormat mDefaultFormat
Definition: Project.h:620
wxString PluginID
Definition: Types.h:209
const Scrubber & GetScrubber() const
Definition: Project.h:802
void SetShowId3Dialog(bool flag)
Definition: Project.h:317
std::shared_ptr< DirManager > mDirManager
Definition: Project.h:614
bool mEmptyCanBeDirty
Definition: Project.h:729
bool IsWindowAccessible(wxRect *requestedRect)
Definition: Project.cpp:667
CommandContext provides addiitonal information to an 'Apply()' command. It provides the project...
CommandManager mCommandManager
Definition: Project.h:659
virtual void TP_ScrollWindow(double scrollto)=0
CommandManager * GetCommandManager()
Definition: Project.h:346
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:612
const TrackPanel * GetTrackPanel() const
Definition: Project.h:308
std::shared_ptr< AudacityProject > AProjectHolder
Definition: Project.h:119
MixerBoard * GetMixerBoard()
Definition: Project.h:516
StatusBarField
Definition: Project.h:131
bool HandleXMLTag(const wxChar *tag, const wxChar **attrs) override
Definition: Project.cpp:490
void ResetTimerRecordFlag()
Definition: Project.h:714
Used to create a WaveTrack, or a LabelTrack.. Implementation of the functions of this class are dispe...
Definition: Track.h:863
std::unique_ptr< RecordingRecoveryHandler > mRecordingRecoveryHandler
Definition: Project.h:754
std::shared_ptr< Tags > mTags
Definition: Project.h:629
virtual const NumericFormatId & SSBL_GetFrequencySelectionFormatName()=0
DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, EVT_CAPTURE_KEY,-1)
Custom events.
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:639
void GetDefaultWindowRect(wxRect *defRect)
Definition: Project.cpp:623
wxRect mNormalizedWindowState
Definition: Project.h:764
std::shared_ptr< BackgroundCell > mBackgroundCell
Definition: Project.h:795
Defines a selected portion of a project.
double mRate
Definition: Project.h:619
The TrackPanel class coordinates updates and operations on the main part of the screen which contains...
Definition: TrackPanel.h:245
std::vector< std::shared_ptr< WaveTrack > > WaveTrackArray
Definition: AudioIO.h:66
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:635
struct holding stream options, including a pointer to the TimeTrack and AudioIOListener and whether t...
Definition: AudioIO.h:123
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:781
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:644
static double msClipT1
Definition: Project.h:645
CommandFlag mLastFlags
Definition: Project.h:661
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:704
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:654
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:70
AudacityProject * mProject
Definition: Project.h:826
AUDACITY_DLL_API void CloseAllProjects()
Definition: Project.cpp:611
ViewInfo mViewInfo
Definition: Project.h:558
virtual const NumericFormatId & AS_GetSelectionFormat()=0
const int AudacityProjectTimerID
Definition: Project.h:49
std::unique_ptr< Track >(WaveTrack::* EditDestFunction)(double, double)
Definition: Project.h:413
wxArrayString mStrOtherNamesArray
Definition: Project.h:759
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:833
IdentInterfaceSymbol pairs a persistent string identifier used internally with an optional...
std::unique_ptr< Overlay > mScrubOverlay
Definition: Project.h:798
ImportXMLTagHandler(AudacityProject *pProject)
Definition: Project.h:146
virtual void TP_ScrollRight()=0
wxString mAutoSaveFileName
Definition: Project.h:742
bool mNormalizeOnLoad
Definition: Project.h:727
ID3 Tags (for MP3)
Definition: Tags.h:70
int mWhatIfNoSelection
Definition: Project.h:732
bool IsSoloNone() const
Definition: Project.h:607
bool IsSoloSimple() const
Definition: Project.h:606
NumericFormatId mFrequencySelectionFormatName
Definition: Project.h:636
std::vector< AProjectHolder > AProjectArray
Definition: Project.h:120
virtual void OnAudioIONewBlockFiles(const AutoSaveFile &blockFileLog)=0
Destroy_ptr< ContrastDialog > mContrastDialog
Definition: Project.h:690
Monitors record play start/stop and new blockfiles. Has callbacks for these events.
wxStatusBar * GetStatusBar()
Definition: Project.h:518
wxStatusBar * mStatusBar
Definition: Project.h:668
CommandFlag
Definition: CommandFlag.h:16
bool mStopIfWasPaused
Definition: Project.h:733
UndoManager * GetUndoManager()
Definition: Project.h:195
PlaybackScroller & GetPlaybackScroller()
Definition: Project.h:832
wxString mHelpPref
Definition: Project.h:706
wxScrollBar * mHsbar
Definition: Project.h:677
std::unique_ptr< ToolManager > mToolManager
Definition: Project.h:701
LyricsWindow * GetLyricsWindow()
Definition: Project.h:515
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:393
bool GetTracksFitVerticallyZoomed()
Definition: Project.h:313
Works with HistoryWindow to provide the Undo functionality.
Definition: UndoManager.h:93
static int mProjectCounter
Definition: Project.h:616
virtual void OnAudioIORate(int rate)=0
TrackPanel * GetTrackPanel()
Definition: Project.h:307
virtual bool TP_ScrollUpDown(int delta)=0
void RefreshCursorForAllProjects()
Definition: Project.cpp:604
wxRect GetNormalizedWindowState() const
Definition: Project.h:711
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:316
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:642
void SetNormalizedWindowState(wxRect pSizeAndLocation)
Definition: Project.h:710
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:643
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:632
A ToolBar that provides the record and playback volume settings.
Definition: MixerToolBar.h:25
wxLongLong mLastSelectionAdjustment
Definition: Project.h:783
virtual ToolsToolBar * TP_GetToolsToolBar()=0
virtual void AS_ModifySelection(double &start, double &end, bool done)=0
wxPanel * mMainPanel
Definition: Project.h:676
NumericFormatId mBandwidthSelectionFormatName
Definition: Project.h:637
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:689