Debian Codegraph @

src/tracks/playabletrack/wavetrack/ui/PitchAndSpeedDialog.h

raw
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /**********************************************************************
3
4 Audacity: A Digital Audio Editor
5
6 @file PitchAndSpeedDialog.h
7
8 Dmitry Vedenko
9
10 **********************************************************************/
11 #pragma once
12
13 #include "ClientData.h"
14 #include "Observer.h"
15 #include "WaveClip.h"
16 #include "WaveTrack.h"
17 #include "wxPanelWrapper.h"
18
19 struct TrackPanelMouseEvent;
20 class AudacityProject;
21 class ShuttleGui;
22 class WaveClip;
23
24 enum class PitchAndSpeedDialogGroup
25 {
26 Pitch,
27 Speed
28 };
29
30 class PitchAndSpeedDialog final :
31 public wxDialogWrapper,
32 public ClientData::Base
33 {
34 public:
35 static PitchAndSpeedDialog& Get(AudacityProject& project);
36 static const PitchAndSpeedDialog& Get(const AudacityProject& project);
37 static void Destroy(AudacityProject& project);
38
39 PitchAndSpeedDialog(AudacityProject& project);
40
41 PitchAndSpeedDialog& Retarget(
42 const std::shared_ptr<WaveTrack>& track,
43 const WaveTrack::IntervalHolder& wideClip);
44 PitchAndSpeedDialog&
45 SetFocus(const std::optional<PitchAndSpeedDialogGroup>& group);
46 void TryRetarget(const TrackPanelMouseEvent& event);
47
48 struct PitchShift
49 {
50 int semis = 0;
51 int cents = 0;
52 bool operator==(const PitchShift& other) const
53 {
54 return semis == other.semis && cents == other.cents;
55 }
56 bool operator!=(const PitchShift& other) const
57 {
58 return !(*this == other);
59 }
60 };
61
62 private:
63 bool Show(bool show) override
64 {
65 return wxDialogWrapper::Show(show);
66 }
67 void SetFocus() override
68 {
69 wxDialogWrapper::SetFocus();
70 }
71
72 void PopulateOrExchange(ShuttleGui& s);
73 void SetSemitoneShift();
74 bool SetClipSpeed();
75 void UpdateDialog();
76 void UpdateHistory(const TranslatableString& desc);
77
78 struct StrongTarget
79 {
80 const std::shared_ptr<WaveTrack> track;
81 WaveClipHolder clip;
82 };
83
84 std::optional<StrongTarget> LockTarget();
85
86 AudacityProject& mProject;
87 const wxString mTitle;
88 Observer::Subscription mProjectCloseSubscription;
89 Observer::Subscription mAudioIOSubscription;
90 Observer::Subscription mClipDeletedSubscription;
91 Observer::Subscription mClipCentShiftChangeSubscription;
92 Observer::Subscription mClipSpeedChangeSubscription;
93 double mClipSpeed = 100;
94 double mOldClipSpeed = mClipSpeed;
95 PitchShift mShift;
96 PitchShift mOldShift;
97 std::weak_ptr<WaveClip> mLeftClip;
98 std::weak_ptr<WaveClip> mRightClip;
99 std::weak_ptr<WaveTrack> mTrack;
100 bool mConsolidateHistory = true;
101 bool mFirst = true;
102 bool mFormantPreservation = false;
103 bool mOldFormantPreservation = mFormantPreservation;
104 };