Audacity 3.2.0
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
MixerTrackCluster Class Referencefinal

#include <MixerBoard.h>

Inheritance diagram for MixerTrackCluster:
[legend]
Collaboration diagram for MixerTrackCluster:
[legend]

Public Member Functions

 MixerTrackCluster (wxWindow *parent, MixerBoard *grandParent, AudacityProject *project, const std::shared_ptr< PlayableTrack > &pTrack, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize)
 
virtual ~MixerTrackCluster ()
 
WaveTrackGetWave () const
 
WaveTrackGetRight () const
 
void HandleResize ()
 
void HandleSliderGain (const bool bWantPushState=false)
 
void HandleSliderPan (const bool bWantPushState=false)
 
void ResetMeter (const bool bResetClipping)
 
void UpdateForStateChange ()
 
void UpdateMeter (const double t0, const double t1)
 
- Public Member Functions inherited from wxPanelWrapper
 wxPanelWrapper ()
 
 wxPanelWrapper (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
void SetLabel (const TranslatableString &label)
 
void SetName (const TranslatableString &name)
 
void SetToolTip (const TranslatableString &toolTip)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Public Attributes

std::shared_ptr< PlayableTrackmTrack
 

Private Member Functions

wxColour GetTrackColor ()
 
void HandleSelect (bool bShiftDown, bool bControlDown)
 
void OnKeyEvent (wxKeyEvent &event)
 
void OnMouseEvent (wxMouseEvent &event)
 
void OnPaint (wxPaintEvent &evt)
 
void OnButton_MusicalInstrument (wxCommandEvent &event)
 
void OnSlider_Gain (wxCommandEvent &event)
 
void OnSlider_Pan (wxCommandEvent &event)
 
void OnButton_Mute (wxCommandEvent &event)
 
void OnButton_Solo (wxCommandEvent &event)
 

Private Attributes

MixerBoardmMixerBoard
 
AudacityProjectmProject
 
auStaticTextmStaticText_TrackName
 
wxBitmapButton * mBitmapButton_MusicalInstrument
 
AButtonmToggleButton_Mute
 
AButtonmToggleButton_Solo
 
MixerTrackSlidermSlider_Pan
 
MixerTrackSlidermSlider_Gain
 
wxWeakRef< MeterPanelmMeter
 

Detailed Description

Definition at line 77 of file MixerBoard.h.

Constructor & Destructor Documentation

◆ MixerTrackCluster()

MixerTrackCluster::MixerTrackCluster ( wxWindow *  parent,
MixerBoard grandParent,
AudacityProject project,
const std::shared_ptr< PlayableTrack > &  pTrack,
const wxPoint &  pos = wxDefaultPosition,
const wxSize &  size = wxDefaultSize 
)

Definition at line 173 of file MixerBoard.cpp.

178: wxPanelWrapper(parent, -1, pos, size)
179, mTrack{ pTrack }
180{
181 mMixerBoard = grandParent;
182 mProject = project;
183 wxASSERT( pTrack );
184
185 SetName( Verbatim( mTrack->GetName() ) );
186
187 //this->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
188 this->SetBackgroundColour( theTheme.Colour( clrMedium ) );
189 // Not sure why, but sizers weren't getting offset vertically,
190 // probably because not using wxDefaultPosition,
191 // so positions are calculated explicitly below, and sizers code was removed.
192 // (Still available in Audacity_UmixIt branch off 1.2.6.)
193
194 // track name
195 wxPoint ctrlPos(kDoubleInset, kDoubleInset);
196 wxSize ctrlSize(size.GetWidth() - kQuadrupleInset, TRACK_NAME_HEIGHT);
198 safenew auStaticText(this, mTrack->GetName());
199 //v Useful when different tracks are different colors, but not now.
200 // mStaticText_TrackName->SetBackgroundColour(this->GetTrackColor());
201 mStaticText_TrackName->SetForegroundColour(theTheme.Colour(clrMedium));
202 mStaticText_TrackName->SetForegroundColour(theTheme.Colour(clrTrackPanelText));
203 mStaticText_TrackName->SetSize( ctrlSize );
204 mStaticText_TrackName->SetPosition( ctrlPos );
205
206
207 // gain and velocity sliders at left (both in same place)
208 ctrlPos.x = kDoubleInset;
209 ctrlPos.y += TRACK_NAME_HEIGHT + kDoubleInset;
210 const int nGainSliderHeight =
211 size.GetHeight() - ctrlPos.y - kQuadrupleInset;
212 ctrlSize.Set(kLeftSideStackWidth - kQuadrupleInset, nGainSliderHeight);
213
216 this, ID_SLIDER_GAIN,
217 /* i18n-hint: title of the Gain slider, used to adjust the volume */
218 XO("Gain"),
219 ctrlPos, ctrlSize,
221 .Style( DB_SLIDER )
222 .Orientation( wxVERTICAL ));
223 mSlider_Gain->SetName(_("Gain"));
224
225#ifdef EXPERIMENTAL_MIDI_OUT
226 mSlider_Velocity =
228 this, ID_SLIDER_VELOCITY,
229 /* i18n-hint: title of the MIDI Velocity slider */
230 XO("Velocity"),
231 ctrlPos, ctrlSize,
233 .Style( VEL_SLIDER )
234 .Orientation( wxVERTICAL ));
235 mSlider_Velocity->SetName(_("Velocity"));
236#endif
237
238 // other controls and meter at right
239
240 // musical instrument image
241 ctrlPos.x += kLeftSideStackWidth + kInset; // + kInset to center it in right side stack
243 wxBitmap* bitmap = mMixerBoard->GetMusicalInstrumentBitmap(mTrack.get());
244 wxASSERT(bitmap);
246 safenew wxBitmapButton(this, ID_BITMAPBUTTON_MUSICAL_INSTRUMENT, *bitmap,
247 ctrlPos, ctrlSize,
248 wxBU_AUTODRAW, wxDefaultValidator,
249 _("Musical Instrument"));
250 mBitmapButton_MusicalInstrument->SetName(_("Musical Instrument"));
251
252
253 // pan slider
254 ctrlPos.x -= kInset; // Remove inset for instrument, so Pan is at leftmost of left side stack.
256 ctrlSize.Set(kRightSideStackWidth, PAN_HEIGHT);
257
258 // The width of the pan slider must be odd (don't ask).
259 if (!(ctrlSize.x & 1))
260 ctrlSize.x--;
261
264 this, ID_SLIDER_PAN,
265 /* i18n-hint: Title of the Pan slider, used to move the sound left or right */
266 XO("Pan"),
267 ctrlPos, ctrlSize,
269 mSlider_Pan->SetName(_("Pan"));
270
271 // mute/solo buttons stacked below Pan slider
272 ctrlPos.y += PAN_HEIGHT + kDoubleInset;
276 ctrlPos, ctrlSize,
280 true); // toggle button
281 mToggleButton_Mute->SetName(_("Mute"));
283 1,
287
288 ctrlPos.y += MUTE_SOLO_HEIGHT;
291 ctrlPos, ctrlSize,
295 true); // toggle button
296 mToggleButton_Solo->SetName(_("Solo"));
297 bool bSoloNone = ProjectSettings::Get( *mProject ).IsSoloNone();
298 mToggleButton_Solo->Show(!bSoloNone);
299
300
301 // meter
302 ctrlPos.y += (bSoloNone ? 0 : MUTE_SOLO_HEIGHT) + kDoubleInset;
303 const int nMeterHeight =
304 nGainSliderHeight -
307 (MUTE_SOLO_HEIGHT + (bSoloNone ? 0 : MUTE_SOLO_HEIGHT) + kDoubleInset);
308 ctrlSize.Set(kRightSideStackWidth, nMeterHeight);
309
310 mMeter.Release();
311 if (GetWave()) {
312 mMeter =
313 safenew MeterPanel(mProject, // AudacityProject* project,
314 this, -1, // wxWindow* parent, wxWindowID id,
315 false, // bool isInput
316 ctrlPos, ctrlSize, // const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
317 MeterPanel::MixerTrackCluster); // Style style = HorizontalStereo,
318 mMeter->SetName(XO("Signal Level Meter"));
319 }
320
321 #if wxUSE_TOOLTIPS
322 mStaticText_TrackName->SetToolTip(mTrack->GetName());
325 if (GetWave())
326 mMeter->SetToolTip(XO("Signal Level Meter"));
327 #endif // wxUSE_TOOLTIPS
328
330
331 #ifdef __WXMAC__
332 wxSizeEvent event(GetSize(), GetId());
333 event.SetEventObject(this);
334 GetEventHandler()->ProcessEvent(event);
335 #endif
336}
#define VEL_SLIDER
Definition: ASlider.h:37
#define DB_SLIDER
Definition: ASlider.h:33
#define PAN_SLIDER
Definition: ASlider.h:34
XO("Cut/Copy/Paste")
#define _(s)
Definition: Internat.h:75
#define safenew
Definition: MemoryX.h:10
const int MUSICAL_INSTRUMENT_HEIGHT_AND_WIDTH
Definition: MixerBoard.cpp:139
const int kDoubleInset
Definition: MixerBoard.cpp:134
const int kQuadrupleInset
Definition: MixerBoard.cpp:136
const int MUTE_SOLO_HEIGHT
Definition: MixerBoard.cpp:140
const int PAN_HEIGHT
Definition: MixerBoard.cpp:141
const int kLeftSideStackWidth
Definition: MixerBoard.cpp:143
const int kInset
Definition: MixerBoard.cpp:133
const int kRightSideStackWidth
Definition: MixerBoard.cpp:144
const int TRACK_NAME_HEIGHT
Definition: MixerBoard.cpp:138
@ ID_BITMAPBUTTON_MUSICAL_INSTRUMENT
Definition: MixerBoard.cpp:148
@ ID_SLIDER_PAN
Definition: MixerBoard.cpp:149
@ ID_SLIDER_GAIN
Definition: MixerBoard.cpp:150
@ ID_TOGGLEBUTTON_MUTE
Definition: MixerBoard.cpp:154
@ ID_TOGGLEBUTTON_SOLO
Definition: MixerBoard.cpp:155
THEME_API Theme theTheme
Definition: Theme.cpp:82
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.
A wxButton with mouse-over behaviour.
Definition: AButton.h:104
void SetToolTip(const TranslatableString &toolTip)
Definition: AButton.cpp:184
void SetAlternateImages(unsigned idx, const wxImage &up, const wxImage &over, const wxImage &down, const wxImage &overDown, const wxImage &dis)
Definition: AButton.cpp:210
MeterPanel is a panel that paints the meter used for monitoring or playback.
Definition: MeterPanel.h:104
@ MixerTrackCluster
Definition: MeterPanel.h:114
std::unique_ptr< wxImage > mImageMuteDown
Definition: MixerBoard.h:245
std::unique_ptr< wxImage > mImageMuteDisabled
Definition: MixerBoard.h:247
std::unique_ptr< wxImage > mImageMuteOver
Definition: MixerBoard.h:245
std::unique_ptr< wxImage > mImageSoloDown
Definition: MixerBoard.h:247
std::unique_ptr< wxImage > mImageMuteUp
Definition: MixerBoard.h:245
wxBitmap * GetMusicalInstrumentBitmap(const Track *pTrack)
std::unique_ptr< wxImage > mImageSoloDisabled
Definition: MixerBoard.h:247
std::unique_ptr< wxImage > mImageSoloUp
Definition: MixerBoard.h:247
std::unique_ptr< wxImage > mImageSoloOver
Definition: MixerBoard.h:247
int mMuteSoloWidth
Definition: MixerBoard.h:249
wxBitmapButton * mBitmapButton_MusicalInstrument
Definition: MixerBoard.h:138
MixerTrackSlider * mSlider_Gain
Definition: MixerBoard.h:142
void UpdateForStateChange()
Definition: MixerBoard.cpp:469
std::shared_ptr< PlayableTrack > mTrack
Definition: MixerBoard.h:130
AudacityProject * mProject
Definition: MixerBoard.h:134
WaveTrack * GetWave() const
Definition: MixerBoard.cpp:338
AButton * mToggleButton_Mute
Definition: MixerBoard.h:139
MixerBoard * mMixerBoard
Definition: MixerBoard.h:133
wxWeakRef< MeterPanel > mMeter
Definition: MixerBoard.h:146
MixerTrackSlider * mSlider_Pan
Definition: MixerBoard.h:141
auStaticText * mStaticText_TrackName
Definition: MixerBoard.h:137
AButton * mToggleButton_Solo
Definition: MixerBoard.h:140
static ProjectSettings & Get(AudacityProject &project)
bool IsSoloNone() const
wxColour & Colour(int iIndex)
is like wxStaticText, except it can be themed. wxStaticText can't be.
Definition: auStaticText.h:20
Options & Style(int s)
Definition: ASlider.h:280

