MCPcopy Create free account
hub / github.com/audacity/audacity / FrequencyToPosition

Function FrequencyToPosition

src/tracks/ui/SelectHandle.cpp:69–80  ·  view source on GitHub ↗

Converts a frequency to screen y position.

Source from the content-addressed store, hash-verified

67{
68 /// Converts a frequency to screen y position.
69 wxInt64 FrequencyToPosition(const WaveChannel &wc,
70 double frequency,
71 wxInt64 trackTopEdge,
72 int trackHeight)
73 {
74 const auto &settings = SpectrogramSettings::Get(wc);
75 float minFreq, maxFreq;
76 SpectrogramBounds::Get(wc).GetBounds(wc, minFreq, maxFreq);
77 const NumberScale numberScale(settings.GetScale(minFreq, maxFreq));
78 const float p = numberScale.ValueToPosition(frequency);
79 return trackTopEdge + wxInt64((1.0 - p) * trackHeight);
80 }
81
82 /// Converts a position (mouse Y coordinate) to
83 /// frequency, in Hz.

Callers 1

ChooseBoundaryFunction · 0.70

Calls 4

GetFunction · 0.85
GetScaleMethod · 0.80
GetBoundsMethod · 0.45
ValueToPositionMethod · 0.45

Tested by

no test coverage detected