mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-01 08:29:27 +02:00
Simplified passing of min/min/rmx/bl/where values for drawing waveforms
This commit is contained in:
parent
34b09053b4
commit
29fb5a2ffe
@ -1106,15 +1106,18 @@ void TrackArtist::DrawWaveformBackground(wxDC &dc, const wxRect &r, const double
|
||||
#ifdef EXPERIMENTAL_OUTPUT_DISPLAY
|
||||
void TrackArtist::DrawMinMaxRMS(wxDC &dc, const wxRect &r, const double env[],
|
||||
float zoomMin, float zoomMax, bool dB,
|
||||
const float min[], const float max[], const float rms[],
|
||||
const int bl[], bool showProgress, bool muted, const float gain)
|
||||
const WaveDisplay &display, bool showProgress, bool muted, const float gain)
|
||||
#else
|
||||
void TrackArtist::DrawMinMaxRMS(wxDC &dc, const wxRect &r, const double env[],
|
||||
float zoomMin, float zoomMax, bool dB,
|
||||
const float min[], const float max[], const float rms[],
|
||||
const int bl[], bool WXUNUSED(showProgress), bool muted)
|
||||
const WaveDisplay &display, bool WXUNUSED(showProgress), bool muted)
|
||||
#endif
|
||||
{
|
||||
const float *const min = display.min;
|
||||
const float *const max = display.max;
|
||||
const float *const rms = display.rms;
|
||||
const int *const bl = display.bl;
|
||||
|
||||
// Display a line representing the
|
||||
// min and max of the samples in this region
|
||||
int lasth1 = std::numeric_limits<int>::max();
|
||||
@ -1656,26 +1659,16 @@ void TrackArtist::DrawClipWaveform(WaveTrack *track,
|
||||
float zoomMin, zoomMax;
|
||||
track->GetDisplayBounds(&zoomMin, &zoomMax);
|
||||
|
||||
// Arrays containing the shape of the waveform - each array
|
||||
// has one value per pixel.
|
||||
float *min = new float[mid.width];
|
||||
float *max = new float[mid.width];
|
||||
float *rms = new float[mid.width];
|
||||
sampleCount *where = new sampleCount[mid.width + 1];
|
||||
int *bl = new int[mid.width];
|
||||
WaveDisplay display;
|
||||
bool isLoadingOD = false;//true if loading on demand block in sequence.
|
||||
|
||||
// The WaveClip class handles the details of computing the shape
|
||||
// of the waveform. The only way GetWaveDisplay will fail is if
|
||||
// there's a serious error, like some of the waveform data can't
|
||||
// be loaded. So if the function returns false, we can just exit.
|
||||
if (!clip->GetWaveDisplay(min, max, rms, bl, where,
|
||||
mid.width, t0, pps, isLoadingOD)) {
|
||||
delete[] min;
|
||||
delete[] max;
|
||||
delete[] rms;
|
||||
delete[] where;
|
||||
delete[] bl;
|
||||
display.Allocate(mid.width);
|
||||
if (!clip->GetWaveDisplay(display,
|
||||
t0, pps, isLoadingOD)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1690,7 +1683,7 @@ void TrackArtist::DrawClipWaveform(WaveTrack *track,
|
||||
// the envelope and using a colored pen for the selected
|
||||
// part of the waveform
|
||||
DrawWaveformBackground(dc, mid, envValues, zoomMin, zoomMax, dB,
|
||||
where, ssel0, ssel1, drawEnvelope,
|
||||
display.where, ssel0, ssel1, drawEnvelope,
|
||||
!track->GetSelected());
|
||||
|
||||
if (!showIndividualSamples) {
|
||||
@ -1699,7 +1692,7 @@ void TrackArtist::DrawClipWaveform(WaveTrack *track,
|
||||
min, max, rms, bl, isLoadingOD, muted, track->GetChannelGain(track->GetChannel()));
|
||||
#else
|
||||
DrawMinMaxRMS(dc, mid, envValues, zoomMin, zoomMax, dB,
|
||||
min, max, rms, bl, isLoadingOD, muted);
|
||||
display, isLoadingOD, muted);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
@ -1714,11 +1707,6 @@ void TrackArtist::DrawClipWaveform(WaveTrack *track,
|
||||
}
|
||||
|
||||
delete[] envValues;
|
||||
delete[] min;
|
||||
delete[] max;
|
||||
delete[] rms;
|
||||
delete[] where;
|
||||
delete[] bl;
|
||||
|
||||
// Draw arrows on the left side if the track extends to the left of the
|
||||
// beginning of time. :)
|
||||
|
@ -28,6 +28,7 @@ class wxRect;
|
||||
class wxHashTable;
|
||||
|
||||
class Track;
|
||||
class WaveDisplay;
|
||||
class WaveTrack;
|
||||
class WaveTrackCache;
|
||||
class WaveClip;
|
||||
@ -156,13 +157,11 @@ class AUDACITY_DLL_API TrackArtist {
|
||||
#ifdef EXPERIMENTAL_OUTPUT_DISPLAY
|
||||
void DrawMinMaxRMS(wxDC & dc, const wxRect & r, const double env[],
|
||||
float zoomMin, float zoomMax, bool dB,
|
||||
const float min[], const float max[], const float rms[],
|
||||
const int bl[], bool showProgress, bool muted, const float gain);
|
||||
const WaveDisplay &display, bool showProgress, bool muted, const float gain);
|
||||
#else
|
||||
void DrawMinMaxRMS(wxDC & dc, const wxRect & r, const double env[],
|
||||
float zoomMin, float zoomMax, bool dB,
|
||||
const float min[], const float max[], const float rms[],
|
||||
const int bl[], bool showProgress, bool muted);
|
||||
const WaveDisplay &display, bool showProgress, bool muted);
|
||||
#endif
|
||||
void DrawIndividualSamples(wxDC & dc, const wxRect & r,
|
||||
float zoomMin, float zoomMax, bool dB,
|
||||
|
@ -553,11 +553,16 @@ fillWhere(sampleCount where[], int len, double bias, double correction,
|
||||
// clipping calculations
|
||||
//
|
||||
|
||||
bool WaveClip::GetWaveDisplay(float *min, float *max, float *rms,int* bl,
|
||||
sampleCount *where,
|
||||
int numPixels, double t0,
|
||||
bool WaveClip::GetWaveDisplay(WaveDisplay &display, double t0,
|
||||
double pixelsPerSecond, bool &isLoadingOD)
|
||||
{
|
||||
int numPixels = display.width;
|
||||
float *const min = display.min;
|
||||
float *const max = display.max;
|
||||
float *const rms = display.rms;
|
||||
int *const bl = display.bl;
|
||||
sampleCount *const where = display.where;
|
||||
|
||||
ODLocker locker(mWaveCacheMutex);
|
||||
|
||||
|
||||
|
@ -58,6 +58,51 @@ class WaveClip;
|
||||
WX_DECLARE_USER_EXPORTED_LIST(WaveClip, WaveClipList, AUDACITY_DLL_API);
|
||||
WX_DEFINE_USER_EXPORTED_ARRAY_PTR(WaveClip*, WaveClipArray, class AUDACITY_DLL_API);
|
||||
|
||||
struct WaveDisplay
|
||||
{
|
||||
int width;
|
||||
sampleCount *where;
|
||||
float *min, *max, *rms;
|
||||
int* bl;
|
||||
|
||||
WaveDisplay()
|
||||
: width(0), where(0), min(0), max(0), rms(0), bl(0)
|
||||
{
|
||||
}
|
||||
|
||||
~WaveDisplay()
|
||||
{
|
||||
Deallocate();
|
||||
}
|
||||
|
||||
void WaveDisplay::Allocate(int w)
|
||||
{
|
||||
width = w;
|
||||
|
||||
// One more to hold the past-the-end sample count:
|
||||
where = new sampleCount[1 + width];
|
||||
|
||||
min = new float[width];
|
||||
max = new float[width];
|
||||
rms = new float[width];
|
||||
bl = new int[width];
|
||||
}
|
||||
|
||||
void WaveDisplay::Deallocate()
|
||||
{
|
||||
delete[] where;
|
||||
where = 0;
|
||||
delete[] min;
|
||||
min = 0;
|
||||
delete[] max;
|
||||
max = 0;
|
||||
delete[] rms;
|
||||
rms = 0;
|
||||
delete[] bl;
|
||||
bl = 0;
|
||||
}
|
||||
};
|
||||
|
||||
class AUDACITY_DLL_API WaveClip : public XMLTagHandler
|
||||
{
|
||||
private:
|
||||
@ -139,8 +184,8 @@ public:
|
||||
|
||||
/** Getting high-level data from the for screen display and clipping
|
||||
* calculations and Contrast */
|
||||
bool GetWaveDisplay(float *min, float *max, float *rms,int* bl, sampleCount *where,
|
||||
int numPixels, double t0, double pixelsPerSecond, bool &isLoadingOD);
|
||||
bool GetWaveDisplay(WaveDisplay &display,
|
||||
double t0, double pixelsPerSecond, bool &isLoadingOD);
|
||||
bool GetSpectrogram(WaveTrackCache &cache,
|
||||
float *buffer, sampleCount *where,
|
||||
int numPixels,
|
||||
|
Loading…
x
Reference in New Issue
Block a user