Audacity 3.2.0
WaveformView.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3Audacity: A Digital Audio Editor
4
5WaveformView.cpp
6
7Paul Licameli split from WaveChannelView.cpp
8
9**********************************************************************/
10
11
12#include "WaveformView.h"
13
14#include "WaveformAppearance.h"
15#include "ClipParameters.h"
16#include "WaveChannelView.h"
19
20#include "SampleHandle.h"
21#include "../../../ui/EnvelopeHandle.h"
22#include "../../../ui/TimeShiftHandle.h"
23#include "AColor.h"
24#include "Envelope.h"
25#include "../../../../EnvelopeEditor.h"
26#include "PendingTracks.h"
27#include "../../../../ProjectSettings.h"
28#include "SelectedRegion.h"
29#include "SyncLock.h"
30#include "../../../../TrackArt.h"
31#include "../../../../TrackArtist.h"
32#include "../../../../TrackPanelDrawingContext.h"
33#include "../../../../TrackPanelMouseEvent.h"
34#include "ViewInfo.h"
36#include "WaveClip.h"
37#include "WaveTrack.h"
38#include "WaveTrackUtilities.h"
39#include "../../../../WaveTrackLocation.h"
40#include "prefs/WaveformScale.h"
41#include "WaveformSettings.h"
42
43#include "FrameStatistics.h"
44
45#include <wx/graphics.h>
46#include <wx/dc.h>
47#include <wx/gdicmn.h>
48
49#include <wx/dcmemory.h>
53
54#include <atomic>
55
56#include "prefs/GUIPrefs.h"
57
58
61 { wxT("Waveform"), XXO("Wa&veform") }
62};
63
65
67
68std::vector<UIHandlePtr> WaveformView::DetailedHitTest(
69 const TrackPanelMouseState &st,
70 const AudacityProject *pProject, int currentTool, bool bMultiTool )
71{
72 auto &view = *this;
73 const auto pChannel = view.FindChannel<WaveChannel>();
74
76 st, pProject, currentTool, bMultiTool, pChannel);
77 auto &results = pair.second;
78
79 if (!pair.first) {
80 UIHandlePtr result;
81
82 if (bMultiTool) {
83 // Conditional hit tests
84 // If Tools toolbar were eliminated, we would keep these
85 // The priority of these, in case more than one might apply at one
86 // point, seems arbitrary
87 if (nullptr != (result = EnvelopeHandle::WaveChannelHitTest(
88 view.mEnvelopeHandle, st.state, st.rect,
89 pProject, pChannel)))
90 results.push_back(result);
91 if (nullptr != (result = TimeShiftHandle::HitTest(
92 view.mTimeShiftHandle, st.state, st.rect,
93 pChannel->GetTrack().SharedPointer())))
94 // This is the hit test on the "grips" drawn left and
95 // right in Multi only
96 results.push_back(result);
97 if (nullptr != (result = SampleHandle::HitTest(
98 view.mSampleHandle, st.state, st.rect,
99 pProject, pChannel)))
100 results.push_back(result);
101 }
102 else {
103 switch ( currentTool ) {
104 // Unconditional hits appropriate to the tool
105 // If tools toolbar were eliminated, we would eliminate these
107 auto &viewInfo = ViewInfo::Get(*pProject);
108 auto time =
109 viewInfo.PositionToTime(st.state.m_x, st.rect.GetX());
110 const auto envelope =
113 view.mEnvelopeHandle, envelope,
114 std::dynamic_pointer_cast<const Channel>(pChannel),
115 false);
116 break;
117 }
120 view.mSampleHandle, st.state, pChannel);
121 break;
122 default:
123 result = {};
124 break;
125 }
126 if (result)
127 results.push_back(result);
128 }
129 }
130
131 return std::move( results );
132}
133
134void WaveformView::DoSetMinimized( bool minimized )
135{
136 auto wt = FindWaveChannel();
137
138 bool bHalfWave;
139 gPrefs->Read(wxT("/GUI/CollapseToHalfWave"), &bHalfWave, false);
140 if (wt && bHalfWave) {
141 auto &cache = WaveformScale::Get(*wt);
142 if (minimized)
143 // Zoom to show fractionally more than the top half of the wave.
144 cache.SetDisplayBounds( -0.01f, 1.0f );
145 else
146 // Zoom out full
147 cache.SetDisplayBounds( -1.0f, 1.0f );
148 }
149
151}
152
153auto WaveformView::SubViewType() const -> const Type &
154{
155 return sType;
156}
157
158std::shared_ptr<ChannelVRulerControls> WaveformView::DoGetVRulerControls()
159{
160 return std::make_shared<WaveformVRulerControls>(shared_from_this());
161}
162
163namespace
164{
165
166
168{
169 const auto c = pen.GetColour();
170 return graphics::Color(c.Red(), c.Green(), c.Blue());
171}
172
174{
175 const auto c = brush.GetColour();
176 return graphics::Color(c.Red(), c.Green(), c.Blue());
177}
178
179
181{
182 uint8_t* Allocate(size_t width, size_t height) override
183 {
184 mImage = wxImage(width, height, false);
185 mBitmap = wxBitmap();
186 return mImage.GetData();
187 }
188
189 wxBitmap& GetBitmap()
190 {
191 if(!mBitmap.IsOk() && mImage.IsOk())
192 mBitmap = wxBitmap(mImage);
193 return mBitmap;
194 }
195
196 size_t Width() const override
197 {
198 return mImage.GetWidth();
199 }
200
201 size_t Height() const override
202 {
203 return mImage.GetHeight();
204 }
205
206private:
207 wxBitmap mBitmap;
209};
210
211
213 : public WaveClipListener
214{
215public:
216
217 static WaveformPainter& Get(const WaveClip& clip);
218
220 {
221 }
222
224 {
225 const auto changed = mChanged.exchange(false);
226 if (&clip != mWaveClip || changed)
227 mChannelCaches.clear();
228
229 const auto nChannels = clip.NChannels();
230
231 if (mChannelCaches.size() == nChannels)
232 return *this;
233
234 mWaveClip = &clip;
235
236 mChannelCaches.reserve(nChannels);
237
238 for (auto channelIndex = 0; channelIndex < nChannels; ++channelIndex)
239 {
240 auto dataCache = std::make_shared<WaveDataCache>(clip, channelIndex);
241
242 auto bitmapCache = std::make_unique<WaveBitmapCache>(
243 clip, dataCache,
244 [] { return std::make_unique<WaveBitmapCacheElementWX>(); });
245
246 mChannelCaches.push_back(
247 { std::move(dataCache), std::move(bitmapCache) });
248 }
249
250 return *this;
251 }
252
253 void SetSelection(const ZoomInfo& zoomInfo, float t0, float t1, bool selected)
254 {
255 for (auto& channelCache : mChannelCaches)
256 channelCache.BitmapCache->SetSelection(zoomInfo, t0, t1, selected);
257 }
258
259 void Draw(
260 int channelIndex, wxDC& dc, const WavePaintParameters& params,
261 const ZoomInfo& zoomInfo, const wxRect& targetRect, int leftOffset,
262 double from, double to)
263 {
264 auto& channelCache = mChannelCaches[channelIndex];
265
266 channelCache.BitmapCache->SetPaintParameters(params);
267
268 auto range = channelCache.BitmapCache->PerformLookup(zoomInfo, from, to);
269
270 auto left = targetRect.x + leftOffset;
271 auto height = targetRect.height;
272
273 const auto top = targetRect.y;
274
275 wxMemoryDC memdc;
276 for (auto it = range.begin(); it != range.end(); ++it)
277 {
278 const auto elementLeftOffset = it.GetLeftOffset();
279 const auto elementRightOffset = it.GetRightOffset();
280
281 const auto width = WaveBitmapCache::CacheElementWidth -
282 elementLeftOffset - elementRightOffset;
283
284 auto& bitmap = static_cast<WaveBitmapCacheElementWX&>(*it).GetBitmap();
285 memdc.SelectObject(bitmap);
286 dc.Blit(
287 wxPoint(left, targetRect.y), wxSize(width, it->Height()), &memdc,
288 wxPoint(elementLeftOffset, 0));
289
290 left += width;
291 }
292 }
293
294 void SwapChannels() override
295 {
296 //Wave data cache captures channel index which becomes
297 //part of it's state, request cache rebuild...
298 mChanged.store(true);
299 }
300
301 void MarkChanged() noexcept override
302 {
303 //Triggered when any part of the waveform has changed
304 //TODO: invalidate parts of the cache that intersect changes
305 mChanged.store(true);
306 }
307
308 void Invalidate() override
309 {
310 for (auto& channelCache : mChannelCaches)
311 {
312 channelCache.DataCache->Invalidate();
313 channelCache.BitmapCache->Invalidate();
314 }
315 }
316
317 std::unique_ptr<WaveClipListener> Clone() const override
318 {
319 return std::make_unique<WaveformPainter>();
320 }
321
322private:
323 const WaveClip* mWaveClip {};
324
325 struct ChannelCaches final
326 {
327 std::shared_ptr<WaveDataCache> DataCache;
328 std::unique_ptr<WaveBitmapCache> BitmapCache;
329 };
330
331 std::vector<ChannelCaches> mChannelCaches;
332 std::atomic<bool> mChanged = false;
333};
334
336 TrackPanelDrawingContext& context, const WaveTrack& track, const WaveChannelInterval& channelInterval,
337 int leftOffset, double t0, double t1,
338 const wxRect & rect, float zoomMin, float zoomMax, bool dB, float dBRange,
339 bool muted)
340{
341 auto& clip = channelInterval.GetClip();
342 const auto channelIndex = channelInterval.GetChannelIndex();
343
344 const auto artist = TrackArtist::Get(context);
345 const ZoomInfo zoomInfo(0.0, artist->pZoomInfo->GetZoom());
346
347 auto& clipPainter = WaveformPainter::Get(clip);
348
349 const auto trimLeft = clip.GetTrimLeft();
350 const auto sequenceStartTime = clip.GetSequenceStartTime();
351
352 WavePaintParameters paintParameters;
353
354 paintParameters
356 rect.GetHeight(), zoomMin, zoomMax, ShowClippingPref().Read())
357 .SetDBParameters(dBRange, dB)
358 .SetBlankColor(ColorFromWXBrush(artist->blankBrush))
360 .SetShowRMS(ShowRMSPref().Read())
362 ColorFromWXPen(muted ? artist->muteSamplePen : artist->samplePen),
363 ColorFromWXPen(muted ? artist->muteSamplePen : artist->samplePen))
365 ColorFromWXPen(muted ? artist->muteRmsPen : artist->rmsPen),
366 ColorFromWXPen(muted ? artist->muteRmsPen : artist->rmsPen))
368 ColorFromWXBrush(artist->unselectedBrush),
369 ColorFromWXBrush(artist->selectedBrush))
371 ColorFromWXPen(muted ? artist->muteClippedPen : artist->clippedPen),
372 ColorFromWXPen(muted ? artist->muteClippedPen : artist->clippedPen))
373 .SetEnvelope(clip.GetEnvelope());
374
375 clipPainter.SetSelection(
376 zoomInfo, artist->pSelectedRegion->t0() - sequenceStartTime,
377 artist->pSelectedRegion->t1() - sequenceStartTime,
379
380 clipPainter.Draw(
381 channelIndex, context.dc, paintParameters, zoomInfo, rect, leftOffset,
382 t0 + trimLeft, t1 + trimLeft);
383}
384
385
386
388 int leftOffset, const wxRect &rect,
389 const double env[],
390 float zoomMin, float zoomMax,
391 int zeroLevelYCoordinate,
392 bool dB, float dBRange,
393 double t0, double t1,
394 bool bIsSyncLockSelected,
395 bool highlightEnvelope)
396{
397 auto &dc = context.dc;
398 const auto artist = TrackArtist::Get( context );
399 const auto &zoomInfo = *artist->pZoomInfo;
400
401 // Visually (one vertical slice of the waveform background, on its side;
402 // the "*" is the actual waveform background we're drawing
403 //
404 //1.0 0.0 -1.0
405 // |--------------------------------|--------------------------------|
406 // *************** ***************
407 // | | | |
408 // maxtop maxbot mintop minbot
409
410 int h = rect.height;
411 int halfHeight = wxMax(h / 2, 1);
412 int maxtop, lmaxtop = 0;
413 int mintop, lmintop = 0;
414 int maxbot, lmaxbot = 0;
415 int minbot, lminbot = 0;
416 bool sel, lsel = false;
417 int xx, lx = 0;
418 int l, w;
419
420 const auto &blankBrush = artist->blankBrush;
421 const auto &selectedBrush = artist->selectedBrush;
422 const auto &unselectedBrush = artist->unselectedBrush;
423 const auto &envelopeBackgroundBrush = artist->envelopeBackgroundBrush;
424
425 dc.SetPen(*wxTRANSPARENT_PEN);
426 dc.SetBrush(envelopeBackgroundBrush);
427 dc.DrawRectangle(rect);
428
429 // Bug 2389 - always draw at least one pixel of selection.
430 int selectedX = zoomInfo.TimeToPosition(t0, -leftOffset);
431
432 double time = zoomInfo.PositionToTime(0, -leftOffset), nextTime;
433 for (xx = 0; xx < rect.width; ++xx, time = nextTime) {
434 nextTime = zoomInfo.PositionToTime(xx + 1, -leftOffset);
435 // First we compute the truncated shape of the waveform background.
436 // If drawEnvelope is true, then we compute the lower border of the
437 // envelope.
438
439 maxtop = GetWaveYPos(env[xx], zoomMin, zoomMax,
440 h, dB, true, dBRange, true);
441 maxbot = GetWaveYPos(env[xx], zoomMin, zoomMax,
442 h, dB, false, dBRange, true);
443
444 mintop = GetWaveYPos(-env[xx], zoomMin, zoomMax,
445 h, dB, false, dBRange, true);
446 minbot = GetWaveYPos(-env[xx], zoomMin, zoomMax,
447 h, dB, true, dBRange, true);
448
449 // Make sure it's odd so that a that max and min mirror each other
450 mintop +=1;
451 minbot +=1;
452
453 const auto drawEnvelope = artist->drawEnvelope;
454 if (!drawEnvelope || maxbot > mintop) {
455 maxbot = halfHeight;
456 mintop = halfHeight;
457 }
458
459 sel = (t0 <= time && nextTime < t1);
460 sel = sel || (xx == selectedX);
461 // We don't draw selection color for sync-lock selected tracks.
462 sel = sel && !bIsSyncLockSelected;
463
464 if (lmaxtop == maxtop &&
465 lmintop == mintop &&
466 lmaxbot == maxbot &&
467 lminbot == minbot &&
468 lsel == sel) {
469 continue;
470 }
471
472 dc.SetBrush(lsel ? selectedBrush : unselectedBrush);
473
474 l = rect.x + lx;
475 w = xx - lx;
476 if (lmaxbot < lmintop - 1) {
477 dc.DrawRectangle(l, rect.y + lmaxtop, w, lmaxbot - lmaxtop);
478 dc.DrawRectangle(l, rect.y + lmintop, w, lminbot - lmintop);
479 }
480 else {
481 dc.DrawRectangle(l, rect.y + lmaxtop, w, lminbot - lmaxtop);
482 }
483
484 if (highlightEnvelope && lmaxbot < lmintop - 1) {
485 dc.SetBrush( AColor::uglyBrush );
486 dc.DrawRectangle(l, rect.y + lmaxbot, w, lmintop - lmaxbot);
487 }
488
489 lmaxtop = maxtop;
490 lmintop = mintop;
491 lmaxbot = maxbot;
492 lminbot = minbot;
493 lsel = sel;
494 lx = xx;
495 }
496
497 dc.SetBrush(lsel ? selectedBrush : unselectedBrush);
498 l = rect.x + lx;
499 w = xx - lx;
500 if (lmaxbot < lmintop - 1) {
501 dc.DrawRectangle(l, rect.y + lmaxtop, w, lmaxbot - lmaxtop);
502 dc.DrawRectangle(l, rect.y + lmintop, w, lminbot - lmintop);
503 }
504 else {
505 dc.DrawRectangle(l, rect.y + lmaxtop, w, lminbot - lmaxtop);
506 }
507 if (highlightEnvelope && lmaxbot < lmintop - 1) {
508 dc.SetBrush( AColor::uglyBrush );
509 dc.DrawRectangle(l, rect.y + lmaxbot, w, lmintop - lmaxbot);
510 }
511
512 // If sync-lock selected, draw in linked graphics.
513 if (bIsSyncLockSelected && t0 < t1) {
514 const int begin = std::max(0, std::min(rect.width, (int)(zoomInfo.TimeToPosition(t0, -leftOffset))));
515 const int end = std::max(0, std::min(rect.width, (int)(zoomInfo.TimeToPosition(t1, -leftOffset))));
517 { rect.x + begin, rect.y, end - 1 - begin, rect.height } );
518 }
519
520 //OK, the display bounds are between min and max, which
521 //is spread across rect.height. Draw the line at the proper place.
522 if (zeroLevelYCoordinate >= rect.GetTop() &&
523 zeroLevelYCoordinate <= rect.GetBottom()) {
524 dc.SetPen(*wxBLACK_PEN);
525 AColor::Line(dc, rect.x, zeroLevelYCoordinate,
526 rect.x + rect.width - 1, zeroLevelYCoordinate);
527 }
528}
529
531 wxRect rect;
534 WavePortion(int x, int y, int w, int h, double zoom, bool i)
535 : rect(x, y, w, h), averageZoom(zoom), inFisheye(i)
536 {}
537};
538
540 (std::vector<WavePortion> &portions, const wxRect &rect, const ZoomInfo &zoomInfo,
541 const ClipParameters &params)
542{
543 // If there is no fisheye, then only one rectangle has nonzero width.
544 // If there is a fisheye, make rectangles for before and after
545 // (except when they are squeezed to zero width), and at least one for inside
546 // the fisheye.
547
548 const auto intervals = zoomInfo.FindIntervals(rect.width, rect.x);
549 ZoomInfo::Intervals::const_iterator it = intervals.begin(), end = intervals.end(), prev;
550 wxASSERT(it != end && it->position == rect.x);
551 const int rightmost = rect.x + rect.width;
552 for (int left = rect.x; left < rightmost;) {
553 while (it != end && it->position <= left)
554 prev = it++;
555 if (it == end)
556 break;
557 const int right = std::max(left, (int)(it->position));
558 const int width = right - left;
559 if (width > 0)
560 portions.push_back(
561 WavePortion(left, rect.y, width, rect.height,
562 prev->averageZoom, prev->inFisheye)
563 );
564 left = right;
565 }
566}
567
569 int leftOffset, const wxRect &rect,
570 float zoomMin, float zoomMax,
571 bool dB, float dBRange,
572 const WaveChannelInterval &clip,
573 bool showPoints, bool muted,
574 bool highlight)
575{
576 const Envelope &envelope = clip.GetEnvelope();
577 auto &dc = context.dc;
578 const auto artist = TrackArtist::Get(context);
579 const auto &zoomInfo = *artist->pZoomInfo;
580
581 const double toffset = clip.GetPlayStartTime();
582 const double rate = clip.GetRate() / clip.GetStretchRatio();
583 const double t0 = std::max(0.0, zoomInfo.PositionToTime(0, -leftOffset) - toffset);
584 const auto s0 = sampleCount(floor(t0 * rate));
585 const auto snSamples = clip.GetVisibleSampleCount();
586 if (s0 > snSamples)
587 return;
588
589 const double t1 = zoomInfo.PositionToTime(rect.width - 1, -leftOffset) - toffset;
590 const auto s1 = sampleCount(ceil(t1 * rate));
591
592 // Assume size_t will not overflow, else we wouldn't be here drawing the
593 // few individual samples
594 auto slen = std::min(snSamples - s0, s1 - s0 + 1).as_size_t();
595
596 if (slen <= 0)
597 return;
598
599 Floats buffer{ size_t(slen) };
600 clip.GetSamples((samplePtr)buffer.get(), floatSample, s0, slen,
601 // Suppress exceptions in this drawing operation:
602 false);
603
604 ArrayOf<int> xpos{ size_t(slen) };
605 ArrayOf<int> ypos{ size_t(slen) };
606 ArrayOf<int> clipped;
607 int clipcnt = 0;
608
609 const auto bShowClipping = ShowClippingPref().Read();
610 if (bShowClipping)
611 clipped.reinit( size_t(slen) );
612
613 const auto &muteSamplePen = artist->muteSamplePen;
614 const auto &samplePen = artist->samplePen;
615 auto &pen = highlight ? AColor::uglyPen : muted ? muteSamplePen : samplePen;
616 dc.SetPen( pen );
617
618 for (decltype(slen) s = 0; s < slen; s++) {
619 const double time = toffset + (s + s0).as_double() / rate;
620 const int xx = // An offset into the rectangle rect
621 std::max(-10000, std::min(10000,
622 (int)(zoomInfo.TimeToPosition(time, -leftOffset))));
623 xpos[s] = xx;
624
625 // Calculate sample as it would be rendered, so quantize time
626 double value = envelope.GetValue(time, 1.0 / clip.GetRate());
627 const double tt = buffer[s] * value;
628
629 if (clipped && bShowClipping && ((tt <= -MAX_AUDIO) || (tt >= MAX_AUDIO)))
630 clipped[clipcnt++] = xx;
631 ypos[s] =
632 std::max(-1,
633 std::min(rect.height,
634 GetWaveYPos(tt, zoomMin, zoomMax,
635 rect.height, dB, true, dBRange, false)));
636 }
637
638
639 if (showPoints) {
640 // Draw points where spacing is enough
641 const auto bigPoints = artist->bigPoints;
642 const int tickSize = bigPoints ? 4 : 3;// Bigger ellipses when draggable.
643 wxRect pr;
644 pr.width = tickSize;
645 pr.height = tickSize;
646 //different colour when draggable.
647 const auto &dragsampleBrush = artist->dragsampleBrush;
648 const auto &sampleBrush = artist->sampleBrush;
649 auto &brush = highlight
651 : bigPoints ? dragsampleBrush : sampleBrush;
652 dc.SetBrush( brush );
653 for (decltype(slen) s = 0; s < slen; s++) {
654 if (ypos[s] >= 0 && ypos[s] < rect.height) {
655 pr.x = rect.x + xpos[s] - tickSize/2;
656 pr.y = rect.y + ypos[s] - tickSize/2;
657 dc.DrawEllipse(pr);
658 }
659 }
660 }
661
662 const auto sampleDisplay = artist->mSampleDisplay;
663 if (showPoints &&
664 (sampleDisplay == (int) WaveChannelViewConstants::StemPlot)
665 ){
666 // Draw vertical lines
667 int yZero = GetWaveYPos(0.0, zoomMin, zoomMax, rect.height, dB, true, dBRange, false);
668 yZero = rect.y + std::max(-1, std::min(rect.height, yZero));
669 for (decltype(slen) s = 0; s < slen; s++) {
670 AColor::Line(dc,
671 rect.x + xpos[s], rect.y + ypos[s],
672 rect.x + xpos[s], yZero);
673 }
674 }
675 else {
676 // Connect samples with straight lines
677 for (decltype(slen) s = 0; s < slen - 1; s++) {
678 AColor::Line(dc,
679 rect.x + xpos[s], rect.y + ypos[s],
680 rect.x + xpos[s + 1], rect.y + ypos[s + 1]);
681 }
682 }
683
684 // Draw clipping
685 if (clipcnt) {
686 const auto &muteClippedPen = artist->muteClippedPen;
687 const auto &clippedPen = artist->clippedPen;
688 dc.SetPen(muted ? muteClippedPen : clippedPen);
689 while (--clipcnt >= 0) {
690 auto s = clipped[clipcnt];
691 AColor::Line(dc, rect.x + s, rect.y, rect.x + s, rect.y + rect.height);
692 }
693 }
694}
695
698 const wxRect &rect, int x0, int y0, int cy, bool top )
699{
700 auto &dc = context.dc;
701
702 int xx = rect.x + x0;
703 int yy = rect.y + cy;
704
705 if (y0 < 0) {
706 if (x0 % 4 != 3) {
707 AColor::Line(dc, xx, yy, xx, yy + 3);
708 }
709 }
710 else if (y0 > rect.height) {
711 if (x0 % 4 != 3) {
712 AColor::Line(dc, xx, yy - 3, xx, yy);
713 }
714 }
715 else {
716 if (top) {
717 AColor::Line(dc, xx, yy, xx, yy + 3);
718 }
719 else {
720 AColor::Line(dc, xx, yy - 3, xx, yy);
721 }
722 }
723}
724
726 const wxRect &rect, const double env[],
727 float zoomMin, float zoomMax,
728 bool dB, float dBRange, bool highlight)
729{
730 auto &dc = context.dc;
731
732 int h = rect.height;
733
734 auto &pen = highlight ? AColor::uglyPen : AColor::envelopePen;
735 dc.SetPen( pen );
736
737 for (int x0 = 0; x0 < rect.width; ++x0) {
738 int cenvTop = GetWaveYPos(env[x0], zoomMin, zoomMax,
739 h, dB, true, dBRange, true);
740
741 int cenvBot = GetWaveYPos(-env[x0], zoomMin, zoomMax,
742 h, dB, true, dBRange, true);
743
744 int envTop = GetWaveYPos(env[x0], zoomMin, zoomMax,
745 h, dB, true, dBRange, false);
746
747 int envBot = GetWaveYPos(-env[x0], zoomMin, zoomMax,
748 h, dB, true, dBRange, false);
749
750 // Make the collision at zero actually look solid
751 if (cenvBot - cenvTop < 9) {
752 int value = (int)((zoomMax / (zoomMax - zoomMin)) * h);
753 cenvTop = value - 4;
754 cenvBot = value + 4;
755 }
756
757 DrawEnvLine( context, rect, x0, envTop, cenvTop, true );
758 DrawEnvLine( context, rect, x0, envBot, cenvBot, false );
759 }
760}
761
762// Headers needed only for experimental drawing below
763//#include "tracks/playabletrack/wavetrack/ui/SampleHandle.h"
764//#include "tracks/ui/EnvelopeHandle.h"
766 const WaveChannel &channel, const WaveChannelInterval &clip,
767 const wxRect &rect, bool dB, bool muted, bool selected)
768{
769 const Envelope &envelope = clip.GetEnvelope();
770 auto &dc = context.dc;
771 const auto artist = TrackArtist::Get(context);
772 const auto &selectedRegion = *artist->pSelectedRegion;
773 const auto &zoomInfo = *artist->pZoomInfo;
774
776
777 bool highlightEnvelope = false;
778#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
779 auto target = dynamic_cast<EnvelopeHandle*>(context.target.get());
780 highlightEnvelope = target && target->GetEnvelope() == &envelope;
781#endif
782
783 //If clip is "too small" draw a placeholder instead of
784 //attempting to fit the contents into a few pixels
785 if (!WaveChannelView::ClipDetailsVisible(clip, zoomInfo, rect))
786 {
787 auto clipRect = ClipParameters::GetClipRect(clip, zoomInfo, rect);
788 TrackArt::DrawClipFolded(dc, clipRect);
789 return;
790 }
791
792 const ClipParameters params { clip, rect, zoomInfo };
793 const wxRect &hiddenMid = params.hiddenMid;
794 // The "hiddenMid" rect contains the part of the display actually
795 // containing the waveform, as it appears without the fisheye. If it's empty, we're done.
796 if (hiddenMid.width <= 0) {
797 return;
798 }
799
800 const double &t0 = params.t0;
801 const double &t1 = params.t1;
802 const double playStartTime = clip.GetPlayStartTime();
803 const double &trackRectT0 = params.trackRectT0;
804 const double &averagePixelsPerSecond = params.averagePixelsPerSecond;
805 const double sampleRate = clip.GetRate();
806 const double stretchRatio = clip.GetStretchRatio();
807 double leftOffset = params.leftOffset;
808 const wxRect &mid = params.mid;
809
810 auto &settings = WaveformSettings::Get(channel);
811 const float dBRange = settings.dBRange;
812
813 dc.SetPen(*wxTRANSPARENT_PEN);
814 int iColorIndex = WaveColorAttachment::Get(clip).GetColorIndex();
815 artist->SetColours( iColorIndex );
816
817 // The bounds (controlled by vertical zooming; -1.0...1.0
818 // by default)
819 float zoomMin, zoomMax;
820 auto &cache = WaveformScale::Get(channel);
821 cache.GetDisplayBounds(zoomMin, zoomMax);
822
823 std::vector<double> vEnv(mid.width);
824 double *const env = &vEnv[0];
825 CommonChannelView::GetEnvelopeValues(envelope, playStartTime,
826
827 // PRL: change back to make envelope evaluate only at sample times
828 // and then interpolate the display
829 0, // 1.0 / sampleRate,
830
831 env, mid.width, leftOffset, zoomInfo);
832
833 // Draw the background of the track, outlining the shape of
834 // the envelope and using a colored pen for the selected
835 // part of the waveform
836 {
837 double tt0, tt1;
838 const auto &track = channel.GetTrack();
840 tt0 = track.SnapToSample(selectedRegion.t0());
841 tt1 = track.SnapToSample(selectedRegion.t1());
842 }
843 else
844 tt0 = tt1 = 0.0;
845 DrawWaveformBackground(context, leftOffset, mid,
846 env,
847 zoomMin, zoomMax,
848 cache.ZeroLevelYCoordinate(mid),
849 dB, dBRange,
850 tt0, tt1,
851 !track.GetSelected(), highlightEnvelope);
852 }
853
854 // Require at least 1/2 pixel per sample for drawing individual samples.
855 const double threshold1 = 0.5 * sampleRate / stretchRatio;
856 // Require at least 3 pixels per sample for drawing the draggable points.
857 const double threshold2 = 3 * sampleRate / stretchRatio;
858
859 bool highlight = false;
860#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
861 auto target = dynamic_cast<SampleHandle*>(context.target.get());
862 highlight = target && target->FindChannel().get() == &track;
863#endif
864
865 const bool showIndividualSamples = zoomInfo.GetZoom() > threshold1;
866 const bool showPoints = zoomInfo.GetZoom() > threshold2;
867
868 if(!showIndividualSamples)
869 {
871 context, channel.GetTrack(), clip, leftOffset, t0, t1,
872 rect, zoomMin, zoomMax, dB, dBRange, muted);
873 }
874 else
875 {
876 std::vector<WavePortion> portions;
877 FindWavePortions(portions, rect, zoomInfo, params);
878 auto offset = leftOffset;
879 for(const auto& portion : portions)
880 {
881 assert(!portion.inFisheye && portion.averageZoom > threshold1);
882 if(portion.inFisheye || portion.averageZoom <= threshold1)
883 continue;
884
885 wxRect rectPortion = portion.rect;
886 rectPortion.Intersect(mid);
888 context, offset, rectPortion, zoomMin, zoomMax, dB, dBRange, clip,
889 showPoints, muted, highlight);
890 offset += rectPortion.width;
891 }
892
893 }
894
895 const auto drawEnvelope = artist->drawEnvelope;
896 if (drawEnvelope) {
898 context, mid, env, zoomMin, zoomMax, dB, dBRange, highlightEnvelope);
900 context, mid, dB, dBRange, zoomMin, zoomMax, true, rect.x - mid.x);
901 }
902
903 // Draw arrows on the left side if the track extends to the left of the
904 // beginning of time. :)
905 if (trackRectT0 == 0.0 && playStartTime < 0.0)
906 {
908 }
909 {
910 auto clipRect = ClipParameters::GetClipRect(clip, zoomInfo, rect);
911 TrackArt::DrawClipEdges(dc, clipRect, selected);
912 }
913}
914
916 const wxRect & rect,
917 bool rightwards, bool highlight )
918{
919 auto &dc = context.dc;
920
921 const int border = 3; // 3 pixels all round.
922 const int width = 6; // width of the drag box.
923 const int taper = 6; // how much the box tapers by.
924 const int barSpacing = 4; // how far apart the bars are.
925 const int barWidth = 3;
926 const int xFlat = 3;
927
928 //Enough space to draw in?
929 if (rect.height <= ((taper+border + barSpacing) * 2)) {
930 return;
931 }
932 if (rect.width <= (width * 2 + border * 3)) {
933 return;
934 }
935
936 // The draggable box is tapered towards the direction you drag it.
937 int leftTaper = rightwards ? 0 : 6;
938 int rightTaper = rightwards ? 6 : 0;
939
940 int xLeft = rightwards ? (rect.x + border - 2)
941 : (rect.x + rect.width + 1 - (border + width));
942 int yTop = rect.y + border;
943 int yBot = rect.y + rect.height - border - 1;
944
945 AColor::Light(&dc, false, highlight);
946 AColor::Line(dc, xLeft, yBot - leftTaper, xLeft, yTop + leftTaper);
947 AColor::Line(dc, xLeft, yTop + leftTaper, xLeft + xFlat, yTop);
948 AColor::Line(dc, xLeft + xFlat, yTop, xLeft + width, yTop + rightTaper);
949
950 AColor::Dark(&dc, false, highlight);
951 AColor::Line(dc, xLeft + width, yTop + rightTaper, xLeft + width, yBot - rightTaper);
952 AColor::Line(dc, xLeft + width, yBot - rightTaper, xLeft + width-xFlat, yBot);
953 AColor::Line(dc, xLeft + width - xFlat, yBot, xLeft, yBot - leftTaper);
954
955 int firstBar = yTop + taper + taper / 2;
956 int nBars = (yBot - yTop - taper * 3) / barSpacing + 1;
957 xLeft += (width - barWidth + 1) / 2;
958 int yy;
959 int i;
960
961 AColor::Light(&dc, false, highlight);
962 for (i = 0;i < nBars; i++) {
963 yy = firstBar + barSpacing * i;
964 AColor::Line(dc, xLeft, yy, xLeft + barWidth, yy);
965 }
966 AColor::Dark(&dc, false, highlight);
967 for(i = 0;i < nBars; i++){
968 yy = firstBar + barSpacing * i + 1;
969 AColor::Line(dc, xLeft, yy, xLeft + barWidth, yy);
970 }
971}
972
973}
974
975// Header needed only for experimental drawing below
976//#include "tracks/ui/TimeShiftHandle.h"
978 const WaveChannel &channel,
979 const WaveTrack::Interval* selectedClip,
980 const wxRect& rect,
981 bool muted)
982{
983 auto &dc = context.dc;
984 const auto artist = TrackArtist::Get( context );
985
986 bool highlight = false;
987 bool gripHit = false;
988#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
989 auto target = dynamic_cast<TimeShiftHandle*>(context.target.get());
990 gripHit = target && target->IsGripHit();
991 highlight = target && target->FindTrack().get() ==
992 &static_cast<const Track &>(channel.GetChannelGroup());
993#endif
994
995 const bool dB = !WaveformSettings::Get(channel).isLinear();
996
997 const auto &blankSelectedBrush = artist->blankSelectedBrush;
998 const auto &blankBrush = artist->blankBrush;
1000 context, rect, channel, blankSelectedBrush, blankBrush );
1001
1002 for (const auto &pInterval : channel.Intervals()) {
1003 bool selected = selectedClip &&
1004 selectedClip == &pInterval->GetClip();
1005 DrawClipWaveform(context, channel, *pInterval, rect, dB, muted, selected);
1006 }
1007 DrawBoldBoundaries(context, channel, rect);
1008
1009 const auto drawSliders = artist->drawSliders;
1010 if (drawSliders) {
1011 DrawTimeSlider( context, rect, true, highlight && gripHit ); // directed right
1012 DrawTimeSlider( context, rect, false, highlight && gripHit ); // directed left
1013 }
1014}
1015
1017 TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass )
1018{
1019 if ( iPass == TrackArtist::PassTracks ) {
1020 const auto artist = TrackArtist::Get(context);
1021 const auto &pendingTracks = *artist->pPendingTracks;
1022 auto &dc = context.dc;
1023
1024 const auto pChannel = FindChannel();
1025 if (!pChannel)
1026 return;
1027 const auto &wc = static_cast<const WaveChannel&>(
1028 pendingTracks.SubstitutePendingChangedChannel(*pChannel));
1029
1030 const auto hasSolo = artist->hasSolo;
1031 bool muted = (hasSolo || wc.GetTrack().GetMute()) &&
1032 !wc.GetTrack().GetSolo();
1033
1034#if defined(__WXMAC__)
1035 wxAntialiasMode aamode = dc.GetGraphicsContext()->GetAntialiasMode();
1036 dc.GetGraphicsContext()->SetAntialiasMode(wxANTIALIAS_NONE);
1037#endif
1038
1039 auto waveChannelView = GetWaveChannelView().lock();
1040 wxASSERT(waveChannelView.use_count());
1041
1042 auto selectedClip = waveChannelView->GetSelectedClip();
1043 DoDraw(context, wc, selectedClip.get(), rect, muted);
1044
1045#if defined(__WXMAC__)
1046 dc.GetGraphicsContext()->SetAntialiasMode(aamode);
1047#endif
1048 }
1049 WaveChannelSubView::Draw(context, rect, iPass);
1050}
1051
1053 [](WaveChannelView &view) {
1054 return std::make_shared<WaveformView>( view );
1055 }
1056};
1057
1058// The following attaches the wave color sub-menu to the wave track popup
1059// menu. It is appropriate only to waveform view and so is kept in this
1060// source file with the rest of the waveform view implementation.
1061
1062#include <mutex> // for std::call_once
1063#include "WaveTrackControls.h"
1064#include "../../../../widgets/PopupMenuTable.h"
1065#include "ProjectAudioIO.h"
1066#include "ProjectHistory.h"
1067#include "../../../../RefreshCode.h"
1068
1069//=============================================================================
1070// Table class for a sub-menu
1072{
1073 WaveColorMenuTable() : PopupMenuTable{ "WaveColor", XO("&Wave Color") } {}
1075
1076 static WaveColorMenuTable &Instance();
1077
1078 void InitUserData(void *pUserData) override;
1079
1081
1082 int IdOfWaveColor(int WaveColor);
1083 void OnWaveColorChange(wxCommandEvent & event);
1084
1086};
1087
1089{
1090 static WaveColorMenuTable instance;
1091 return instance;
1092}
1093
1095{
1096 mpData = static_cast<PlayableTrackControls::InitMenuData*>(pUserData);
1097}
1098
1099namespace {
1100using ValueFinder = std::function< int( WaveTrack& ) >;
1101
1103{
1104 return XXO("Instrument %i").Format( colorIndex+1 );
1105}
1106}
1107
1109 static const auto fn = []( PopupMenuHandler &handler, wxMenu &menu, int id ){
1110 auto &me = static_cast<WaveColorMenuTable&>( handler );
1111 auto pData = me.mpData;
1112 const auto &track = static_cast<WaveTrack&>(pData->track);
1113 auto &project = pData->project;
1114 bool unsafe = ProjectAudioIO::Get( project ).IsAudioActive();
1115
1116 menu.Check(id, id == me.IdOfWaveColor(
1118 menu.Enable( id, !unsafe );
1119 };
1120
1121 static std::once_flag flag;
1122 std::call_once( flag, [this]{
1123 auto &hostTable = GetWaveTrackMenuTable();
1124 OnInstrument1ID = hostTable.ReserveId();
1125 OnInstrument2ID = hostTable.ReserveId();
1126 OnInstrument3ID = hostTable.ReserveId();
1127 OnInstrument4ID = hostTable.ReserveId();
1128 } );
1129
1130 AppendRadioItem( "Instrument1", OnInstrument1ID,
1131 GetWaveColorStr(0), POPUP_MENU_FN( OnWaveColorChange ), fn );
1132 AppendRadioItem( "Instrument2", OnInstrument2ID,
1133 GetWaveColorStr(1), POPUP_MENU_FN( OnWaveColorChange ), fn );
1134 AppendRadioItem( "Instrument3", OnInstrument3ID,
1135 GetWaveColorStr(2), POPUP_MENU_FN( OnWaveColorChange ), fn );
1136 AppendRadioItem( "Instrument4", OnInstrument4ID,
1137 GetWaveColorStr(3), POPUP_MENU_FN( OnWaveColorChange ), fn );
1138
1140
1141
1142int WaveColorMenuTable::IdOfWaveColor(int WaveColor)
1143{ return OnInstrument1ID + WaveColor;}
1144
1147void WaveColorMenuTable::OnWaveColorChange(wxCommandEvent & event)
1148{
1149 int id = event.GetId();
1150 wxASSERT(id >= OnInstrument1ID && id <= OnInstrument4ID);
1151 auto &track = static_cast<WaveTrack&>(mpData->track);
1152
1153 int newWaveColor = id - OnInstrument1ID;
1154
1156
1157 WaveformAppearance::Get(track).SetColorIndex(newWaveColor);
1158
1160 .PushState(XO("Changed '%s' to %s")
1161 .Format(track.GetName(), GetWaveColorStr(newWaveColor)),
1162 XO("WaveColor Change"));
1163
1164 using namespace RefreshCode;
1166}
1167
1168namespace {
1171 { "SubViews/Extra" },
1172 std::make_unique<PopupMenuSection>( "WaveColor",
1173 // Conditionally add sub-menu for wave color, if showing waveform
1174 PopupMenuTable::Adapt<WaveTrackPopupMenuTable>(
1175 [](WaveTrackPopupMenuTable &table) {
1176 const auto pTrack = &table.FindWaveTrack();
1177 const auto &view = WaveChannelView::GetFirst(*pTrack);
1178 const auto displays = view.GetDisplays();
1179 bool hasWaveform = (displays.end() != std::find(
1180 displays.begin(), displays.end(),
1182 WaveChannelViewConstants::Waveform, {} }
1183 ) );
1184 return hasWaveform
1186 .Get(table.mpData))
1187 : nullptr;
1188 } ) )
1189};
1190
1191}
1192
1193static WaveClip::Attachments::RegisteredFactory sKeyW{ [](WaveClip&) {
1194 return std::make_unique<WaveformPainter>();
1195} };
1196
1198{
1199 return const_cast< WaveClip& >( clip ) // Consider it mutable data
1200 .Attachments::Get<WaveformPainter>(sKeyW).EnsureClip(clip);
1201}
wxImage(22, 22)
wxT("CloseDown"))
std::shared_ptr< UIHandle > UIHandlePtr
Definition: CellularPanel.h:28
int min(int a, int b)
EffectDistortionSettings params
XO("Cut/Copy/Paste")
XXO("&Cut/Copy/Paste Toolbar")
BoolSetting & ShowRMSPref()
Definition: GUIPrefs.cpp:190
BoolSetting & ShowClippingPref()
Definition: GUIPrefs.cpp:196
#define MAX_AUDIO
Definition: MemoryX.h:341
#define END_POPUP_MENU()
#define BEGIN_POPUP_MENU(HandlerClass)
#define POPUP_MENU_FN(memFn)
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
constexpr sampleFormat floatSample
Definition: SampleFormat.h:45
char * samplePtr
Definition: SampleFormat.h:57
const auto project
int GetWaveYPos(float value, float min, float max, int height, bool dB, bool outer, float dBr, bool clip)
Definition: TrackArt.cpp:66
static Settings & settings()
Definition: TrackInfo.cpp:51
WaveTrackPopupMenuTable & GetWaveTrackMenuTable()
static WaveChannelSubViewType::RegisteredType reg
static const auto fn
AppendRadioItem("Instrument1", OnInstrument1ID, GetWaveColorStr(0), POPUP_MENU_FN(OnWaveColorChange), fn)
static WaveClip::Attachments::RegisteredFactory sKeyW
static const WaveChannelSubViews::RegisteredFactory key
static WaveChannelSubView::Type sType
static std::once_flag flag
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
Definition: AColor.cpp:194
static wxBrush uglyBrush
Definition: AColor.h:141
static void Light(wxDC *dc, bool selected, bool highlight=false)
Definition: AColor.cpp:395
static wxPen uglyPen
Definition: AColor.h:140
static void Dark(wxDC *dc, bool selected, bool highlight=false)
Definition: AColor.cpp:421
static wxPen envelopePen
Definition: AColor.h:116
void reinit(Integral count, bool initialize=false)
Definition: MemoryX.h:59
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
ChannelGroup & GetChannelGroup()
Channel object's lifetime is assumed to be nested in its Track's.
Definition: Channel.cpp:43
virtual void DoSetMinimized(bool isMinimized)
Client code makes static instance from a factory of attachments; passes it to Get or Find as a retrie...
Definition: ClientData.h:275
auto FindChannel() -> std::shared_ptr< Subtype >
May return null.
static void GetEnvelopeValues(const Envelope &env, double aligned_time, double sampleDur, double *buffer, int bufferLen, int leftOffset, const ZoomInfo &zoomInfo)
Get many envelope points for pixel columns at once, but don't assume uniform time per pixel.
static void DrawPoints(const Envelope &env, TrackPanelDrawingContext &context, const wxRect &r, bool dB, double dBRange, float zoomMin, float zoomMax, bool mirrored, int origin=0)
static UIHandlePtr WaveChannelHitTest(std::weak_ptr< EnvelopeHandle > &holder, const wxMouseState &state, const wxRect &rect, const AudacityProject *pProject, const std::shared_ptr< WaveChannel > &wt)
Envelope * GetEnvelope() const
static UIHandlePtr HitAnywhere(std::weak_ptr< EnvelopeHandle > &holder, Envelope *envelope, std::weak_ptr< const Channel > wChannel, bool timeTrack)
Piecewise linear or piecewise exponential function from double to double.
Definition: Envelope.h:72
double GetValue(double t, double sampleDur=0) const
Get envelope value at time t.
Definition: Envelope.cpp:880
Abstract base class used in importing a file.
@ WaveformView
Time required to draw a single clip.
static Stopwatch CreateStopwatch(SectionID section) noexcept
Create a Stopwatch for the section specified.
static constexpr uint32_t CacheElementWidth
bool IsAudioActive() const
static ProjectAudioIO & Get(AudacityProject &project)
void PushState(const TranslatableString &desc, const TranslatableString &shortDesc)
static ProjectHistory & Get(AudacityProject &project)
static UIHandlePtr HitAnywhere(std::weak_ptr< SampleHandle > &holder, const wxMouseState &state, const std::shared_ptr< WaveChannel > &pChannel)
static UIHandlePtr HitTest(std::weak_ptr< SampleHandle > &holder, const wxMouseState &state, const wxRect &rect, const AudacityProject *pProject, const std::shared_ptr< WaveChannel > &pChannel)
bool Read(T *pVar) const
overload of Read returning a boolean that is true if the value was previously defined *‍/
Definition: Prefs.h:207
static bool IsSelectedOrSyncLockSelected(const Track &track)
Definition: SyncLock.cpp:104
static UIHandlePtr HitTest(std::weak_ptr< TimeShiftHandle > &holder, const wxMouseState &state, const wxRect &rect, const std::shared_ptr< Track > &pTrack)
bool IsGripHit() const
static TrackArtist * Get(TrackPanelDrawingContext &)
Definition: TrackArtist.cpp:81
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:110
virtual void Draw(TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass)
Holds a msgid for the translation catalog; may also bind format arguments.
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235
An element, that contains a rasterized bitmap matching the WaveDataCacheElement.
WaveTrack & GetTrack()
Definition: WaveTrack.h:841
IteratorRange< IntervalIterator< WaveClipChannel > > Intervals()
Definition: WaveTrack.cpp:762
std::shared_ptr< WaveChannel > FindWaveChannel()
static void DrawBoldBoundaries(TrackPanelDrawingContext &context, const WaveChannel &channel, const wxRect &rect)
std::pair< bool, std::vector< UIHandlePtr > > DoDetailedHitTest(const TrackPanelMouseState &state, const AudacityProject *pProject, int currentTool, bool bMultiTool, const std::shared_ptr< WaveChannel > &wt)
std::weak_ptr< WaveChannelView > GetWaveChannelView() const
static bool ClipDetailsVisible(const ClipTimes &clip, const ZoomInfo &zoomInfo, const wxRect &viewRect)
static WaveChannelView & GetFirst(WaveTrack &wt)
Get the view of the first channel.
WaveClip & GetClip()
Definition: WaveClip.h:96
sampleCount GetVisibleSampleCount() const override
Definition: WaveClip.cpp:188
size_t GetChannelIndex() const
Definition: WaveClip.h:99
Envelope & GetEnvelope()
Definition: WaveClip.cpp:64
int GetRate() const override
Definition: WaveClip.cpp:193
double GetPlayStartTime() const override
Definition: WaveClip.cpp:198
double GetStretchRatio() const override
Definition: WaveClip.cpp:218
bool GetSamples(samplePtr buffer, sampleFormat format, sampleCount start, size_t len, bool mayThrow=true) const
Definition: WaveClip.cpp:115
This allows multiple clips to be a part of one WaveTrack.
Definition: WaveClip.h:238
size_t NChannels() const override
How many Sequences the clip contains.
Definition: WaveClip.cpp:373
A Track that contains audio waveform data.
Definition: WaveTrack.h:203
bool GetSolo() const override
May vary asynchronously.
Definition: WaveTrack.cpp:2344
static WaveformAppearance & Get(WaveTrack &track)
void SetColorIndex(int colorIndex)
static WaveformScale & Get(const WaveTrack &track)
Mutative access to attachment even if the track argument is const.
bool isLinear() const
static WaveformSettings & Get(const WaveTrack &track)
void Draw(TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass) override
~WaveformView() override
std::shared_ptr< ChannelVRulerControls > DoGetVRulerControls() override
static void DoDraw(TrackPanelDrawingContext &context, const WaveChannel &channel, const WaveTrack::Interval *selectedClip, const wxRect &rect, bool muted)
void DoSetMinimized(bool minimized) override
const Type & SubViewType() const override
std::vector< UIHandlePtr > DetailedHitTest(const TrackPanelMouseState &state, const AudacityProject *pProject, int currentTool, bool bMultiTool) override
double SnapToSample(double t) const
Intervals FindIntervals(int64 width, int64 origin=0) const
Definition: ZoomInfo.cpp:99
void SetSelection(const ZoomInfo &zoomInfo, float t0, float t1, bool selected)
std::unique_ptr< WaveClipListener > Clone() const override
void SwapChannels() override
Default implementation does nothing.
void Draw(int channelIndex, wxDC &dc, const WavePaintParameters &params, const ZoomInfo &zoomInfo, const wxRect &targetRect, int leftOffset, double from, double to)
WaveformPainter & EnsureClip(const WaveClip &clip)
virtual bool Read(const wxString &key, bool *value) const =0
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:19
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:202
Namespace containing an enum 'what to do on a refresh?'.
Definition: RefreshCode.h:16
std::unique_ptr< detail::IndirectItem< Item > > Indirect(const std::shared_ptr< Item > &ptr)
A convenience function.
Definition: Registry.h:175
AUDACITY_DLL_API void DrawBackgroundWithSelection(TrackPanelDrawingContext &context, const wxRect &rect, const Channel &channel, const wxBrush &selBrush, const wxBrush &unselBrush, bool useSelection=true, bool useBeatsAlternateColor=false)
Helper: draws background with selection rect.
Definition: TrackArt.cpp:648
AUDACITY_DLL_API void DrawSyncLockTiles(TrackPanelDrawingContext &context, const wxRect &rect)
Definition: TrackArt.cpp:365
AUDACITY_DLL_API void DrawClipFolded(wxDC &dc, const wxRect &rect)
Definition: TrackArt.cpp:346
AUDACITY_DLL_API void DrawClipEdges(wxDC &dc, const wxRect &clipRect, bool selected=false)
Definition: TrackArt.cpp:309
AUDACITY_DLL_API void DrawNegativeOffsetTrackArrows(TrackPanelDrawingContext &context, const wxRect &rect)
Definition: TrackArt.cpp:143
WAVE_TRACK_API Envelope * GetEnvelopeAtTime(WaveChannel &channel, double time)
void DrawClipWaveform(TrackPanelDrawingContext &context, const WaveChannel &channel, const WaveChannelInterval &clip, const wxRect &rect, bool dB, bool muted, bool selected)
std::function< int(WaveTrack &) > ValueFinder
const TranslatableString GetWaveColorStr(int colorIndex)
void DrawEnvLine(TrackPanelDrawingContext &context, const wxRect &rect, int x0, int y0, int cy, bool top)
void DrawIndividualSamples(TrackPanelDrawingContext &context, int leftOffset, const wxRect &rect, float zoomMin, float zoomMax, bool dB, float dBRange, const WaveChannelInterval &clip, bool showPoints, bool muted, bool highlight)
void DrawEnvelope(TrackPanelDrawingContext &context, const wxRect &rect, const double env[], float zoomMin, float zoomMax, bool dB, float dBRange, bool highlight)
void DrawTimeSlider(TrackPanelDrawingContext &context, const wxRect &rect, bool rightwards, bool highlight)
PopupMenuTable::AttachedItem sAttachment
void DrawWaveform(TrackPanelDrawingContext &context, const WaveTrack &track, const WaveChannelInterval &channelInterval, int leftOffset, double t0, double t1, const wxRect &rect, float zoomMin, float zoomMax, bool dB, float dBRange, bool muted)
void FindWavePortions(std::vector< WavePortion > &portions, const wxRect &rect, const ZoomInfo &zoomInfo, const ClipParameters &params)
graphics::Color ColorFromWXPen(const wxPen &pen)
graphics::Color ColorFromWXBrush(const wxBrush &brush)
void DrawWaveformBackground(TrackPanelDrawingContext &context, int leftOffset, const wxRect &rect, const double env[], float zoomMin, float zoomMax, int zeroLevelYCoordinate, bool dB, float dBRange, double t0, double t1, bool bIsSyncLockSelected, bool highlightEnvelope)
const char * end(const char *str) noexcept
Definition: StringUtils.h:106
const char * begin(const char *str) noexcept
Definition: StringUtils.h:101
constexpr Color Black
Opaque black color constant.
Definition: Color.h:283
static wxRect GetClipRect(const ClipTimes &clip, const ZoomInfo &zoomInfo, const wxRect &viewRect, bool *outShowSamples=nullptr)
static WaveColorAttachment & Get(WaveClip &clip)
PlayableTrackControls::InitMenuData * mpData
DECLARE_POPUP_MENU(WaveColorMenuTable)
void InitUserData(void *pUserData) override
Called before the menu items are appended.
int IdOfWaveColor(int WaveColor)
Converts a WaveColor enumeration to a wxWidgets menu item Id.
void OnWaveColorChange(wxCommandEvent &event)
static WaveColorMenuTable & Instance()
Parameters for the waveform painting.
WavePaintParameters & SetBlankColor(graphics::Color color) noexcept
Sets the blank color.
WavePaintParameters & SetShowRMS(bool showRMS) noexcept
Sets the ShowRMS flag.
WavePaintParameters & SetBackgroundColors(graphics::Color normal, graphics::Color selected) noexcept
Sets the background colors.
WavePaintParameters & SetZeroLineColor(graphics::Color color) noexcept
Sets the horizontal zero line color.
WavePaintParameters & SetDBParameters(double dbRange, bool dbScale) noexcept
Sets the dB scale parameters.
WavePaintParameters & SetClippingColors(graphics::Color normal, graphics::Color selected) noexcept
Sets the clipping colors.
WavePaintParameters & SetSampleColors(graphics::Color normal, graphics::Color selected) noexcept
Sets the sample colors.
WavePaintParameters & SetDisplayParameters(int height, double zoomMin, double zoomMax, bool showClipping) noexcept
Sets the basic painting parameters.
WavePaintParameters & SetEnvelope(const Envelope &envelope) noexcept
Sets volume envelope.
WavePaintParameters & SetRMSColors(graphics::Color normal, graphics::Color selected) noexcept
Sets the RMS colors.
WaveTrack & FindWaveTrack() const
PlayableTrackControls::InitMenuData * mpData
uint8_t * Allocate(size_t width, size_t height) override
WavePortion(int x, int y, int w, int h, double zoom, bool i)
Class for storing color in 32-bit format.
Definition: Color.h:29