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
 
WaveChannelGetRight () 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
 
ChannelGroupSampleView mSampleView
 

Detailed Description

Definition at line 81 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 176 of file MixerBoard.cpp.

181: wxPanelWrapper(parent, -1, pos, size)
182, mTrack{ pTrack }
183{
184 mMixerBoard = grandParent;
186 wxASSERT( pTrack );
187
188 SetName( Verbatim( mTrack->GetName() ) );
189
190 //this->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
191 this->SetBackgroundColour( theTheme.Colour( clrMedium ) );
192 // Not sure why, but sizers weren't getting offset vertically,
193 // probably because not using wxDefaultPosition,
194 // so positions are calculated explicitly below, and sizers code was removed.
195 // (Still available in Audacity_UmixIt branch off 1.2.6.)
196
197 // track name
198 wxPoint ctrlPos(kDoubleInset, kDoubleInset);
199 wxSize ctrlSize(size.GetWidth() - kQuadrupleInset, TRACK_NAME_HEIGHT);
201 safenew auStaticText(this, mTrack->GetName());
202 //v Useful when different tracks are different colors, but not now.
203 // mStaticText_TrackName->SetBackgroundColour(this->GetTrackColor());
204 mStaticText_TrackName->SetForegroundColour(theTheme.Colour(clrMedium));
205 mStaticText_TrackName->SetForegroundColour(theTheme.Colour(clrTrackPanelText));
206 mStaticText_TrackName->SetSize( ctrlSize );
207 mStaticText_TrackName->SetPosition( ctrlPos );
208
209
210 // gain and velocity sliders at left (both in same place)
211 ctrlPos.x = kDoubleInset;
212 ctrlPos.y += TRACK_NAME_HEIGHT + kDoubleInset;
213 const int nGainSliderHeight =
214 size.GetHeight() - ctrlPos.y - kQuadrupleInset;
215 ctrlSize.Set(kLeftSideStackWidth - kQuadrupleInset, nGainSliderHeight);
216
219 this, ID_SLIDER_GAIN,
220 /* i18n-hint: title of the Gain slider, used to adjust the volume */
221 XO("Gain"),
222 ctrlPos, ctrlSize,
224 .Style( DB_SLIDER )
225 .Orientation( wxVERTICAL ));
226 mSlider_Gain->SetName(_("Gain"));
227
228#ifdef EXPERIMENTAL_MIDI_OUT
229 mSlider_Velocity =
231 this, ID_SLIDER_VELOCITY,
232 /* i18n-hint: title of the MIDI Velocity slider */
233 XO("Velocity"),
234 ctrlPos, ctrlSize,
236 .Style( VEL_SLIDER )
237 .Orientation( wxVERTICAL ));
238 mSlider_Velocity->SetName(_("Velocity"));
239#endif
240
241 // other controls and meter at right
242
243 // musical instrument image
244 ctrlPos.x += kLeftSideStackWidth + kInset; // + kInset to center it in right side stack
246 wxBitmap* bitmap = mMixerBoard->GetMusicalInstrumentBitmap(mTrack.get());
247 wxASSERT(bitmap);
249 safenew wxBitmapButton(this, ID_BITMAPBUTTON_MUSICAL_INSTRUMENT, *bitmap,
250 ctrlPos, ctrlSize,
251 wxBU_AUTODRAW, wxDefaultValidator,
252 _("Musical Instrument"));
253 mBitmapButton_MusicalInstrument->SetName(_("Musical Instrument"));
254
255
256 // pan slider
257 ctrlPos.x -= kInset; // Remove inset for instrument, so Pan is at leftmost of left side stack.
259 ctrlSize.Set(kRightSideStackWidth, PAN_HEIGHT);
260
261 // The width of the pan slider must be odd (don't ask).
262 if (!(ctrlSize.x & 1))
263 ctrlSize.x--;
264
267 this, ID_SLIDER_PAN,
268 /* i18n-hint: Title of the Pan slider, used to move the sound left or right */
269 XO("Pan"),
270 ctrlPos, ctrlSize,
272 mSlider_Pan->SetName(_("Pan"));
273
274 // mute/solo buttons stacked below Pan slider
275 ctrlPos.y += PAN_HEIGHT + kDoubleInset;
279 ctrlPos, ctrlSize,
283 true); // toggle button
284 mToggleButton_Mute->SetName(_("Mute"));
286 1,
290
291 ctrlPos.y += MUTE_SOLO_HEIGHT;
294 ctrlPos, ctrlSize,
298 true); // toggle button
299 mToggleButton_Solo->SetName(_("Solo"));
300 bool bSoloNone = (TracksBehaviorsSolo.ReadEnum() == SoloBehaviorNone);
301 mToggleButton_Solo->Show(!bSoloNone);
302
303
304 // meter
305 ctrlPos.y += (bSoloNone ? 0 : MUTE_SOLO_HEIGHT) + kDoubleInset;
306 const int nMeterHeight =
307 nGainSliderHeight -
310 (MUTE_SOLO_HEIGHT + (bSoloNone ? 0 : MUTE_SOLO_HEIGHT) + kDoubleInset);
311 ctrlSize.Set(kRightSideStackWidth, nMeterHeight);
312
313 mMeter.Release();
314 if (GetWave()) {
315 mMeter =
316 safenew MeterPanel(mProject, // AudacityProject* project,
317 this, -1, // wxWindow* parent, wxWindowID id,
318 false, // bool isInput
319 ctrlPos, ctrlSize, // const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
320 MeterPanel::MixerTrackCluster); // Style style = HorizontalStereo,
321 mMeter->SetName(XO("Signal Level Meter"));
322 }
323
324 #if wxUSE_TOOLTIPS
325 mStaticText_TrackName->SetToolTip(mTrack->GetName());
328 if (GetWave())
329 mMeter->SetToolTip(XO("Signal Level Meter"));
330 #endif // wxUSE_TOOLTIPS
331
333
334 #ifdef __WXMAC__
335 wxSizeEvent event(GetSize(), GetId());
336 event.SetEventObject(this);
337 GetEventHandler()->ProcessEvent(event);
338 #endif
339}
#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:73
#define safenew
Definition: MemoryX.h:10
const int MUSICAL_INSTRUMENT_HEIGHT_AND_WIDTH
Definition: MixerBoard.cpp:142
const int kDoubleInset
Definition: MixerBoard.cpp:137
const int kQuadrupleInset
Definition: MixerBoard.cpp:139
const int MUTE_SOLO_HEIGHT
Definition: MixerBoard.cpp:143
const int PAN_HEIGHT
Definition: MixerBoard.cpp:144
const int kLeftSideStackWidth
Definition: MixerBoard.cpp:146
const int kInset
Definition: MixerBoard.cpp:136
const int kRightSideStackWidth
Definition: MixerBoard.cpp:147
const int TRACK_NAME_HEIGHT
Definition: MixerBoard.cpp:141
@ ID_BITMAPBUTTON_MUSICAL_INSTRUMENT
Definition: MixerBoard.cpp:151
@ ID_SLIDER_PAN
Definition: MixerBoard.cpp:152
@ ID_SLIDER_GAIN
Definition: MixerBoard.cpp:153
@ ID_TOGGLEBUTTON_MUTE
Definition: MixerBoard.cpp:157
@ ID_TOGGLEBUTTON_SOLO
Definition: MixerBoard.cpp:158
EnumSetting< SoloBehavior > TracksBehaviorsSolo
@ SoloBehaviorNone
Definition: PlayableTrack.h:72
const auto project
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:250
std::unique_ptr< wxImage > mImageMuteDisabled
Definition: MixerBoard.h:252
std::unique_ptr< wxImage > mImageMuteOver
Definition: MixerBoard.h:250
std::unique_ptr< wxImage > mImageSoloDown
Definition: MixerBoard.h:252
std::unique_ptr< wxImage > mImageMuteUp
Definition: MixerBoard.h:250
wxBitmap * GetMusicalInstrumentBitmap(const Track *pTrack)
std::unique_ptr< wxImage > mImageSoloDisabled
Definition: MixerBoard.h:252
std::unique_ptr< wxImage > mImageSoloUp
Definition: MixerBoard.h:252
std::unique_ptr< wxImage > mImageSoloOver
Definition: MixerBoard.h:252
int mMuteSoloWidth
Definition: MixerBoard.h:254
wxBitmapButton * mBitmapButton_MusicalInstrument
Definition: MixerBoard.h:142
MixerTrackSlider * mSlider_Gain
Definition: MixerBoard.h:146
void UpdateForStateChange()
Definition: MixerBoard.cpp:470
std::shared_ptr< PlayableTrack > mTrack
Definition: MixerBoard.h:134
AudacityProject * mProject
Definition: MixerBoard.h:138
WaveTrack * GetWave() const
Definition: MixerBoard.cpp:341
AButton * mToggleButton_Mute
Definition: MixerBoard.h:143
MixerBoard * mMixerBoard
Definition: MixerBoard.h:137
wxWeakRef< MeterPanel > mMeter
Definition: MixerBoard.h:150
MixerTrackSlider * mSlider_Pan
Definition: MixerBoard.h:145
auStaticText * mStaticText_TrackName
Definition: MixerBoard.h:141
AButton * mToggleButton_Solo
Definition: MixerBoard.h:144
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 89 of file MixerBoard.h.