◆ ~MixerTrackCluster()

virtual MixerTrackCluster::~MixerTrackCluster ( )
inlinevirtual

Definition at line 85 of file MixerBoard.h.

85{}

Member Function Documentation

◆ GetRight()

WaveTrack * MixerTrackCluster::GetRight ( ) const

Definition at line 343 of file MixerBoard.cpp.

344{
345 // TODO: more-than-two-channels
346 auto left = GetWave();
347 if (left) {
348 auto channels = TrackList::Channels(left);
349 if ( channels.size() > 1 )
350 return * ++ channels.first;
351 }
352 return nullptr;
353}
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1541

References TrackList::Channels(), and GetWave().

Referenced by HandleSliderGain(), HandleSliderPan(), and UpdateMeter().

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

◆ GetTrackColor()

wxColour MixerTrackCluster::GetTrackColor ( )
private

Definition at line 673 of file MixerBoard.cpp.

674{
675 return wxColour(102, 255, 102); // same as Meter playback color
676}

◆ GetWave()

WaveTrack * MixerTrackCluster::GetWave ( ) const

Definition at line 338 of file MixerBoard.cpp.

339{
340 return dynamic_cast< WaveTrack * >( mTrack.get() );
341}
A Track that contains audio waveform data.
Definition: WaveTrack.h:57

