Audacity 3.2.0
ChangePitchBase.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4 Audacity(R) is copyright (c) 1999-2012 Audacity Team.
5 License: GPL v2 or later. See License.txt.
6
7 ChangePitchBase.h
8 Vaughan Johnson, Dominic Mazzoni, Steve Daulton
9
10******************************************************************//*******************************************************************/
17
18#if USE_SOUNDTOUCH
19
20#pragma once
21
22#include "SettingsVisitor.h"
23#include "SoundTouchBase.h"
24
25class BUILTIN_EFFECTS_API ChangePitchBase : public SoundTouchBase
26{
27public:
28 static inline ChangePitchBase*
29 FetchParameters(ChangePitchBase& e, EffectSettings&)
30 {
31 return &e;
32 }
33 static const ComponentInterfaceSymbol Symbol;
34
35 ChangePitchBase();
36 virtual ~ChangePitchBase();
37
38 // ComponentInterface implementation
39
40 ComponentInterfaceSymbol GetSymbol() const override;
41 TranslatableString GetDescription() const override;
42 ManualPageID ManualPage() const override;
43
44 // EffectDefinitionInterface implementation
45
46 EffectType GetType() const override;
47 OptionalMessage LoadFactoryDefaults(EffectSettings& settings) const override;
48 OptionalMessage DoLoadFactoryDefaults(EffectSettings& settings);
49
50 bool Process(EffectInstance& instance, EffectSettings& settings) override;
51 bool CheckWhetherSkipEffect(const EffectSettings& settings) const override;
52
53protected:
54 // ChangePitchBase implementation
55
56 // Deduce m_FromFrequency from the samples at the beginning of
57 // the selection. Then set some other params accordingly.
58 void DeduceFrequencies();
59
60 // calculations
61 void Calc_ToPitch(); // Update m_nToPitch from NEW m_dSemitonesChange.
62 void Calc_ToOctave();
63 void Calc_SemitonesChange_fromPitches();
64 void Calc_SemitonesChange_fromOctaveChange();
65 void Calc_SemitonesChange_fromPercentChange();
66 void Calc_ToFrequency(); // Update m_ToFrequency from m_FromFrequency &
67 // m_dPercentChange.
68 void Calc_PercentChange(); // Update m_dPercentChange based on NEW
69 // m_dSemitonesChange.
70
71 bool mUseSBSMS;
72 // effect parameters
73 int m_nFromPitch; // per PitchIndex()
74 int m_nFromOctave; // per PitchOctave()
75 int m_nToPitch; // per PitchIndex()
76 int m_nToOctave; // per PitchOctave()
77
78 double m_FromFrequency; // starting frequency of selection
79 double m_ToFrequency; // target frequency of selection
80
81 double m_dSemitonesChange; // how many semitones to change pitch
82 double m_dStartFrequency; // starting frequency of first 0.2s of selection
83 double
84 m_dPercentChange; // percent change to apply to pitch
85 // Slider is (-100, 200], but textCtrls can set higher.
86
87 bool m_bLoopDetect; // Used to avoid loops in initialization and in event
88 // handling.
89
90 const EffectParameterMethods& Parameters() const override;
91
92 static constexpr EffectParameter Percentage {
93 &ChangePitchBase::m_dPercentChange, L"Percentage", 0.0, -99.0, 3000.0, 1
94 };
95 static constexpr EffectParameter UseSBSMS {
96 &ChangePitchBase::mUseSBSMS, L"SBSMS", false, false, true, 1
97 };
98};
99
100#endif // USE_SOUNDTOUCH
EffectType
std::optional< std::unique_ptr< EffectSettingsAccess::Message > > OptionalMessage
static Settings & settings()
Definition: TrackInfo.cpp:51
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Performs effect computation.
Interface for manipulations of an Effect's settings.
Holds a msgid for the translation catalog; may also bind format arguments.
Externalized state of a plug-in.