Audacity  3.0.3
Classes | Namespaces | Functions | Variables
TrackArtist.h File Reference
#include <wx/brush.h>
#include <wx/pen.h>
#include "Prefs.h"
Include dependency graph for TrackArtist.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  TrackArtist
 This class handles the actual rendering of WaveTracks (both waveforms and spectra), NoteTracks, LabelTracks and TimeTracks. More...
 

Namespaces

 TrackArt
 

Functions

AUDACITY_DLL_API void TrackArt::DrawClipAffordance (wxDC &dc, const wxRect &affordanceRect, const wxString &title, bool highlight=false, bool selected=false)
 
AUDACITY_DLL_API wxRect TrackArt::GetAffordanceTitleRect (const wxRect &affordanceRect)
 
AUDACITY_DLL_API void TrackArt::DrawClipEdges (wxDC &dc, const wxRect &clipRect, bool selected=false)
 
AUDACITY_DLL_API void TrackArt::DrawSyncLockTiles (TrackPanelDrawingContext &context, const wxRect &rect)
 
AUDACITY_DLL_API void TrackArt::DrawBackgroundWithSelection (TrackPanelDrawingContext &context, const wxRect &rect, const Track *track, const wxBrush &selBrush, const wxBrush &unselBrush, bool useSelection=true)
 
AUDACITY_DLL_API void TrackArt::DrawCursor (TrackPanelDrawingContext &context, const wxRect &rect, const Track *track)
 
AUDACITY_DLL_API void TrackArt::DrawNegativeOffsetTrackArrows (TrackPanelDrawingContext &context, const wxRect &rect)
 
AUDACITY_DLL_API wxString TrackArt::TruncateText (wxDC &dc, const wxString &text, const int maxWidth)
 
AUDACITY_DLL_API int GetWaveYPos (float value, float min, float max, int height, bool dB, bool outer, float dBr, bool clip)
 
float FromDB (float value, double dBRange)
 
AUDACITY_DLL_API float ValueOfPixel (int yy, int height, bool offset, bool dB, double dBRange, float zoomMin, float zoomMax)
 

Variables

static constexpr int TrackArt::ClipFrameRadius { 6 }
 

Function Documentation

◆ FromDB()

float FromDB ( float  value,
double  dBRange 
)

Definition at line 183 of file TrackArtist.cpp.

184 {
185  if (value == 0)
186  return 0;
187 
188  double sign = (value >= 0 ? 1 : -1);
189  return DB_TO_LINEAR((fabs(value) * dBRange) - dBRange) * sign;
190 }

References DB_TO_LINEAR().

Referenced by ValueOfPixel().

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

◆ GetWaveYPos()

AUDACITY_DLL_API 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 136 of file TrackArtist.cpp.

139 {
140  if (dB) {
141  if (height == 0) {
142  return 0;
143  }
144 
145  float sign = (value >= 0 ? 1 : -1);
146 
147  if (value != 0.) {
148  float db = LINEAR_TO_DB(fabs(value));
149  value = (db + dBr) / dBr;
150  if (!outer) {
151  value -= 0.5;
152  }
153  if (value < 0.0) {
154  value = 0.0;
155  }
156  value *= sign;
157  }
158  }
159  else {
160  if (!outer) {
161  if (value >= 0.0) {
162  value -= 0.5;
163  }
164  else {
165  value += 0.5;
166  }
167  }
168  }
169 
170  if (clip) {
171  if (value < min) {
172  value = min;
173  }
174  if (value > max) {
175  value = max;
176  }
177  }
178 
179  value = (max - value) / (max - min);
180  return (int) (value * (height - 1) + 0.5);
181 }

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()

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

Definition at line 192 of file TrackArtist.cpp.

194 {
195  wxASSERT(height > 0);
196  // Map 0 to max and height - 1 (not height) to min
197  float v =
198  height == 1 ? (zoomMin + zoomMax) / 2 :
199  zoomMax - (yy / (float)(height - 1)) * (zoomMax - zoomMin);
200  if (offset) {
201  if (v > 0.0)
202  v += .5;
203  else
204  v -= .5;
205  }
206 
207  if (dB)
208  v = FromDB(v, dBRange);
209 
210  return v;
211 }

References FromDB().

Referenced by SampleHandle::FindSampleEditingLevel().

Here is the call graph for this function:
Here is the caller graph for this function:
DB_TO_LINEAR
const double MIN_Threshold_Linear DB_TO_LINEAR(MIN_Threshold_dB)
outer
static const wxPoint2DDouble outer[]
Definition: ASlider.cpp:395
FromDB
float FromDB(float value, double dBRange)
Definition: TrackArtist.cpp:183
min
int min(int a, int b)
Definition: CompareAudioCommand.cpp:106
LINEAR_TO_DB
#define LINEAR_TO_DB(x)
Definition: MemoryX.h:631