Audacity 3.2.0
Namespaces | Typedefs | Functions | Variables
WaveformVRulerControls.cpp File Reference
#include "WaveformVRulerControls.h"
#include "WaveformVZoomHandle.h"
#include "WaveChannelVRulerControls.h"
#include "prefs/WaveformScale.h"
#include "../../../ui/ChannelView.h"
#include "NumberScale.h"
#include "ProjectHistory.h"
#include "../../../../RefreshCode.h"
#include "../../../../TrackPanelMouseEvent.h"
#include "../../../../UIHandle.h"
#include "WaveTrack.h"
#include "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 35 of file WaveformVRulerControls.cpp.

Function Documentation

◆ RegenerateLinearDBValues()

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

Definition at line 39 of file WaveformVRulerControls.cpp.

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