89{}

Member Function Documentation

◆ GetRight()

WaveChannel * MixerTrackCluster::GetRight ( ) const

Definition at line 346 of file MixerBoard.cpp.

347{
348 // TODO: more-than-two-channels
349 auto left = GetWave();
350 if (left) {
351 auto channels = left->Channels();
352 if (channels.size() > 1)
353 return (* ++ channels.first).get();
354 }
355 return nullptr;
356}

References GetWave().

Here is the call graph for this function:

◆ GetTrackColor()

wxColour MixerTrackCluster::GetTrackColor ( )
private

Definition at line 702 of file MixerBoard.cpp.

703{
704 return wxColour(102, 255, 102); // same as Meter playback color
705}

◆ GetWave()

WaveTrack * MixerTrackCluster::GetWave ( ) const

Definition at line 341 of file MixerBoard.cpp.

342{
343 return dynamic_cast< WaveTrack * >( mTrack.get() );
344}
A Track that contains audio waveform data.
Definition: WaveTrack.h:222

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 377 of file MixerBoard.cpp.

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

References kDoubleInset, kInset, kQuadrupleInset, mMeter, mSlider_Gain, mToggleButton_Solo, MUSICAL_INSTRUMENT_HEIGHT_AND_WIDTH, MUTE_SOLO_HEIGHT, PAN_HEIGHT, SoloBehaviorNone, TRACK_NAME_HEIGHT, and TracksBehaviorsSolo.

