Audacity 3.2.0
Classes | 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 "TimeAndPitchInterface.h"
#include "Track.h"
#include "TrackArtist.h"
#include "TrackPanelDrawingContext.h"
#include "ZoomInfo.h"
#include "TimeDisplayMode.h"
#include "ProjectTimeRuler.h"
#include "ProjectTimeSignature.h"
#include "widgets/BeatsFormat.h"
#include <wx/app.h>
#include <wx/dc.h>
#include <cassert>
#include <cstdint>
#include <cmath>
#include <utility>
Include dependency graph for TrackArt.cpp:

Go to the source code of this file.

Classes

struct  anonymous_namespace{TrackArt.cpp}::BeatsGridlinePainter
 

Namespaces

namespace  anonymous_namespace{TrackArt.cpp}
 

Functions

wxRect anonymous_namespace{TrackArt.cpp}::GetAffordanceTitleRect (const wxRect &rect)
 
wxString anonymous_namespace{TrackArt.cpp}::GetTruncatedTitle (wxDC &dc, const wxString &title, const wxRect &affordanceRect)
 
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)
 
wxRect anonymous_namespace{TrackArt.cpp}::GetClipAffordanceRect (wxDC &dc, const wxRect &clipRect, std::optional< wxRect > &clippedClipRect)
 
wxRect anonymous_namespace{TrackArt.cpp}::GetClipTruncatedTitleRect (wxDC &dc, const wxRect &affordanceRect, const wxString &title)
 
const AudacityProjectanonymous_namespace{TrackArt.cpp}::GetProject (const Track &track)
 

Variables

static constexpr int ClipSelectionStrokeSize { 1 }
 
constexpr double anonymous_namespace{TrackArt.cpp}::minSubdivisionWidth = 12.0
 

Function Documentation

◆ FromDB()

float FromDB ( float  value,
double  dBRange 
)

Definition at line 113 of file TrackArt.cpp.

114{
115 if (value == 0)
116 return 0;
117
118 double sign = (value >= 0 ? 1 : -1);
119 return DB_TO_LINEAR((fabs(value) * dBRange) - dBRange) * sign;
120}
#define DB_TO_LINEAR(x)
Definition: MemoryX.h:338

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

Definition at line 66 of file TrackArt.cpp.

69{
70 if (dB) {
71 if (height == 0) {
72 return 0;
73 }
74
75 float sign = (value >= 0 ? 1 : -1);
76
77 if (value != 0.) {
78 float db = LINEAR_TO_DB(fabs(value));
79 value = (db + dBr) / dBr;
80 if (!outer) {
81 value -= 0.5;
82 }
83 if (value < 0.0) {
84 value = 0.0;
85 }
86 value *= sign;
87 }
88 }
89 else {
90 if (!outer) {
91 if (value >= 0.0) {
92 value -= 0.5;
93 }
94 else {
95 value += 0.5;
96 }
97 }
98 }
99
100 if (clip) {
101 if (value < min) {
102 value = min;
103 }
104 if (value > max) {
105 value = max;
106 }
107 }
108
109 value = (max - value) / (max - min);
110 return (int) (value * (height - 1) + 0.5);
111}
static const wxPoint2DDouble outer[]
Definition: ASlider.cpp:401
int min(int a, int b)
#define LINEAR_TO_DB(x)
Definition: MemoryX.h:339

References LINEAR_TO_DB, min(), and outer.

Referenced by anonymous_namespace{WaveformView.cpp}::DrawEnvelope(), anonymous_namespace{WaveformView.cpp}::DrawIndividualSamples(), 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 122 of file TrackArt.cpp.

124{
125 wxASSERT(height > 0);
126 // Map 0 to max and height - 1 (not height) to min
127 float v =
128 height == 1 ? (zoomMin + zoomMax) / 2 :
129 zoomMax - (yy / (float)(height - 1)) * (zoomMax - zoomMin);
130 if (offset) {
131 if (v > 0.0)
132 v += .5;
133 else
134 v -= .5;
135 }
136
137 if (dB)
138 v = FromDB(v, dBRange);
139
140 return v;
141}
float FromDB(float value, double dBRange)
Definition: TrackArt.cpp:113

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