From b759cc5483b3aa720879fac9a6a8fe612337f621 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Tue, 9 Jun 2015 15:37:28 -0400 Subject: [PATCH 1/5] collapse some repeated code into a loop --- src/widgets/Ruler.cpp | 71 +++++++++++++++---------------------------- 1 file changed, 25 insertions(+), 46 deletions(-) diff --git a/src/widgets/Ruler.cpp b/src/widgets/Ruler.cpp index 81f0308c6..0c4455f0e 100644 --- a/src/widgets/Ruler.cpp +++ b/src/widgets/Ruler.cpp @@ -79,7 +79,7 @@ array of Ruler::Label. #include "../Prefs.h" #include "../Snap.h" -#define max(a,b) ( (a 0.0? 1.0: -1.0; - // Major ticks - double d, warpedD; - d = mMin - UPP/2; - if(timetrack) - warpedD = timetrack->ComputeWarpedLength(0.0, d); - else - warpedD = d; - // using ints for majorint doesn't work, as - // majorint will overflow and be negative at high zoom. - double majorInt = floor(sg * warpedD / mMajor); - i = -1; - while(i <= mLength) { - i++; - if(timetrack) - warpedD += timetrack->ComputeWarpedLength(d, d + UPP); + // Major and minor ticks + for (int jj = 0; jj < 2; ++jj) { + const double denom = jj == 0 ? mMajor : mMinor; + double d, warpedD; + d = mMin - UPP / 2; + if (timetrack) + warpedD = timetrack->ComputeWarpedLength(0.0, d); else - warpedD += UPP; - d += UPP; + warpedD = d; + // using ints doesn't work, as + // this will overflow and be negative at high zoom. + double step = floor(sg * warpedD / denom); + i = -1; + while (i <= mLength) { + i++; + if (timetrack) + warpedD += timetrack->ComputeWarpedLength(d, d + UPP); + else + warpedD += UPP; + d += UPP; - if (floor(sg * warpedD / mMajor) > majorInt) { - majorInt = floor(sg * warpedD / mMajor); - Tick(i, sg * majorInt * mMajor, true, false); - } - } - - // Minor ticks - d = mMin - UPP/2; - if(timetrack) - warpedD = timetrack->ComputeWarpedLength(0.0, d); - else - warpedD = d; - // using ints for majorint doesn't work, as - // majorint will overflow and be negative at high zoom. - // MB: I assume the same applies to minorInt - double minorInt = floor(sg * warpedD / mMinor); - i = -1; - while(i <= mLength) { - i++; - if(timetrack) - warpedD += timetrack->ComputeWarpedLength(d, d + UPP); - else - warpedD += UPP; - d += UPP; - - if (floor(sg * warpedD / mMinor) > minorInt) { - minorInt = floor(sg * warpedD / mMinor); - Tick(i, sg * minorInt * mMinor, false, true); + if (floor(sg * warpedD / denom) > step) { + step = floor(sg * warpedD / denom); + bool major = jj == 0; + Tick(i, sg * step * denom, major, !major); + } } } From 68174ad657be9cd3ff83c68645e7a13db1646378 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Tue, 9 Jun 2015 10:58:09 -0400 Subject: [PATCH 2/5] Envelope::GetValue works faster when called in a loop with increasing arugments --- src/Envelope.cpp | 36 +++++++++++++++++++++++++++++++++--- src/Envelope.h | 2 ++ 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/Envelope.cpp b/src/Envelope.cpp index 61b719e47..91f6edda5 100644 --- a/src/Envelope.cpp +++ b/src/Envelope.cpp @@ -65,6 +65,8 @@ Envelope::Envelope() mMaxValue = 2.0; mButton = wxMOUSE_BTN_NONE; + + mSearchGuess = -1; } Envelope::~Envelope() @@ -1023,6 +1025,7 @@ void Envelope::SetTrackLen(double trackLen) // Accessors double Envelope::GetValue(double t) const { + // t is absolute time double temp; GetValues(&temp, 1, t, 1.0); @@ -1037,14 +1040,38 @@ double Envelope::GetValueAtX(int x, const wxRect & r, double h, double pps) return GetValue(t); } -/// @param Lo returns index before this time. -/// @param Hi returns index after this time. +/// @param Lo returns last index at or before this time. +/// @param Hi returns first index after this time. void Envelope::BinarySearchForTime( int &Lo, int &Hi, double t ) const { Lo = 0; Hi = mEnv.Count() - 1; // JC: Do we have a problem if the envelope only has one point?? - wxASSERT( Hi > Lo ); + wxASSERT(Hi > Lo); + + // Optimizations for the usual pattern of repeated calls with + // small increases of t. + { + if (mSearchGuess >= 0 && mSearchGuess < int(mEnv.Count()) - 1) { + if (t >= mEnv[mSearchGuess]->GetT() && + t < mEnv[1 + mSearchGuess]->GetT()) { + Lo = mSearchGuess; + Hi = 1 + mSearchGuess; + return; + } + } + + ++mSearchGuess; + if (mSearchGuess >= 0 && mSearchGuess < int(mEnv.Count()) - 1) { + if (t >= mEnv[mSearchGuess]->GetT() && + t < mEnv[1 + mSearchGuess]->GetT()) { + Lo = mSearchGuess; + Hi = 1 + mSearchGuess; + return; + } + } + } + while (Hi > (Lo + 1)) { int mid = (Lo + Hi) / 2; if (t < mEnv[mid]->GetT()) @@ -1053,6 +1080,8 @@ void Envelope::BinarySearchForTime( int &Lo, int &Hi, double t ) const Lo = mid; } wxASSERT( Hi == ( Lo+1 )); + + mSearchGuess = Lo; } /// GetInterpolationStartValueAtPoint() is used to select either the @@ -1072,6 +1101,7 @@ double Envelope::GetInterpolationStartValueAtPoint( int iPoint ) const void Envelope::GetValues(double *buffer, int bufferLen, double t0, double tstep) const { + // Convert t0 from absolute to clip-relative time t0 -= mOffset; // JC: If bufferLen ==0 we have probably just allocated a zero sized buffer. diff --git a/src/Envelope.h b/src/Envelope.h index c1e25bc59..6d33ec9cf 100644 --- a/src/Envelope.h +++ b/src/Envelope.h @@ -248,6 +248,8 @@ private: double lastIntegral_t1; double lastIntegral_result; + mutable int mSearchGuess; + }; inline double EnvPoint::ClampValue(double val) From 9a22b94d99f8a3c88839ab231445f5681b996987 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Mon, 8 Jun 2015 21:19:41 -0400 Subject: [PATCH 3/5] Change some argument names. I don't like one-letter variable names. --- src/TrackArtist.cpp | 484 ++++++++++++++++++++++---------------------- src/TrackArtist.h | 54 ++--- 2 files changed, 269 insertions(+), 269 deletions(-) diff --git a/src/TrackArtist.cpp b/src/TrackArtist.cpp index 2f832ac3f..b7502b68f 100644 --- a/src/TrackArtist.cpp +++ b/src/TrackArtist.cpp @@ -247,10 +247,10 @@ const int notePos[12] = { 1, 6, 11, 16, 21, 27, // IPITCH_TO_Y above, which computes coordinates relative to GetBottom() // Note the -NOTE_MARGIN, which leaves a little margin to draw notes that // are out of bounds. I'm not sure why the -2 is necessary. -int TrackArtist::GetBottom(NoteTrack *t, const wxRect &r) +int TrackArtist::GetBottom(NoteTrack *t, const wxRect &rect) { int bottomNote = t->GetBottomNote(); - int bottom = r.y + r.height - 2 - t->GetNoteMargin() + + int bottom = rect.y + rect.height - 2 - t->GetNoteMargin() + ((bottomNote / 12) * octaveHeight + notePos[bottomNote % 12]); return bottom; @@ -316,14 +316,14 @@ void TrackArtist::DrawTracks(TrackList * tracks, Track * start, wxDC & dc, wxRegion & reg, - wxRect & r, + wxRect & rect, wxRect & clip, ViewInfo * viewInfo, bool drawEnvelope, - bool drawSamples, + bool bigPoints, bool drawSliders) { - wxRect trackRect = r; + wxRect trackRect = rect; wxRect stereoTrackRect; TrackListIterator iter(tracks); @@ -344,7 +344,7 @@ void TrackArtist::DrawTracks(TrackList * tracks, // This just show what the passed in rectanges enclose dc.SetPen(wxColour(*wxGREEN)); dc.SetBrush(*wxTRANSPARENT_BRUSH); - dc.DrawRectangle(r); + dc.DrawRectangle(rect); dc.SetPen(wxColour(*wxBLUE)); dc.SetBrush(*wxTRANSPARENT_BRUSH); dc.DrawRectangle(clip); @@ -406,7 +406,7 @@ void TrackArtist::DrawTracks(TrackList * tracks, rr.width -= (mInsetLeft + mInsetRight); rr.height -= (mInsetTop + mInsetBottom); DrawTrack(t, dc, rr, viewInfo, - drawEnvelope, drawSamples, drawSliders, hasSolo); + drawEnvelope, bigPoints, drawSliders, hasSolo); } #ifdef EXPERIMENTAL_OUTPUT_DISPLAY @@ -424,7 +424,7 @@ void TrackArtist::DrawTracks(TrackList * tracks, rr.width -= (mInsetLeft + mInsetRight); rr.height -= (mInsetTop + mInsetBottom); DrawTrack(t, dc, rr, viewInfo, - drawEnvelope, drawSamples, drawSliders, hasSolo); + drawEnvelope, bigPoints, drawSliders, hasSolo); } } #endif @@ -435,10 +435,10 @@ void TrackArtist::DrawTracks(TrackList * tracks, void TrackArtist::DrawTrack(const Track * t, wxDC & dc, - const wxRect & r, + const wxRect & rect, const ViewInfo * viewInfo, bool drawEnvelope, - bool drawSamples, + bool bigPoints, bool drawSliders, bool hasSolo) { @@ -454,19 +454,19 @@ void TrackArtist::DrawTrack(const Track * t, switch (wt->GetDisplay()) { case WaveTrack::WaveformDisplay: - DrawWaveform(wt, dc, r, viewInfo, - drawEnvelope, drawSamples, drawSliders, false, muted); + DrawWaveform(wt, dc, rect, viewInfo, + drawEnvelope, bigPoints, drawSliders, false, muted); break; case WaveTrack::WaveformDBDisplay: - DrawWaveform(wt, dc, r, viewInfo, - drawEnvelope, drawSamples, drawSliders, true, muted); + DrawWaveform(wt, dc, rect, viewInfo, + drawEnvelope, bigPoints, drawSliders, true, muted); break; case WaveTrack::SpectrumDisplay: case WaveTrack::SpectrumLogDisplay: case WaveTrack::SpectralSelectionDisplay: case WaveTrack::SpectralSelectionLogDisplay: case WaveTrack::PitchDisplay: - DrawSpectrum(wt, dc, r, viewInfo); + DrawSpectrum(wt, dc, rect, viewInfo); break; } if (mbShowTrackNameInWaveform && @@ -475,7 +475,7 @@ void TrackArtist::DrawTrack(const Track * t, wxFont labelFont(12, wxSWISS, wxNORMAL, wxNORMAL); dc.SetFont(labelFont); dc.SetTextForeground(wxColour(255, 255, 0)); - dc.DrawText (wt->GetName(), r.x+10, r.y); // move right 10 pixels to avoid overwriting <- symbol + dc.DrawText (wt->GetName(), rect.x+10, rect.y); // move right 10 pixels to avoid overwriting <- symbol } break; // case Wave } @@ -483,27 +483,27 @@ void TrackArtist::DrawTrack(const Track * t, case Track::Note: { bool muted = (hasSolo || t->GetMute()) && !t->GetSolo(); - DrawNoteTrack((NoteTrack *)t, dc, r, viewInfo, muted); + DrawNoteTrack((NoteTrack *)t, dc, rect, viewInfo, muted); break; } #endif // USE_MIDI case Track::Label: - DrawLabelTrack((LabelTrack *)t, dc, r, viewInfo); + DrawLabelTrack((LabelTrack *)t, dc, rect, viewInfo); break; case Track::Time: - DrawTimeTrack((TimeTrack *)t, dc, r, viewInfo); + DrawTimeTrack((TimeTrack *)t, dc, rect, viewInfo); break; } } -void TrackArtist::DrawVRuler(Track *t, wxDC * dc, wxRect & r) +void TrackArtist::DrawVRuler(Track *t, wxDC * dc, wxRect & rect) { int kind = t->GetKind(); // Label and Time tracks do not have a vruler // But give it a beveled area if (kind == Track::Label) { - wxRect bev = r; + wxRect bev = rect; bev.Inflate(-1, -1); bev.width += 1; AColor::BevelTrackInfo(*dc, true, bev); @@ -513,15 +513,15 @@ void TrackArtist::DrawVRuler(Track *t, wxDC * dc, wxRect & r) // Time tracks if (kind == Track::Time) { - wxRect bev = r; + wxRect bev = rect; bev.Inflate(-1, -1); bev.width += 1; AColor::BevelTrackInfo(*dc, true, bev); // Right align the ruler - wxRect rr = r; + wxRect rr = rect; rr.width--; - if (t->vrulerSize.GetWidth() < r.GetWidth()) { + if (t->vrulerSize.GetWidth() < rect.GetWidth()) { int adj = rr.GetWidth() - t->vrulerSize.GetWidth(); rr.x += adj; rr.width -= adj; @@ -537,7 +537,7 @@ void TrackArtist::DrawVRuler(Track *t, wxDC * dc, wxRect & r) // All waves have a ruler in the info panel // The ruler needs a bevelled surround. if (kind == Track::Wave) { - wxRect bev = r; + wxRect bev = rect; bev.Inflate(-1, -1); bev.width += 1; AColor::BevelTrackInfo(*dc, true, bev); @@ -548,9 +548,9 @@ void TrackArtist::DrawVRuler(Track *t, wxDC * dc, wxRect & r) } // Right align the ruler - wxRect rr = r; + wxRect rr = rect; rr.width--; - if (t->vrulerSize.GetWidth() < r.GetWidth()) { + if (t->vrulerSize.GetWidth() < rect.GetWidth()) { int adj = rr.GetWidth() - t->vrulerSize.GetWidth(); rr.x += adj; rr.width -= adj; @@ -566,23 +566,23 @@ void TrackArtist::DrawVRuler(Track *t, wxDC * dc, wxRect & r) #ifdef USE_MIDI // The note track draws a vertical keyboard to label pitches if (kind == Track::Note) { - UpdateVRuler(t, r); + UpdateVRuler(t, rect); dc->SetPen(*wxTRANSPARENT_PEN); dc->SetBrush(*wxWHITE_BRUSH); - wxRect bev = r; + wxRect bev = rect; bev.x++; bev.y++; bev.width--; bev.height--; dc->DrawRectangle(bev); - r.y += 2; - r.height -= 2; + rect.y += 2; + rect.height -= 2; - //int bottom = GetBottom((NoteTrack *) t, r); + //int bottom = GetBottom((NoteTrack *) t, rect); NoteTrack *track = (NoteTrack *) t; - track->PrepareIPitchToY(r); + track->PrepareIPitchToY(rect); wxPen hilitePen; hilitePen.SetColour(120, 120, 120); @@ -603,23 +603,23 @@ void TrackArtist::DrawVRuler(Track *t, wxDC * dc, wxRect & r) int obottom = track->GetOctaveBottom(octave); int marg = track->GetNoteMargin(); //IPITCH_TO_Y(octave * 12) + PITCH_HEIGHT + 1; - while (obottom >= r.y) { + while (obottom >= rect.y) { dc->SetPen(*wxBLACK_PEN); for (int white = 0; white < 7; white++) { int pos = track->GetWhitePos(white); - if (obottom - pos > r.y + marg + 1 && + if (obottom - pos > rect.y + marg + 1 && // don't draw too close to margin line -- it's annoying - obottom - pos < r.y + r.height - marg - 3) - AColor::Line(*dc, r.x, obottom - pos, - r.x + r.width, obottom - pos); + obottom - pos < rect.y + rect.height - marg - 3) + AColor::Line(*dc, rect.x, obottom - pos, + rect.x + rect.width, obottom - pos); } - wxRect br = r; + wxRect br = rect; br.height = track->GetPitchHeight(); br.x++; br.width = 17; for (int black = 0; black < 5; black++) { br.y = obottom - track->GetBlackPos(black); - if (br.y > r.y + marg - 2 && br.y + br.height < r.y + r.height - marg) { + if (br.y > rect.y + marg - 2 && br.y + br.height < rect.y + rect.height - marg) { dc->SetPen(hilitePen); dc->DrawRectangle(br); dc->SetPen(*wxBLACK_PEN); @@ -639,10 +639,10 @@ void TrackArtist::DrawVRuler(Track *t, wxDC * dc, wxRect & r) s.Printf(wxT("C%d"), octave - 1); wxCoord width, height; dc->GetTextExtent(s, &width, &height); - if (obottom - height + 4 > r.y && - obottom + 4 < r.y + r.height) { + if (obottom - height + 4 > rect.y && + obottom + 4 < rect.y + rect.height) { dc->SetTextForeground(wxColour(60, 60, 255)); - dc->DrawText(s, r.x + r.width - width, + dc->DrawText(s, rect.x + rect.width - width, obottom - height + 2); } } @@ -651,19 +651,19 @@ void TrackArtist::DrawVRuler(Track *t, wxDC * dc, wxRect & r) // draw lines delineating the out-of-bounds margins dc->SetPen(*wxBLACK_PEN); // you would think the -1 offset here should be -2 to match the - // adjustment to r.y (see above), but -1 produces correct output - AColor::Line(*dc, r.x, r.y + marg - 1, r.x + r.width, r.y + marg - 1); + // adjustment to rect.y (see above), but -1 produces correct output + AColor::Line(*dc, rect.x, rect.y + marg - 1, rect.x + rect.width, rect.y + marg - 1); // since the margin gives us the bottom of the line, // the extra -1 gets us to the top - AColor::Line(*dc, r.x, r.y + r.height - marg - 1, - r.x + r.width, r.y + r.height - marg - 1); + AColor::Line(*dc, rect.x, rect.y + rect.height - marg - 1, + rect.x + rect.width, rect.y + rect.height - marg - 1); } #endif // USE_MIDI } -void TrackArtist::UpdateVRuler(Track *t, wxRect & r) +void TrackArtist::UpdateVRuler(Track *t, wxRect & rect) { // Label tracks do not have a vruler if (t->GetKind() == Track::Label) { @@ -677,7 +677,7 @@ void TrackArtist::UpdateVRuler(Track *t, wxRect & r) min = tt->GetRangeLower() * 100.0; max = tt->GetRangeUpper() * 100.0; - vruler->SetBounds(r.x, r.y+1, r.x + r.width, r.y + r.height-1); + vruler->SetBounds(rect.x, rect.y+1, rect.x + rect.width, rect.y + rect.height-1); vruler->SetOrientation(wxVERTICAL); vruler->SetRange(max, min); vruler->SetFormat((tt->GetDisplayLog()) ? Ruler::RealLogFormat : Ruler::RealFormat); @@ -719,7 +719,7 @@ void TrackArtist::UpdateVRuler(Track *t, wxRect & r) wt->SetDisplayBounds(min, max); } - vruler->SetBounds(r.x, r.y+1, r.x + r.width, r.y + r.height-1); + vruler->SetBounds(rect.x, rect.y+1, rect.x + rect.width, rect.y + rect.height-1); vruler->SetOrientation(wxVERTICAL); vruler->SetRange(max, min); vruler->SetFormat(Ruler::RealFormat); @@ -760,7 +760,7 @@ void TrackArtist::UpdateVRuler(Track *t, wxRect & r) if (max > 0) { int top = 0; float topval = 0; - int bot = r.height; + int bot = rect.height; float botval = -mdBrange; if (min < 0) { @@ -780,7 +780,7 @@ void TrackArtist::UpdateVRuler(Track *t, wxRect & r) botval = -((1-min)*mdBrange); } - vruler->SetBounds(r.x, r.y+top+1, r.x + r.width, r.y + bot-1); + vruler->SetBounds(rect.x, rect.y+top+1, rect.x + rect.width, rect.y + bot-1); vruler->SetOrientation(wxVERTICAL); vruler->SetRange(topval, botval); } @@ -796,7 +796,7 @@ void TrackArtist::UpdateVRuler(Track *t, wxRect & r) { // Spectrum - if (r.height < 60) + if (rect.height < 60) return; double rate = wt->GetRate(); @@ -815,7 +815,7 @@ void TrackArtist::UpdateVRuler(Track *t, wxRect & r) we will use Hz if maxFreq is < 2000, otherwise we represent kHz, and append to the numbers a "k" */ - vruler->SetBounds(r.x, r.y+1, r.x + r.width, r.y + r.height-1); + vruler->SetBounds(rect.x, rect.y+1, rect.x + rect.width, rect.y + rect.height-1); vruler->SetOrientation(wxVERTICAL); vruler->SetFormat(Ruler::RealFormat); vruler->SetLabelEdges(true); @@ -836,7 +836,7 @@ void TrackArtist::UpdateVRuler(Track *t, wxRect & r) { // SpectrumLog - if (r.height < 10) + if (rect.height < 10) return; double rate = wt->GetRate(); @@ -855,7 +855,7 @@ void TrackArtist::UpdateVRuler(Track *t, wxRect & r) we will use Hz if maxFreq is < 2000, otherwise we represent kHz, and append to the numbers a "k" */ - vruler->SetBounds(r.x, r.y+1, r.x + r.width, r.y + r.height-1); + vruler->SetBounds(rect.x, rect.y+1, rect.x + rect.width, rect.y + rect.height-1); vruler->SetOrientation(wxVERTICAL); vruler->SetFormat(Ruler::IntFormat); vruler->SetLabelEdges(true); @@ -872,7 +872,7 @@ void TrackArtist::UpdateVRuler(Track *t, wxRect & r) // The note track isn't drawing a ruler at all! // But it needs to! else if (t->GetKind() == Track::Note) { - vruler->SetBounds(r.x, r.y+1, r.x + 1, r.y + r.height-1); + vruler->SetBounds(rect.x, rect.y+1, rect.x + 1, rect.y + rect.height-1); vruler->SetOrientation(wxVERTICAL); } #endif // USE_MIDI @@ -959,7 +959,7 @@ float ValueOfPixel(int y, int height, bool offset, return v; } -void TrackArtist::DrawNegativeOffsetTrackArrows(wxDC &dc, const wxRect &r) +void TrackArtist::DrawNegativeOffsetTrackArrows(wxDC &dc, const wxRect &rect) { // Draws two black arrows on the left side of the track to // indicate the user that the track has been time-shifted @@ -967,26 +967,26 @@ void TrackArtist::DrawNegativeOffsetTrackArrows(wxDC &dc, const wxRect &r) dc.SetPen(*wxBLACK_PEN); AColor::Line(dc, - r.x + 2, r.y + 6, - r.x + 8, r.y + 6); + rect.x + 2, rect.y + 6, + rect.x + 8, rect.y + 6); AColor::Line(dc, - r.x + 2, r.y + 6, - r.x + 6, r.y + 2); + rect.x + 2, rect.y + 6, + rect.x + 6, rect.y + 2); AColor::Line(dc, - r.x + 2, r.y + 6, - r.x + 6, r.y + 10); + rect.x + 2, rect.y + 6, + rect.x + 6, rect.y + 10); AColor::Line(dc, - r.x + 2, r.y + r.height - 8, - r.x + 8, r.y + r.height - 8); + rect.x + 2, rect.y + rect.height - 8, + rect.x + 8, rect.y + rect.height - 8); AColor::Line(dc, - r.x + 2, r.y + r.height - 8, - r.x + 6, r.y + r.height - 4); + rect.x + 2, rect.y + rect.height - 8, + rect.x + 6, rect.y + rect.height - 4); AColor::Line(dc, - r.x + 2, r.y + r.height - 8, - r.x + 6, r.y + r.height - 12); + rect.x + 2, rect.y + rect.height - 8, + rect.x + 6, rect.y + rect.height - 12); } -void TrackArtist::DrawWaveformBackground(wxDC &dc, const wxRect &r, const double env[], +void TrackArtist::DrawWaveformBackground(wxDC &dc, const wxRect &rect, const double env[], float zoomMin, float zoomMax, bool dB, const sampleCount where[], sampleCount ssel0, sampleCount ssel1, @@ -1001,7 +1001,7 @@ void TrackArtist::DrawWaveformBackground(wxDC &dc, const wxRect &r, const double // | | | | // maxtop maxbot mintop minbot - int h = r.height; + int h = rect.height; int halfHeight = wxMax(h / 2, 1); int maxtop, lmaxtop = 0; int mintop, lmintop = 0; @@ -1013,9 +1013,9 @@ void TrackArtist::DrawWaveformBackground(wxDC &dc, const wxRect &r, const double dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(blankBrush); - dc.DrawRectangle(r); + dc.DrawRectangle(rect); - for (x = 0; x < r.width; x++) { + for (x = 0; x < rect.width; x++) { // First we compute the truncated shape of the waveform background. // If drawEnvelope is true, then we compute the lower border of the // envelope. @@ -1052,14 +1052,14 @@ void TrackArtist::DrawWaveformBackground(wxDC &dc, const wxRect &r, const double dc.SetBrush(lsel ? selectedBrush : unselectedBrush); - l = r.x + lx; + l = rect.x + lx; w = x - lx; if (lmaxbot < lmintop - 1) { - dc.DrawRectangle(l, r.y + lmaxtop, w, lmaxbot - lmaxtop); - dc.DrawRectangle(l, r.y + lmintop, w, lminbot - lmintop); + dc.DrawRectangle(l, rect.y + lmaxtop, w, lmaxbot - lmaxtop); + dc.DrawRectangle(l, rect.y + lmintop, w, lminbot - lmintop); } else { - dc.DrawRectangle(l, r.y + lmaxtop, w, lminbot - lmaxtop); + dc.DrawRectangle(l, rect.y + lmaxtop, w, lminbot - lmaxtop); } lmaxtop = maxtop; @@ -1071,39 +1071,39 @@ void TrackArtist::DrawWaveformBackground(wxDC &dc, const wxRect &r, const double } dc.SetBrush(lsel ? selectedBrush : unselectedBrush); - l = r.x + lx; + l = rect.x + lx; w = x - lx; if (lmaxbot < lmintop - 1) { - dc.DrawRectangle(l, r.y + lmaxtop, w, lmaxbot - lmaxtop); - dc.DrawRectangle(l, r.y + lmintop, w, lminbot - lmintop); + dc.DrawRectangle(l, rect.y + lmaxtop, w, lmaxbot - lmaxtop); + dc.DrawRectangle(l, rect.y + lmintop, w, lminbot - lmintop); } else { - dc.DrawRectangle(l, r.y + lmaxtop, w, lminbot - lmaxtop); + dc.DrawRectangle(l, rect.y + lmaxtop, w, lminbot - lmaxtop); } // If sync-lock selected, draw in linked graphics. if (bIsSyncLockSelected && ssel0 < ssel1) { // Find the beginning/end of the selection int begin, end; - for (x = 0; x < r.width && where[x] < ssel0; ++x); + for (x = 0; x < rect.width && where[x] < ssel0; ++x); begin = x; - for (; x < r.width && where[x] < ssel1; ++x); + for (; x < rect.width && where[x] < ssel1; ++x); end = x; - DrawSyncLockTiles(&dc, wxRect(r.x + begin, r.y, end - 1 - begin, r.height)); + DrawSyncLockTiles(&dc, wxRect(rect.x + begin, rect.y, end - 1 - begin, rect.height)); } //OK, the display bounds are between min and max, which - //is spread across r.height. Draw the line at the proper place. + //is spread across rect.height. Draw the line at the proper place. if (zoomMin < 0 && zoomMax > 0) { int half = (int)((zoomMax / (zoomMax - zoomMin)) * h); dc.SetPen(*wxBLACK_PEN); - AColor::Line(dc, r.x, r.y + half, r.x + r.width, r.y + half); + AColor::Line(dc, rect.x, rect.y + half, rect.x + rect.width, rect.y + half); } } -void TrackArtist::DrawMinMaxRMS(wxDC &dc, const wxRect &r, const double env[], +void TrackArtist::DrawMinMaxRMS(wxDC &dc, const wxRect &rect, const double env[], float zoomMin, float zoomMax, bool dB, const WaveDisplay &display, bool /* showProgress */, bool muted #ifdef EXPERIMENTAL_OUTPUT_DISPLAY @@ -1122,14 +1122,14 @@ void TrackArtist::DrawMinMaxRMS(wxDC &dc, const wxRect &r, const double env[], int lasth2 = std::numeric_limits::min(); int h1; int h2; - int *r1 = new int[r.width]; - int *r2 = new int[r.width]; + int *r1 = new int[rect.width]; + int *r2 = new int[rect.width]; int *clipped = NULL; int clipcnt = 0; int x; if (mShowClipping) { - clipped = new int[r.width]; + clipped = new int[rect.width]; } long pixAnimOffset = (long)fabs((double)(wxDateTime::Now().GetTicks() * -10)) + @@ -1139,8 +1139,8 @@ void TrackArtist::DrawMinMaxRMS(wxDC &dc, const wxRect &r, const double env[], bool drawWaveform = true; dc.SetPen(muted ? muteSamplePen : samplePen); - for (x = 0; x < r.width; x++) { - int xx = r.x + x; + for (x = 0; x < rect.width; x++) { + int xx = rect.x + x; double v; #ifdef EXPERIMENTAL_OUTPUT_DISPLAY //JWA: "gain" variable passed to function includes the pan value and is used below 4/14/13 @@ -1155,7 +1155,7 @@ void TrackArtist::DrawMinMaxRMS(wxDC &dc, const wxRect &r, const double env[], } } h1 = GetWaveYPos(v, zoomMin, zoomMax, - r.height, dB, true, mdBrange, true); + rect.height, dB, true, mdBrange, true); #ifdef EXPERIMENTAL_OUTPUT_DISPLAY v = max[x] * env[x] * gain; @@ -1169,7 +1169,7 @@ void TrackArtist::DrawMinMaxRMS(wxDC &dc, const wxRect &r, const double env[], } } h2 = GetWaveYPos(v, zoomMin, zoomMax, - r.height, dB, true, mdBrange, true); + rect.height, dB, true, mdBrange, true); // JKC: This adjustment to h1 and h2 ensures that the drawn // waveform is continuous. @@ -1186,14 +1186,14 @@ void TrackArtist::DrawMinMaxRMS(wxDC &dc, const wxRect &r, const double env[], #ifdef EXPERIMENTAL_OUTPUT_DISPLAY r1[x] = GetWaveYPos(-rms[x] * env[x]*gain, zoomMin, zoomMax, - r.height, dB, true, mdBrange, true); + rect.height, dB, true, mdBrange, true); r2[x] = GetWaveYPos(rms[x] * env[x]*gain, zoomMin, zoomMax, - r.height, dB, true, mdBrange, true); + rect.height, dB, true, mdBrange, true); #else r1[x] = GetWaveYPos(-rms[x] * env[x], zoomMin, zoomMax, - r.height, dB, true, mdBrange, true); + rect.height, dB, true, mdBrange, true); r2[x] = GetWaveYPos(rms[x] * env[x], zoomMin, zoomMax, - r.height, dB, true, mdBrange, true); + rect.height, dB, true, mdBrange, true); #endif // Make sure the rms isn't larger than the waveform min/max if (r1[x] > h1 - 1) { @@ -1210,13 +1210,13 @@ void TrackArtist::DrawMinMaxRMS(wxDC &dc, const wxRect &r, const double env[], if (drawStripes) { // TODO:unify with buffer drawing. dc.SetPen((bl[x] % 2) ? muteSamplePen : samplePen); - for (int y = 0; y < r.height / 25 + 1; y++) { + for (int y = 0; y < rect.height / 25 + 1; y++) { // we are drawing over the buffer, but I think DrawLine takes care of this. AColor::Line(dc, xx, - r.y + 25 * y + (x /*+pixAnimOffset*/) % 25, + rect.y + 25 * y + (x /*+pixAnimOffset*/) % 25, xx, - r.y + 25 * y + (x /*+pixAnimOffset*/) % 25 + 6); //take the min so we don't draw past the edge + rect.y + 25 * y + (x /*+pixAnimOffset*/) % 25 + 6); //take the min so we don't draw past the edge } } @@ -1225,10 +1225,10 @@ void TrackArtist::DrawMinMaxRMS(wxDC &dc, const wxRect &r, const double env[], if (drawWaveform) { int triX; dc.SetPen(samplePen); - triX = fabs((double)((x + pixAnimOffset) % (2 * r.height)) - r.height) + r.height; - for (int y = 0; y < r.height; y++) { - if ((y + triX) % r.height == 0) { - dc.DrawPoint(xx, r.y + y); + triX = fabs((double)((x + pixAnimOffset) % (2 * rect.height)) - rect.height) + rect.height; + for (int y = 0; y < rect.height; y++) { + if ((y + triX) % rect.height == 0) { + dc.DrawPoint(xx, rect.y + y); } } } @@ -1237,18 +1237,18 @@ void TrackArtist::DrawMinMaxRMS(wxDC &dc, const wxRect &r, const double env[], dc.SetPen(muted ? muteSamplePen : samplePen); } else { - AColor::Line(dc, xx, r.y + h2, xx, r.y + h1); + AColor::Line(dc, xx, rect.y + h2, xx, rect.y + h1); } } // Stroke rms over the min-max dc.SetPen(muted ? muteRmsPen : rmsPen); - for (int x = 0; x < r.width; x++) { - int xx = r.x + x; + for (int x = 0; x < rect.width; x++) { + int xx = rect.x + x; if (bl[x] <= -1) { } else if (r1[x] != r2[x]) { - AColor::Line(dc, xx, r.y + r2[x], xx, r.y + r1[x]); + AColor::Line(dc, xx, rect.y + r2[x], xx, rect.y + r1[x]); } } @@ -1257,7 +1257,7 @@ void TrackArtist::DrawMinMaxRMS(wxDC &dc, const wxRect &r, const double env[], dc.SetPen(muted ? muteClippedPen : clippedPen); while (--clipcnt >= 0) { int xx = clipped[clipcnt]; - AColor::Line(dc, xx, r.y, xx, r.y + r.height); + AColor::Line(dc, xx, rect.y, xx, rect.y + rect.height); } } @@ -1269,15 +1269,15 @@ void TrackArtist::DrawMinMaxRMS(wxDC &dc, const wxRect &r, const double env[], delete [] r2; } -void TrackArtist::DrawIndividualSamples(wxDC &dc, const wxRect &r, +void TrackArtist::DrawIndividualSamples(wxDC &dc, const wxRect &rect, float zoomMin, float zoomMax, bool dB, WaveClip *clip, double t0, double pps, double WXUNUSED(h), - bool drawSamples, bool showPoints, bool muted) + bool bigPoints, bool showPoints, bool muted) { double rate = clip->GetRate(); sampleCount s0 = (sampleCount) (t0 * rate + 0.5); - sampleCount slen = (sampleCount) (r.width * rate / pps + 0.5); + sampleCount slen = (sampleCount) (rect.width * rate / pps + 0.5); sampleCount snSamples = clip->GetNumSamples(); slen += 4; @@ -1321,39 +1321,39 @@ void TrackArtist::DrawIndividualSamples(wxDC &dc, const wxRect &r, xpos[s] = xx; - // t0 + clip->GetOffset() is 'h' (the absolute time of the left edge) for 'r'. - tt = buffer[s] * clip->GetEnvelope()->GetValueAtX(xx + r.x, r, t0 + clip->GetOffset(), pps); + // t0 + clip->GetOffset() is 'h' (the absolute time of the left edge) for 'rect'. + tt = buffer[s] * clip->GetEnvelope()->GetValueAtX(xx + rect.x, rect, t0 + clip->GetOffset(), pps); if (clipped && mShowClipping && ((tt <= -MAX_AUDIO) || (tt >= MAX_AUDIO))) clipped[clipcnt++] = xx; ypos[s] = GetWaveYPos(tt, zoomMin, zoomMax, - r.height, dB, true, mdBrange, false); + rect.height, dB, true, mdBrange, false); if (ypos[s] < -1) { ypos[s] = -1; } - if (ypos[s] > r.height) { - ypos[s] = r.height; + if (ypos[s] > rect.height) { + ypos[s] = rect.height; } } // Draw lines for (s = 0; s < slen - 1; s++) { AColor::Line(dc, - r.x + xpos[s], r.y + ypos[s], - r.x + xpos[s + 1], r.y + ypos[s + 1]); + rect.x + xpos[s], rect.y + ypos[s], + rect.x + xpos[s + 1], rect.y + ypos[s + 1]); } if (showPoints) { // Draw points - int tickSize= drawSamples ? 4 : 3;// Bigger ellipses when draggable. + int tickSize= bigPoints ? 4 : 3;// Bigger ellipses when draggable. wxRect pr; pr.width = tickSize; pr.height = tickSize; //different colour when draggable. - dc.SetBrush( drawSamples ? dragsampleBrush : sampleBrush); + dc.SetBrush( bigPoints ? dragsampleBrush : sampleBrush); for (s = 0; s < slen; s++) { - if (ypos[s] >= 0 && ypos[s] < r.height) { - pr.x = r.x + xpos[s] - tickSize/2; - pr.y = r.y + ypos[s] - tickSize/2; + if (ypos[s] >= 0 && ypos[s] < rect.height) { + pr.x = rect.x + xpos[s] - tickSize/2; + pr.y = rect.y + ypos[s] - tickSize/2; dc.DrawEllipse(pr); } } @@ -1364,7 +1364,7 @@ void TrackArtist::DrawIndividualSamples(wxDC &dc, const wxRect &r, dc.SetPen(muted ? muteClippedPen : clippedPen); while (--clipcnt >= 0) { s = clipped[clipcnt]; - AColor::Line(dc, r.x + s, r.y, r.x + s, r.y + r.height); + AColor::Line(dc, rect.x + s, rect.y, rect.x + s, rect.y + rect.height); } } @@ -1377,14 +1377,14 @@ void TrackArtist::DrawIndividualSamples(wxDC &dc, const wxRect &r, delete[]ypos; } -void TrackArtist::DrawEnvelope(wxDC &dc, const wxRect &r, const double env[], +void TrackArtist::DrawEnvelope(wxDC &dc, const wxRect &rect, const double env[], float zoomMin, float zoomMax, bool dB) { - int h = r.height; + int h = rect.height; dc.SetPen(AColor::envelopePen); - for (int x = 0; x < r.width; x++) { + for (int x = 0; x < rect.width; x++) { int cenvTop = GetWaveYPos(env[x], zoomMin, zoomMax, h, dB, true, mdBrange, true); @@ -1404,22 +1404,22 @@ void TrackArtist::DrawEnvelope(wxDC &dc, const wxRect &r, const double env[], cenvBot = value + 4; } - DrawEnvLine(dc, r, x, envTop, cenvTop, true); - DrawEnvLine(dc, r, x, envBot, cenvBot, false); + DrawEnvLine(dc, rect, x, envTop, cenvTop, true); + DrawEnvLine(dc, rect, x, envBot, cenvBot, false); } } -void TrackArtist::DrawEnvLine(wxDC &dc, const wxRect &r, int x, int y, int cy, bool top) +void TrackArtist::DrawEnvLine(wxDC &dc, const wxRect &rect, int x, int y, int cy, bool top) { - int xx = r.x + x; - int yy = r.y + cy; + int xx = rect.x + x; + int yy = rect.y + cy; if (y < 0) { if (x % 4 != 3) { AColor::Line(dc, xx, yy, xx, yy + 3); } } - else if (y > r.height) { + else if (y > rect.height) { if (x % 4 != 3) { AColor::Line(dc, xx, yy - 3, xx, yy); } @@ -1436,21 +1436,21 @@ void TrackArtist::DrawEnvLine(wxDC &dc, const wxRect &r, int x, int y, int cy, b void TrackArtist::DrawWaveform(WaveTrack *track, wxDC & dc, - const wxRect & r, + const wxRect & rect, const ViewInfo *viewInfo, bool drawEnvelope, - bool drawSamples, + bool bigPoints, bool drawSliders, bool dB, bool muted) { - DrawBackgroundWithSelection(&dc, r, track, blankSelectedBrush, blankBrush, + DrawBackgroundWithSelection(&dc, rect, track, blankSelectedBrush, blankBrush, viewInfo->selectedRegion.t0(), viewInfo->selectedRegion.t1(), viewInfo->h, viewInfo->zoom); for (WaveClipList::compatibility_iterator it = track->GetClipIterator(); it; it = it->GetNext()) - DrawClipWaveform(track, it->GetData(), dc, r, viewInfo, - drawEnvelope, drawSamples, + DrawClipWaveform(track, it->GetData(), dc, rect, viewInfo, + drawEnvelope, bigPoints, dB, muted); // Update cache for locations, e.g. cutlines and merge points @@ -1459,24 +1459,24 @@ void TrackArtist::DrawWaveform(WaveTrack *track, for (int i = 0; iGetNumCachedLocations(); i++) { WaveTrack::Location loc = track->GetCachedLocation(i); double x = (loc.pos - viewInfo->h) * viewInfo->zoom; - if (x >= 0 && x < r.width) { + if (x >= 0 && x < rect.width) { dc.SetPen(*wxGREY_PEN); - AColor::Line(dc, (int) (r.x + x - 1), r.y, (int) (r.x + x - 1), r.y + r.height); + AColor::Line(dc, (int) (rect.x + x - 1), rect.y, (int) (rect.x + x - 1), rect.y + rect.height); if (loc.typ == WaveTrack::locationCutLine) { dc.SetPen(*wxRED_PEN); } else { dc.SetPen(*wxBLACK_PEN); } - AColor::Line(dc, (int) (r.x + x), r.y, (int) (r.x + x), r.y + r.height); + AColor::Line(dc, (int) (rect.x + x), rect.y, (int) (rect.x + x), rect.y + rect.height); dc.SetPen(*wxGREY_PEN); - AColor::Line(dc, (int) (r.x + x + 1), r.y, (int) (r.x + x + 1), r.y + r.height); + AColor::Line(dc, (int) (rect.x + x + 1), rect.y, (int) (rect.x + x + 1), rect.y + rect.height); } } if (drawSliders) { - DrawTimeSlider(dc, r, true); // directed right - DrawTimeSlider(dc, r, false); // directed left + DrawTimeSlider(dc, rect, true); // directed right + DrawTimeSlider(dc, rect, false); // directed left } } @@ -1486,7 +1486,7 @@ struct ClipParameters { // Do a bunch of calculations common to waveform and spectrum drawing. ClipParameters - (bool spectrum, const WaveTrack *track, const WaveClip *clip, const wxRect &r, + (bool spectrum, const WaveTrack *track, const WaveClip *clip, const wxRect &rect, const SelectedRegion &selectedRegion, const ViewInfo &viewInfo) { selectedRegion; @@ -1511,7 +1511,7 @@ struct ClipParameters tstep = 1.0 / pps; // Seconds per point tpre = h - tOffset; // offset corrected time of // left edge of display - tpost = tpre + (r.width * tstep); // offset corrected time of + tpost = tpre + (rect.width * tstep); // offset corrected time of // right edge of display const double sps = 1. / rate; //seconds-per-sample @@ -1559,7 +1559,7 @@ struct ClipParameters // The variable "mid" will be the rectangle containing the // actual waveform, as opposed to any blank area before // or after the track. - mid = r; + mid = rect; // If the left edge of the track is to the right of the left // edge of the display, then there's some blank area to the @@ -1567,7 +1567,7 @@ struct ClipParameters // rect by size of the blank area. if (tpre < 0) { // Fill in the area to the left of the track - double delta = r.width; + double delta = rect.width; if (t0 < tpost) { delta = (int)((t0 - tpre) * pps); } @@ -1583,11 +1583,11 @@ struct ClipParameters // of the track. Reduce the "mid" rect by the // size of the blank area. if (tpost > t1) { - wxRect post = r; + wxRect post = rect; if (t1 > tpre) { post.x += (int)((t1 - tpre) * pps); } - post.width = r.width - (post.x - r.x); + post.width = rect.width - (post.x - rect.x); // Reduce the rectangle containing the waveform by the width // of the area we just erased. mid.width -= post.width; @@ -1620,10 +1620,10 @@ struct ClipParameters void TrackArtist::DrawClipWaveform(WaveTrack *track, WaveClip *clip, wxDC & dc, - const wxRect & r, + const wxRect & rect, const ViewInfo *viewInfo, bool drawEnvelope, - bool drawSamples, + bool bigPoints, bool dB, bool muted) { @@ -1631,7 +1631,7 @@ void TrackArtist::DrawClipWaveform(WaveTrack *track, Profiler profiler; #endif - const ClipParameters params(false, track, clip, r, viewInfo->selectedRegion, *viewInfo); + const ClipParameters params(false, track, clip, rect, viewInfo->selectedRegion, *viewInfo); const wxRect &mid = params.mid; // The "mid" rect contains the part of the display actually // containing the waveform. If it's empty, we're done. @@ -1703,12 +1703,12 @@ void TrackArtist::DrawClipWaveform(WaveTrack *track, else { DrawIndividualSamples(dc, mid, zoomMin, zoomMax, dB, clip, t0, pps, h, - drawSamples, showPoints, muted); + bigPoints, showPoints, muted); } if (drawEnvelope) { DrawEnvelope(dc, mid, envValues, zoomMin, zoomMax, dB); - clip->GetEnvelope()->DrawPoints(dc, r, h, pps, dB, zoomMin, zoomMax); + clip->GetEnvelope()->DrawPoints(dc, rect, h, pps, dB, zoomMin, zoomMax); } delete[] envValues; @@ -1716,7 +1716,7 @@ void TrackArtist::DrawClipWaveform(WaveTrack *track, // Draw arrows on the left side if the track extends to the left of the // beginning of time. :) if (h == 0.0 && tOffset < 0.0) { - DrawNegativeOffsetTrackArrows(dc, r); + DrawNegativeOffsetTrackArrows(dc, rect); } // Draw clip edges @@ -1724,18 +1724,18 @@ void TrackArtist::DrawClipWaveform(WaveTrack *track, if (tpre < 0) { AColor::Line(dc, mid.x - 1, mid.y, - mid.x - 1, mid.y + r.height); + mid.x - 1, mid.y + rect.height); } if (tpost > t1) { AColor::Line(dc, mid.x + mid.width, mid.y, - mid.x + mid.width, mid.y + r.height); + mid.x + mid.width, mid.y + rect.height); } } void TrackArtist::DrawTimeSlider(wxDC & dc, - const wxRect & r, + const wxRect & rect, bool rightwards) { const int border = 3; // 3 pixels all round. @@ -1746,10 +1746,10 @@ void TrackArtist::DrawTimeSlider(wxDC & dc, const int xFlat = 3; //Enough space to draw in? - if (r.height <= ((taper+border + barSpacing) * 2)) { + if (rect.height <= ((taper+border + barSpacing) * 2)) { return; } - if (r.width <= (width * 2 + border * 3)) { + if (rect.width <= (width * 2 + border * 3)) { return; } @@ -1757,10 +1757,10 @@ void TrackArtist::DrawTimeSlider(wxDC & dc, int leftTaper = rightwards ? 0 : 6; int rightTaper = rightwards ? 6 : 0; - int xLeft = rightwards ? (r.x + border - 2) - : (r.x + r.width + 1 - (border + width)); - int yTop = r.y + border; - int yBot = r.y + r.height - border - 1; + int xLeft = rightwards ? (rect.x + border - 2) + : (rect.x + rect.width + 1 - (border + width)); + int yTop = rect.y + border; + int yBot = rect.y + rect.height - border - 1; AColor::Light(&dc, false); AColor::Line(dc, xLeft, yBot - leftTaper, xLeft, yTop + leftTaper); @@ -1793,16 +1793,16 @@ void TrackArtist::DrawTimeSlider(wxDC & dc, void TrackArtist::DrawSpectrum(WaveTrack *track, wxDC & dc, - const wxRect & r, + const wxRect & rect, const ViewInfo *viewInfo) { - DrawBackgroundWithSelection(&dc, r, track, blankSelectedBrush, blankBrush, + DrawBackgroundWithSelection(&dc, rect, track, blankSelectedBrush, blankBrush, viewInfo->selectedRegion.t0(), viewInfo->selectedRegion.t1(), viewInfo->h, viewInfo->zoom); WaveTrackCache cache(track); for (WaveClipList::compatibility_iterator it = track->GetClipIterator(); it; it = it->GetNext()) { - DrawClipSpectrum(cache, it->GetData(), dc, r, viewInfo); + DrawClipSpectrum(cache, it->GetData(), dc, rect, viewInfo); } } @@ -1876,7 +1876,7 @@ AColor::ColorGradientChoice ChooseColorSet( float bin0, float bin1, float selBin void TrackArtist::DrawClipSpectrum(WaveTrackCache &cache, WaveClip *clip, wxDC & dc, - const wxRect & r, + const wxRect & rect, const ViewInfo *viewInfo) { #ifdef PROFILE_WAVEFORM @@ -1892,7 +1892,7 @@ void TrackArtist::DrawClipSpectrum(WaveTrackCache &cache, enum { MONOCHROME_LINE = 230, COLORED_LINE = 0 }; enum { DASH_LENGTH = 10 /* pixels */ }; - const ClipParameters params(true, track, clip, r, viewInfo->selectedRegion, *viewInfo); + const ClipParameters params(true, track, clip, rect, viewInfo->selectedRegion, *viewInfo); const wxRect &mid = params.mid; // The "mid" rect contains the part of the display actually // containing the waveform. If it's empty, we're done. @@ -2466,8 +2466,8 @@ const char *LookupAtomAttribute(Alg_note_ptr note, Alg_attribute attr, char *def return def; } -#define TIME_TO_X(t) (r.x + (int) (((t) - h) * pps)) -#define X_TO_TIME(xx) (((xx) - r.x) / pps + h) +#define TIME_TO_X(t) (rect.x + (int) (((t) - h) * pps)) +#define X_TO_TIME(xx) (((xx) - rect.x) / pps + h) // CLIP(x) changes x to lie between +/- CLIP_MAX due to graphics display problems // with very large coordinate values (this happens when you zoom in very far) @@ -2484,7 +2484,7 @@ const char *LookupAtomAttribute(Alg_note_ptr note, Alg_attribute attr, char *def #define GREEN(i) ( unsigned char )( (((i) >> 8) & 0xff) ) #define BLUE(i) ( unsigned char )( ((i) & 0xff) ) -//#define PITCH_TO_Y(p) (r.y + r.height - int(pitchht * ((p) + 0.5 - pitch0) + 0.5)) +//#define PITCH_TO_Y(p) (rect.y + rect.height - int(pitchht * ((p) + 0.5 - pitch0) + 0.5)) /* int PitchToY(double p, int bottom) @@ -2500,13 +2500,13 @@ int PitchToY(double p, int bottom) /* DrawNoteBackground is called by DrawNoteTrack twice: once to draw the unselected background, and once to draw the selected background. The selected background is the same except for the horizontal range - and the colors. The background rectangle region is given by r; the + and the colors. The background rectangle region is given by rect; the selected region is given by sel. The first time this is called, - sel is equal to r, and the entire region is drawn with unselected + sel is equal to rect, and the entire region is drawn with unselected background colors. */ void TrackArtist::DrawNoteBackground(NoteTrack *track, wxDC &dc, - const wxRect &r, const wxRect &sel, + const wxRect &rect, const wxRect &sel, const ViewInfo *viewInfo, const wxBrush &wb, const wxPen &wp, const wxBrush &bb, const wxPen &bp, @@ -2534,16 +2534,16 @@ void TrackArtist::DrawNoteBackground(NoteTrack *track, wxDC &dc, // eOffset is for the line between E and F; there's another line // between B and C, hence the offset of 2 for two line thicknesses int eOffset = track->GetPitchHeight() * 5 + 2; - while (obottom > r.y + track->GetNoteMargin() + 3) { + while (obottom > rect.y + track->GetNoteMargin() + 3) { // draw a black line separating octaves if this octave botton is visible - if (obottom < r.y + r.height - track->GetNoteMargin()) { + if (obottom < rect.y + rect.height - track->GetNoteMargin()) { dc.SetPen(*wxBLACK_PEN); // obottom - 1 because obottom is at the bottom of the line AColor::Line(dc, left, obottom - 1, right, obottom - 1); } dc.SetPen(bp); // draw a black-key stripe colored line separating E and F if visible - if (obottom - eOffset > r.y && obottom - eOffset < r.y + r.height) { + if (obottom - eOffset > rect.y && obottom - eOffset < rect.y + rect.height) { AColor::Line(dc, left, obottom - eOffset, right, obottom - eOffset); } @@ -2555,7 +2555,7 @@ void TrackArtist::DrawNoteBackground(NoteTrack *track, wxDC &dc, br.height = track->GetPitchHeight(); for (int black = 0; black < 5; black++) { br.y = obottom - track->GetBlackPos(black); - if (br.y > r.y && br.y + br.height < r.y + r.height) { + if (br.y > rect.y && br.y + br.height < rect.y + rect.height) { dc.DrawRectangle(br); // draw each black key background stripe } } @@ -2603,7 +2603,7 @@ window and draw out-of-bounds notes here instead. */ void TrackArtist::DrawNoteTrack(NoteTrack *track, wxDC & dc, - const wxRect & r, + const wxRect & rect, const ViewInfo *viewInfo, bool muted) { @@ -2613,7 +2613,7 @@ void TrackArtist::DrawNoteTrack(NoteTrack *track, double sel0 = viewInfo->selectedRegion.t0(); double sel1 = viewInfo->selectedRegion.t1(); - double h1 = X_TO_TIME(r.x + r.width); + double h1 = X_TO_TIME(rect.x + rect.width); Alg_seq_ptr seq = track->mSeq; if (!seq) { @@ -2636,14 +2636,14 @@ void TrackArtist::DrawNoteTrack(NoteTrack *track, // reserve 1/2 note height at top and bottom of track for // out-of-bounds notes - int numPitches = (r.height) / track->GetPitchHeight(); + int numPitches = (rect.height) / track->GetPitchHeight(); if (numPitches < 0) numPitches = 0; // cannot be negative // bottom is the hypothetical location of the bottom of pitch 0 relative to - // the top of the clipping region r: r.height - PITCH_HEIGHT/2 is where the + // the top of the clipping region rect: rect.height - PITCH_HEIGHT/2 is where the // bottomNote is displayed, and to that // we add the height of bottomNote from the position of pitch 0 - track->PrepareIPitchToY(r); + track->PrepareIPitchToY(rect); // Background comes in 6 colors: // 214, 214,214 -- unselected white keys @@ -2659,17 +2659,17 @@ void TrackArtist::DrawNoteTrack(NoteTrack *track, wxPen barLinePen; barLinePen.SetColour(170, 170, 170); - DrawNoteBackground(track, dc, r, r, viewInfo, blankBrush, blankPen, + DrawNoteBackground(track, dc, rect, rect, viewInfo, blankBrush, blankPen, blackStripeBrush, blackStripePen, barLinePen); - dc.SetClippingRegion(r); + dc.SetClippingRegion(rect); // Draw the selection background // First, the white keys, as a single rectangle // In other words fill the selection area with selectedWhiteKeyPen wxRect selBG; - selBG.y = r.y; - selBG.height = r.height; + selBG.y = rect.y; + selBG.height = rect.height; selBG.x = TIME_TO_X(sel0); selBG.width = TIME_TO_X(sel1) - TIME_TO_X(sel0); @@ -2687,7 +2687,7 @@ void TrackArtist::DrawNoteTrack(NoteTrack *track, wxPen selectedBarLinePen; selectedBarLinePen.SetColour(131, 131, 150); - DrawNoteBackground(track, dc, r, selBG, viewInfo, + DrawNoteBackground(track, dc, rect, selBG, viewInfo, selectedWhiteKeyBrush, selectedWhiteKeyPen, selectedBlackKeyBrush, selectedBlackKeyPen, selectedBarLinePen); @@ -2742,40 +2742,40 @@ void TrackArtist::DrawNoteTrack(NoteTrack *track, nr.y = track->PitchToY(note->pitch); nr.height = track->GetPitchHeight(); - nr.x = r.x + (int) ((x - h) * pps); + nr.x = rect.x + (int) ((x - h) * pps); nr.width = (int) ((note->dur * pps) + 0.5); - if (nr.x + nr.width >= r.x && nr.x < r.x + r.width) { - if (nr.x < r.x) { - nr.width -= (r.x - nr.x); - nr.x = r.x; + if (nr.x + nr.width >= rect.x && nr.x < rect.x + rect.width) { + if (nr.x < rect.x) { + nr.width -= (rect.x - nr.x); + nr.x = rect.x; } - if (nr.x + nr.width > r.x + r.width) // clip on right - nr.width = r.x + r.width - nr.x; + if (nr.x + nr.width > rect.x + rect.width) // clip on right + nr.width = rect.x + rect.width - nr.x; - if (nr.y + nr.height < r.y + marg + 3) { + if (nr.y + nr.height < rect.y + marg + 3) { // too high for window - nr.y = r.y; + nr.y = rect.y; nr.height = marg; dc.SetBrush(*wxBLACK_BRUSH); dc.SetPen(*wxBLACK_PEN); dc.DrawRectangle(nr); - } else if (nr.y >= r.y + r.height - marg - 1) { + } else if (nr.y >= rect.y + rect.height - marg - 1) { // too low for window - nr.y = r.y + r.height - marg; + nr.y = rect.y + rect.height - marg; nr.height = marg; dc.SetBrush(*wxBLACK_BRUSH); dc.SetPen(*wxBLACK_PEN); dc.DrawRectangle(nr); } else { - if (nr.y + nr.height > r.y + r.height - marg) - nr.height = r.y + r.height - nr.y; - if (nr.y < r.y + marg) { - int offset = r.y + marg - nr.y; + if (nr.y + nr.height > rect.y + rect.height - marg) + nr.height = rect.y + rect.height - nr.y; + if (nr.y < rect.y + marg) { + int offset = rect.y + marg - nr.y; nr.height -= offset; nr.y += offset; } - // nr.y += r.y; + // nr.y += rect.y; if (muted) AColor::LightMIDIChannel(&dc, note->chan + 1); else @@ -2961,12 +2961,12 @@ void TrackArtist::DrawNoteTrack(NoteTrack *track, iterator.end(); // draw black line between top/bottom margins and the track dc.SetPen(*wxBLACK_PEN); - AColor::Line(dc, r.x, r.y + marg, r.x + r.width, r.y + marg); - AColor::Line(dc, r.x, r.y + r.height - marg - 1, // subtract 1 to get - r.x + r.width, r.y + r.height - marg - 1); // top of line + AColor::Line(dc, rect.x, rect.y + marg, rect.x + rect.width, rect.y + marg); + AColor::Line(dc, rect.x, rect.y + rect.height - marg - 1, // subtract 1 to get + rect.x + rect.width, rect.y + rect.height - marg - 1); // top of line if (h == 0.0 && track->GetOffset() < 0.0) { - DrawNegativeOffsetTrackArrows(dc, r); + DrawNegativeOffsetTrackArrows(dc, rect); } dc.DestroyClippingRegion(); @@ -2977,7 +2977,7 @@ void TrackArtist::DrawNoteTrack(NoteTrack *track, void TrackArtist::DrawLabelTrack(LabelTrack *track, wxDC & dc, - const wxRect & r, + const wxRect & rect, const ViewInfo *viewInfo) { double sel0 = viewInfo->selectedRegion.t0(); @@ -2986,16 +2986,16 @@ void TrackArtist::DrawLabelTrack(LabelTrack *track, if (!track->GetSelected() && !track->IsSyncLockSelected()) sel0 = sel1 = 0.0; - track->Draw(dc, r, viewInfo->h, viewInfo->zoom, sel0, sel1); + track->Draw(dc, rect, viewInfo->h, viewInfo->zoom, sel0, sel1); } void TrackArtist::DrawTimeTrack(TimeTrack *track, wxDC & dc, - const wxRect & r, + const wxRect & rect, const ViewInfo *viewInfo) { - track->Draw(dc, r, viewInfo->h, viewInfo->zoom); - wxRect envRect = r; + track->Draw(dc, rect, viewInfo->h, viewInfo->zoom); + wxRect envRect = rect; envRect.height -= 2; double lower = track->GetRangeLower(), upper = track->GetRangeUpper(); if(track->GetDisplayLog()) { @@ -3089,7 +3089,7 @@ void TrackArtist::SetSpectrumLogMaxFreq(int freq) // 5x5 box. // // There may be a better way to do this, or a more appealing pattern. -void TrackArtist::DrawSyncLockTiles(wxDC *dc, wxRect r) +void TrackArtist::DrawSyncLockTiles(wxDC *dc, wxRect rect) { wxBitmap syncLockBitmap(theTheme.Image(bmpSyncLockSelTile)); @@ -3098,10 +3098,10 @@ void TrackArtist::DrawSyncLockTiles(wxDC *dc, wxRect r) int gridH = syncLockBitmap.GetHeight() - 8; // Horizontal position within the grid, modulo its period - int blockX = (r.x / gridW) % 5; + int blockX = (rect.x / gridW) % 5; // Amount to offset drawing of first column - int xOffset = r.x % gridW; + int xOffset = rect.x % gridW; if (xOffset < 0) xOffset += gridW; // Check if we're missing an extra column to the left (this can happen @@ -3116,20 +3116,20 @@ void TrackArtist::DrawSyncLockTiles(wxDC *dc, wxRect r) if (blockX < 0) blockX += 5; int x = 0; - while (x < r.width) { + while (x < rect.width) { int width = syncLockBitmap.GetWidth() - xOffset; - if (x + width > r.width) - width = r.width - x; + if (x + width > rect.width) + width = rect.width - x; // // Draw each row in this column // // Vertical position in the grid, modulo its period - int blockY = (r.y / gridH) % 5; + int blockY = (rect.y / gridH) % 5; // Amount to offset drawing of first row - int yOffset = r.y % gridH; + int yOffset = rect.y % gridH; if (yOffset < 0) yOffset += gridH; // Check if we're missing an extra row on top (this can happen because @@ -3144,11 +3144,11 @@ void TrackArtist::DrawSyncLockTiles(wxDC *dc, wxRect r) if (blockY < 0) blockY += 5; int y = 0; - while (y < r.height) + while (y < rect.height) { int height = syncLockBitmap.GetHeight() - yOffset; - if (y + height > r.height) - height = r.height - y; + if (y + height > rect.height) + height = rect.height - y; // AWD: draw blocks according to our pattern if ((blockX == 0 && blockY == 0) || (blockX == 2 && blockY == 1) || @@ -3160,10 +3160,10 @@ void TrackArtist::DrawSyncLockTiles(wxDC *dc, wxRect r) if (width != syncLockBitmap.GetWidth() || height != syncLockBitmap.GetHeight()) { wxBitmap subSyncLockBitmap = syncLockBitmap.GetSubBitmap(wxRect(xOffset, yOffset, width, height)); - dc->DrawBitmap(subSyncLockBitmap, r.x + x, r.y + y, true); + dc->DrawBitmap(subSyncLockBitmap, rect.x + x, rect.y + y, true); } else { - dc->DrawBitmap(syncLockBitmap, r.x + x, r.y + y, true); + dc->DrawBitmap(syncLockBitmap, rect.x + x, rect.y + y, true); } } @@ -3196,7 +3196,7 @@ void TrackArtist::DrawSyncLockTiles(wxDC *dc, wxRect r) } } -void TrackArtist::DrawBackgroundWithSelection(wxDC *dc, const wxRect &r, +void TrackArtist::DrawBackgroundWithSelection(wxDC *dc, const wxRect &rect, Track *track, wxBrush &selBrush, wxBrush &unselBrush, double sel0, double sel1, double h, double pps) { @@ -3209,13 +3209,13 @@ void TrackArtist::DrawBackgroundWithSelection(wxDC *dc, const wxRect &r, if (track->GetSelected() || track->IsSyncLockSelected()) { // Rectangles before, within, after the selction - wxRect before = r; - wxRect within = r; - wxRect after = r; + wxRect before = rect; + wxRect within = rect; + wxRect after = rect; before.width = int ((sel0 - h) * pps + 2.5); - if (before.GetRight() > r.GetRight()) { - before.width = r.width; + if (before.GetRight() > rect.GetRight()) { + before.width = rect.width; } if (before.width > 0) { @@ -3224,10 +3224,10 @@ void TrackArtist::DrawBackgroundWithSelection(wxDC *dc, const wxRect &r, within.x = before.GetRight(); } - within.width = r.x + int ((sel1 - h) * pps + 2.5) - within.x; + within.width = rect.x + int ((sel1 - h) * pps + 2.5) - within.x; - if (within.GetRight() > r.GetRight()) { - within.width = r.GetRight() - within.x; + if (within.GetRight() > rect.GetRight()) { + within.width = rect.GetRight() - within.x; } if (within.width > 0) { @@ -3249,7 +3249,7 @@ void TrackArtist::DrawBackgroundWithSelection(wxDC *dc, const wxRect &r, after.x = within.x; } - after.width = r.GetRight() - after.x; + after.width = rect.GetRight() - after.x; if (after.width > 0) { dc->SetBrush(unselBrush); dc->DrawRectangle(after); @@ -3259,7 +3259,7 @@ void TrackArtist::DrawBackgroundWithSelection(wxDC *dc, const wxRect &r, { // Track not selected; just draw background dc->SetBrush(unselBrush); - dc->DrawRectangle(r); + dc->DrawRectangle(rect); } } diff --git a/src/TrackArtist.h b/src/TrackArtist.h index 1fa32dd8e..471bdd191 100644 --- a/src/TrackArtist.h +++ b/src/TrackArtist.h @@ -52,17 +52,17 @@ class AUDACITY_DLL_API TrackArtist { void SetColours(); void DrawTracks(TrackList *tracks, Track *start, wxDC & dc, wxRegion & reg, - wxRect & r, wxRect & clip, ViewInfo *viewInfo, - bool drawEnvelope, bool drawSamples, bool drawSliders); + wxRect & rect, wxRect & clip, ViewInfo *viewInfo, + bool drawEnvelope, bool bigPoints, bool drawSliders); void DrawTrack(const Track *t, - wxDC & dc, const wxRect & r, const ViewInfo *viewInfo, - bool drawEnvelope, bool drawSamples, bool drawSliders, + wxDC & dc, const wxRect & rect, const ViewInfo *viewInfo, + bool drawEnvelope, bool bigPoints, bool drawSliders, bool hasSolo); - void DrawVRuler(Track *t, wxDC *dc, wxRect & r); + void DrawVRuler(Track *t, wxDC *dc, wxRect & rect); - void UpdateVRuler(Track *t, wxRect & r); + void UpdateVRuler(Track *t, wxRect & rect); void SetInset(int left, int top, int right, int bottom); @@ -90,10 +90,10 @@ class AUDACITY_DLL_API TrackArtist { } // Helper: draws the "sync-locked" watermark tiled to a rectangle - static void DrawSyncLockTiles(wxDC *dc, wxRect r); + static void DrawSyncLockTiles(wxDC *dc, wxRect rect); // Helper: draws background with selection rect - static void DrawBackgroundWithSelection(wxDC *dc, const wxRect &r, + static void DrawBackgroundWithSelection(wxDC *dc, const wxRect &rect, Track *track, wxBrush &selBrush, wxBrush &unselBrush, double sel0, double sel1, double h, double pps); @@ -104,67 +104,67 @@ class AUDACITY_DLL_API TrackArtist { // void DrawWaveform(WaveTrack *track, - wxDC & dc, const wxRect & r, const ViewInfo *viewInfo, - bool drawEnvelope, bool drawSamples, bool drawSliders, + wxDC & dc, const wxRect & rect, const ViewInfo *viewInfo, + bool drawEnvelope, bool bigPoints, bool drawSliders, bool dB, bool muted); void DrawSpectrum(WaveTrack *track, - wxDC & dc, const wxRect & r, const ViewInfo *viewInfo); + wxDC & dc, const wxRect & rect, const ViewInfo *viewInfo); #ifdef USE_MIDI - int GetBottom(NoteTrack *t, const wxRect &r); + int GetBottom(NoteTrack *t, const wxRect &rect); void DrawNoteBackground(NoteTrack *track, wxDC &dc, - const wxRect &r, const wxRect &sel, + const wxRect &rect, const wxRect &sel, const ViewInfo *viewInfo, const wxBrush &wb, const wxPen &wp, const wxBrush &bb, const wxPen &bp, const wxPen &mp); void DrawNoteTrack(NoteTrack *track, - wxDC & dc, const wxRect & r, const ViewInfo *viewInfo, + wxDC & dc, const wxRect & rect, const ViewInfo *viewInfo, bool muted); #endif // USE_MIDI void DrawLabelTrack(LabelTrack *track, - wxDC & dc, const wxRect & r, const ViewInfo *viewInfo); + wxDC & dc, const wxRect & rect, const ViewInfo *viewInfo); void DrawTimeTrack(TimeTrack *track, - wxDC & dc, const wxRect & r, const ViewInfo *viewInfo); + wxDC & dc, const wxRect & rect, const ViewInfo *viewInfo); - void DrawTimeSlider(wxDC & dc, const wxRect & r, + void DrawTimeSlider(wxDC & dc, const wxRect & rect, bool rightwards); void DrawClipWaveform(WaveTrack *track, WaveClip *clip, - wxDC & dc, const wxRect & r, const ViewInfo *viewInfo, - bool drawEnvelope, bool drawSamples, + wxDC & dc, const wxRect & rect, const ViewInfo *viewInfo, + bool drawEnvelope, bool bigPoints, bool dB, bool muted); void DrawClipSpectrum(WaveTrackCache &cache, WaveClip *clip, - wxDC & dc, const wxRect & r, const ViewInfo *viewInfo); + wxDC & dc, const wxRect & rect, const ViewInfo *viewInfo); // Waveform utility functions - void DrawWaveformBackground(wxDC & dc, const wxRect &r, const double env[], + void DrawWaveformBackground(wxDC & dc, const wxRect &rect, const double env[], float zoomMin, float zoomMax, bool dB, const sampleCount where[], sampleCount ssel0, sampleCount ssel1, bool drawEnvelope, bool bIsSyncLockSelected); - void DrawMinMaxRMS(wxDC &dc, const wxRect &r, const double env[], + void DrawMinMaxRMS(wxDC &dc, const wxRect &rect, const double env[], float zoomMin, float zoomMax, bool dB, const WaveDisplay &display, bool /* showProgress */, bool muted #ifdef EXPERIMENTAL_OUTPUT_DISPLAY , const float gain #endif ); - void DrawIndividualSamples(wxDC & dc, const wxRect & r, + void DrawIndividualSamples(wxDC & dc, const wxRect & rect, float zoomMin, float zoomMax, bool dB, WaveClip *clip, double t0, double pps, double h, - bool drawSamples, bool showPoints, bool muted); + bool bigPoints, bool showPoints, bool muted); - void DrawNegativeOffsetTrackArrows(wxDC & dc, const wxRect & r); + void DrawNegativeOffsetTrackArrows(wxDC & dc, const wxRect & rect); - void DrawEnvelope(wxDC & dc, const wxRect & r, const double env[], + void DrawEnvelope(wxDC & dc, const wxRect & rect, const double env[], float zoomMin, float zoomMax, bool dB); - void DrawEnvLine(wxDC & dc, const wxRect & r, int x, int y, int cy, bool top); + void DrawEnvLine(wxDC & dc, const wxRect & rect, int x, int y, int cy, bool top); // Preference values float mdBrange; // "/GUI/EnvdBRange" From 1b125f8fe3fd0c111e2a8840c74621c9bf9b66a2 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Tue, 9 Jun 2015 21:43:00 -0400 Subject: [PATCH 4/5] more variable name changes --- src/TrackArtist.cpp | 239 ++++++++++++++++++++++---------------------- src/TrackArtist.h | 4 +- 2 files changed, 121 insertions(+), 122 deletions(-) diff --git a/src/TrackArtist.cpp b/src/TrackArtist.cpp index b7502b68f..5eeafb298 100644 --- a/src/TrackArtist.cpp +++ b/src/TrackArtist.cpp @@ -941,11 +941,11 @@ float FromDB(float value, double dBRange) return pow(10.0, ((fabs(value) * dBRange) - dBRange) / 20.0)*sign; } -float ValueOfPixel(int y, int height, bool offset, +float ValueOfPixel(int yy, int height, bool offset, bool dB, double dBRange, float zoomMin, float zoomMax) { wxASSERT(height > 0); - float v = zoomMax - (y / (float)height) * (zoomMax - zoomMin); + float v = zoomMax - (yy / (float)height) * (zoomMax - zoomMin); if (offset) { if (v > 0.0) v += .5; @@ -1008,26 +1008,26 @@ void TrackArtist::DrawWaveformBackground(wxDC &dc, const wxRect &rect, const dou int maxbot, lmaxbot = 0; int minbot, lminbot = 0; bool sel, lsel = false; - int x, lx = 0; + int xx, lx = 0; int l, w; dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(blankBrush); dc.DrawRectangle(rect); - for (x = 0; x < rect.width; x++) { + for (xx = 0; xx < rect.width; ++xx) { // First we compute the truncated shape of the waveform background. // If drawEnvelope is true, then we compute the lower border of the // envelope. - maxtop = GetWaveYPos(env[x], zoomMin, zoomMax, + maxtop = GetWaveYPos(env[xx], zoomMin, zoomMax, h, dB, true, mdBrange, true); - maxbot = GetWaveYPos(env[x], zoomMin, zoomMax, + maxbot = GetWaveYPos(env[xx], zoomMin, zoomMax, h, dB, false, mdBrange, true); - mintop = GetWaveYPos(-env[x], zoomMin, zoomMax, + mintop = GetWaveYPos(-env[xx], zoomMin, zoomMax, h, dB, false, mdBrange, true); - minbot = GetWaveYPos(-env[x], zoomMin, zoomMax, + minbot = GetWaveYPos(-env[xx], zoomMin, zoomMax, h, dB, true, mdBrange, true); // Make sure it's odd so that a that max and min mirror each other @@ -1040,7 +1040,7 @@ void TrackArtist::DrawWaveformBackground(wxDC &dc, const wxRect &rect, const dou } // We don't draw selection color for sync-lock selected tracks. - sel = (ssel0 <= where[x] && where[x + 1] < ssel1) && !bIsSyncLockSelected; + sel = (ssel0 <= where[xx] && where[xx + 1] < ssel1) && !bIsSyncLockSelected; if (lmaxtop == maxtop && lmintop == mintop && @@ -1053,7 +1053,7 @@ void TrackArtist::DrawWaveformBackground(wxDC &dc, const wxRect &rect, const dou dc.SetBrush(lsel ? selectedBrush : unselectedBrush); l = rect.x + lx; - w = x - lx; + w = xx - lx; if (lmaxbot < lmintop - 1) { dc.DrawRectangle(l, rect.y + lmaxtop, w, lmaxbot - lmaxtop); dc.DrawRectangle(l, rect.y + lmintop, w, lminbot - lmintop); @@ -1067,12 +1067,12 @@ void TrackArtist::DrawWaveformBackground(wxDC &dc, const wxRect &rect, const dou lmaxbot = maxbot; lminbot = minbot; lsel = sel; - lx = x; + lx = xx; } dc.SetBrush(lsel ? selectedBrush : unselectedBrush); l = rect.x + lx; - w = x - lx; + w = xx - lx; if (lmaxbot < lmintop - 1) { dc.DrawRectangle(l, rect.y + lmaxtop, w, lmaxbot - lmaxtop); dc.DrawRectangle(l, rect.y + lmintop, w, lminbot - lmintop); @@ -1085,10 +1085,10 @@ void TrackArtist::DrawWaveformBackground(wxDC &dc, const wxRect &rect, const dou if (bIsSyncLockSelected && ssel0 < ssel1) { // Find the beginning/end of the selection int begin, end; - for (x = 0; x < rect.width && where[x] < ssel0; ++x); - begin = x; - for (; x < rect.width && where[x] < ssel1; ++x); - end = x; + for (xx = 0; xx < rect.width && where[xx] < ssel0; ++xx); + begin = xx; + for (; xx < rect.width && where[xx] < ssel1; ++xx); + end = xx; DrawSyncLockTiles(&dc, wxRect(rect.x + begin, rect.y, end - 1 - begin, rect.height)); } @@ -1126,7 +1126,6 @@ void TrackArtist::DrawMinMaxRMS(wxDC &dc, const wxRect &rect, const double env[] int *r2 = new int[rect.width]; int *clipped = NULL; int clipcnt = 0; - int x; if (mShowClipping) { clipped = new int[rect.width]; @@ -1139,14 +1138,14 @@ void TrackArtist::DrawMinMaxRMS(wxDC &dc, const wxRect &rect, const double env[] bool drawWaveform = true; dc.SetPen(muted ? muteSamplePen : samplePen); - for (x = 0; x < rect.width; x++) { - int xx = rect.x + x; + for (int x0 = 0; x0 < rect.width; ++x0) { + int xx = rect.x + x0; double v; #ifdef EXPERIMENTAL_OUTPUT_DISPLAY //JWA: "gain" variable passed to function includes the pan value and is used below 4/14/13 - v = min[x] * env[x] * gain; + v = min[x0] * env[x0] * gain; #else - v = min[x] * env[x]; + v = min[x0] * env[x0]; #endif if (clipped && mShowClipping && (v <= -MAX_AUDIO)) { @@ -1158,9 +1157,9 @@ void TrackArtist::DrawMinMaxRMS(wxDC &dc, const wxRect &rect, const double env[] rect.height, dB, true, mdBrange, true); #ifdef EXPERIMENTAL_OUTPUT_DISPLAY - v = max[x] * env[x] * gain; + v = max[x0] * env[x0] * gain; #else - v = max[x] * env[x]; + v = max[x0] * env[x0]; #endif if (clipped && mShowClipping && (v >= MAX_AUDIO)) { @@ -1173,7 +1172,7 @@ void TrackArtist::DrawMinMaxRMS(wxDC &dc, const wxRect &rect, const double env[] // JKC: This adjustment to h1 and h2 ensures that the drawn // waveform is continuous. - if (x > 0) { + if (x0 > 0) { if (h1 < lasth2) { h1 = lasth2 - 1; } @@ -1185,38 +1184,38 @@ void TrackArtist::DrawMinMaxRMS(wxDC &dc, const wxRect &rect, const double env[] lasth2 = h2; #ifdef EXPERIMENTAL_OUTPUT_DISPLAY - r1[x] = GetWaveYPos(-rms[x] * env[x]*gain, zoomMin, zoomMax, + r1[x0] = GetWaveYPos(-rms[x0] * env[x0]*gain, zoomMin, zoomMax, rect.height, dB, true, mdBrange, true); - r2[x] = GetWaveYPos(rms[x] * env[x]*gain, zoomMin, zoomMax, + r2[x0] = GetWaveYPos(rms[xx0 * env[x0]*gain, zoomMin, zoomMax, rect.height, dB, true, mdBrange, true); #else - r1[x] = GetWaveYPos(-rms[x] * env[x], zoomMin, zoomMax, + r1[x0] = GetWaveYPos(-rms[x0] * env[x0], zoomMin, zoomMax, rect.height, dB, true, mdBrange, true); - r2[x] = GetWaveYPos(rms[x] * env[x], zoomMin, zoomMax, + r2[x0] = GetWaveYPos(rms[x0] * env[x0], zoomMin, zoomMax, rect.height, dB, true, mdBrange, true); #endif // Make sure the rms isn't larger than the waveform min/max - if (r1[x] > h1 - 1) { - r1[x] = h1 - 1; + if (r1[x0] > h1 - 1) { + r1[x0] = h1 - 1; } - if (r2[x] < h2 + 1) { - r2[x] = h2 + 1; + if (r2[x0] < h2 + 1) { + r2[x0] = h2 + 1; } - if (r2[x] > r1[x]) { - r2[x] = r1[x]; + if (r2[x0] > r1[x0]) { + r2[x0] = r1[x0]; } - if (bl[x] <= -1) { + if (bl[x0] <= -1) { if (drawStripes) { // TODO:unify with buffer drawing. - dc.SetPen((bl[x] % 2) ? muteSamplePen : samplePen); - for (int y = 0; y < rect.height / 25 + 1; y++) { + dc.SetPen((bl[x0] % 2) ? muteSamplePen : samplePen); + for (int yy = 0; yy < rect.height / 25 + 1; ++yy) { // we are drawing over the buffer, but I think DrawLine takes care of this. AColor::Line(dc, xx, - rect.y + 25 * y + (x /*+pixAnimOffset*/) % 25, + rect.y + 25 * yy + (x0 /*+pixAnimOffset*/) % 25, xx, - rect.y + 25 * y + (x /*+pixAnimOffset*/) % 25 + 6); //take the min so we don't draw past the edge + rect.y + 25 * yy + (x0 /*+pixAnimOffset*/) % 25 + 6); //take the min so we don't draw past the edge } } @@ -1225,10 +1224,10 @@ void TrackArtist::DrawMinMaxRMS(wxDC &dc, const wxRect &rect, const double env[] if (drawWaveform) { int triX; dc.SetPen(samplePen); - triX = fabs((double)((x + pixAnimOffset) % (2 * rect.height)) - rect.height) + rect.height; - for (int y = 0; y < rect.height; y++) { - if ((y + triX) % rect.height == 0) { - dc.DrawPoint(xx, rect.y + y); + triX = fabs((double)((x0 + pixAnimOffset) % (2 * rect.height)) - rect.height) + rect.height; + for (int yy = 0; yy < rect.height; ++yy) { + if ((yy + triX) % rect.height == 0) { + dc.DrawPoint(xx, rect.y + yy); } } } @@ -1243,12 +1242,12 @@ void TrackArtist::DrawMinMaxRMS(wxDC &dc, const wxRect &rect, const double env[] // Stroke rms over the min-max dc.SetPen(muted ? muteRmsPen : rmsPen); - for (int x = 0; x < rect.width; x++) { - int xx = rect.x + x; - if (bl[x] <= -1) { + for (int x0 = 0; x0 < rect.width; ++x0) { + int xx = rect.x + x0; + if (bl[x0] <= -1) { } - else if (r1[x] != r2[x]) { - AColor::Line(dc, xx, rect.y + r2[x], xx, rect.y + r1[x]); + else if (r1[x0] != r2[x0]) { + AColor::Line(dc, xx, rect.y + r2[x0], xx, rect.y + r1[x0]); } } @@ -1384,17 +1383,17 @@ void TrackArtist::DrawEnvelope(wxDC &dc, const wxRect &rect, const double env[], dc.SetPen(AColor::envelopePen); - for (int x = 0; x < rect.width; x++) { - int cenvTop = GetWaveYPos(env[x], zoomMin, zoomMax, + for (int x0 = 0; x0 < rect.width; ++x0) { + int cenvTop = GetWaveYPos(env[x0], zoomMin, zoomMax, h, dB, true, mdBrange, true); - int cenvBot = GetWaveYPos(-env[x], zoomMin, zoomMax, + int cenvBot = GetWaveYPos(-env[x0], zoomMin, zoomMax, h, dB, true, mdBrange, true); - int envTop = GetWaveYPos(env[x], zoomMin, zoomMax, + int envTop = GetWaveYPos(env[x0], zoomMin, zoomMax, h, dB, true, mdBrange, false); - int envBot = GetWaveYPos(-env[x], zoomMin, zoomMax, + int envBot = GetWaveYPos(-env[x0], zoomMin, zoomMax, h, dB, true, mdBrange, false); // Make the collision at zero actually look solid @@ -1404,23 +1403,23 @@ void TrackArtist::DrawEnvelope(wxDC &dc, const wxRect &rect, const double env[], cenvBot = value + 4; } - DrawEnvLine(dc, rect, x, envTop, cenvTop, true); - DrawEnvLine(dc, rect, x, envBot, cenvBot, false); + DrawEnvLine(dc, rect, x0, envTop, cenvTop, true); + DrawEnvLine(dc, rect, x0, envBot, cenvBot, false); } } -void TrackArtist::DrawEnvLine(wxDC &dc, const wxRect &rect, int x, int y, int cy, bool top) +void TrackArtist::DrawEnvLine(wxDC &dc, const wxRect &rect, int x0, int y0, int cy, bool top) { - int xx = rect.x + x; + int xx = rect.x + x0; int yy = rect.y + cy; - if (y < 0) { - if (x % 4 != 3) { + if (y0 < 0) { + if (x0 % 4 != 3) { AColor::Line(dc, xx, yy, xx, yy + 3); } } - else if (y > rect.height) { - if (x % 4 != 3) { + else if (y0 > rect.height) { + if (x0 % 4 != 3) { AColor::Line(dc, xx, yy - 3, xx, yy); } } @@ -1458,19 +1457,19 @@ void TrackArtist::DrawWaveform(WaveTrack *track, for (int i = 0; iGetNumCachedLocations(); i++) { WaveTrack::Location loc = track->GetCachedLocation(i); - double x = (loc.pos - viewInfo->h) * viewInfo->zoom; - if (x >= 0 && x < rect.width) { + double xx = (loc.pos - viewInfo->h) * viewInfo->zoom; + if (xx >= 0 && xx < rect.width) { dc.SetPen(*wxGREY_PEN); - AColor::Line(dc, (int) (rect.x + x - 1), rect.y, (int) (rect.x + x - 1), rect.y + rect.height); + AColor::Line(dc, (int) (rect.x + xx - 1), rect.y, (int) (rect.x + xx - 1), rect.y + rect.height); if (loc.typ == WaveTrack::locationCutLine) { dc.SetPen(*wxRED_PEN); } else { dc.SetPen(*wxBLACK_PEN); } - AColor::Line(dc, (int) (rect.x + x), rect.y, (int) (rect.x + x), rect.y + rect.height); + AColor::Line(dc, (int) (rect.x + xx), rect.y, (int) (rect.x + xx), rect.y + rect.height); dc.SetPen(*wxGREY_PEN); - AColor::Line(dc, (int) (rect.x + x + 1), rect.y, (int) (rect.x + x + 1), rect.y + rect.height); + AColor::Line(dc, (int) (rect.x + xx + 1), rect.y, (int) (rect.x + xx + 1), rect.y + rect.height); } } @@ -1775,18 +1774,18 @@ void TrackArtist::DrawTimeSlider(wxDC & dc, int firstBar = yTop + taper + taper / 2; int nBars = (yBot - yTop - taper * 3) / barSpacing + 1; xLeft += (width - barWidth + 1) / 2; - int y; + int yy; int i; AColor::Light(&dc, false); for (i = 0;i < nBars; i++) { - y = firstBar + barSpacing * i; - AColor::Line(dc, xLeft, y, xLeft + barWidth, y); + yy = firstBar + barSpacing * i; + AColor::Line(dc, xLeft, yy, xLeft + barWidth, yy); } AColor::Dark(&dc, false); for(i = 0;i < nBars; i++){ - y = firstBar + barSpacing * i + 1; - AColor::Line(dc, xLeft, y, xLeft + barWidth, y); + yy = firstBar + barSpacing * i + 1; + AColor::Line(dc, xLeft, yy, xLeft + barWidth, yy); } } @@ -1989,17 +1988,17 @@ void TrackArtist::DrawClipSpectrum(WaveTrackCache &cache, bool *yGrid; yGrid = new bool[mid.height]; - for (int y = 0; y < mid.height; y++) { - float n = (float(y) / mid.height*scale2 - lmin2) * 12; - float n2 = (float(y + 1) / mid.height*scale2 - lmin2) * 12; + for (int yy = 0; yy < mid.height; ++yy) { + float n = (float(yy) / mid.height*scale2 - lmin2) * 12; + float n2 = (float(yy + 1) / mid.height*scale2 - lmin2) * 12; float f = float(minFreq) / (fftSkipPoints + 1)*powf(2.0f, n / 12.0f + lmin2); float f2 = float(minFreq) / (fftSkipPoints + 1)*powf(2.0f, n2 / 12.0f + lmin2); n = logf(f / 440) / log2 * 12; n2 = logf(f2 / 440) / log2 * 12; if (floor(n) < floor(n2)) - yGrid[y] = true; + yGrid[yy] = true; else - yGrid[y] = false; + yGrid[yy] = false; } #endif //EXPERIMENTAL_FFT_Y_GRID @@ -2180,7 +2179,7 @@ void TrackArtist::DrawClipSpectrum(WaveTrackCache &cache, } clip->mSpecPxCache->values[xx * mid.height + yy] = value; yy2 = yy2_base; - } // each y + } // each yy } // is logF } // each xx @@ -2282,7 +2281,7 @@ void TrackArtist::DrawClipSpectrum(WaveTrackCache &cache, data[px++] = rv; data[px++] = gv; data[px] = bv; - } // each y + } // each yy } // logF } // each xx @@ -2477,8 +2476,8 @@ const char *LookupAtomAttribute(Alg_note_ptr note, Alg_attribute attr, char *def // particular, line plots will be correct at any zoom (limited by floating point // precision). #define CLIP_MAX 16000 -#define CLIP(x) { long c = (x); if (c < -CLIP_MAX) c = -CLIP_MAX; \ - if (c > CLIP_MAX) c = CLIP_MAX; (x) = c; } +#define CLIP(xx) { long c = (xx); if (c < -CLIP_MAX) c = -CLIP_MAX; \ + if (c > CLIP_MAX) c = CLIP_MAX; (xx) = c; } #define RED(i) ( unsigned char )( (((i) >> 16) & 0xff) ) #define GREEN(i) ( unsigned char )( (((i) >> 8) & 0xff) ) @@ -2588,9 +2587,9 @@ void TrackArtist::DrawNoteBackground(NoteTrack *track, wxDC &dc, // map beat to time double t = seq->get_time_map()->beat_to_time(next_bar_beat); // map time to position - int x = TIME_TO_X(t + track->GetOffset()); - if (x > right) break; - AColor::Line(dc, x, sel.y, x, sel.y + sel.height); + int xx = TIME_TO_X(t + track->GetOffset()); + if (xx > right) break; + AColor::Line(dc, xx, sel.y, xx, sel.y + sel.height); next_bar_beat += beats_per_measure; } } @@ -2733,16 +2732,16 @@ void TrackArtist::DrawNoteTrack(NoteTrack *track, Alg_note_ptr note = (Alg_note_ptr) evt; // if the note's channel is visible if (visibleChannels & (1 << (evt->chan & 15))) { - double x = note->time + track->GetOffset(); - double x1 = x + note->dur; - if (x < h1 && x1 > h) { // omit if outside box + double xx = note->time + track->GetOffset(); + double x1 = xx + note->dur; + if (xx < h1 && x1 > h) { // omit if outside box const char *shape = NULL; if (note->loud > 0.0 || 0 == (shape = IsShape(note))) { wxRect nr; // "note rectangle" nr.y = track->PitchToY(note->pitch); nr.height = track->GetPitchHeight(); - nr.x = rect.x + (int) ((x - h) * pps); + nr.x = rect.x + (int) ((xx - h) * pps); nr.width = (int) ((note->dur * pps) + 0.5); if (nr.x + nr.width >= rect.x && nr.x < rect.x + rect.width) { @@ -2799,7 +2798,7 @@ void TrackArtist::DrawNoteTrack(NoteTrack *track, // add 0.5 to pitch because pitches are plotted with // height = PITCH_HEIGHT; thus, the center is raised // by PITCH_HEIGHT * 0.5 - int y = track->PitchToY(note->pitch); + int yy = track->PitchToY(note->pitch); long linecolor = LookupIntAttribute(note, linecolori, -1); long linethick = LookupIntAttribute(note, linethicki, 1); long fillcolor = -1; @@ -2829,44 +2828,44 @@ void TrackArtist::DrawNoteTrack(NoteTrack *track, if (shape == line) { // extreme zooms caues problems under windows, so we have to do some // clipping before calling display routine - if (x < h) { // clip line on left - y = int((y + (y1 - y) * (h - x) / (x1 - x)) + 0.5); - x = h; + if (xx < h) { // clip line on left + yy = int((yy + (y1 - yy) * (h - xx) / (x1 - xx)) + 0.5); + xx = h; } if (x1 > h1) { // clip line on right - y1 = int((y + (y1 - y) * (h1 - x) / (x1 - x)) + 0.5); + y1 = int((yy + (y1 - yy) * (h1 - xx) / (x1 - xx)) + 0.5); x1 = h1; } - AColor::Line(dc, TIME_TO_X(x), y, TIME_TO_X(x1), y1); + AColor::Line(dc, TIME_TO_X(xx), yy, TIME_TO_X(x1), y1); } else if (shape == rectangle) { - if (x < h) { // clip on left, leave 10 pixels to spare - x = h - (linethick + 10) / pps; + if (xx < h) { // clip on left, leave 10 pixels to spare + xx = h - (linethick + 10) / pps; } if (x1 > h1) { // clip on right, leave 10 pixels to spare x1 = h1 + (linethick + 10) / pps; } - dc.DrawRectangle(TIME_TO_X(x), y, int((x1 - x) * pps + 0.5), y1 - y + 1); + dc.DrawRectangle(TIME_TO_X(xx), yy, int((x1 - xx) * pps + 0.5), y1 - yy + 1); } else if (shape == triangle) { wxPoint points[3]; - points[0].x = TIME_TO_X(x); + points[0].x = TIME_TO_X(xx); CLIP(points[0].x); - points[0].y = y; + points[0].y = yy; points[1].x = TIME_TO_X(LookupRealAttribute(note, x1r, note->pitch)); CLIP(points[1].x); points[1].y = y1; - points[2].x = TIME_TO_X(LookupRealAttribute(note, x2r, x)); + points[2].x = TIME_TO_X(LookupRealAttribute(note, x2r, xx)); CLIP(points[2].x); points[2].y = track->PitchToY(LookupRealAttribute(note, y2r, note->pitch)); dc.DrawPolygon(3, points); } else if (shape == polygon) { wxPoint points[20]; // upper bound of 20 sides - points[0].x = TIME_TO_X(x); + points[0].x = TIME_TO_X(xx); CLIP(points[0].x); - points[0].y = y; - points[1].x = TIME_TO_X(LookupRealAttribute(note, x1r, x)); + points[0].y = yy; + points[1].x = TIME_TO_X(LookupRealAttribute(note, x1r, xx)); CLIP(points[1].x); points[1].y = y1; - points[2].x = TIME_TO_X(LookupRealAttribute(note, x2r, x)); + points[2].x = TIME_TO_X(LookupRealAttribute(note, x2r, xx)); CLIP(points[2].x); points[2].y = track->PitchToY(LookupRealAttribute(note, y2r, note->pitch)); int n = 3; @@ -2887,11 +2886,11 @@ void TrackArtist::DrawNoteTrack(NoteTrack *track, } dc.DrawPolygon(n, points); } else if (shape == oval) { - int ix = TIME_TO_X(x); + int ix = TIME_TO_X(xx); CLIP(ix); - int ix1 = int((x1 - x) * pps + 0.5); + int ix1 = int((x1 - xx) * pps + 0.5); if (ix1 > CLIP_MAX * 2) ix1 = CLIP_MAX * 2; // CLIP a width - dc.DrawEllipse(ix, y, ix1, y1 - y + 1); + dc.DrawEllipse(ix, yy, ix1, y1 - yy + 1); } else if (shape == text) { if (linecolor != -1) dc.SetTextForeground(wxColour(RED(linecolor), @@ -2948,10 +2947,10 @@ void TrackArtist::DrawNoteTrack(NoteTrack *track, GREEN(fillcolor), BLUE(fillcolor)), 1, wxSOLID)); - dc.DrawRectangle(TIME_TO_X(x) + hoffset, y + voffset, + dc.DrawRectangle(TIME_TO_X(xx) + hoffset, yy + voffset, textWidth, textHeight); } - dc.DrawText(LAT1CTOWX(s), TIME_TO_X(x) + hoffset, y + voffset); + dc.DrawText(LAT1CTOWX(s), TIME_TO_X(xx) + hoffset, yy + voffset); } } } @@ -3115,11 +3114,11 @@ void TrackArtist::DrawSyncLockTiles(wxDC *dc, wxRect rect) // Make sure blockX is non-negative if (blockX < 0) blockX += 5; - int x = 0; - while (x < rect.width) { + int xx = 0; + while (xx < rect.width) { int width = syncLockBitmap.GetWidth() - xOffset; - if (x + width > rect.width) - width = rect.width - x; + if (xx + width > rect.width) + width = rect.width - xx; // // Draw each row in this column @@ -3143,12 +3142,12 @@ void TrackArtist::DrawSyncLockTiles(wxDC *dc, wxRect rect) // Make sure blockY is non-negative if (blockY < 0) blockY += 5; - int y = 0; - while (y < rect.height) + int yy = 0; + while (yy < rect.height) { int height = syncLockBitmap.GetHeight() - yOffset; - if (y + height > rect.height) - height = rect.height - y; + if (yy + height > rect.height) + height = rect.height - yy; // AWD: draw blocks according to our pattern if ((blockX == 0 && blockY == 0) || (blockX == 2 && blockY == 1) || @@ -3160,10 +3159,10 @@ void TrackArtist::DrawSyncLockTiles(wxDC *dc, wxRect rect) if (width != syncLockBitmap.GetWidth() || height != syncLockBitmap.GetHeight()) { wxBitmap subSyncLockBitmap = syncLockBitmap.GetSubBitmap(wxRect(xOffset, yOffset, width, height)); - dc->DrawBitmap(subSyncLockBitmap, rect.x + x, rect.y + y, true); + dc->DrawBitmap(subSyncLockBitmap, rect.x + xx, rect.y + yy, true); } else { - dc->DrawBitmap(syncLockBitmap, rect.x + x, rect.y + y, true); + dc->DrawBitmap(syncLockBitmap, rect.x + xx, rect.y + yy, true); } } @@ -3175,7 +3174,7 @@ void TrackArtist::DrawSyncLockTiles(wxDC *dc, wxRect rect) } else { // Move on in y, no more offset rows - y += gridH - yOffset; + yy += gridH - yOffset; yOffset = 0; } blockY = (blockY + 1) % 5; @@ -3189,7 +3188,7 @@ void TrackArtist::DrawSyncLockTiles(wxDC *dc, wxRect rect) } else { // Move on in x, no more offset rows - x += gridW - xOffset; + xx += gridW - xOffset; xOffset = 0; } blockX = (blockX + 1) % 5; diff --git a/src/TrackArtist.h b/src/TrackArtist.h index 471bdd191..9aa2a4d87 100644 --- a/src/TrackArtist.h +++ b/src/TrackArtist.h @@ -164,7 +164,7 @@ class AUDACITY_DLL_API TrackArtist { void DrawEnvelope(wxDC & dc, const wxRect & rect, const double env[], float zoomMin, float zoomMax, bool dB); - void DrawEnvLine(wxDC & dc, const wxRect & rect, int x, int y, int cy, bool top); + void DrawEnvLine(wxDC & dc, const wxRect & rect, int x0, int y0, int cy, bool top); // Preference values float mdBrange; // "/GUI/EnvdBRange" @@ -217,7 +217,7 @@ extern int GetWaveYPos(float value, float min, float max, int height, bool dB, bool outer, float dBr, bool clip); extern float FromDB(float value, double dBRange); -extern float ValueOfPixel(int y, int height, bool offset, +extern float ValueOfPixel(int yy, int height, bool offset, bool dB, double dBRange, float zoomMin, float zoomMax); #endif // define __AUDACITY_TRACKARTIST__ From 35e0897bf7a076e30b8d31f89e2a8c969ab57234 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Mon, 8 Jun 2015 15:19:18 -0400 Subject: [PATCH 5/5] Avoid needless mix/max/rms calculation when showing individual samples. --- src/TrackArtist.cpp | 42 ++++++++++++++++++++++++------------------ src/TrackArtist.h | 4 ++-- src/WaveClip.cpp | 9 +++++---- 3 files changed, 31 insertions(+), 24 deletions(-) diff --git a/src/TrackArtist.cpp b/src/TrackArtist.cpp index 5eeafb298..d8f14be8e 100644 --- a/src/TrackArtist.cpp +++ b/src/TrackArtist.cpp @@ -988,7 +988,7 @@ void TrackArtist::DrawNegativeOffsetTrackArrows(wxDC &dc, const wxRect &rect) void TrackArtist::DrawWaveformBackground(wxDC &dc, const wxRect &rect, const double env[], float zoomMin, float zoomMax, bool dB, - const sampleCount where[], + const ViewInfo &viewInfo, double t0, double rate, sampleCount ssel0, sampleCount ssel1, bool drawEnvelope, bool bIsSyncLockSelected) { @@ -1015,7 +1015,10 @@ void TrackArtist::DrawWaveformBackground(wxDC &dc, const wxRect &rect, const dou dc.SetBrush(blankBrush); dc.DrawRectangle(rect); - for (xx = 0; xx < rect.width; ++xx) { + const double samplesPerPixel = rate / viewInfo.zoom; + double where = t0 * rate; + for (xx = 0; xx < rect.width; ++xx, where += samplesPerPixel) { + // First we compute the truncated shape of the waveform background. // If drawEnvelope is true, then we compute the lower border of the // envelope. @@ -1040,7 +1043,7 @@ void TrackArtist::DrawWaveformBackground(wxDC &dc, const wxRect &rect, const dou } // We don't draw selection color for sync-lock selected tracks. - sel = (ssel0 <= where[xx] && where[xx + 1] < ssel1) && !bIsSyncLockSelected; + sel = (ssel0 <= where && where + samplesPerPixel < ssel1) && !bIsSyncLockSelected; if (lmaxtop == maxtop && lmintop == mintop && @@ -1085,9 +1088,10 @@ void TrackArtist::DrawWaveformBackground(wxDC &dc, const wxRect &rect, const dou if (bIsSyncLockSelected && ssel0 < ssel1) { // Find the beginning/end of the selection int begin, end; - for (xx = 0; xx < rect.width && where[xx] < ssel0; ++xx); + double where = t0 * rate; + for (xx = 0; xx < rect.width && where < ssel0; ++xx, where += samplesPerPixel); begin = xx; - for (; xx < rect.width && where[xx] < ssel1; ++xx); + for (; xx < rect.width && where < ssel1; ++xx, where += samplesPerPixel); end = xx; DrawSyncLockTiles(&dc, wxRect(rect.x + begin, rect.y, end - 1 - begin, rect.height)); } @@ -1650,6 +1654,7 @@ void TrackArtist::DrawClipWaveform(WaveTrack *track, const double &tpre = params.tpre; const double &tpost = params.tpost; const double &t1 = params.t1; + const double &rate = params.rate; // Calculate sample-based offset-corrected selection @@ -1664,18 +1669,6 @@ void TrackArtist::DrawClipWaveform(WaveTrack *track, float zoomMin, zoomMax; track->GetDisplayBounds(&zoomMin, &zoomMax); - WaveDisplay display(mid.width); - 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(display, - t0, pps, isLoadingOD)) { - return; - } - // Get the values of the envelope corresponding to each pixel // in the display, and use these to compute the height of the // track at each pixel @@ -1687,10 +1680,23 @@ 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, - &display.where[0], ssel0, ssel1, drawEnvelope, + *viewInfo, t0, rate, + ssel0, ssel1, drawEnvelope, !track->GetSelected()); if (!showIndividualSamples) { + WaveDisplay display(mid.width); + 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(display, + t0, pps, isLoadingOD)) { + return; + } + #ifdef EXPERIMENTAL_OUTPUT_DISPLAY DrawMinMaxRMS(dc, mid, envValues, zoomMin, zoomMax, dB, min, max, rms, bl, isLoadingOD, muted, track->GetChannelGain(track->GetChannel())); diff --git a/src/TrackArtist.h b/src/TrackArtist.h index 9aa2a4d87..9173a2f04 100644 --- a/src/TrackArtist.h +++ b/src/TrackArtist.h @@ -21,7 +21,7 @@ #include #include #include "Experimental.h" -#include "Sequence.h" +#include "audacity/Types.h" class wxDC; class wxRect; @@ -144,7 +144,7 @@ class AUDACITY_DLL_API TrackArtist { void DrawWaveformBackground(wxDC & dc, const wxRect &rect, const double env[], float zoomMin, float zoomMax, bool dB, - const sampleCount where[], + const ViewInfo &viewInfo, double t0, double rate, sampleCount ssel0, sampleCount ssel1, bool drawEnvelope, bool bIsSyncLockSelected); void DrawMinMaxRMS(wxDC &dc, const wxRect &rect, const double env[], diff --git a/src/WaveClip.cpp b/src/WaveClip.cpp index fd66e7c4c..3103f2001 100644 --- a/src/WaveClip.cpp +++ b/src/WaveClip.cpp @@ -349,7 +349,8 @@ public: #ifdef EXPERIMENTAL_USE_REALFFTF #include "FFT.h" -static void ComputeSpectrumUsingRealFFTf(float *buffer, HFFT hFFT, const float *window, int len, float *out) +static void ComputeSpectrumUsingRealFFTf + (float *buffer, HFFT hFFT, const float *window, int len, float *out) { int i; if(len > hFFT->Points*2) @@ -568,11 +569,11 @@ fillWhere(std::vector &where, int len, double bias, double correcti double t0, double rate, double samplesPerPixel) { // Be careful to make the first value non-negative - correction += 0.5 + bias; - where[0] = sampleCount(std::max(0.0, floor(correction + t0 * rate))); + const double w0 = 0.5 + correction + bias + t0 * rate; + where[0] = sampleCount(std::max(0.0, floor(w0))); for (sampleCount x = 1; x < len + 1; x++) where[x] = sampleCount( - floor(correction + t0 * rate + double(x) * samplesPerPixel) + floor(w0 + double(x) * samplesPerPixel) ); }