◆ HandleSelect()

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

Definition at line 710 of file MixerBoard.cpp.

711{
713 *mTrack, bShiftDown, bControlDown, true);
714}
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 416 of file MixerBoard.cpp.

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

References CONSOLIDATE, ProjectHistory::Get(), TrackPanel::Get(), ASlider::Get(), 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 445 of file MixerBoard.cpp.

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

References CONSOLIDATE, ProjectHistory::Get(), TrackPanel::Get(), ASlider::Get(), 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 751 of file MixerBoard.cpp.

752{
753 const auto &state = ::wxGetMouseState();
754 this->HandleSelect(state.ShiftDown(), state.ControlDown());
755}
void HandleSelect(bool bShiftDown, bool bControlDown)
Definition: MixerBoard.cpp:710

References HandleSelect().

Here is the call graph for this function:

◆ OnButton_Mute()

void MixerTrackCluster::OnButton_Mute ( wxCommandEvent &  event)
private

Definition at line 789 of file MixerBoard.cpp.

790{
793 mToggleButton_Mute->SetAlternateIdx(mTrack->GetSolo() ? 1 : 0);
794
795 // Update the TrackPanel correspondingly.
796 if (TracksBehaviorsSolo.ReadEnum() == SoloBehaviorSimple)
797 Viewport::Get(*mProject).Redraw();
798 else
799 // Update only the changed track.
800 TrackPanel::Get( *mProject ).RefreshTrack(mTrack.get());
801}
@ SoloBehaviorSimple
Definition: PlayableTrack.h:70
void SetAlternateIdx(unsigned idx)
Definition: AButton.cpp:232
bool WasShiftDown()
Definition: AButton.cpp:541
void Redraw()
Definition: Viewport.cpp:776
static Viewport & Get(AudacityProject &project)
Definition: Viewport.cpp:32
void DoTrackMute(AudacityProject &project, Track *t, bool exclusive)

