Audacity 3.2.0
Functions
anonymous_namespace{BrushHandle.cpp} Namespace Reference

Functions

wxInt64 FrequencyToPosition (const WaveChannel &wc, double frequency, wxInt64 trackTopEdge, int trackHeight)
 Converts a frequency to screen y position. More...
 
double PositionToFrequency (const WaveChannel &wc, bool maySnap, wxInt64 mouseYCoordinate, wxInt64 trackTopEdge, int trackHeight)
 
long long PositionToLongSample (const WaveTrack *wt, const ViewInfo &viewInfo, int trackTopEdgeX, int mousePosX)
 
template<typename T >
void SetIfNotNull (T *pValue, const T Value)
 
bool isSpectralSelectionView (const ChannelView *pChannelView)
 
wxCursor * CrosshairCursor ()
 
template<class A , class B , class DIST >
bool within (A a, B b, DIST d)
 
double findMaxRatio (double center, double rate)
 

Function Documentation

◆ CrosshairCursor()

wxCursor * anonymous_namespace{BrushHandle.cpp}::CrosshairCursor ( )

Definition at line 130 of file BrushHandle.cpp.

131 {
132 static auto crosshairCursor =
133 ::MakeCursor(wxCURSOR_IBEAM, CrosshairCursorXpm, 16, 16);
134 return &*crosshairCursor;
135 }
std::unique_ptr< wxCursor > MakeCursor(int WXUNUSED(CursorId), const char *const pXpm[36], int HotX, int HotY)
Definition: TrackPanel.cpp:189

References MakeCursor().

Referenced by BrushHandle::Preview().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ findMaxRatio()

double anonymous_namespace{BrushHandle.cpp}::findMaxRatio ( double  center,
double  rate 
)
inline

Definition at line 181 of file BrushHandle.cpp.

182 {
183 const double minFrequency = 1.0;
184 const double maxFrequency = (rate / 2.0);
185 const double frequency =
186 std::min(maxFrequency,
187 std::max(minFrequency, center));
188 return
189 std::min(frequency / minFrequency, maxFrequency / frequency);
190 }
int min(int a, int b)

References min().

Here is the call graph for this function:

◆ FrequencyToPosition()

wxInt64 anonymous_namespace{BrushHandle.cpp}::FrequencyToPosition ( const WaveChannel wc,
double  frequency,
wxInt64  trackTopEdge,
int  trackHeight 
)

Converts a frequency to screen y position.

Definition at line 65 of file BrushHandle.cpp.

69 {
70 const auto &settings = SpectrogramSettings::Get(wc);
71 float minFreq, maxFreq;
72 SpectrogramBounds::Get(wc).GetBounds(wc, minFreq, maxFreq);
73 const NumberScale numberScale(settings.GetScale(minFreq, maxFreq));
74 const float p = numberScale.ValueToPosition(frequency);
75 return trackTopEdge + wxInt64((1.0 - p) * trackHeight);
76 }
static Settings & settings()
Definition: TrackInfo.cpp:69
void GetBounds(const WaveChannel &wc, float &min, float &max) const
static SpectrogramBounds & Get(WaveTrack &track)
Get either the global default settings, or the track's own if previously created.
static SpectrogramSettings & Get(const WaveTrack &track)

References SpectrogramSettings::Get(), SpectrogramBounds::Get(), SpectrogramBounds::GetBounds(), settings(), and NumberScale::ValueToPosition().

Here is the call graph for this function:

◆ isSpectralSelectionView()

bool anonymous_namespace{BrushHandle.cpp}::isSpectralSelectionView ( const ChannelView pChannelView)
inline

Definition at line 124 of file BrushHandle.cpp.

124 {
125 const auto pChannel = pChannelView && pChannelView->IsSpectral()
126 ? pChannelView->FindChannel<const WaveChannel>() : nullptr;
127 return pChannel &&
129 }
virtual bool IsSpectral() const
auto FindChannel() -> std::shared_ptr< Subtype >
May return null.
bool SpectralSelectionEnabled() const

References CommonChannelCell::FindChannel(), SpectrogramSettings::Get(), ChannelView::IsSpectral(), and SpectrogramSettings::SpectralSelectionEnabled().

Here is the call graph for this function:

◆ PositionToFrequency()

double anonymous_namespace{BrushHandle.cpp}::PositionToFrequency ( const WaveChannel wc,
bool  maySnap,
wxInt64  mouseYCoordinate,
wxInt64  trackTopEdge,
int  trackHeight 
)

Converts a position (mouse Y coordinate) to frequency, in Hz.

Definition at line 80 of file BrushHandle.cpp.

85 {
86 const double rate = wc.GetRate();
87
88 // Handle snapping
89 if (maySnap &&
90 mouseYCoordinate - trackTopEdge < FREQ_SNAP_DISTANCE)
91 return rate;
92 if (maySnap &&
93 trackTopEdge + trackHeight - mouseYCoordinate < FREQ_SNAP_DISTANCE)
94 return -1;
95
96 const auto &settings = SpectrogramSettings::Get(wc);
97 const auto &cache = SpectrogramBounds::Get(wc);
98 float minFreq, maxFreq;
99 cache.GetBounds(wc, minFreq, maxFreq);
100 const NumberScale numberScale(settings.GetScale(minFreq, maxFreq));
101 const double p = double(mouseYCoordinate - trackTopEdge) / trackHeight;
102 return numberScale.PositionToValue(1.0 - p);
103 }
@ FREQ_SNAP_DISTANCE
Definition: BrushHandle.cpp:52
double GetRate() const override
Definition: WaveTrack.cpp:793

References FREQ_SNAP_DISTANCE, SpectrogramSettings::Get(), SpectrogramBounds::Get(), WaveChannel::GetRate(), NumberScale::PositionToValue(), and settings().

Referenced by BrushHandle::Drag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PositionToLongSample()

long long anonymous_namespace{BrushHandle.cpp}::PositionToLongSample ( const WaveTrack wt,
const ViewInfo viewInfo,
int  trackTopEdgeX,
int  mousePosX 
)

Definition at line 105 of file BrushHandle.cpp.

109 {
110 wxInt64 posTime = viewInfo.PositionToTime(mousePosX, trackTopEdgeX);
111 sampleCount sc = wt->TimeToLongSamples(posTime);
112 return sc.as_long_long();
113 }
sampleCount TimeToLongSamples(double t0) const
double PositionToTime(int64 position, int64 origin=0, bool ignoreFisheye=false) const
Definition: ZoomInfo.cpp:34
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:19
long long as_long_long() const
Definition: SampleCount.h:48

References sampleCount::as_long_long(), ZoomInfo::PositionToTime(), and WideSampleSequence::TimeToLongSamples().

Here is the call graph for this function:

◆ SetIfNotNull()

template<typename T >
void anonymous_namespace{BrushHandle.cpp}::SetIfNotNull ( T *  pValue,
const T  Value 
)
inline

Definition at line 116 of file BrushHandle.cpp.

117 {
118 if (pValue == NULL)
119 return;
120 *pValue = Value;
121 }

◆ within()

template<class A , class B , class DIST >
bool anonymous_namespace{BrushHandle.cpp}::within ( A  a,
b,
DIST  d 
)

Definition at line 176 of file BrushHandle.cpp.

177 {
178 return (a > b - d) && (a < b + d);
179 }