Audacity 3.2.0
Namespaces | Typedefs | Functions | Variables
WaveformVRulerControls.cpp File Reference
#include "WaveformVRulerControls.h"
#include "WaveformVZoomHandle.h"
#include "WaveTrackVRulerControls.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 WaveTrack &track)
 
void anonymous_namespace{WaveformVRulerControls.cpp}::SetLastScaleType (WaveformScale &cache, const WaveTrack &track)
 

Variables

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

Typedef Documentation

◆ LinearDBValues

using LinearDBValues = std::vector<double>

Definition at line 33 of file WaveformVRulerControls.cpp.

Function Documentation

◆ RegenerateLinearDBValues()

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

Definition at line 37 of file WaveformVRulerControls.cpp.

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