References TrackUtilities::DoTrackMute(), Viewport::Get(), TrackPanel::Get(), mProject, mToggleButton_Mute, mTrack, Viewport::Redraw(), TrackPanel::RefreshTrack(), AButton::SetAlternateIdx(), SoloBehaviorSimple, TracksBehaviorsSolo, and AButton::WasShiftDown().

Here is the call graph for this function:

◆ OnButton_Solo()

void MixerTrackCluster::OnButton_Solo ( wxCommandEvent &  event)
private

Definition at line 803 of file MixerBoard.cpp.

804{
807 bool bIsSolo = mTrack->GetSolo();
808 mToggleButton_Mute->SetAlternateIdx(bIsSolo ? 1 : 0);
809
810 // Update the TrackPanel correspondingly.
811 // Bug 509: Must repaint all, as many tracks can change with one Solo change.
812 Viewport::Get(*mProject).Redraw();
813}
void DoTrackSolo(AudacityProject &project, Track *t, bool exclusive)

References TrackUtilities::DoTrackSolo(), Viewport::Get(), mProject, mToggleButton_Mute, mToggleButton_Solo, mTrack, Viewport::Redraw(), 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 716 of file MixerBoard.cpp.

717{
718 if (event.ButtonUp())
719 this->HandleSelect(event.ShiftDown(), event.ControlDown());
720 else
721 event.Skip();
722}

References HandleSelect().

Here is the call graph for this function:

◆ OnPaint()

void MixerTrackCluster::OnPaint ( wxPaintEvent &  evt)
private

Definition at line 724 of file MixerBoard.cpp.

725{
727
728 auto selected = mTrack->GetSelected();
729
730 wxColour col = theTheme.Colour(selected ? clrTrackInfoSelected : clrTrackInfo) ;
731 SetBackgroundColour( col );
732 if (mMeter)
733 mMeter->SetBackgroundColour( col );
734 mStaticText_TrackName->SetBackgroundColour( col );
737
738 wxPaintDC dc(this);
739
740 AColor::MediumTrackInfo(&dc, selected);
741 dc.DrawRectangle(this->GetClientRect());
742
743 wxSize clusterSize = this->GetSize();
744 wxRect bev(0, 0, clusterSize.GetWidth() - 1, clusterSize.GetHeight() - 1);
745
746 //bev.Inflate(-1, -1);
747 AColor::Bevel(dc, true, bev);// same bevel whether selected or not.
748}
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 757 of file MixerBoard.cpp.

758{
759 this->HandleSliderGain();
760}
void HandleSliderGain(const bool bWantPushState=false)
Definition: MixerBoard.cpp:416

References HandleSliderGain().

Here is the call graph for this function:

◆ OnSlider_Pan()

void MixerTrackCluster::OnSlider_Pan ( wxCommandEvent &  event)
private

Definition at line 784 of file MixerBoard.cpp.

785{
786 this->HandleSliderPan();
787}
void HandleSliderPan(const bool bWantPushState=false)
Definition: MixerBoard.cpp:445

References HandleSliderPan().

Here is the call graph for this function:

◆ ResetMeter()

void MixerTrackCluster::ResetMeter ( const bool  bResetClipping)

