Audacity 3.2.0
Namespaces | Functions | Variables
TrackArt.cpp File Reference
#include "TrackArt.h"
#include "AColor.h"
#include "AllThemeResources.h"
#include "SelectedRegion.h"
#include "SyncLock.h"
#include "Theme.h"
#include "Track.h"
#include "TrackArtist.h"
#include "TrackPanelDrawingContext.h"
#include "ZoomInfo.h"
#include <wx/app.h>
#include <wx/dc.h>
Include dependency graph for TrackArt.cpp:

Go to the source code of this file.

Namespaces

namespace  anonymous_namespace{TrackArt.cpp}
 

Functions

wxRect anonymous_namespace{TrackArt.cpp}::GetAffordanceTitleRect (const wxRect &rect)
 
int GetWaveYPos (float value, float min, float max, int height, bool dB, bool outer, float dBr, bool clip)
 
float FromDB (float value, double dBRange)
 
float ValueOfPixel (int yy, int height, bool offset, bool dB, double dBRange, float zoomMin, float zoomMax)
 

Variables

static constexpr int ClipSelectionStrokeSize { 1 }
 

Function Documentation

◆ FromDB()

float FromDB ( float  value,
double  dBRange 
)

Definition at line 96 of file TrackArt.cpp.

97{
98 if (value == 0)
99 return 0;
100
101 double sign = (value >= 0 ? 1 : -1);
102 return DB_TO_LINEAR((fabs(value) * dBRange) - dBRange) * sign;
103}
#define DB_TO_LINEAR(x)
Definition: MemoryX.h:535

References DB_TO_LINEAR.

Referenced by ValueOfPixel().

Here is the caller graph for this function:

◆ GetWaveYPos()

int GetWaveYPos ( float  value,
float  min,
float  max,
int  height,
bool  dB,
bool  outer,
float  dBr,
bool  clip 
)

Takes a value between min and max and returns a value between height and 0

Todo:
Should this function move int GuiWaveTrack where it can then use the zoomMin, zoomMax and height values without having to have them passed in to it??

Definition at line 49 of file TrackArt.cpp.

52{
53 if (dB) {
54 if (height == 0) {
55 return 0;
56 }
57
58 float sign = (value >= 0 ? 1 : -1);
59
60 if (value != 0.) {
61 float db = LINEAR_TO_DB(fabs(value));
62 value = (db + dBr) / dBr;
63 if (!outer) {
64 value -= 0.5;
65 }
66 if (value < 0.0) {
67 value = 0.0;
68 }
69 value *= sign;
70 }
71 }
72 else {
73 if (!outer) {
74 if (value >= 0.0) {
75 value -= 0.5;
76 }
77 else {
78 value += 0.5;
79 }
80 }
81 }
82
83 if (clip) {
84 if (value < min) {
85 value = min;
86 }
87 if (value > max) {
88 value = max;
89 }
90 }
91
92 value = (max - value) / (max - min);
93 return (int) (value * (height - 1) + 0.5);
94}
static const wxPoint2DDouble outer[]
Definition: ASlider.cpp:395
int min(int a, int b)
#define LINEAR_TO_DB(x)
Definition: MemoryX.h:536

References LINEAR_TO_DB, min(), and outer.

Referenced by anonymous_namespace{WaveformView.cpp}::DrawEnvelope(), anonymous_namespace{WaveformView.cpp}::DrawIndividualSamples(), anonymous_namespace{WaveformView.cpp}::DrawMinMaxRMS(), EnvelopeEditor::DrawPoints(), anonymous_namespace{WaveformView.cpp}::DrawWaveformBackground(), EnvelopeEditor::HandleMouseButtonDown(), EnvelopeHandle::HitEnvelope(), and SampleHandle::HitTest().

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

◆ ValueOfPixel()

float ValueOfPixel ( int  yy,
int  height,
bool  offset,
bool  dB,
double  dBRange,
float  zoomMin,
float  zoomMax 
)

Definition at line 105 of file TrackArt.cpp.

107{
108 wxASSERT(height > 0);
109 // Map 0 to max and height - 1 (not height) to min
110 float v =
111 height == 1 ? (zoomMin + zoomMax) / 2 :
112 zoomMax - (yy / (float)(height - 1)) * (zoomMax - zoomMin);
113 if (offset) {
114 if (v > 0.0)
115 v += .5;
116 else
117 v -= .5;
118 }
119
120 if (dB)
121 v = FromDB(v, dBRange);
122
123 return v;
124}
float FromDB(float value, double dBRange)
Definition: TrackArt.cpp:96

References FromDB().

Referenced by SampleHandle::FindSampleEditingLevel().

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

Variable Documentation

◆ ClipSelectionStrokeSize

constexpr int ClipSelectionStrokeSize { 1 }
staticconstexpr