References mTrack.

Referenced by GetRight(), HandleSliderGain(), HandleSliderPan(), ResetMeter(), UpdateForStateChange(), and UpdateMeter().

Here is the caller graph for this function:

◆ HandleResize()

void MixerTrackCluster::HandleResize ( )

Definition at line 374 of file MixerBoard.cpp.

375{
376 wxSize scrolledWindowClientSize = this->GetParent()->GetClientSize();
377 const int newClusterHeight =
378 scrolledWindowClientSize.GetHeight() - kDoubleInset - // nClusterHeight from MixerBoard::UpdateTrackClusters
379 wxSystemSettings::GetMetric(wxSYS_HSCROLL_Y) + // wxScrolledWindow::GetClientSize doesn't account for its scrollbar size.
381
382 this->SetSize(-1, newClusterHeight);
383
384 // Change only the heights of mSlider_Gain and mMeter.
385 // But update shown status of mToggleButton_Solo, which affects top of mMeter.
386 const int nGainSliderHeight =
387 newClusterHeight -
388 (kInset + // margin above mStaticText_TrackName
389 TRACK_NAME_HEIGHT + kDoubleInset) - // mStaticText_TrackName + margin
390 kQuadrupleInset; // margin below gain slider
391 mSlider_Gain->SetSize(-1, nGainSliderHeight);
392#ifdef EXPERIMENTAL_MIDI_OUT
393 mSlider_Velocity->SetSize(-1, nGainSliderHeight);
394#endif
395
396 bool bSoloNone = ProjectSettings::Get( *mProject ).IsSoloNone();
397
398 mToggleButton_Solo->Show(!bSoloNone);
399
400 const int nRequiredHeightAboveMeter =
403 MUTE_SOLO_HEIGHT + (bSoloNone ? 0 : MUTE_SOLO_HEIGHT) + kDoubleInset;
404 const int nMeterY =
405 kDoubleInset + // margin at top
407 nRequiredHeightAboveMeter;
408 const int nMeterHeight = nGainSliderHeight - nRequiredHeightAboveMeter;
409 if (mMeter)
410 mMeter->SetSize(-1, nMeterY, -1, nMeterHeight);
411}