Definition at line 460 of file MixerBoard.cpp.

461{
462 if (mMeter)
463 mMeter->Reset(GetWave()->GetRate(), bResetClipping);
464 // Release view to allow cache eviction after/before playback.
465 mSampleView.clear();
466}
ChannelGroupSampleView mSampleView
Definition: MixerBoard.h:151
double GetRate(const Track &track)
Definition: TimeTrack.cpp:196

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

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 470 of file MixerBoard.cpp.

471{
472 const wxString newName = mTrack->GetName();
473 if (newName != GetName()) {
474 SetName( Verbatim( newName ) );
475 mStaticText_TrackName->SetLabel(newName);
476 mStaticText_TrackName->SetName(newName);
477#if wxUSE_TOOLTIPS
478 mStaticText_TrackName->SetToolTip(newName);
479#endif
480 mBitmapButton_MusicalInstrument->SetBitmapLabel(
482 }
483
484 mToggleButton_Mute->SetAlternateIdx(mTrack->GetSolo() ? 1 : 0);
485 if (mTrack->GetMute())
487 else
489
490 bool bIsSolo = mTrack->GetSolo();
491 if (bIsSolo)
493 else
495 mToggleButton_Mute->SetAlternateIdx(bIsSolo ? 1 : 0);
496
497 if (!GetWave())
498 mSlider_Pan->Hide();
499 else
500 mSlider_Pan->Set(GetWave()->GetPan());
501
502 if (!GetWave())
503 mSlider_Gain->Hide();
504 else
505 mSlider_Gain->Set(GetWave()->GetGain());
506
507#ifdef EXPERIMENTAL_MIDI_OUT
508 if (!GetNote())
509 mSlider_Velocity->Hide();
510 else
511 mSlider_Velocity->Set(GetNote()->GetVelocity());
512#endif
513}
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 538 of file MixerBoard.cpp.

539{
540 // NoteTracks do not (currently) register on meters. It would probably be
541 // a good idea to display 16 channel "active" lights rather than a meter
542 if (!GetWave())
543 return;
544
545 if ((t0 < 0.0) || (t1 < 0.0) || (t0 >= t1) || // bad time value or nothing to show
546 ((mMixerBoard->HasSolo() || mTrack->GetMute()) && !mTrack->GetSolo())
547 )
548 {
549 //v Vaughan, 2011-02-25: Moved the update back to TrackPanel::OnTimer() as it helps with
550 // playback issues reported by Bill and noted on Bug 258, so no assert.
551 // Vaughan, 2011-02-04: Now that we're updating all meters from audacityAudioCallback,
552 // this causes an assert if you click Mute while playing, because ResetMeter() resets
553 // the timer, and wxTimerbase says that can only be done from main thread --
554 // but it seems to work fine.
555 this->ResetMeter(false);
556 return;
557 }
558
559 // Vaughan, 2010-11-27:
560 // This commented out code is flawed. Mistaken understanding of "frame" vs "window".
561 // Caused me to override MeterPanel::UpdateDisplay().
562 // But I think it's got a good idea, of calling WaveTracks' GetMinMax and GetRMS
563 // instead of passing in all the data and asking the meter to derive peak and rms.
564 // May be worth revisiting as I think it should perform better, because it uses the min/max/rms
565 // stored in sample blocks, rather than calculating them, but for now, changing it to use the
566 // original MeterPanel::UpdateDisplay(). New code is below the previous (now commented out).
567 //
568 //const size_t kFramesPerBuffer = 4;
569 //float min; // dummy, since it's not shown in meters
570 //Floats maxLeft{kFramesPerBuffer};
571 //Floats rmsLeft{kFramesPerBuffer};
572 //Floats maxRight{kFramesPerBuffer};
573 //Floats rmsRight{kFramesPerBuffer};
574 //
575 //#ifdef EXPERIMENTAL_MIDI_OUT
576 // bool bSuccess = (GetWave() != nullptr);
577 //#else
578 // bool bSuccess = true;
579 //#endif
580
581 //const double dFrameInterval = (t1 - t0) / (double)kFramesPerBuffer;
582 //double dFrameT0 = t0;
583 //double dFrameT1 = t0 + dFrameInterval;
584 //int i = 0;
585 //while (bSuccess && (i < kFramesPerBuffer))
586 //{
587 // bSuccess &=
588 // mTrack->GetMinMax(&min, &(maxLeft[i]), dFrameT0, dFrameT1) &&
589 // mTrack->GetRMS(&(rmsLeft[i]), dFrameT0, dFrameT1);
590 // if (bSuccess && mRightTrack)
591 // bSuccess &=
592 // mRightTrack->GetMinMax(&min, &(maxRight[i]), dFrameT0, dFrameT1) &&
593 // mRightTrack->GetRMS(&(rmsRight[i]), dFrameT0, dFrameT1);
594 // else
595 // {
596 // // Mono: Start with raw values same as left.
597 // // To be modified by bWantPostFadeValues and channel pan/gain.
598 // maxRight[i] = maxLeft[i];
599 // rmsRight[i] = rmsLeft[i];
600 // }
601 // dFrameT0 += dFrameInterval;
602 // dFrameT1 += dFrameInterval;
603 // i++;
604 //}
605 //
606 //const bool bWantPostFadeValues = true; //v Turn this into a checkbox on MixerBoard? For now, always true.
607 //if (bSuccess && bWantPostFadeValues)
608 //if (bSuccess)
609 //{
610 // for (i = 0; i < kFramesPerBuffer; i++)
611 // {
612 // float gain = mTrack->GetChannelGain(0);
613 // maxLeft[i] *= gain;
614 // rmsLeft[i] *= gain;
615 // if (mRightTrack)
616 // gain = mRightTrack->GetChannelGain(1);
617 // maxRight[i] *= gain;
618 // rmsRight[i] *= gain;
619 // }
620 // if ( mMeter ) mMeter->UpdateDisplay(
621 // 2, // If mono, show left track values in both meters, as in MeterToolBar, rather than nChannels.
622 // kFramesPerBuffer,
623 // maxLeft, rmsLeft,
624 // maxRight, rmsRight,
625 // mTrack->TimeToLongSamples(t1 - t0));
626 //}
627 //
628
629 // PRL: TODO: don't fetch from wave tracks at calculated times, for update
630 // of the meter display, but instead consult PlaybackPolicy
631
632 const auto pTrack = GetWave();
633
634 // Don't throw on read error in this drawing update routine
635 constexpr auto mayThrow = false;
636
637 // Not sure how to prove satisfaction of the invariant of GetSampleView
638 mSampleView = pTrack->GetSampleView(t0, t1, mayThrow);
639
640 // Expect that the difference of t1 and t0 is the part of a track played
641 // in about 1/20 second (ticks of TrackPanel timer), so this won't overflow,
642 // unless stretch ratio is extremely low.
643 const auto nFrames = GetNumSamplesInView(mSampleView[0]);
644
645 Floats tempFloatsArray;
646 try {
647 tempFloatsArray.reinit(nFrames);
648 }
649 catch (const std::bad_alloc&) {
650 // Just in case we did not satisfy GetSampleView and computed a bogus
651 // size_t value
652 return;
653 }
654 FillBufferWithSampleView(tempFloatsArray.get(), mSampleView[0]);
655
656 decltype(tempFloatsArray) meterFloatsArray;
657 // We always pass a stereo sample array to the meter, as it shows 2 channels.
658 // Mono shows same in both meters.
659 // Since we're not mixing, need to duplicate same signal for "right" channel in mono case.
660 try {
661 meterFloatsArray.reinit(2 * nFrames );
662 }
663 catch (const std::bad_alloc&) {
664 // Just in case we did not satisfy GetSampleView and computed a bogus
665 // size_t value
666 return;
667 }
668
669 // Interleave for stereo. Left/mono first.
670 for (unsigned int index = 0; index < nFrames; index++)
671 meterFloatsArray[2 * index] = tempFloatsArray[index];
672
673 if (mSampleView.size() > 1u)
674 FillBufferWithSampleView(tempFloatsArray.get(), mSampleView[1]);
675
676 // Interleave right channel, or duplicate same signal for "right" channel in mono case.
677 for (unsigned int index = 0; index < nFrames; index++)
678 meterFloatsArray[(2 * index) + 1] = tempFloatsArray[index];
679
680 //const bool bWantPostFadeValues = true; //v Turn this into a checkbox on MixerBoard? For now, always true.
681 //if (bSuccess && bWantPostFadeValues)
682 //vvv Need to apply envelope, too? See Mixer::MixSameRate.
683 float gain = pTrack->GetChannelGain(0);
684 for (unsigned int index = 0; index < nFrames; index++)
685 meterFloatsArray[2 * index] *= gain;
686 gain = pTrack->GetChannelGain(1);
687 for (unsigned int index = 0; index < nFrames; index++)
688 meterFloatsArray[(2 * index) + 1] *= gain;
689 // Clip to [-1.0, 1.0] range.
690 for (unsigned int index = 0; index < 2 * nFrames; index++)
691 if (meterFloatsArray[index] < -1.0)
692 meterFloatsArray[index] = -1.0;
693 else if (meterFloatsArray[index] > 1.0)
694 meterFloatsArray[index] = 1.0;
695
696 if (mMeter)
697 mMeter->UpdateDisplay(2, nFrames, meterFloatsArray.get());
698}
void reinit(Integral count, bool initialize=false)
Definition: MemoryX.h:57
bool HasSolo()
void ResetMeter(const bool bResetClipping)
Definition: MixerBoard.cpp:460
size_t GetNumSamplesInView(const ChannelSampleView &view)
Definition: MixerBoard.cpp:516
void FillBufferWithSampleView(float *buffer, const ChannelSampleView &view)
Definition: MixerBoard.cpp:526

References anonymous_namespace{MixerBoard.cpp}::FillBufferWithSampleView(), anonymous_namespace{MixerBoard.cpp}::GetNumSamplesInView(), GetWave(), MixerBoard::HasSolo(), mMeter, mMixerBoard, mSampleView, mTrack, ArrayOf< X >::reinit(), and ResetMeter().

Here is the call graph for this function:

Member Data Documentation

◆ mBitmapButton_MusicalInstrument

wxBitmapButton* MixerTrackCluster::mBitmapButton_MusicalInstrument
private

Definition at line 142 of file MixerBoard.h.

Referenced by UpdateForStateChange().

◆ mMeter

wxWeakRef<MeterPanel> MixerTrackCluster::mMeter
private

Definition at line 150 of file MixerBoard.h.

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

◆ mMixerBoard

MixerBoard* MixerTrackCluster::mMixerBoard
private

Definition at line 137 of file MixerBoard.h.

Referenced by UpdateForStateChange(), and UpdateMeter().

◆ mProject

AudacityProject* MixerTrackCluster::mProject
private

◆ mSampleView

ChannelGroupSampleView MixerTrackCluster::mSampleView
private

Definition at line 151 of file MixerBoard.h.

Referenced by ResetMeter(), and UpdateMeter().

◆ mSlider_Gain

MixerTrackSlider* MixerTrackCluster::mSlider_Gain
private

Definition at line 146 of file MixerBoard.h.

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

◆ mSlider_Pan

MixerTrackSlider* MixerTrackCluster::mSlider_Pan
private

Definition at line 145 of file MixerBoard.h.

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

◆ mStaticText_TrackName

auStaticText* MixerTrackCluster::mStaticText_TrackName
private

Definition at line 141 of file MixerBoard.h.

Referenced by OnPaint(), and UpdateForStateChange().

◆ mToggleButton_Mute

AButton* MixerTrackCluster::mToggleButton_Mute
private

Definition at line 143 of file MixerBoard.h.

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

◆ mToggleButton_Solo

AButton* MixerTrackCluster::mToggleButton_Solo
private

Definition at line 144 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: