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