References ProjectSettings::Get(), ProjectSettings::IsSoloNone(), kDoubleInset, kInset, kQuadrupleInset, mMeter, mSlider_Gain, mToggleButton_Solo, MUSICAL_INSTRUMENT_HEIGHT_AND_WIDTH, MUTE_SOLO_HEIGHT, PAN_HEIGHT, and TRACK_NAME_HEIGHT.

Here is the call graph for this function:

◆ HandleSelect()

void MixerTrackCluster::HandleSelect ( bool  bShiftDown,
bool  bControlDown 
)
private

Definition at line 681 of file MixerBoard.cpp.

682{
684 mTrack.get(), bShiftDown, bControlDown, true);
685}
void DoListSelection(AudacityProject &project, Track *t, bool shift, bool ctrl, bool modifyState)

References SelectUtilities::DoListSelection(), mProject, and mTrack.

Referenced by OnButton_MusicalInstrument(), and OnMouseEvent().

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

◆ HandleSliderGain()

void MixerTrackCluster::HandleSliderGain ( const bool  bWantPushState = false)

Definition at line 413 of file MixerBoard.cpp.

414{
415 float fValue = mSlider_Gain->Get();
416 if (GetWave())
417 GetWave()->SetGain(fValue);
418 if (GetRight())
419 GetRight()->SetGain(fValue);
420
421 // Update the TrackPanel correspondingly.
422 TrackPanel::Get( *mProject ).RefreshTrack(mTrack.get());
423 if (bWantPushState)
425 .PushState(XO("Moved gain slider"), XO("Gain"), UndoPush::CONSOLIDATE );
426}
float Get(bool convert=true)
Definition: ASlider.cpp:1845
WaveTrack * GetRight() const
Definition: MixerBoard.cpp:343
void PushState(const TranslatableString &desc, const TranslatableString &shortDesc)
static ProjectHistory & Get(AudacityProject &project)
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:230
void RefreshTrack(Track *trk, bool refreshbacking=true)
Definition: TrackPanel.cpp:748
void SetGain(float newGain)
Definition: WaveTrack.cpp:502

References CONSOLIDATE, ProjectHistory::Get(), TrackPanel::Get(), ASlider::Get(), GetRight(), GetWave(), mProject, mSlider_Gain, mTrack, ProjectHistory::PushState(), TrackPanel::RefreshTrack(), WaveTrack::SetGain(), and XO().

Referenced by MixerTrackSlider::OnMouseEvent(), and OnSlider_Gain().

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

◆ HandleSliderPan()

void MixerTrackCluster::HandleSliderPan ( const bool  bWantPushState = false)

Definition at line 444 of file MixerBoard.cpp.

