Audacity  3.0.3
WaveTrackControls.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 
3 Audacity: A Digital Audio Editor
4 
5 WaveTrackControls.cpp
6 
7 Paul Licameli split from TrackPanel.cpp
8 
9 **********************************************************************/
10 
11 
12 #include "WaveTrackControls.h"
13 
14 #include "../../ui/PlayableTrackButtonHandles.h"
15 #include "WaveTrackSliderHandles.h"
16 
17 #include "WaveTrackView.h"
18 #include "WaveTrackViewConstants.h"
19 #include "../../../../AudioIOBase.h"
20 #include "../../../../CellularPanel.h"
21 #include "../../../../Project.h"
22 #include "../../../../ProjectAudioIO.h"
23 #include "../../../../ProjectHistory.h"
24 #include "../../../../RefreshCode.h"
25 #include "../../../../ShuttleGui.h"
26 #include "../../../../TrackArtist.h"
27 #include "../../../../TrackPanel.h"
28 #include "../../../../TrackPanelAx.h"
29 #include "../../../../TrackPanelMouseEvent.h"
30 #include "../../../../WaveTrack.h"
31 #include "../../../../effects/RealtimeEffectManager.h"
32 #include "../../../../prefs/PrefsDialog.h"
33 #include "../../../../prefs/ThemePrefs.h"
34 #include "../../../../widgets/AudacityMessageBox.h"
35 #include "widgets/ProgressDialog.h"
36 #include "UserException.h"
37 #include "audacity/Types.h"
38 
39 #include <wx/combobox.h>
40 #include <wx/frame.h>
41 #include <wx/sizer.h>
42 
44 {
45 }
46 
47 
48 std::vector<UIHandlePtr> WaveTrackControls::HitTest
49 (const TrackPanelMouseState & st,
50  const AudacityProject *pProject)
51 {
52  // Hits are mutually exclusive, results single
53  const wxMouseState &state = st.state;
54  const wxRect &rect = st.rect;
55  if (state.ButtonIsDown(wxMOUSE_BTN_LEFT)) {
56  auto track = FindTrack();
57  std::vector<UIHandlePtr> results;
58  auto result = [&]{
59  UIHandlePtr result;
60  if (NULL != (result = MuteButtonHandle::HitTest(
61  mMuteHandle, state, rect, pProject, track)))
62  return result;
63 
64  if (NULL != (result = SoloButtonHandle::HitTest(
65  mSoloHandle, state, rect, pProject, track)))
66  return result;
67 
68  if (NULL != (result = GainSliderHandle::HitTest(
69  mGainHandle, state, rect, track)))
70  return result;
71 
72  if (NULL != (result = PanSliderHandle::HitTest(
73  mPanHandle, state, rect, track)))
74  return result;
75 
76  return result;
77  }();
78  if (result) {
79  results.push_back(result);
80  return results;
81  }
82  }
83 
84  return PlayableTrackControls::HitTest(st, pProject);
85 }
86 
88 {
89  return *static_cast< WaveTrack* >( mpData->pTrack );
90 };
91 
92 enum {
94 
95  OnRate8ID = 30000, // <---
96  OnRate11ID, // |
97  OnRate16ID, // |
98  OnRate22ID, // |
99  OnRate44ID, // |
100  OnRate48ID, // | Leave these in order
108  // |
109  On16BitID, // |
110  On24BitID, // |
111  OnFloatID, // <---
112 
114 
116 
120 
122 
126 
128 
129  // Range of ids for registered items -- keep this last!
131 };
132 
133 
134 namespace {
135 using ValueFinder = std::function< int( WaveTrack& ) >;
136 
137 // A function that makes functions that check and enable sub-menu items,
138 // parametrized by how you get the relevant value from a track's settings
139 template< typename Table >
141 {
142  return [findValue]( PopupMenuHandler &handler, wxMenu &menu, int id ){
143  auto pData = static_cast<Table&>( handler ).mpData;
144  const auto pTrack = static_cast<WaveTrack*>(pData->pTrack);
145  auto &project = pData->project;
146  bool unsafe = ProjectAudioIO::Get( project ).IsAudioActive();
147 
148  menu.Check( id, id == findValue( *pTrack ) );
149  menu.Enable( id, !unsafe );
150  };
151 };
152 }
153 
154 
155 //=============================================================================
156 // Table class for a sub-menu
158 {
160  : PopupMenuTable{ "SampleFormat", XO("&Format") }
161  {}
163 
164  static FormatMenuTable &Instance();
165 
166  void InitUserData(void *pUserData) override;
167 
168  void DestroyMenu() override
169  {
170  mpData = NULL;
171  }
172 
174 
175  static int IdOfFormat(int format);
176 
177  void OnFormatChange(wxCommandEvent & event);
178 };
179 
181 {
182  static FormatMenuTable instance;
183  return instance;
184 }
185 
186 void FormatMenuTable::InitUserData(void *pUserData)
187 {
188  mpData = static_cast<PlayableTrackControls::InitMenuData*>(pUserData);
189 }
190 
191 
193  static const auto fn = initFn< FormatMenuTable >(
194  []( WaveTrack &track ){
195  return IdOfFormat( track.GetSampleFormat() );
196  }
197  );
198 
200  GetSampleFormatStr(int16Sample), POPUP_MENU_FN( OnFormatChange ), fn );
202  GetSampleFormatStr( int24Sample), POPUP_MENU_FN( OnFormatChange ), fn );
204  GetSampleFormatStr(floatSample), POPUP_MENU_FN( OnFormatChange ), fn );
205 
207 
208 int FormatMenuTable::IdOfFormat(int format)
210 {
211  switch (format) {
212  case int16Sample:
213  return On16BitID;
214  case int24Sample:
215  return On24BitID;
216  case floatSample:
217  return OnFloatID;
218  default:
219  // ERROR -- should not happen
220  wxASSERT(false);
221  break;
222  }
223  return OnFloatID;// Compiler food.
224 }
225 
228 void FormatMenuTable::OnFormatChange(wxCommandEvent & event)
229 {
230  int id = event.GetId();
231  wxASSERT(id >= On16BitID && id <= OnFloatID);
232  const auto pTrack = static_cast<WaveTrack*>(mpData->pTrack);
233 
234  sampleFormat newFormat = int16Sample;
235 
236  switch (id) {
237  case On16BitID:
238  newFormat = int16Sample;
239  break;
240  case On24BitID:
241  newFormat = int24Sample;
242  break;
243  case OnFloatID:
244  newFormat = floatSample;
245  break;
246  default:
247  // ERROR -- should not happen
248  wxASSERT(false);
249  break;
250  }
251  if (newFormat == pTrack->GetSampleFormat())
252  return; // Nothing to do.
253 
254  AudacityProject *const project = &mpData->project;
255 
256  ProgressDialog progress{ XO("Changing sample format"),
257  XO("Processing... 0%%"),
259 
260  sampleCount totalSamples{ 0 };
261  for (const auto& channel : TrackList::Channels(pTrack))
262  totalSamples += channel->GetNumSamples();
263  sampleCount processedSamples{ 0 };
264 
265  // Below is the lambda function that is passed along the call chain to
266  // the Sequence::ConvertToSampleFormat. This callback function is used
267  // to report the conversion progress and update the progress dialog.
268  auto progressUpdate = [&progress, &totalSamples, &processedSamples]
269  (size_t newlyProcessedCount)->void
270  {
271  processedSamples += newlyProcessedCount;
272  double d_processed = processedSamples.as_double();
273  double d_total = totalSamples.as_double();
274  int percentage{ static_cast<int>((d_processed / d_total) * 100) };
275 
276  auto progressStatus = progress.Update(d_processed, d_total,
277  XO("Processing... %i%%").Format(percentage));
278 
279  if (progressStatus != ProgressResult::Success)
280  throw UserException{};
281  };
282 
283  for (auto channel : TrackList::Channels(pTrack))
284  channel->ConvertToSampleFormat(
285  newFormat, progressUpdate);
286 
287  ProjectHistory::Get( *project )
288  /* i18n-hint: The strings name a track and a format */
289  .PushState(XO("Changed '%s' to %s")
290  .Format( pTrack->GetName(), GetSampleFormatStr(newFormat) ),
291  XO("Format Change"));
292 
293  using namespace RefreshCode;
295 }
296 
297 
298 //=============================================================================
299 // Table class for a sub-menu
301 {
303  : PopupMenuTable{ "SampleRate", XO("Rat&e") }
304  {}
306 
307  static RateMenuTable &Instance();
308 
309  void InitUserData(void *pUserData) override;
310 
311  void DestroyMenu() override
312  {
313  mpData = NULL;
314  }
315 
317 
318  static int IdOfRate(int rate);
319  void SetRate(WaveTrack * pTrack, double rate);
320 
321  void OnRateChange(wxCommandEvent & event);
322  void OnRateOther(wxCommandEvent & event);
323 };
324 
326 {
327  static RateMenuTable instance;
328  return instance;
329 }
330 
331 void RateMenuTable::InitUserData(void *pUserData)
332 {
333  mpData = static_cast<PlayableTrackControls::InitMenuData*>(pUserData);
334 }
335 
336 // Because of Bug 1780 we can't use AppendRadioItem
337 // If we did, we'd get no message when clicking on Other...
338 // when it is already selected.
340  static const auto fn = initFn< RateMenuTable >(
341  []( WaveTrack &track ){
342  return IdOfRate( (int)track.GetRate() );
343  }
344  );
345 
346  AppendCheckItem( "8000", OnRate8ID, XXO("8000 Hz"), POPUP_MENU_FN( OnRateChange ), fn );
347  AppendCheckItem( "11025", OnRate11ID, XXO("11025 Hz"), POPUP_MENU_FN( OnRateChange ), fn );
348  AppendCheckItem( "16000", OnRate16ID, XXO("16000 Hz"), POPUP_MENU_FN( OnRateChange ), fn );
349  AppendCheckItem( "22050", OnRate22ID, XXO("22050 Hz"), POPUP_MENU_FN( OnRateChange ), fn );
350  AppendCheckItem( "44100", OnRate44ID, XXO("44100 Hz"), POPUP_MENU_FN( OnRateChange ), fn );
351  AppendCheckItem( "48000", OnRate48ID, XXO("48000 Hz"), POPUP_MENU_FN( OnRateChange ), fn );
352  AppendCheckItem( "88200", OnRate88ID, XXO("88200 Hz"), POPUP_MENU_FN( OnRateChange ), fn );
353  AppendCheckItem( "96000", OnRate96ID, XXO("96000 Hz"), POPUP_MENU_FN( OnRateChange ), fn );
354  AppendCheckItem( "176400", OnRate176ID, XXO("176400 Hz"), POPUP_MENU_FN( OnRateChange ), fn );
355  AppendCheckItem( "192000", OnRate192ID, XXO("192000 Hz"), POPUP_MENU_FN( OnRateChange ), fn );
356  AppendCheckItem( "352800", OnRate352ID, XXO("352800 Hz"), POPUP_MENU_FN( OnRateChange ), fn );
357  AppendCheckItem( "384000", OnRate384ID, XXO("384000 Hz"), POPUP_MENU_FN( OnRateChange ), fn );
358  AppendCheckItem( "Other", OnRateOtherID, XXO("&Other..."), POPUP_MENU_FN( OnRateOther ), fn );
359 
361 
362 const int nRates = 12;
363 
366 static int gRates[nRates] = { 8000, 11025, 16000, 22050, 44100, 48000, 88200, 96000,
367 176400, 192000, 352800, 384000 };
368 
371 {
372  for (int i = 0; i<nRates; i++) {
373  if (gRates[i] == rate)
374  return i + OnRate8ID;
375  }
376  return OnRateOtherID;
377 }
378 
381 void RateMenuTable::SetRate(WaveTrack * pTrack, double rate)
382 {
383  AudacityProject *const project = &mpData->project;
384  for (auto channel : TrackList::Channels(pTrack))
385  channel->SetRate(rate);
386 
387  // Separate conversion of "rate" enables changing the decimals without affecting i18n
388  wxString rateString = wxString::Format(wxT("%.3f"), rate);
389  ProjectHistory::Get( *project )
390  /* i18n-hint: The string names a track */
391  .PushState(XO("Changed '%s' to %s Hz")
392  .Format( pTrack->GetName(), rateString),
393  XO("Rate Change"));
394 }
395 
398 void RateMenuTable::OnRateChange(wxCommandEvent & event)
399 {
400  int id = event.GetId();
401  wxASSERT(id >= OnRate8ID && id <= OnRate384ID);
402  const auto pTrack = static_cast<WaveTrack*>(mpData->pTrack);
403 
404  SetRate(pTrack, gRates[id - OnRate8ID]);
405 
406  using namespace RefreshCode;
408 }
409 
410 void RateMenuTable::OnRateOther(wxCommandEvent &)
411 {
412  const auto pTrack = static_cast<WaveTrack*>(mpData->pTrack);
413 
414  int newRate;
415 
418  while (true)
419  {
420  wxDialogWrapper dlg(mpData->pParent, wxID_ANY, XO("Set Rate"));
421  dlg.SetName();
422  ShuttleGui S(&dlg, eIsCreating);
423  wxString rate;
424  wxComboBox *cb;
425 
426  rate.Printf(wxT("%ld"), lrint(pTrack->GetRate()));
427 
428  wxArrayStringEx rates{
429  wxT("8000") ,
430  wxT("11025") ,
431  wxT("16000") ,
432  wxT("22050") ,
433  wxT("44100") ,
434  wxT("48000") ,
435  wxT("88200") ,
436  wxT("96000") ,
437  wxT("176400") ,
438  wxT("192000") ,
439  wxT("352800") ,
440  wxT("384000") ,
441  };
442 
443  S.StartVerticalLay(true);
444  {
445  S.SetBorder(10);
446  S.StartHorizontalLay(wxEXPAND, false);
447  {
448  cb = S.AddCombo(XXO("New sample rate (Hz):"),
449  rate,
450  rates);
451 #if defined(__WXMAC__)
452  // As of wxMac-2.8.12, setting manually is required
453  // to handle rates not in the list. See: Bug #427
454  cb->SetValue(rate);
455 #endif
456  }
457  S.EndHorizontalLay();
458  S.AddStandardButtons();
459  }
460  S.EndVerticalLay();
461 
462  dlg.SetClientSize(dlg.GetSizer()->CalcMin());
463  dlg.Center();
464 
465  if (dlg.ShowModal() != wxID_OK)
466  {
467  return; // user cancelled dialog
468  }
469 
470  long lrate;
471  if (cb->GetValue().ToLong(&lrate) && lrate >= 1 && lrate <= 1000000)
472  {
473  newRate = (int)lrate;
474  break;
475  }
476 
478  XO("The entered value is invalid"),
479  XO("Error"),
480  wxICON_ERROR,
481  mpData->pParent);
482  }
483 
484  SetRate(pTrack, newRate);
485 
486  using namespace RefreshCode;
488 }
489 
490 static const auto MenuPathStart = wxT("WaveTrackMenu");
491 
492 //=============================================================================
493 // Class defining common command handlers for mono and stereo tracks
495  : ComputedPopupMenuTable< WaveTrackMenuTable, WaveTrackPopupMenuTable >
496 {
497  static WaveTrackMenuTable &Instance();
498 
501  MenuPathStart }
502  {
503  mNextId = FirstAttachedItemId;
504  }
505 
506  void InitUserData(void *pUserData) override;
507 
508  void DestroyMenu() override
509  {
510  //mpData = nullptr;
511  }
512 
514 
515  void OnMultiView(wxCommandEvent & event);
516  void OnSetDisplay(wxCommandEvent & event);
517 
518  void OnChannelChange(wxCommandEvent & event);
519  void OnMergeStereo(wxCommandEvent & event);
520 
521  // TODO: more-than-two-channels
522  // How should we define generalized channel manipulation operations?
523  void SplitStereo(bool stereo);
524 
525  void OnSwapChannels(wxCommandEvent & event);
526  void OnSplitStereo(wxCommandEvent & event);
527  void OnSplitStereoMono(wxCommandEvent & event);
528 };
529 
531 {
532  static WaveTrackMenuTable instance;
533  return instance;
534 }
535 
536 void WaveTrackMenuTable::InitUserData(void *pUserData)
537 {
538  mpData = static_cast<PlayableTrackControls::InitMenuData*>(pUserData);
539 }
540 
541 static std::vector<WaveTrackSubViewType> AllTypes()
542 {
543  auto result = WaveTrackSubViewType::All();
544  if ( result.size() > reserveDisplays ) {
545  wxASSERT( false );
546  result.resize( reserveDisplays );
547  }
548  return result;
549 }
550 
552  // Functions usable in callbacks to check and disable items
553  static const auto isMono =
554  []( PopupMenuHandler &handler ) -> bool {
555  auto &track =
556  static_cast< WaveTrackMenuTable& >( handler ).FindWaveTrack();
557  return 1 == TrackList::Channels( &track ).size();
558  };
559 
560  static const auto isUnsafe =
561  []( PopupMenuHandler &handler ) -> bool {
562  auto &project =
563  static_cast< WaveTrackMenuTable& >( handler ).mpData->project;
565  ProjectAudioIO::Get( project ).IsAudioActive();
566  };
567 
568  BeginSection( "SubViews" );
569  // Multi-view check mark item, if more than one track sub-view type is
570  // known
571  Append( []( My &table ) -> Registry::BaseItemPtr {
572  if ( WaveTrackSubViews::slots() > 1 )
573  return std::make_unique<Entry>(
574  "MultiView", Entry::CheckItem, OnMultiViewID, XXO("&Multi-view"),
575  POPUP_MENU_FN( OnMultiView ),
576  table,
577  []( PopupMenuHandler &handler, wxMenu &menu, int id ){
578  auto &table = static_cast< WaveTrackMenuTable& >( handler );
579  auto &track = table.FindWaveTrack();
580  const auto &view = WaveTrackView::Get( track );
581  menu.Check( id, view.GetMultiView() );
582  } );
583  else
584  return nullptr;
585  } );
586 
587  // Append either a checkbox or radio item for each sub-view.
588  // Radio buttons if in single-view mode, else checkboxes
589  int id = OnSetDisplayId;
590  for ( const auto &type : AllTypes() ) {
591  static const auto initFn = []( bool radio ){ return
592  [radio]( PopupMenuHandler &handler, wxMenu &menu, int id ){
593  // Find all known sub-view types
594  const auto allTypes = AllTypes();
595 
596  // How to convert a type to a menu item id
597  const auto IdForType =
598  [&allTypes]( const WaveTrackSubViewType &type ) -> int {
599  const auto begin = allTypes.begin();
600  return OnSetDisplayId +
601  (std::find( begin, allTypes.end(), type ) - begin);
602  };
603 
604  auto &table = static_cast< WaveTrackMenuTable& >( handler );
605  auto &track = table.FindWaveTrack();
606 
607  const auto &view = WaveTrackView::Get( track );
608 
609  const auto displays = view.GetDisplays();
610  const auto end = displays.end();
611  bool check = (end !=
612  std::find_if( displays.begin(), end,
613  [&]( const WaveTrackSubViewType &type ){
614  return id == IdForType( type ); } ) );
615  menu.Check( id, check );
616 
617  // Bug2275 residual
618  // Disable the checking-off of the only sub-view
619  if ( !radio && displays.size() == 1 && check )
620  menu.Enable( id, false );
621  };
622  };
623  Append( [type, id]( My &table ) -> Registry::BaseItemPtr {
624  const auto pTrack = &table.FindWaveTrack();
625  const auto &view = WaveTrackView::Get( *pTrack );
626  const auto itemType =
627  view.GetMultiView() ? Entry::CheckItem : Entry::RadioItem;
628  return std::make_unique<Entry>( type.name.Internal(), itemType,
629  id, type.name.Msgid(),
630  POPUP_MENU_FN( OnSetDisplay ), table,
631  initFn( !view.GetMultiView() ) );
632  } );
633  ++id;
634  }
635  BeginSection( "Extra" );
637  EndSection();
638 
639  BeginSection( "Channels" );
640  // If these are enabled again, choose a hot key for Mono that does not conflict
641  // with Multi View
642  // AppendRadioItem(OnChannelMonoID, XXO("&Mono"),
643  // POPUP_MENU_FN( OnChannelChange ),
644  // []( PopupMenuHandler &handler, wxMenu &menu, int id ){
645  // menu.Enable( id, isMono( handler ) );
646  // menu.Check( id, findTrack( handler ).GetChannel() == Track::MonoChannel );
647  // }
648  // );
649  // AppendRadioItem(OnChannelLeftID, XXO("&Left Channel"),
650  // POPUP_MENU_FN( OnChannelChange ),
651  // []( PopupMenuHandler &handler, wxMenu &menu, int id ){
652  // menu.Enable( id, isMono( handler ) );
653  // menu.Check( id, findTrack( handler ).GetChannel() == Track::LeftChannel );
654  // }
655  // );
656  // AppendRadioItem(OnChannelRightID, XXO("R&ight Channel"),
657  // POPUP_MENU_FN( OnChannelChange ),
658  // []( PopupMenuHandler &handler, wxMenu &menu, int id ){
659  // menu.Enable( id, isMono( handler ) );
660  // menu.Check( id, findTrack( handler ).GetChannel() == Track::RightChannel );
661  // }
662  // );
663  AppendItem( "MakeStereo", OnMergeStereoID, XXO("Ma&ke Stereo Track"),
664  POPUP_MENU_FN( OnMergeStereo ),
665  []( PopupMenuHandler &handler, wxMenu &menu, int id ){
666  bool canMakeStereo = !isUnsafe( handler ) && isMono( handler );
667  if ( canMakeStereo ) {
668  AudacityProject &project =
669  static_cast< WaveTrackMenuTable& >( handler ).mpData->project;
670  auto &tracks = TrackList::Get( project );
671  auto &table = static_cast< WaveTrackMenuTable& >( handler );
672  auto &track = table.FindWaveTrack();
673  auto next = * ++ tracks.Find(&track);
674  canMakeStereo =
675  (next &&
676  TrackList::Channels(next).size() == 1 &&
677  track_cast<WaveTrack*>(next));
678  }
679  menu.Enable( id, canMakeStereo );
680  }
681  );
682 
683  AppendItem( "Swap", OnSwapChannelsID, XXO("Swap Stereo &Channels"),
684  POPUP_MENU_FN( OnSwapChannels ),
685  []( PopupMenuHandler &handler, wxMenu &menu, int id ){
686  auto &track =
687  static_cast< WaveTrackMenuTable& >( handler ).FindWaveTrack();
688  bool isStereo =
689  2 == TrackList::Channels( &track ).size();
690  menu.Enable( id, isStereo && !isUnsafe( handler ) );
691  }
692  );
693 
694  static const auto enableSplitStereo =
695  []( PopupMenuHandler &handler, wxMenu &menu, int id ){
696  menu.Enable( id, !isMono( handler ) && !isUnsafe( handler ) );
697  };
698 
699  AppendItem( "Split", OnSplitStereoID, XXO("Spl&it Stereo Track"),
700  POPUP_MENU_FN( OnSplitStereo ), enableSplitStereo );
701  // DA: Uses split stereo track and then drag pan sliders for split-stereo-to-mono
702  #ifndef EXPERIMENTAL_DA
704  XXO("Split Stereo to Mo&no"), POPUP_MENU_FN( OnSplitStereoMono ),
706  #endif
707  EndSection();
708 
709  BeginSection( "Format" );
711  EndSection();
712 
713  BeginSection( "Rate" );
715  EndSection();
717 
718 
719 void WaveTrackMenuTable::OnMultiView(wxCommandEvent & event)
720 {
721  const auto pTrack = static_cast<WaveTrack*>(mpData->pTrack);
722  const auto &view = WaveTrackView::Get( *pTrack );
723  bool multi = !view.GetMultiView();
724  const auto &displays = view.GetDisplays();
725  const auto display = displays.empty()
726  ? WaveTrackViewConstants::Waveform : displays.begin()->id;
727  for (const auto channel : TrackList::Channels(pTrack)) {
728  auto &channelView = WaveTrackView::Get( *channel );
729  channelView.SetMultiView( multi );
730 
731  // Whichever sub-view was on top stays on top
732  // If going into Multi-view, it will be 1/nth the height.
733  // If exiting multi-view, it will be full height.
734  channelView.SetDisplay(display, !multi);
735  }
736 }
737 
739 void WaveTrackMenuTable::OnSetDisplay(wxCommandEvent & event)
740 {
741  int idInt = event.GetId();
742  wxASSERT(idInt >= OnSetDisplayId &&
743  idInt <= lastDisplayId);
744  const auto pTrack = static_cast<WaveTrack*>(mpData->pTrack);
745 
746  auto id = AllTypes()[ idInt - OnSetDisplayId ].id;
747 
748  auto &view = WaveTrackView::Get( *pTrack );
749  if ( view.GetMultiView() ) {
750  for (auto channel : TrackList::Channels(pTrack)) {
751  if ( !WaveTrackView::Get( *channel )
752  .ToggleSubView( WaveTrackView::Display{ id } ) ) {
753  // Trying to toggle off the last sub-view. It was refused.
754  // Decide what to do here. Turn off multi-view instead?
755  // PRL: I don't agree that it makes sense
756  }
757  else
759  }
760  }
761  else {
762  const auto displays = view.GetDisplays();
763  const bool wrongType =
764  !(displays.size() == 1 && displays[0].id == id);
765  if (wrongType) {
766  for (auto channel : TrackList::Channels(pTrack)) {
767  WaveTrackView::Get( *channel )
769  }
770 
771  AudacityProject *const project = &mpData->project;
772  ProjectHistory::Get( *project ).ModifyState(true);
773 
774  using namespace RefreshCode;
776  }
777  }
778 }
779 
780 #if 0
781 void WaveTrackMenuTable::OnChannelChange(wxCommandEvent & event)
782 {
783  int id = event.GetId();
784  wxASSERT(id >= OnChannelLeftID && id <= OnChannelMonoID);
785  WaveTrack *const pTrack = static_cast<WaveTrack*>(mpData->pTrack);
786  wxASSERT(pTrack);
787  Track::ChannelType channel;
788  TranslatableString channelmsg;
789  switch (id) {
790  default:
791  case OnChannelMonoID:
792  channel = Track::MonoChannel;
793  channelmsg = XO("Mono");
794  break;
795  case OnChannelLeftID:
796  channel = Track::LeftChannel;
797  channelmsg = XO("Left Channel");
798  break;
799  case OnChannelRightID:
800  channel = Track::RightChannel;
801  channelmsg = XO("Right Channel");
802  break;
803  }
804  pTrack->SetChannel(channel);
805  AudacityProject *const project = &mpData->project;
806  ProjectHistory::Get( *project )
807  .PushState(
808 /* i18n-hint: The strings name a track and a channel choice (mono, left, or right) */
809  XO("Changed '%s' to %s").Format( pTrack->GetName(), channelmsg ),
810  XO("Channel"));
812 }
813 #endif
814 
816 void WaveTrackMenuTable::OnMergeStereo(wxCommandEvent &)
817 {
818  AudacityProject *const project = &mpData->project;
819  auto &tracks = TrackList::Get( *project );
820 
821  WaveTrack *const pTrack = static_cast<WaveTrack*>(mpData->pTrack);
822  wxASSERT(pTrack);
823 
824  auto partner = static_cast< WaveTrack * >
825  ( *tracks.Find( pTrack ).advance( 1 ) );
826 
827  bool bBothMinimizedp =
828  ((TrackView::Get( *pTrack ).GetMinimized()) &&
829  (TrackView::Get( *partner ).GetMinimized()));
830 
831  tracks.GroupChannels( *pTrack, 2 );
832 
833  // Set partner's parameters to match target.
834  partner->Merge(*pTrack);
835 
836  pTrack->SetPan( 0.0f );
837  partner->SetPan( 0.0f );
838 
839  // Set NEW track heights and minimized state
840  auto
841  &view = WaveTrackView::Get( *pTrack ),
842  &partnerView = WaveTrackView::Get( *partner );
843  view.SetMinimized(false);
844  partnerView.SetMinimized(false);
845  int AverageHeight = (view.GetHeight() + partnerView.GetHeight()) / 2;
846  view.SetHeight(AverageHeight);
847  partnerView.SetHeight(AverageHeight);
848  view.SetMinimized(bBothMinimizedp);
849  partnerView.SetMinimized(bBothMinimizedp);
850 
851  partnerView.RestorePlacements( view.SavePlacements() );
852  partnerView.SetMultiView( view.GetMultiView() );
853 
854  ProjectHistory::Get( *project ).PushState(
855  /* i18n-hint: The string names a track */
856  XO("Made '%s' a stereo track").Format( pTrack->GetName() ),
857  XO("Make Stereo"));
858 
859  using namespace RefreshCode;
861 }
862 
865 {
866  WaveTrack *const pTrack = static_cast<WaveTrack*>(mpData->pTrack);
867  wxASSERT(pTrack);
868  AudacityProject *const project = &mpData->project;
869  auto channels = TrackList::Channels( pTrack );
870 
871  int totalHeight = 0;
872  int nChannels = 0;
873  for (auto channel : channels) {
874  // Keep original stereo track name.
875  channel->SetName(pTrack->GetName());
876  auto &view = TrackView::Get( *channel );
877  if (stereo)
878  channel->SetPanFromChannelType();
879 
880  //make sure no channel is smaller than its minimum height
881  if (view.GetHeight() < view.GetMinimizedHeight())
882  view.SetHeight(view.GetMinimizedHeight());
883  totalHeight += view.GetHeight();
884  ++nChannels;
885  }
886 
887  TrackList::Get( *project ).GroupChannels( *pTrack, 1 );
888  int averageHeight = totalHeight / nChannels;
889 
890  for (auto channel : channels)
891  // Make tracks the same height
892  TrackView::Get( *channel ).SetHeight( averageHeight );
893 }
894 
897 {
898  AudacityProject *const project = &mpData->project;
899 
900  WaveTrack *const pTrack = static_cast<WaveTrack*>(mpData->pTrack);
901  auto channels = TrackList::Channels( pTrack );
902  if (channels.size() != 2)
903  return;
904 
905  auto &trackFocus = TrackFocus::Get( *project );
906  Track *const focused = trackFocus.Get();
907  const bool hasFocus = channels.contains( focused );
908 
909  auto partner = *channels.rbegin();
910 
911  SplitStereo(false);
912 
913  auto &tracks = TrackList::Get( *project );
914  tracks.MoveUp( partner );
915  tracks.GroupChannels( *partner, 2 );
916 
917  if (hasFocus)
918  trackFocus.Set(partner);
919 
920  ProjectHistory::Get( *project ).PushState(
921  /* i18n-hint: The string names a track */
922  XO("Swapped Channels in '%s'").Format( pTrack->GetName() ),
923  XO("Swap Channels"));
924 
926 }
927 
929 void WaveTrackMenuTable::OnSplitStereo(wxCommandEvent &)
930 {
931  SplitStereo(true);
932  WaveTrack *const pTrack = static_cast<WaveTrack*>(mpData->pTrack);
933  AudacityProject *const project = &mpData->project;
934  ProjectHistory::Get( *project ).PushState(
935  /* i18n-hint: The string names a track */
936  XO("Split stereo track '%s'").Format( pTrack->GetName() ),
937  XO("Split"));
938 
939  using namespace RefreshCode;
941 }
942 
945 {
946  SplitStereo(false);
947  WaveTrack *const pTrack = static_cast<WaveTrack*>(mpData->pTrack);
948  AudacityProject *const project = &mpData->project;
949  ProjectHistory::Get( *project ).PushState(
950  /* i18n-hint: The string names a track */
951  XO("Split Stereo to Mono '%s'").Format( pTrack->GetName() ),
952  XO("Split to Mono"));
953 
954  using namespace RefreshCode;
956 }
957 
958 //=============================================================================
960 {
963  {
964  {wxT("/SubViews/Extra"), wxT("WaveColor,SpectrogramSettings")},
965  }
966  };
967 
969  return &result;
970 }
971 
973 {
975 }
976 
977 // drawing related
978 #include "../../../../widgets/ASlider.h"
979 #include "../../../../TrackInfo.h"
980 #include "../../../../TrackPanelDrawingContext.h"
981 #include "../../../../ViewInfo.h"
982 
983 namespace {
984 
986 ( LWSlider *(*Selector)
987  (const wxRect &sliderRect, const WaveTrack *t, bool captured, wxWindow*),
988  wxDC *dc, const wxRect &rect, const Track *pTrack,
989  wxWindow *pParent,
990  bool captured, bool highlight )
991 {
992  wxRect sliderRect = rect;
993  TrackInfo::GetSliderHorizontalBounds( rect.GetTopLeft(), sliderRect );
994  auto wt = static_cast<const WaveTrack*>( pTrack );
995  Selector( sliderRect, wt, captured, pParent )->OnPaint(*dc, highlight);
996 }
997 
999 ( TrackPanelDrawingContext &context,
1000  const wxRect &rect, const Track *pTrack )
1001 {
1002  auto target = dynamic_cast<PanSliderHandle*>( context.target.get() );
1003  auto dc = &context.dc;
1004  bool hit = target && target->GetTrack().get() == pTrack;
1005  bool captured = hit && target->IsClicked();
1006 
1007  const auto artist = TrackArtist::Get( context );
1008  auto pParent = FindProjectFrame( artist->parent->GetProject() );
1009 
1011  &WaveTrackControls::PanSlider, dc, rect, pTrack,
1012  pParent, captured, hit);
1013 }
1014 
1016 ( TrackPanelDrawingContext &context,
1017  const wxRect &rect, const Track *pTrack )
1018 {
1019  auto target = dynamic_cast<GainSliderHandle*>( context.target.get() );
1020  auto dc = &context.dc;
1021  bool hit = target && target->GetTrack().get() == pTrack;
1022  if( hit )
1023  hit=hit;
1024  bool captured = hit && target->IsClicked();
1025 
1026  const auto artist = TrackArtist::Get( context );
1027  auto pParent = FindProjectFrame( artist->parent->GetProject() );
1028 
1030  &WaveTrackControls::GainSlider, dc, rect, pTrack,
1031  pParent, captured, hit);
1032 }
1033 
1035  ( const TranslatableString &string, wxDC *dc, const wxRect &rect )
1036 {
1037  static const int offset = 3;
1038  dc->DrawText(string.Translation(), rect.x + offset, rect.y);
1039 }
1040 
1042 ( TrackPanelDrawingContext &context,
1043  const wxRect &rect, const Track *pTrack )
1044 {
1045  auto dc = &context.dc;
1046  auto wt = static_cast<const WaveTrack*>(pTrack);
1047 
1051  auto rate = wt ? wt->GetRate() : 44100.0;
1053  if (!pTrack || TrackList::Channels(pTrack).size() > 1)
1054  // TODO: more-than-two-channels-message
1055  // more appropriate strings
1056  s = XO("Stereo, %dHz");
1057  else {
1058  if (wt->GetChannel() == Track::MonoChannel)
1059  s = XO("Mono, %dHz");
1060  else if (wt->GetChannel() == Track::LeftChannel)
1061  s = XO("Left, %dHz");
1062  else if (wt->GetChannel() == Track::RightChannel)
1063  s = XO("Right, %dHz");
1064  }
1065  s.Format( (int) (rate + 0.5) );
1066 
1067  StatusDrawFunction( s, dc, rect );
1068 }
1069 
1071 ( TrackPanelDrawingContext &context,
1072  const wxRect &rect, const Track *pTrack )
1073 {
1074  auto dc = &context.dc;
1075  auto wt = static_cast<const WaveTrack*>(pTrack);
1076  auto format = wt ? wt->GetSampleFormat() : floatSample;
1077  auto s = GetSampleFormatStr(format);
1078  StatusDrawFunction( s, dc, rect );
1079 }
1080 
1081 }
1082 
1084 
1085 static const struct WaveTrackTCPLines
1087  (TCPLines&)*this =
1089  insert( end(), {
1090 
1095 
1096 #ifdef EXPERIMENTAL_DA
1097  // DA: Does not have status information for a track.
1098 #else
1099  { TCPLine::kItemStatusInfo1, 12, 0,
1101  { TCPLine::kItemStatusInfo2, 12, 0,
1103 #endif
1104 
1105  } );
1107 
1108 void WaveTrackControls::GetGainRect(const wxPoint &topleft, wxRect & dest)
1109 {
1110  TrackInfo::GetSliderHorizontalBounds( topleft, dest );
1111  auto results = CalcItemY( waveTrackTCPLines, TCPLine::kItemGain );
1112  dest.y = topleft.y + results.first;
1113  dest.height = results.second;
1114 }
1115 
1116 void WaveTrackControls::GetPanRect(const wxPoint &topleft, wxRect & dest)
1117 {
1118  GetGainRect( topleft, dest );
1119  auto results = CalcItemY( waveTrackTCPLines, TCPLine::kItemPan );
1120  dest.y = topleft.y + results.first;
1121 }
1122 
1124 {
1126 }
1127 
1129 {
1130  return waveTrackTCPLines;
1131 }
1132 
1133 namespace
1134 {
1135 std::unique_ptr<LWSlider>
1139  , gPan;
1140 }
1141 
1143  CellularPanel &panel, const WaveTrack &wt )
1144 {
1145  auto &controls = TrackControls::Get( wt );
1146  auto rect = panel.FindRect( controls );
1147  wxRect sliderRect;
1148  GetGainRect( rect.GetTopLeft(), sliderRect );
1149  return GainSlider( sliderRect, &wt, false, &panel );
1150 }
1151 
1153 (const wxRect &sliderRect, const WaveTrack *t, bool captured, wxWindow *pParent)
1154 {
1155  static std::once_flag flag;
1156  std::call_once( flag, [] {
1157  wxCommandEvent dummy;
1158  ReCreateGainSlider( dummy );
1159  wxTheApp->Bind(EVT_THEME_CHANGE, ReCreateGainSlider);
1160  } );
1161 
1162  wxPoint pos = sliderRect.GetPosition();
1163  float gain = t ? t->GetGain() : 1.0;
1164 
1165  gGain->Move(pos);
1166  gGain->Set(gain);
1167  gGainCaptured->Move(pos);
1168  gGainCaptured->Set(gain);
1169 
1170  auto slider = (captured ? gGainCaptured : gGain).get();
1171  slider->SetParent( pParent );
1172  return slider;
1173 }
1174 
1176 {
1177  event.Skip();
1178 
1179  const wxPoint point{ 0, 0 };
1180  wxRect sliderRect;
1181  GetGainRect(point, sliderRect);
1182 
1183  float defPos = 1.0;
1184  /* i18n-hint: Title of the Gain slider, used to adjust the volume */
1185  gGain = std::make_unique<LWSlider>(nullptr, XO("Gain"),
1186  wxPoint(sliderRect.x, sliderRect.y),
1187  wxSize(sliderRect.width, sliderRect.height),
1188  DB_SLIDER);
1189  gGain->SetDefaultValue(defPos);
1190 
1191  gGainCaptured = std::make_unique<LWSlider>(nullptr, XO("Gain"),
1192  wxPoint(sliderRect.x, sliderRect.y),
1193  wxSize(sliderRect.width, sliderRect.height),
1194  DB_SLIDER);
1195  gGainCaptured->SetDefaultValue(defPos);
1196 }
1197 
1199  CellularPanel &panel, const WaveTrack &wt )
1200 {
1201  auto &controls = TrackControls::Get( wt );
1202  auto rect = panel.FindRect( controls );
1203  wxRect sliderRect;
1204  GetPanRect( rect.GetTopLeft(), sliderRect );
1205  return PanSlider( sliderRect, &wt, false, &panel );
1206 }
1207 
1209 (const wxRect &sliderRect, const WaveTrack *t, bool captured, wxWindow *pParent)
1210 {
1211  static std::once_flag flag;
1212  std::call_once( flag, [] {
1213  wxCommandEvent dummy;
1214  ReCreatePanSlider( dummy );
1215  wxTheApp->Bind(EVT_THEME_CHANGE, ReCreatePanSlider);
1216  } );
1217 
1218  wxPoint pos = sliderRect.GetPosition();
1219  float pan = t ? t->GetPan() : 0.0;
1220 
1221  gPan->Move(pos);
1222  gPan->Set(pan);
1223  gPanCaptured->Move(pos);
1224  gPanCaptured->Set(pan);
1225 
1226  auto slider = (captured ? gPanCaptured : gPan).get();
1227  slider->SetParent( pParent );
1228  return slider;
1229 }
1230 
1232 {
1233  event.Skip();
1234 
1235  const wxPoint point{ 0, 0 };
1236  wxRect sliderRect;
1237  GetPanRect(point, sliderRect);
1238 
1239  float defPos = 0.0;
1240  /* i18n-hint: Title of the Pan slider, used to move the sound left or right */
1241  gPan = std::make_unique<LWSlider>(nullptr, XO("Pan"),
1242  wxPoint(sliderRect.x, sliderRect.y),
1243  wxSize(sliderRect.width, sliderRect.height),
1244  PAN_SLIDER);
1245  gPan->SetDefaultValue(defPos);
1246 
1247  gPanCaptured = std::make_unique<LWSlider>(nullptr, XO("Pan"),
1248  wxPoint(sliderRect.x, sliderRect.y),
1249  wxSize(sliderRect.width, sliderRect.height),
1250  PAN_SLIDER);
1251  gPanCaptured->SetDefaultValue(defPos);
1252 }
1253 
1255 template<> template<> auto DoGetWaveTrackControls::Implementation() -> Function {
1256  return [](WaveTrack &track) {
1257  return std::make_shared<WaveTrackControls>( track.SharedPointer() );
1258  };
1259 }
1261 
1263 template<> template<>
1264 auto GetDefaultWaveTrackHeight::Implementation() -> Function {
1265  return [](WaveTrack &) {
1267  };
1268 }
1270 
FormatMenuTable::mpData
PlayableTrackControls::InitMenuData * mpData
Definition: WaveTrackControls.cpp:173
lastDisplayId
@ lastDisplayId
Definition: WaveTrackControls.cpp:115
OnRate96ID
@ OnRate96ID
Definition: WaveTrackControls.cpp:102
GainSliderHandle::HitTest
static UIHandlePtr HitTest(std::weak_ptr< GainSliderHandle > &holder, const wxMouseState &state, const wxRect &rect, const std::shared_ptr< Track > &pTrack)
Definition: WaveTrackSliderHandles.cpp:89
ProjectHistory::ModifyState
void ModifyState(bool bWantsAutoSave)
Definition: ProjectHistory.cpp:123
TranslatableString
Definition: Types.h:290
WaveTrackMenuTable::WaveTrackMenuTable
WaveTrackMenuTable()
Definition: WaveTrackControls.cpp:499
RefreshCode::FixScrollbars
@ FixScrollbars
Definition: RefreshCode.h:27
WaveTrackControls::~WaveTrackControls
~WaveTrackControls()
Definition: WaveTrackControls.cpp:43
OnRate16ID
@ OnRate16ID
Definition: WaveTrackControls.cpp:97
anonymous_namespace{WaveTrackControls.cpp}::gGainCaptured
std::unique_ptr< LWSlider > gGainCaptured
Definition: WaveTrackControls.cpp:1137
anonymous_namespace{WaveTrackControls.cpp}::Status2DrawFunction
void Status2DrawFunction(TrackPanelDrawingContext &context, const wxRect &rect, const Track *pTrack)
Definition: WaveTrackControls.cpp:1071
eIsCreating
@ eIsCreating
Definition: ShuttleGui.h:36
WaveTrackMenuTable::OnSetDisplay
void OnSetDisplay(wxCommandEvent &event)
Set the Display mode based on the menu choice in the Track Menu.
Definition: WaveTrackControls.cpp:739
MuteButtonHandle::HitTest
static UIHandlePtr HitTest(std::weak_ptr< MuteButtonHandle > &holder, const wxMouseState &state, const wxRect &rect, const AudacityProject *pProject, const std::shared_ptr< Track > &pTrack)
Definition: PlayableTrackButtonHandles.cpp:59
WaveTrackMenuTable::OnSwapChannels
void OnSwapChannels(wxCommandEvent &event)
Swap the left and right channels of a stero track...
Definition: WaveTrackControls.cpp:896
ShuttleGuiBase::StartVerticalLay
void StartVerticalLay(int iProp=1)
Definition: ShuttleGui.cpp:1177
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:68
RateMenuTable::OnRateOther
void OnRateOther(wxCommandEvent &event)
Definition: WaveTrackControls.cpp:410
Track::RightChannel
static const auto RightChannel
Definition: Track.h:266
kTrackInfoSliderHeight
@ kTrackInfoSliderHeight
Definition: ViewInfo.h:112
ClientData::Site::slots
static size_t slots()
How many static factories have been registered with this specialization of Site.
Definition: ClientData.h:258
WaveTrackControls::ReCreatePanSlider
static void ReCreatePanSlider(wxEvent &)
Definition: WaveTrackControls.cpp:1231
OnRateOtherID
@ OnRateOtherID
Definition: WaveTrackControls.cpp:107
TCPLines
TrackInfo::TCPLines TCPLines
Definition: TrackInfo.cpp:102
RefreshCode::RefreshAll
@ RefreshAll
Definition: RefreshCode.h:26
TrackView::Get
static TrackView & Get(Track &)
Definition: TrackView.cpp:63
nRates
const int nRates
Definition: WaveTrackControls.cpp:362
flag
static std::once_flag flag
Definition: WaveformView.cpp:1113
ClientData::Site::Find
Subclass * Find(const RegisteredFactory &key)
Get a (bare) pointer to an attachment, or null, down-cast it to Subclass *; will not create on demand...
Definition: ClientData.h:333
UserException
Can be thrown when user cancels operations, as with a progress dialog. Delayed handler does nothing.
Definition: UserException.h:17
TrackView::GetMinimized
bool GetMinimized() const
Definition: TrackView.h:49
AudacityMessageBox
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption=AudacityMessageBoxCaptionStr(), long style=wxOK|wxCENTRE, wxWindow *parent=NULL, int x=wxDefaultCoord, int y=wxDefaultCoord)
Definition: AudacityMessageBox.h:20
FormatMenuTable::Instance
static FormatMenuTable & Instance()
Definition: WaveTrackControls.cpp:180
ChannelMenuID
@ ChannelMenuID
Definition: WaveTrackControls.cpp:127
Track::GetName
wxString GetName() const
Definition: Track.h:409
WaveTrackMenuTable::OnChannelChange
void OnChannelChange(wxCommandEvent &event)
PopupMenuTable
Definition: PopupMenuTable.h:104
FormatMenuTable::DECLARE_POPUP_MENU
DECLARE_POPUP_MENU(FormatMenuTable)
int24Sample
@ int24Sample
Definition: Types.h:721
ClientData::Site::Get
Subclass & Get(const RegisteredFactory &key)
Get reference to an attachment, creating on demand if not present, down-cast it to Subclass.
Definition: ClientData.h:309
TrackControls::Get
static TrackControls & Get(Track &track)
Definition: TrackControls.cpp:25
PopupMenuTableEntry::InitFunction
std::function< void(PopupMenuHandler &handler, wxMenu &menu, int id) > InitFunction
Definition: PopupMenuTable.h:38
CommonTrackPanelCell::FindTrack
std::shared_ptr< Track > FindTrack()
Definition: CommonTrackPanelCell.h:44
pdlgHideStopButton
@ pdlgHideStopButton
Definition: ProgressDialog.h:43
TrackPanelDrawingContext
Definition: TrackPanelDrawingContext.h:22
TrackList::Channels
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1467
Format
Abstract base class used in importing a file.
TrackInfo::TCPLine::kItemGain
@ kItemGain
Definition: TrackInfo.h:43
WaveTrackControls::mPanHandle
std::weak_ptr< PanSliderHandle > mPanHandle
Definition: WaveTrackControls.h:68
PopupMenuTable::EndSection
void EndSection()
Definition: PopupMenuTable.cpp:177
Track::SharedPointer
std::shared_ptr< Subclass > SharedPointer()
Definition: Track.h:279
anonymous_namespace{WaveTrackControls.cpp}::Status1DrawFunction
void Status1DrawFunction(TrackPanelDrawingContext &context, const wxRect &rect, const Track *pTrack)
Definition: WaveTrackControls.cpp:1042
enableSplitStereo
static const auto enableSplitStereo
Definition: WaveTrackControls.cpp:694
TrackView::SetHeight
void SetHeight(int height)
Definition: TrackView.cpp:153
AllTypes
static std::vector< WaveTrackSubViewType > AllTypes()
Definition: WaveTrackControls.cpp:541
TrackInfo::CalcItemY
AUDACITY_DLL_API std::pair< int, int > CalcItemY(const TCPLines &lines, unsigned iItem)
Definition: TrackInfo.cpp:146
XO
#define XO(s)
Definition: Internat.h:32
OnRate11ID
@ OnRate11ID
Definition: WaveTrackControls.cpp:96
WaveTrackControls::DefaultWaveTrackHeight
static unsigned DefaultWaveTrackHeight()
Definition: WaveTrackControls.cpp:1123
ProgressDialog.h
TrackPanelDrawingContext::dc
wxDC & dc
Definition: TrackPanelDrawingContext.h:23
anonymous_namespace{WaveTrackControls.cpp}::ValueFinder
std::function< int(WaveTrack &) > ValueFinder
Definition: WaveTrackControls.cpp:135
CommonTrackControls::InitMenuData::result
unsigned result
Definition: CommonTrackControls.h:39
floatSample
@ floatSample
Definition: Types.h:722
OnChannelLeftID
@ OnChannelLeftID
Definition: WaveTrackControls.cpp:117
RateMenuTable::Instance
static RateMenuTable & Instance()
Definition: WaveTrackControls.cpp:325
CellularPanel::FindRect
wxRect FindRect(const TrackPanelCell &cell)
Definition: CellularPanel.cpp:1068
POPUP_MENU_SUB_MENU
#define POPUP_MENU_SUB_MENU(stringId, classname, pUserData)
Definition: PopupMenuTable.h:315
WaveTrackViewConstants::Display
Display
Definition: WaveTrackViewConstants.h:18
ProjectAudioIO::Get
static ProjectAudioIO & Get(AudacityProject &project)
Definition: ProjectAudioIO.cpp:23
OnSwapChannelsID
@ OnSwapChannelsID
Definition: WaveTrackControls.cpp:123
OnRate192ID
@ OnRate192ID
Definition: WaveTrackControls.cpp:104
PopupMenuTableEntry::RadioItem
@ RadioItem
Definition: PopupMenuTable.h:36
PanSliderHandle
Definition: WaveTrackSliderHandles.h:56
wxArrayStringEx
Definition: MemoryX.h:663
TrackPanelMouseState::rect
const wxRect & rect
Definition: TrackPanelMouseEvent.h:39
PopupMenuTable::BeginSection
void BeginSection(const Identifier &name)
Definition: PopupMenuTable.cpp:169
GetWaveTrackMenuTable
WaveTrackPopupMenuTable & GetWaveTrackMenuTable()
Definition: WaveTrackControls.cpp:972
ProjectAudioIO::IsAudioActive
bool IsAudioActive() const
Definition: ProjectAudioIO.cpp:52
PAN_SLIDER
#define PAN_SLIDER
Definition: ASlider.h:34
gRates
static int gRates[nRates]
Definition: WaveTrackControls.cpp:366
OnRate384ID
@ OnRate384ID
Definition: WaveTrackControls.cpp:106
CommonTrackControls::InitMenuData::project
AudacityProject & project
Definition: CommonTrackControls.h:36
WaveTrackControls::GetGainRect
static void GetGainRect(const wxPoint &topLeft, wxRect &dest)
Definition: WaveTrackControls.cpp:1108
WaveTrackView.h
WaveTrack::Merge
void Merge(const Track &orig) override
Definition: WaveTrack.cpp:186
FormatMenuTable::DestroyMenu
void DestroyMenu() override
Definition: WaveTrackControls.cpp:168
On16BitID
@ On16BitID
Definition: WaveTrackControls.cpp:109
RateMenuTable
Definition: WaveTrackControls.cpp:301
anonymous_namespace{WaveTrackControls.cpp}::SliderDrawFunction
void SliderDrawFunction(LWSlider *(*Selector)(const wxRect &sliderRect, const WaveTrack *t, bool captured, wxWindow *), wxDC *dc, const wxRect &rect, const Track *pTrack, wxWindow *pParent, bool captured, bool highlight)
Definition: WaveTrackControls.cpp:986
OnRate8ID
@ OnRate8ID
Definition: WaveTrackControls.cpp:95
WaveTrackControls::GetPanRect
static void GetPanRect(const wxPoint &topLeft, wxRect &dest)
Definition: WaveTrackControls.cpp:1116
AttachedVirtualFunction::Override::Implementation
static Function Implementation()
A function returning a std::function that must be defined so that the program links.
Definition: LabelTrackControls.cpp:182
RateMenuTable::InitUserData
void InitUserData(void *pUserData) override
Definition: WaveTrackControls.cpp:331
isUnsafe
static const auto isUnsafe
Definition: WaveTrackControls.cpp:560
fn
static const auto fn
Definition: WaveTrackControls.cpp:193
sampleFormat
sampleFormat
Definition: Types.h:717
TrackArtist::Get
static TrackArtist * Get(TrackPanelDrawingContext &)
Definition: TrackArtist.cpp:75
reserveDisplays
@ reserveDisplays
Definition: WaveTrackControls.cpp:93
XXO
#define XXO(s)
Definition: Internat.h:45
Registry::BaseItemPtr
std::unique_ptr< BaseItem > BaseItemPtr
Definition: Registry.h:71
ShuttleGuiBase::EndHorizontalLay
void EndHorizontalLay()
Definition: ShuttleGui.cpp:1170
ProgressDialog
ProgressDialog Class.
Definition: ProgressDialog.h:56
TrackInfo::TCPLine::kItemStatusInfo2
@ kItemStatusInfo2
Definition: TrackInfo.h:49
sampleCount::as_double
double as_double() const
Definition: Types.h:616
RateMenuTable::DECLARE_POPUP_MENU
DECLARE_POPUP_MENU(RateMenuTable)
WaveTrackSubViewType
Definition: WaveTrackViewConstants.h:91
WaveTrackControls::mGainHandle
std::weak_ptr< GainSliderHandle > mGainHandle
Definition: WaveTrackControls.h:67
OnSetDisplayId
@ OnSetDisplayId
Definition: WaveTrackControls.cpp:115
LWSlider
Lightweight version of ASlider. In other words it does not have a window permanently associated with ...
Definition: ASlider.h:62
ShuttleGuiBase::StartHorizontalLay
void StartHorizontalLay(int PositionFlags=wxALIGN_CENTRE, int iProp=1)
Definition: ShuttleGui.cpp:1160
ProgressResult::Success
@ Success
CommonTrackControls::HitTest
virtual std::vector< UIHandlePtr > HitTest(const TrackPanelMouseState &state, const AudacityProject *) override=0
Definition: CommonTrackControls.cpp:35
anonymous_namespace{SpectrumView.cpp}::findValue
static float findValue(const float *spectrum, float bin0, float bin1, unsigned nBins, bool autocorrelation, int gain, int range)
Definition: SpectrumView.cpp:95
ShuttleGuiBase::EndVerticalLay
void EndVerticalLay()
Definition: ShuttleGui.cpp:1196
OnSplitStereoMonoID
@ OnSplitStereoMonoID
Definition: WaveTrackControls.cpp:125
RateMenuTable::SetRate
void SetRate(WaveTrack *pTrack, double rate)
Definition: WaveTrackControls.cpp:381
WaveTrackMenuTable::DECLARE_POPUP_MENU
DECLARE_POPUP_MENU(WaveTrackMenuTable)
OnRate176ID
@ OnRate176ID
Definition: WaveTrackControls.cpp:103
Track::MonoChannel
static const auto MonoChannel
Definition: Track.h:267
RateMenuTable::RateMenuTable
RateMenuTable()
Definition: WaveTrackControls.cpp:302
FindProjectFrame
wxFrame * FindProjectFrame(AudacityProject *project)
Get a pointer to the window associated with a project, or null if the given pointer is null.
Definition: Project.h:172
WaveTrackMenuTable::SplitStereo
void SplitStereo(bool stereo)
Split a stereo track (or more-than-stereo?) into two (or more) tracks...
Definition: WaveTrackControls.cpp:864
PopupMenuTable::AppendItem
void AppendItem(const Identifier &stringId, int id, const TranslatableString &string, wxCommandEventFunction memFn, const PopupMenuTableEntry::InitFunction &init={})
Definition: PopupMenuTable.h:191
PopupMenuTable::AppendCheckItem
void AppendCheckItem(const Identifier &stringId, int id, const TranslatableString &string, wxCommandEventFunction memFn, const PopupMenuTableEntry::InitFunction &init={})
Definition: PopupMenuTable.h:203
anonymous_namespace{WaveTrackControls.cpp}::gGain
std::unique_ptr< LWSlider > gGain
Definition: WaveTrackControls.cpp:1139
PanSliderHandle::HitTest
static UIHandlePtr HitTest(std::weak_ptr< PanSliderHandle > &holder, const wxMouseState &state, const wxRect &rect, const std::shared_ptr< Track > &pTrack)
Definition: WaveTrackSliderHandles.cpp:200
UIHandlePtr
std::shared_ptr< UIHandle > UIHandlePtr
Definition: CellularPanel.h:28
FormatMenuTable
Definition: WaveTrackControls.cpp:158
anonymous_namespace{WaveTrackControls.cpp}::gPan
std::unique_ptr< LWSlider > gPan
Definition: WaveTrackControls.cpp:1139
format
int format
Definition: ExportPCM.cpp:54
WaveTrackSubViewType::All
static const std::vector< WaveTrackSubViewType > & All()
Discover all registered types.
Definition: WaveTrackViewConstants.cpp:90
WaveTrackControls::GainSlider
static LWSlider * GainSlider(CellularPanel &panel, const WaveTrack &wt)
Definition: WaveTrackControls.cpp:1142
WaveTrackControls::mSoloHandle
std::weak_ptr< SoloButtonHandle > mSoloHandle
Definition: WaveTrackControls.h:66
TrackInfo::TCPLine::kItemStatusInfo1
@ kItemStatusInfo1
Definition: TrackInfo.h:40
DB_SLIDER
#define DB_SLIDER
Definition: ASlider.h:33
Track::LeftChannel
static const auto LeftChannel
Definition: Track.h:265
TrackFocus::Get
Track * Get()
Definition: TrackPanelAx.cpp:755
RefreshCode::UpdateVRuler
@ UpdateVRuler
Definition: RefreshCode.h:30
WaveTrackControls::ReCreateGainSlider
static void ReCreateGainSlider(wxEvent &)
Definition: WaveTrackControls.cpp:1175
PopupMenuTableEntry::CheckItem
@ CheckItem
Definition: PopupMenuTable.h:36
WaveTrack::GetGain
float GetGain() const
Definition: WaveTrack.cpp:377
anonymous_namespace{WaveTrackControls.cpp}::PanSliderDrawFunction
void PanSliderDrawFunction(TrackPanelDrawingContext &context, const wxRect &rect, const Track *pTrack)
Definition: WaveTrackControls.cpp:999
On24BitID
@ On24BitID
Definition: WaveTrackControls.cpp:110
CommonTrackControls::InitMenuData
Definition: CommonTrackControls.h:34
anonymous_namespace{WaveTrackControls.cpp}::gPanCaptured
std::unique_ptr< LWSlider > gPanCaptured
Definition: WaveTrackControls.cpp:1138
Track::SetChannel
void SetChannel(ChannelType c)
Definition: Track.h:376
WaveTrackMenuTable::OnSplitStereoMono
void OnSplitStereoMono(wxCommandEvent &event)
Split a stereo track into two mono tracks...
Definition: WaveTrackControls.cpp:944
wxDialogWrapper::SetName
void SetName(const TranslatableString &title)
Definition: wxPanelWrapper.cpp:76
OnRate44ID
@ OnRate44ID
Definition: WaveTrackControls.cpp:99
RealtimeEffectManager::RealtimeIsActive
bool RealtimeIsActive()
Definition: RealtimeEffectManager.cpp:103
WaveTrackTCPLines
Definition: WaveTrackControls.cpp:1086
POPUP_MENU_FN
#define POPUP_MENU_FN(memFn)
Definition: PopupMenuTable.h:313
RealtimeEffectManager::Get
static RealtimeEffectManager & Get()
Definition: RealtimeEffectManager.cpp:43
PlayableTrackControls::StaticTCPLines
static const TCPLines & StaticTCPLines()
Definition: PlayableTrackControls.cpp:198
CommonTrackControls::InitMenuData::pParent
wxWindow * pParent
Definition: CommonTrackControls.h:38
FormatMenuTable::OnFormatChange
void OnFormatChange(wxCommandEvent &event)
Definition: WaveTrackControls.cpp:228
UserException.h
An AudacityException with no visible message.
WaveTrackMenuTable::InitUserData
void InitUserData(void *pUserData) override
Definition: WaveTrackControls.cpp:536
OnRate22ID
@ OnRate22ID
Definition: WaveTrackControls.cpp:98
kTrackInfoSliderExtra
@ kTrackInfoSliderExtra
Definition: ViewInfo.h:115
WaveTrackMenuTable::DestroyMenu
void DestroyMenu() override
Definition: WaveTrackControls.cpp:508
waveTrackTCPLines
WaveTrackTCPLines waveTrackTCPLines
Types.h
OnFloatID
@ OnFloatID
Definition: WaveTrackControls.cpp:111
BEGIN_POPUP_MENU
#define BEGIN_POPUP_MENU(HandlerClass)
Definition: PopupMenuTable.h:305
id
int id
Definition: WaveTrackControls.cpp:589
ProjectHistory::PushState
void PushState(const TranslatableString &desc, const TranslatableString &shortDesc)
Definition: ProjectHistory.cpp:89
wxDialogWrapper
Definition: wxPanelWrapper.h:81
TrackInfo::TCPLine::kItemPan
@ kItemPan
Definition: TrackInfo.h:44
WaveTrackTCPLines::WaveTrackTCPLines
WaveTrackTCPLines()
Definition: WaveTrackControls.cpp:1086
anonymous_namespace{WaveTrackControls.cpp}::initFn
PopupMenuTableEntry::InitFunction initFn(const ValueFinder &findValue)
Definition: WaveTrackControls.cpp:140
SoloButtonHandle::HitTest
static UIHandlePtr HitTest(std::weak_ptr< SoloButtonHandle > &holder, const wxMouseState &state, const wxRect &rect, const AudacityProject *pProject, const std::shared_ptr< Track > &pTrack)
Definition: PlayableTrackButtonHandles.cpp:115
OnSplitStereoID
@ OnSplitStereoID
Definition: WaveTrackControls.cpp:124
OnChannelMonoID
@ OnChannelMonoID
Definition: WaveTrackControls.cpp:119
TrackList::GroupChannels
void GroupChannels(Track &track, size_t groupSize, bool resetChannels=true)
Define a group of channels starting at the given track.
Definition: Track.cpp:707
TrackList::Get
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:495
OnChannelRightID
@ OnChannelRightID
Definition: WaveTrackControls.cpp:118
AppendRadioItem
AppendRadioItem("16Bit", On16BitID, GetSampleFormatStr(int16Sample), POPUP_MENU_FN(OnFormatChange), fn)
PopupMenuHandler
Definition: PopupMenuTable.h:82
Track
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:238
GainSliderHandle
Definition: WaveTrackSliderHandles.h:20
RateMenuTable::OnRateChange
void OnRateChange(wxCommandEvent &event)
Definition: WaveTrackControls.cpp:398
TrackInfo::DefaultTrackHeight
AUDACITY_DLL_API unsigned DefaultTrackHeight(const TCPLines &topLines)
Definition: TrackInfo.cpp:566
isMono
static const auto isMono
Definition: WaveTrackControls.cpp:553
WaveTrack::SetPan
void SetPan(float newPan) override
Definition: WaveTrack.cpp:395
XMLValueChecker::ChannelType
ChannelType
Definition: XMLTagHandler.h:67
WaveTrackControls::HitTest
std::vector< UIHandlePtr > HitTest(const TrackPanelMouseState &state, const AudacityProject *pProject) override
Definition: WaveTrackControls.cpp:49
sampleCount
Definition: Types.h:589
OnRate352ID
@ OnRate352ID
Definition: WaveTrackControls.cpp:105
WaveTrackControls::GetMenuExtension
PopupMenuTable * GetMenuExtension(Track *pTrack) override
Definition: WaveTrackControls.cpp:959
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:112
WaveTrackViewConstants.h
TrackInfo::TCPLine
Definition: TrackInfo.h:36
WaveTrackMenuTable::OnSplitStereo
void OnSplitStereo(wxCommandEvent &event)
Split a stereo track into two tracks...
Definition: WaveTrackControls.cpp:929
FormatMenuTable::InitUserData
void InitUserData(void *pUserData) override
Definition: WaveTrackControls.cpp:186
WaveTrackView::Get
static WaveTrackView & Get(WaveTrack &track)
Definition: WaveTrackView.cpp:763
PopupMenuTable::Append
void Append(Registry::BaseItemPtr pItem)
Definition: PopupMenuTable.cpp:155
CellularPanel
Formerly part of TrackPanel, this abstract base class has no special knowledge of Track objects and i...
Definition: CellularPanel.h:34
FormatMenuTable::FormatMenuTable
FormatMenuTable()
Definition: WaveTrackControls.cpp:159
int16Sample
@ int16Sample
Definition: Types.h:720
WaveTrackControls::PanSlider
static LWSlider * PanSlider(CellularPanel &panel, const WaveTrack &wt)
Definition: WaveTrackControls.cpp:1198
registerDoGetWaveTrackControls
static DoGetWaveTrackControls registerDoGetWaveTrackControls
Definition: WaveTrackControls.cpp:1260
TrackPanelMouseState
Definition: TrackPanelMouseEvent.h:28
OnRate48ID
@ OnRate48ID
Definition: WaveTrackControls.cpp:100
TrackPanelDrawingContext::target
UIHandlePtr target
Definition: TrackPanelDrawingContext.h:24
ComputedPopupMenuTable
Definition: PopupMenuTable.h:223
WaveTrackMenuTable::OnMergeStereo
void OnMergeStereo(wxCommandEvent &event)
Merge two tracks into one stereo track ??
Definition: WaveTrackControls.cpp:816
AttachedVirtualFunction::Override
For defining overrides of the method.
Definition: AttachedVirtualFunction.h:190
anonymous_namespace{WaveTrackControls.cpp}::StatusDrawFunction
void StatusDrawFunction(const TranslatableString &string, wxDC *dc, const wxRect &rect)
Definition: WaveTrackControls.cpp:1035
TrackInfo::GetSliderHorizontalBounds
AUDACITY_DLL_API void GetSliderHorizontalBounds(const wxPoint &topleft, wxRect &dest)
Definition: TrackInfo.cpp:488
WaveTrackPopupMenuTable::FindWaveTrack
WaveTrack & FindWaveTrack() const
Definition: WaveTrackControls.cpp:87
ShuttleGui::AddStandardButtons
void AddStandardButtons(long buttons=eOkButton|eCancelButton, wxWindow *extra=NULL)
Definition: ShuttleGui.cpp:2406
WaveTrackControls::GetTCPLines
const TCPLines & GetTCPLines() const override
Definition: WaveTrackControls.cpp:1128
FirstAttachedItemId
@ FirstAttachedItemId
Definition: WaveTrackControls.cpp:130
WaveTrackControls.h
GetSampleFormatStr
TranslatableString GetSampleFormatStr(sampleFormat format)
Definition: SampleFormat.cpp:60
WaveTrackMenuTable::Instance
static WaveTrackMenuTable & Instance()
Definition: WaveTrackControls.cpp:530
ShuttleGuiBase::SetBorder
void SetBorder(int Border)
Definition: ShuttleGui.h:497
OnRate88ID
@ OnRate88ID
Definition: WaveTrackControls.cpp:101
RateMenuTable::IdOfRate
static int IdOfRate(int rate)
Converts a sampling rate to a wxWidgets menu item id.
Definition: WaveTrackControls.cpp:370
WaveTrack::GetPan
float GetPan() const
Definition: WaveTrack.cpp:390
TranslatableString::Format
TranslatableString & Format(Args &&...args) &
Definition: Types.h:363
MenuPathStart
static const auto MenuPathStart
Definition: WaveTrackControls.cpp:490
registerGetDefaultWaveTrackHeight
static GetDefaultWaveTrackHeight registerGetDefaultWaveTrackHeight
Definition: WaveTrackControls.cpp:1269
WaveTrackPopupMenuTable
Definition: WaveTrackControls.h:74
RateMenuTable::DestroyMenu
void DestroyMenu() override
Definition: WaveTrackControls.cpp:311
RefreshCode
Namespace containing an enum 'what to do on a refresh?'.
Definition: RefreshCode.h:16
CommonTrackControls::InitMenuData::pTrack
Track * pTrack
Definition: CommonTrackControls.h:37
lrint
#define lrint(dbl)
Definition: float_cast.h:148
WaveTrackView::SetDisplay
void SetDisplay(Display display, bool exclusive=true)
Definition: WaveTrackView.cpp:863
FormatMenuTable::IdOfFormat
static int IdOfFormat(int format)
Converts a format enumeration to a wxWidgets menu item Id.
Definition: WaveTrackControls.cpp:209
WaveTrackMenuTable
Definition: WaveTrackControls.cpp:496
WaveTrackPopupMenuTable::mpData
PlayableTrackControls::InitMenuData * mpData
Definition: WaveTrackControls.h:76
anonymous_namespace{WaveTrackControls.cpp}::GainSliderDrawFunction
void GainSliderDrawFunction(TrackPanelDrawingContext &context, const wxRect &rect, const Track *pTrack)
Definition: WaveTrackControls.cpp:1016
ShuttleGuiBase::AddCombo
wxComboBox * AddCombo(const TranslatableString &Prompt, const wxString &Selected, const wxArrayStringEx &choices)
Definition: ShuttleGui.cpp:510
TCPLine
TrackInfo::TCPLine TCPLine
Definition: WaveTrackControls.cpp:1083
TrackPanelMouseState::state
wxMouseState & state
Definition: TrackPanelMouseEvent.h:38
ProjectHistory::Get
static ProjectHistory & Get(AudacityProject &project)
Definition: ProjectHistory.cpp:26
WaveTrackViewConstants::Waveform
@ Waveform
Definition: WaveTrackViewConstants.h:24
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:638
WaveTrackControls::mMuteHandle
std::weak_ptr< MuteButtonHandle > mMuteHandle
Definition: WaveTrackControls.h:65
WaveTrackSliderHandles.h
OnMergeStereoID
@ OnMergeStereoID
Definition: WaveTrackControls.cpp:121
Registry::OrderingPreferenceInitializer
Definition: Registry.h:273
END_POPUP_MENU
#define END_POPUP_MENU()
Definition: PopupMenuTable.h:320
OnMultiViewID
@ OnMultiViewID
Definition: WaveTrackControls.cpp:113
WaveTrack::GetRate
double GetRate() const
Definition: WaveTrack.cpp:360