Audacity 3.2.0
Namespaces | Typedefs | Functions | Variables
WaveformVRulerControls.cpp File Reference
#include "WaveformVRulerControls.h"
#include "WaveformVZoomHandle.h"
#include "WaveChannelVRulerControls.h"
#include "../../../ui/ChannelView.h"
#include "NumberScale.h"
#include "ProjectHistory.h"
#include "../../../../RefreshCode.h"
#include "../../../../TrackPanelMouseEvent.h"
#include "../../../../UIHandle.h"
#include "WaveTrack.h"
#include "../../../../prefs/WaveformSettings.h"
#include "../../../../widgets/Ruler.h"
#include "../../../../widgets/LinearUpdater.h"
#include "../../../../widgets/RealFormat.h"
#include "../../../../widgets/CustomUpdaterValue.h"
Include dependency graph for WaveformVRulerControls.cpp:

Go to the source code of this file.

Namespaces

namespace  anonymous_namespace{WaveformVRulerControls.cpp}
 

Typedefs

using LinearDBValues = std::vector< double >
 

Functions

void RegenerateLinearDBValues (int dBRange, float min, float max, int height)
 
void anonymous_namespace{WaveformVRulerControls.cpp}::SetLastdBRange (WaveformScale &cache, const WaveChannel &wc)
 
void anonymous_namespace{WaveformVRulerControls.cpp}::SetLastScaleType (WaveformScale &cache, const WaveChannel &wc)
 

Variables

static LinearDBValues majorValues {}
 
static LinearDBValues minorValues {}
 
static LinearDBValues minorMinorValues {}
 
static CustomUpdaterValue updater
 

Typedef Documentation

◆ LinearDBValues

using LinearDBValues = std::vector<double>

Definition at line 34 of file WaveformVRulerControls.cpp.

Function Documentation

◆ RegenerateLinearDBValues()

void RegenerateLinearDBValues ( int  dBRange,
float  min,
float  max,
int  height 
)

Definition at line 38 of file WaveformVRulerControls.cpp.

39{
40 majorValues.clear();
41 minorValues.clear();
42 minorMinorValues.clear();
43
44 majorValues.push_back(0);
45 majorValues.push_back(-dBRange);
46 majorValues.push_back(2 * -dBRange);
47
48 const double EPSILON = .1e-5;
49
50 // No marks allowed within CENTER_SPACING pixels from the center
51 // Calculate the closest allowed major / minor and remove everything around those
52 const double CENTER = height / 2;
53 const int CENTER_SPACING = 30;
54 const double SIZE_SCALE = (max - min) / 2;
55
56 double centerSpacingMark = 0;
57
58 for (double major = 0.1; major < .95; major += .1) {
59 double val = std::round(major * 10) / 10;
60 double mappedVal = std::trunc(-dBRange * val);
61 double pixDist = CENTER - ((1 - DB_TO_LINEAR(mappedVal)) * CENTER) / SIZE_SCALE;
62 if (pixDist > CENTER_SPACING) {
63 centerSpacingMark = major;
64 majorValues.push_back(mappedVal);
65 majorValues.push_back(-2 * dBRange - mappedVal);
66 }
67 }
68 for (double minor = 0.05; minor < 1 ; minor += .1) {
69 double val = std::round(minor * 100) / 100;
70 double mappedVal = std::trunc(-dBRange * val);
71 if (minor < centerSpacingMark) {
72 minorValues.push_back(mappedVal);
73 minorValues.push_back(-2 * dBRange - mappedVal);
74 }
75 }
76 for (int minorMinor = 1; minorMinor < dBRange - EPSILON; minorMinor++) {
77 double absDist = fabs(fabs(dBRange - minorMinor) - dBRange) / dBRange;
78 if (absDist < centerSpacingMark) {
79 if ((minorMinor % (int)std::round(dBRange / 20)) != 0) {
80 minorMinorValues.push_back(-minorMinor);
81 minorMinorValues.push_back(-2 * dBRange + minorMinor);
82 }
83 }
84 }
85
86}
int min(int a, int b)
#define DB_TO_LINEAR(x)
Definition: MemoryX.h:337
static LinearDBValues majorValues
static LinearDBValues minorMinorValues
static LinearDBValues minorValues
fastfloat_really_inline void round(adjusted_mantissa &am, callback cb) noexcept
Definition: fast_float.h:2512

References DB_TO_LINEAR, majorValues, min(), minorMinorValues, minorValues, and fast_float::round().

Referenced by WaveformVRulerControls::DoUpdateVRuler().

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

Variable Documentation

◆ majorValues

LinearDBValues majorValues {}
static

◆ minorMinorValues

LinearDBValues minorMinorValues {}
static

◆ minorValues

LinearDBValues minorValues {}
static

◆ updater

CustomUpdaterValue updater
static