445{
446 float fValue = mSlider_Pan->Get();
447 if (GetWave()) // test in case track is a NoteTrack
448 GetWave()->SetPan(fValue);
449 if (GetRight())
450 GetRight()->SetPan(fValue);
451
452 // Update the TrackPanel correspondingly.
453 TrackPanel::Get( *mProject ).RefreshTrack(mTrack.get());
454
455 if (bWantPushState)
457 .PushState(XO("Moved pan slider"), XO("Pan"),
459}
void SetPan(float newPan) override
Definition: WaveTrack.cpp:520

References CONSOLIDATE, ProjectHistory::Get(), TrackPanel::Get(), ASlider::Get(), GetRight(), GetWave(), mProject, mSlider_Pan, mTrack, ProjectHistory::PushState(), TrackPanel::RefreshTrack(), WaveTrack::SetPan(), and XO().

Referenced by MixerTrackSlider::OnMouseEvent(), and OnSlider_Pan().

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

◆ OnButton_MusicalInstrument()

void MixerTrackCluster::OnButton_MusicalInstrument ( wxCommandEvent &  event)
private

Definition at line 722 of file MixerBoard.cpp.

723{
724 const auto &state = ::wxGetMouseState();
725 this->HandleSelect(state.ShiftDown(), state.ControlDown());
726}
void HandleSelect(bool bShiftDown, bool bControlDown)
Definition: MixerBoard.cpp:681

References HandleSelect().

Here is the call graph for this function:

◆ OnButton_Mute()

void MixerTrackCluster::OnButton_Mute ( wxCommandEvent &  event)
private

Definition at line 760 of file MixerBoard.cpp.

761{
764 mToggleButton_Mute->SetAlternateIdx(mTrack->GetSolo() ? 1 : 0);
765
766 // Update the TrackPanel correspondingly.
767 if (ProjectSettings::Get(*mProject).IsSoloSimple())
768 ProjectWindow::Get( *mProject ).RedrawProject();
769 else
770 // Update only the changed track.
771 TrackPanel::Get( *mProject ).RefreshTrack(mTrack.get());
772}
void SetAlternateIdx(unsigned idx)
Definition: AButton.cpp:232
bool WasShiftDown()
Definition: AButton.cpp:541
bool IsSoloSimple() const
static ProjectWindow & Get(AudacityProject &project)
void RedrawProject(const bool bForceWaveTracks=false)
void DoTrackMute(AudacityProject &project, Track *t, bool exclusive)

References TrackUtilities::DoTrackMute(), ProjectSettings::Get(), ProjectWindow::Get(), TrackPanel::Get(), ProjectSettings::IsSoloSimple(), mProject, mToggleButton_Mute, mTrack, ProjectWindow::RedrawProject(), TrackPanel::RefreshTrack(), AButton::SetAlternateIdx(), and AButton::WasShiftDown().

Here is the call graph for this function:

◆ OnButton_Solo()

void MixerTrackCluster::OnButton_Solo ( wxCommandEvent &  event)
private

Definition at line 774 of file MixerBoard.cpp.

775{
778 bool bIsSolo = mTrack->GetSolo();
779 mToggleButton_Mute->SetAlternateIdx(bIsSolo ? 1 : 0);
780
781 // Update the TrackPanel correspondingly.
782 // Bug 509: Must repaint all, as many tracks can change with one Solo change.
783 ProjectWindow::Get( *mProject ).RedrawProject();
784}
void DoTrackSolo(AudacityProject &project, Track *t, bool exclusive)

References TrackUtilities::DoTrackSolo(), ProjectWindow::Get(), mProject, mToggleButton_Mute, mToggleButton_Solo, mTrack, ProjectWindow::RedrawProject(), AButton::SetAlternateIdx(), and AButton::WasShiftDown().

Here is the call graph for this function:

◆ OnKeyEvent()

void MixerTrackCluster::OnKeyEvent ( wxKeyEvent &  event)
private

◆ OnMouseEvent()

void MixerTrackCluster::OnMouseEvent ( wxMouseEvent &  event)
private

Definition at line 687 of file MixerBoard.cpp.

688{
689 if (event.ButtonUp())
690 this->HandleSelect(event.ShiftDown(), event.ControlDown());
691 else
692 event.Skip();
693}

References HandleSelect().

Here is the call graph for this function:

◆ OnPaint()

void MixerTrackCluster::OnPaint ( wxPaintEvent &  evt)
private

Definition at line 695 of file MixerBoard.cpp.

696{
698
699 auto selected = mTrack->GetSelected();
700
701 wxColour col = theTheme.Colour(selected ? clrTrackInfoSelected : clrTrackInfo) ;
702 SetBackgroundColour( col );
703 if (mMeter)
704 mMeter->SetBackgroundColour( col );
705 mStaticText_TrackName->SetBackgroundColour( col );
708
709 wxPaintDC dc(this);
710
711 AColor::MediumTrackInfo(&dc, selected);
712 dc.DrawRectangle(this->GetClientRect());
713
714 wxSize clusterSize = this->GetSize();
715 wxRect bev(0, 0, clusterSize.GetWidth() - 1, clusterSize.GetHeight() - 1);
716
717 //bev.Inflate(-1, -1);
718 AColor::Bevel(dc, true, bev);// same bevel whether selected or not.
719}
static void Bevel(wxDC &dc, bool up, const wxRect &r)
Definition: AColor.cpp:266
static void MediumTrackInfo(wxDC *dc, bool selected)
Definition: AColor.cpp:433
bool SetBackgroundColour(const wxColour &colour) override
Definition: ASlider.cpp:1729

References AColor::Bevel(), ThemeBase::Colour(), AColor::MediumTrackInfo(), mMeter, mSlider_Gain, mSlider_Pan, mStaticText_TrackName, mTrack, ASlider::SetBackgroundColour(), theTheme, and UpdateForStateChange().

Here is the call graph for this function:

◆ OnSlider_Gain()

void MixerTrackCluster::OnSlider_Gain ( wxCommandEvent &  event)
private

Definition at line 728 of file MixerBoard.cpp.

729{
730 this->HandleSliderGain();
731}
void HandleSliderGain(const bool bWantPushState=false)
Definition: MixerBoard.cpp:413

References HandleSliderGain().

Here is the call graph for this function:

◆ OnSlider_Pan()

void MixerTrackCluster::OnSlider_Pan ( wxCommandEvent &  event)
private

Definition at line 755 of file MixerBoard.cpp.

756{
757 this->HandleSliderPan();
758}
void HandleSliderPan(const bool bWantPushState=false)
Definition: MixerBoard.cpp:444

References HandleSliderPan().

Here is the call graph for this function:

◆ ResetMeter()

void MixerTrackCluster::ResetMeter ( const bool  bResetClipping)

Definition at line 461 of file MixerBoard.cpp.

462{
463 if (mMeter)
464 mMeter->Reset(GetWave()->GetRate(), bResetClipping);
465}

References anonymous_namespace{TimeTrack.cpp}::GetRate(), GetWave(), and mMeter.

Referenced by UpdateMeter().

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

◆ UpdateForStateChange()

void MixerTrackCluster::UpdateForStateChange ( )

Definition at line 469 of file MixerBoard.cpp.

470{
471 const wxString newName = mTrack->GetName();
472 if (newName != GetName()) {
473 SetName( Verbatim( newName ) );
474 mStaticText_TrackName->SetLabel(newName);
475 mStaticText_TrackName->SetName(newName);
476#if wxUSE_TOOLTIPS
477 mStaticText_TrackName->SetToolTip(newName);
478#endif
479 mBitmapButton_MusicalInstrument->SetBitmapLabel(
481 }
482
483 mToggleButton_Mute->SetAlternateIdx(mTrack->GetSolo() ? 1 : 0);
484 if (mTrack->GetMute())
486 else
488
489 bool bIsSolo = mTrack->GetSolo();
490 if (bIsSolo)
492 else
494 mToggleButton_Mute->SetAlternateIdx(bIsSolo ? 1 : 0);
495
496 if (!GetWave())
497 mSlider_Pan->Hide();
498 else
499 mSlider_Pan->Set(GetWave()->GetPan());
500
501 if (!GetWave())
502 mSlider_Gain->Hide();
503 else
504 mSlider_Gain->Set(GetWave()->GetGain());
505
506#ifdef EXPERIMENTAL_MIDI_OUT
507 if (!GetNote())
508 mSlider_Velocity->Hide();
509 else
510 mSlider_Velocity->Set(GetNote()->GetVelocity());
511#endif
512}
void PushDown()
Definition: AButton.cpp:577
void PopUp()
Definition: AButton.cpp:585
void Set(float value)
Definition: ASlider.cpp:1850

References MixerBoard::GetMusicalInstrumentBitmap(), GetWave(), mBitmapButton_MusicalInstrument, mMixerBoard, mSlider_Gain, mSlider_Pan, mStaticText_TrackName, mToggleButton_Mute, mToggleButton_Solo, mTrack, AButton::PopUp(), AButton::PushDown(), ASlider::Set(), AButton::SetAlternateIdx(), wxPanelWrapper::SetName(), and Verbatim().

Referenced by OnPaint().

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

◆ UpdateMeter()

void MixerTrackCluster::UpdateMeter ( const double  t0,
const double  t1 
)

Definition at line 514 of file MixerBoard.cpp.

515{
516 // NoteTracks do not (currently) register on meters. It would probably be
517 // a good idea to display 16 channel "active" lights rather than a meter
518 if (!GetWave())
519 return;
520
521 if ((t0 < 0.0) || (t1 < 0.0) || (t0 >= t1) || // bad time value or nothing to show
522 ((mMixerBoard->HasSolo() || mTrack->GetMute()) && !mTrack->GetSolo())
523 )
524 {
525 //v Vaughan, 2011-02-25: Moved the update back to TrackPanel::OnTimer() as it helps with
526 // playback issues reported by Bill and noted on Bug 258, so no assert.
527 // Vaughan, 2011-02-04: Now that we're updating all meters from audacityAudioCallback,
528 // this causes an assert if you click Mute while playing, because ResetMeter() resets
529 // the timer, and wxTimerbase says that can only be done from main thread --
530 // but it seems to work fine.
531 this->ResetMeter(false);
532 return;
533 }
534
535 // Vaughan, 2010-11-27:
536 // This commented out code is flawed. Mistaken understanding of "frame" vs "window".
537 // Caused me to override MeterPanel::UpdateDisplay().
538 // But I think it's got a good idea, of calling WaveTracks' GetMinMax and GetRMS
539 // instead of passing in all the data and asking the meter to derive peak and rms.
540 // May be worth revisiting as I think it should perform better, because it uses the min/max/rms
541 // stored in sample blocks, rather than calculating them, but for now, changing it to use the
542 // original MeterPanel::UpdateDisplay(). New code is below the previous (now commented out).
543 //
544 //const size_t kFramesPerBuffer = 4;
545 //float min; // dummy, since it's not shown in meters
546 //Floats maxLeft{kFramesPerBuffer};
547 //Floats rmsLeft{kFramesPerBuffer};
548 //Floats maxRight{kFramesPerBuffer};
549 //Floats rmsRight{kFramesPerBuffer};
550 //
551 //#ifdef EXPERIMENTAL_MIDI_OUT
552 // bool bSuccess = (GetWave() != nullptr);
553 //#else
554 // bool bSuccess = true;
555 //#endif
556
557 //const double dFrameInterval = (t1 - t0) / (double)kFramesPerBuffer;
558 //double dFrameT0 = t0;
559 //double dFrameT1 = t0 + dFrameInterval;
560 //int i = 0;
561 //while (bSuccess && (i < kFramesPerBuffer))
562 //{
563 // bSuccess &=
564 // mTrack->GetMinMax(&min, &(maxLeft[i]), dFrameT0, dFrameT1) &&
565 // mTrack->GetRMS(&(rmsLeft[i]), dFrameT0, dFrameT1);
566 // if (bSuccess && mRightTrack)
567 // bSuccess &=
568 // mRightTrack->GetMinMax(&min, &(maxRight[i]), dFrameT0, dFrameT1) &&
569 // mRightTrack->GetRMS(&(rmsRight[i]), dFrameT0, dFrameT1);
570 // else
571 // {
572 // // Mono: Start with raw values same as left.
573 // // To be modified by bWantPostFadeValues and channel pan/gain.
574 // maxRight[i] = maxLeft[i];
575 // rmsRight[i] = rmsLeft[i];
576 // }
577 // dFrameT0 += dFrameInterval;
578 // dFrameT1 += dFrameInterval;
579 // i++;
580 //}
581 //
582 //const bool bWantPostFadeValues = true; //v Turn this into a checkbox on MixerBoard? For now, always true.
583 //if (bSuccess && bWantPostFadeValues)
584 //if (bSuccess)
585 //{
586 // for (i = 0; i < kFramesPerBuffer; i++)
587 // {
588 // float gain = mTrack->GetChannelGain(0);
589 // maxLeft[i] *= gain;
590 // rmsLeft[i] *= gain;
591 // if (mRightTrack)
592 // gain = mRightTrack->GetChannelGain(1);
593 // maxRight[i] *= gain;
594 // rmsRight[i] *= gain;
595 // }
596 // if ( mMeter ) mMeter->UpdateDisplay(
597 // 2, // If mono, show left track values in both meters, as in MeterToolBar, rather than nChannels.
598 // kFramesPerBuffer,
599 // maxLeft, rmsLeft,
600 // maxRight, rmsRight,
601 // mTrack->TimeToLongSamples(t1 - t0));
602 //}
603 //
604
605 // PRL: TODO: don't fetch from wave tracks at calculated times, for update
606 // of the meter display, but instead consult PlaybackPolicy
607
608 const auto pTrack = GetWave();
609 auto startSample = (sampleCount)((pTrack->GetRate() * t0) + 0.5);
610 auto scnFrames = (sampleCount)((pTrack->GetRate() * (t1 - t0)) + 0.5);
611
612 // Expect that the difference of t1 and t0 is the part of a track played
613 // in about 1/20 second (ticks of TrackPanel timer), so this won't overflow
614 auto nFrames = scnFrames.as_size_t();
615
616 Floats tempFloatsArray{ nFrames };
617 decltype(tempFloatsArray) meterFloatsArray;
618 // Don't throw on read error in this drawing update routine
619 bool bSuccess = pTrack->GetFloats(tempFloatsArray.get(),
620 startSample, nFrames, fillZero, false);
621 if (bSuccess)
622 {
623 // We always pass a stereo sample array to the meter, as it shows 2 channels.
624 // Mono shows same in both meters.
625 // Since we're not mixing, need to duplicate same signal for "right" channel in mono case.
626 meterFloatsArray = Floats{ 2 * nFrames };
627
628 // Interleave for stereo. Left/mono first.
629 for (unsigned int index = 0; index < nFrames; index++)
630 meterFloatsArray[2 * index] = tempFloatsArray[index];
631
632 if (GetRight())
633 // Again, don't throw
634 bSuccess = GetRight()->GetFloats(tempFloatsArray.get(),
635 startSample, nFrames, fillZero, false);
636
637 if (bSuccess)
638 // Interleave right channel, or duplicate same signal for "right" channel in mono case.
639 for (unsigned int index = 0; index < nFrames; index++)
640 meterFloatsArray[(2 * index) + 1] = tempFloatsArray[index];
641 }
642
643 //const bool bWantPostFadeValues = true; //v Turn this into a checkbox on MixerBoard? For now, always true.
644 //if (bSuccess && bWantPostFadeValues)
645 if (bSuccess)
646 {
647 //vvv Need to apply envelope, too? See Mixer::MixSameRate.
648 float gain = pTrack->GetChannelGain(0);
649 for (unsigned int index = 0; index < nFrames; index++)
650 meterFloatsArray[2 * index] *= gain;
651 if (GetRight())
652 gain = GetRight()->GetChannelGain(1);
653 else
654 gain = pTrack->GetChannelGain(1);
655 for (unsigned int index = 0; index < nFrames; index++)
656 meterFloatsArray[(2 * index) + 1] *= gain;
657 // Clip to [-1.0, 1.0] range.
658 for (unsigned int index = 0; index < 2 * nFrames; index++)
659 if (meterFloatsArray[index] < -1.0)
660 meterFloatsArray[index] = -1.0;
661 else if (meterFloatsArray[index] > 1.0)
662 meterFloatsArray[index] = 1.0;
663
664 if (mMeter)
665 mMeter->UpdateDisplay(2, nFrames, meterFloatsArray.get());
666 }
667 else
668 this->ResetMeter(false);
669}
@ fillZero
Definition: SampleFormat.h:60
bool HasSolo()
void ResetMeter(const bool bResetClipping)
Definition: MixerBoard.cpp:461
bool GetFloats(float *buffer, sampleCount start, size_t len, fillFormat fill=fillZero, bool mayThrow=true, sampleCount *pNumWithinClips=nullptr) const
Retrieve samples from a track in floating-point format, regardless of the storage format.
Definition: SampleTrack.h:71
float GetChannelGain(int channel) const override
Takes gain and pan into account.
Definition: WaveTrack.cpp:533
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:19

References fillZero, WaveTrack::GetChannelGain(), SampleTrack::GetFloats(), GetRight(), GetWave(), MixerBoard::HasSolo(), mMeter, mMixerBoard, mTrack, and ResetMeter().

Here is the call graph for this function:

Member Data Documentation

◆ mBitmapButton_MusicalInstrument

wxBitmapButton* MixerTrackCluster::mBitmapButton_MusicalInstrument
private

Definition at line 138 of file MixerBoard.h.

Referenced by UpdateForStateChange().

◆ mMeter

wxWeakRef<MeterPanel> MixerTrackCluster::mMeter
private

Definition at line 146 of file MixerBoard.h.

Referenced by HandleResize(), OnPaint(), ResetMeter(), and UpdateMeter().

◆ mMixerBoard

MixerBoard* MixerTrackCluster::mMixerBoard
private

Definition at line 133 of file MixerBoard.h.

Referenced by UpdateForStateChange(), and UpdateMeter().

◆ mProject

AudacityProject* MixerTrackCluster::mProject
private

◆ mSlider_Gain

MixerTrackSlider* MixerTrackCluster::mSlider_Gain
private

Definition at line 142 of file MixerBoard.h.

Referenced by HandleResize(), HandleSliderGain(), OnPaint(), and UpdateForStateChange().

◆ mSlider_Pan

MixerTrackSlider* MixerTrackCluster::mSlider_Pan
private

Definition at line 141 of file MixerBoard.h.

Referenced by HandleSliderPan(), OnPaint(), and UpdateForStateChange().

◆ mStaticText_TrackName

auStaticText* MixerTrackCluster::mStaticText_TrackName
private

Definition at line 137 of file MixerBoard.h.

Referenced by OnPaint(), and UpdateForStateChange().

◆ mToggleButton_Mute

AButton* MixerTrackCluster::mToggleButton_Mute
private

Definition at line 139 of file MixerBoard.h.

Referenced by OnButton_Mute(), OnButton_Solo(), and UpdateForStateChange().

◆ mToggleButton_Solo

AButton* MixerTrackCluster::mToggleButton_Solo
private

Definition at line 140 of file MixerBoard.h.

Referenced by HandleResize(), OnButton_Solo(), and UpdateForStateChange().

◆ mTrack

std::shared_ptr<PlayableTrack> MixerTrackCluster::mTrack

The documentation for this class was generated from the following files: