Audacity  2.2.2
Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
WaveTrackMenuTable Class Reference
Inheritance diagram for WaveTrackMenuTable:
PopupMenuTable TranslatableArray< std::vector< PopupMenuTableEntry > >

Static Public Member Functions

static WaveTrackMenuTableInstance (Track *pTrack)
 
- Static Public Member Functions inherited from PopupMenuTable
static std::unique_ptr< MenuBuildMenu (wxEvtHandler *pParent, PopupMenuTable *pTable, void *pUserData=NULL)
 

Public Attributes

TrackmpTrack
 

Protected Member Functions

 WaveTrackMenuTable ()
 
void InitMenu (Menu *pMenu, void *pUserData) override
 
void DestroyMenu () override
 
 DECLARE_POPUP_MENU (WaveTrackMenuTable)
 
void OnSetDisplay (wxCommandEvent &event)
 Set the Display mode based on the menu choice in the Track Menu. More...
 
void OnSpectrogramSettings (wxCommandEvent &event)
 
void OnChannelChange (wxCommandEvent &event)
 
void OnMergeStereo (wxCommandEvent &event)
 Merge two tracks into one stereo track ?? More...
 
void SplitStereo (bool stereo)
 Split a stereo track into two tracks... More...
 
void OnSwapChannels (wxCommandEvent &event)
 Swap the left and right channels of a stero track... More...
 
void OnSplitStereo (wxCommandEvent &event)
 Split a stereo track into two tracks... More...
 
void OnSplitStereoMono (wxCommandEvent &event)
 Split a stereo track into two mono tracks... More...
 
- Protected Member Functions inherited from TranslatableArray< std::vector< PopupMenuTableEntry > >
virtual void Populate ()=0
 
void Invalidate (wxCommandEvent &evt)
 

Protected Attributes

TrackControls::InitMenuDatampData
 
- Protected Attributes inherited from TranslatableArray< std::vector< PopupMenuTableEntry > >
std::vector< PopupMenuTableEntrymContents
 

Additional Inherited Members

- Public Types inherited from PopupMenuTable
typedef PopupMenuTableEntry Entry
 
- Public Member Functions inherited from TranslatableArray< std::vector< PopupMenuTableEntry > >
 TranslatableArray ()
 
const std::vector
< PopupMenuTableEntry > & 
Get ()
 

Detailed Description

Definition at line 549 of file WaveTrackControls.cpp.

Constructor & Destructor Documentation

WaveTrackMenuTable::WaveTrackMenuTable ( )
inlineprotected

Definition at line 556 of file WaveTrackControls.cpp.

556 : mpData(NULL) {mpTrack=NULL;}
TrackControls::InitMenuData * mpData

Member Function Documentation

WaveTrackMenuTable::DECLARE_POPUP_MENU ( WaveTrackMenuTable  )
protected
void WaveTrackMenuTable::DestroyMenu ( )
inlineoverrideprotectedvirtual

Implements PopupMenuTable.

Definition at line 560 of file WaveTrackControls.cpp.

References WaveColorMenuTable::mpData.

561  {
562  mpData = nullptr;
563  }
TrackControls::InitMenuData * mpData
void WaveTrackMenuTable::InitMenu ( Menu pMenu,
void *  pUserData 
)
overrideprotectedvirtual

Implements PopupMenuTable.

Definition at line 595 of file WaveTrackControls.cpp.

References gAudioIO, EffectManager::Get(), GetActiveProject(), WaveTrack::GetChannel(), WaveTrack::GetDisplay(), WaveTrack::GetKind(), Track::GetKind(), Track::GetLink(), Track::GetLinked(), TrackList::GetNext(), AudacityProject::GetTracks(), WaveTrack::GetWaveformSettings(), AudacityProject::IsAudioActive(), AudioIO::IsBusy(), WaveformSettings::isLinear(), Track::LeftChannel, WaveColorMenuTable::mpData, OnChannelLeftID, OnChannelMonoID, OnChannelRightID, OnMergeStereoID, OnSpectrogramSettingsID, OnSpectrumID, OnSplitStereoID, OnSplitStereoMonoID, OnSwapChannelsID, OnWaveformDBID, OnWaveformID, TrackControls::InitMenuData::pTrack, EffectManager::RealtimeIsActive(), Track::RightChannel, WaveTrack::Spectrum, Track::Wave, and WaveTrack::Waveform.

596 {
597  mpData = static_cast<TrackControls::InitMenuData*>(pUserData);
598  WaveTrack *const pTrack = static_cast<WaveTrack*>(mpData->pTrack);
599 
600  std::vector<int> checkedIds;
601 
602  const int display = pTrack->GetDisplay();
603  checkedIds.push_back(
604  display == WaveTrack::Waveform
605  ? (pTrack->GetWaveformSettings().isLinear()
607  : OnSpectrumID);
608 
609  // Bug 1253. Shouldn't open preferences if audio is busy.
610  // We can't change them on the fly yet anyway.
611  const bool bAudioBusy = gAudioIO->IsBusy();
612  pMenu->Enable(OnSpectrogramSettingsID,
613  (display == WaveTrack::Spectrum) && !bAudioBusy);
614 
615  AudacityProject *const project = ::GetActiveProject();
616  bool unsafe = EffectManager::Get().RealtimeIsActive() &&
617  project->IsAudioActive();
618 
619  const bool isMono = !pTrack->GetLink();
620  if ( isMono )
621  {
622  mpData = static_cast<TrackControls::InitMenuData*>(pUserData);
623  WaveTrack *const pTrack = static_cast<WaveTrack*>(mpData->pTrack);
624 
625  TrackList *const tracks = project->GetTracks();
626  Track *const next = tracks->GetNext(pTrack);
627 
628  if (isMono) {
629  const bool canMakeStereo =
630  (next && !next->GetLinked()
631  && pTrack->GetKind() == Track::Wave
632  && next->GetKind() == Track::Wave);
633  pMenu->Enable(OnMergeStereoID, canMakeStereo && !unsafe);
634 
635  int itemId;
636  switch (pTrack->GetChannel()) {
637  case Track::LeftChannel:
638  itemId = OnChannelLeftID;
639  break;
640  case Track::RightChannel:
641  itemId = OnChannelRightID;
642  break;
643  default:
644  itemId = OnChannelMonoID;
645  break;
646  }
647  checkedIds.push_back(itemId);
648  }
649  }
650  else
651  {
652  pMenu->Enable(OnMergeStereoID, false);
653  }
654 
655  SetMenuChecks(*pMenu, [&](int id){
656  auto end = checkedIds.end();
657  return end != std::find(checkedIds.begin(), end, id);
658  });
659 
660 
661  pMenu->Enable(OnSwapChannelsID, !isMono && !unsafe);
662  pMenu->Enable(OnSplitStereoID, !isMono && !unsafe);
663 
664 #ifndef EXPERIMENTAL_DA
665  // Can be achieved by split stereo and then dragging pan slider.
666  pMenu->Enable(OnSplitStereoMonoID, !isMono && !unsafe);
667 #endif
668 
669  // Several menu items no longer needed....
670 #if 0
671  pMenu->Enable(OnChannelMonoID, isMono);
672  pMenu->Enable(OnChannelLeftID, isMono);
673  pMenu->Enable(OnChannelRightID, isMono);
674 #endif
675 }
int GetKind() const override
Definition: WaveTrack.h:121
A list of TrackListNode items.
Definition: Track.h:619
bool isLinear() const
const WaveformSettings & GetWaveformSettings() const
Definition: WaveTrack.cpp:738
bool GetLinked() const
Definition: Track.h:279
bool IsBusy()
Returns true if audio i/o is busy starting, stopping, playing, or recording.
Definition: AudioIO.cpp:2882
virtual int GetKind() const
Definition: Track.h:330
TrackControls::InitMenuData * mpData
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
Track * GetNext(Track *t, bool linked=false) const
Return a track in the list that comes after Track t.
Definition: Track.cpp:1048
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
bool IsAudioActive() const
Definition: Project.cpp:1454
static EffectManager & Get()
AudioIO * gAudioIO
Definition: AudioIO.cpp:482
Track * GetLink() const
Definition: Track.cpp:269
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308
TrackList * GetTracks()
Definition: Project.h:192
WaveTrackDisplay GetDisplay() const
Definition: WaveTrack.h:593
bool RealtimeIsActive()
virtual int GetChannel() const override
Definition: WaveTrack.cpp:236
WaveTrackMenuTable & WaveTrackMenuTable::Instance ( Track pTrack)
static

Definition at line 582 of file WaveTrackControls.cpp.

References TranslatableArray< ArrayType >::Invalidate(), and mpTrack.

Referenced by WaveTrackControls::GetMenuExtension().

583 {
584  static WaveTrackMenuTable instance;
585  wxCommandEvent evt;
586  // Clear it out so we force a repopulate
587  instance.Invalidate( evt );
588  // Ensure we know how to poulate.
589  // Messy, but the design does not seem to offer an alternative.
590  // We won't use pTrack after populate.
591  instance.mpTrack = pTrack;
592  return instance;
593 }
void Invalidate(wxCommandEvent &evt)
void WaveTrackMenuTable::OnChannelChange ( wxCommandEvent &  event)
protected

Definition at line 822 of file WaveTrackControls.cpp.

References _(), GetActiveProject(), Track::GetName(), Track::LeftChannel, Track::MonoChannel, WaveColorMenuTable::mpData, OnChannelLeftID, OnChannelMonoID, OnChannelRightID, TrackControls::InitMenuData::pTrack, AudacityProject::PushState(), RefreshCode::RefreshAll, TrackControls::InitMenuData::result, Track::RightChannel, and Track::SetChannel().

823 {
824  int id = event.GetId();
825  wxASSERT(id >= OnChannelLeftID && id <= OnChannelMonoID);
826  WaveTrack *const pTrack = static_cast<WaveTrack*>(mpData->pTrack);
827  wxASSERT(pTrack);
828  int channel;
829  wxString channelmsg;
830  switch (id) {
831  default:
832  case OnChannelMonoID:
833  channel = Track::MonoChannel;
834  channelmsg = _("Mono");
835  break;
836  case OnChannelLeftID:
837  channel = Track::LeftChannel;
838  channelmsg = _("Left Channel");
839  break;
840  case OnChannelRightID:
841  channel = Track::RightChannel;
842  channelmsg = _("Right Channel");
843  break;
844  }
845  pTrack->SetChannel(channel);
846  AudacityProject *const project = ::GetActiveProject();
847  /* i18n-hint: The strings name a track and a channel choice (mono, left, or right) */
848  project->PushState(wxString::Format(_("Changed '%s' to %s"),
849  pTrack->GetName(),
850  channelmsg),
851  _("Channel"));
853 }
void SetChannel(int c)
Definition: Track.h:292
TrackControls::InitMenuData * mpData
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
wxString GetName() const
Definition: Track.h:271
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
void PushState(const wxString &desc, const wxString &shortDesc)
Definition: Project.cpp:4702
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308
void WaveTrackMenuTable::OnMergeStereo ( wxCommandEvent &  event)
protected

Merge two tracks into one stereo track ??

Definition at line 856 of file WaveTrackControls.cpp.

References _(), GetActiveProject(), Track::GetHeight(), Track::GetLink(), Track::GetMinimized(), Track::GetName(), ODManager::Instance, ODManager::IsInstanceCreated(), Track::LeftChannel, WaveTrack::Merge(), WaveColorMenuTable::mpData, TrackControls::InitMenuData::pTrack, AudacityProject::PushState(), RefreshCode::RefreshAll, TrackControls::InitMenuData::result, Track::RightChannel, Track::SetChannel(), Track::SetHeight(), Track::SetLinked(), Track::SetMinimized(), and WaveTrack::SetPan().

857 {
858  WaveTrack *const pTrack = static_cast<WaveTrack*>(mpData->pTrack);
859  wxASSERT(pTrack);
860  pTrack->SetLinked(true);
861  // Assume partner is wave or null
862  const auto partner = static_cast<WaveTrack*>(pTrack->GetLink());
863 
864  if (partner) {
865  // Set partner's parameters to match target.
866  partner->Merge(*pTrack);
867 
868  pTrack->SetPan( 0.0f );
870  partner->SetPan( 0.0f );
871  partner->SetChannel(Track::RightChannel);
872 
873  // Set NEW track heights and minimized state
874  bool bBothMinimizedp = ((pTrack->GetMinimized()) && (partner->GetMinimized()));
875  pTrack->SetMinimized(false);
876  partner->SetMinimized(false);
877  int AverageHeight = (pTrack->GetHeight() + partner->GetHeight()) / 2;
878  pTrack->SetHeight(AverageHeight);
879  partner->SetHeight(AverageHeight);
880  pTrack->SetMinimized(bBothMinimizedp);
881  partner->SetMinimized(bBothMinimizedp);
882 
883  //On Demand - join the queues together.
885  if (!ODManager::Instance()->MakeWaveTrackDependent(partner, pTrack))
886  {
887  ;
888  //TODO: in the future, we will have to check the return value of MakeWaveTrackDependent -
889  //if the tracks cannot merge, it returns false, and in that case we should not allow a merging.
890  //for example it returns false when there are two different types of ODTasks on each track's queue.
891  //we will need to display this to the user.
892  }
893 
894  AudacityProject *const project = ::GetActiveProject();
895  /* i18n-hint: The string names a track */
896  project->PushState(wxString::Format(_("Made '%s' a stereo track"),
897  pTrack->GetName()),
898  _("Make Stereo"));
899  }
900  else
901  pTrack->SetLinked(false);
902 
904 }
static bool IsInstanceCreated()
returns whether or not the singleton instance was created yet
Definition: ODManager.cpp:205
static ODManager *(* Instance)()
Definition: ODManager.h:49
void SetLinked(bool l)
Definition: Track.cpp:244
void Merge(const Track &orig) override
Definition: WaveTrack.cpp:193
void SetHeight(int h)
Definition: Track.cpp:189
bool GetMinimized() const
Definition: Track.cpp:214
void SetMinimized(bool isMinimized)
Definition: Track.cpp:219
void SetChannel(int c)
Definition: Track.h:292
TrackControls::InitMenuData * mpData
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
wxString GetName() const
Definition: Track.h:271
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
void PushState(const wxString &desc, const wxString &shortDesc)
Definition: Project.cpp:4702
Track * GetLink() const
Definition: Track.cpp:269
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308
void SetPan(float newPan) override
Definition: WaveTrack.cpp:430
int GetHeight() const
Definition: Track.cpp:180
void WaveTrackMenuTable::OnSetDisplay ( wxCommandEvent &  event)
protected

Set the Display mode based on the menu choice in the Track Menu.

Definition at line 712 of file WaveTrackControls.cpp.

References GetActiveProject(), WaveTrack::GetDisplay(), WaveTrack::GetIndependentWaveformSettings(), WaveTrack::GetKind(), Track::GetLink(), WaveTrack::GetWaveformSettings(), WaveformSettings::isLinear(), AudacityProject::ModifyState(), WaveColorMenuTable::mpData, TrackControls::InitMenuData::pTrack, RefreshCode::RefreshAll, TrackControls::InitMenuData::result, WaveformSettings::scaleType, WaveTrack::SetDisplay(), WaveTrack::SetLastScaleType(), WaveTrack::Spectrum, WaveformSettings::stLinear, WaveformSettings::stLogarithmic, RefreshCode::UpdateVRuler, Track::Wave, and WaveTrack::Waveform.

713 {
714  int idInt = event.GetId();
715  wxASSERT(idInt >= OnWaveformID && idInt <= OnSpectrumID);
716  WaveTrack *const pTrack = static_cast<WaveTrack*>(mpData->pTrack);
717  wxASSERT(pTrack && pTrack->GetKind() == Track::Wave);
718 
719  bool linear = false;
721  switch (idInt) {
722  default:
723  case OnWaveformID:
724  linear = true, id = WaveTrack::Waveform; break;
725  case OnWaveformDBID:
726  id = WaveTrack::Waveform; break;
727  case OnSpectrumID:
728  id = WaveTrack::Spectrum; break;
729  }
730 
731  const bool wrongType = pTrack->GetDisplay() != id;
732  const bool wrongScale =
733  (id == WaveTrack::Waveform &&
734  pTrack->GetWaveformSettings().isLinear() != linear);
735  if (wrongType || wrongScale) {
736  pTrack->SetLastScaleType();
738  if (wrongScale)
739  pTrack->GetIndependentWaveformSettings().scaleType = linear
742 
743  // Assume partner is wave or null
744  auto partner = static_cast<WaveTrack *>(pTrack->GetLink());
745  if (partner) {
746  partner->SetLastScaleType();
747  partner->SetDisplay(WaveTrack::WaveTrackDisplay(id));
748  if (wrongScale)
749  partner->GetIndependentWaveformSettings().scaleType = linear
752  }
753 
754  AudacityProject *const project = ::GetActiveProject();
755  project->ModifyState(true);
756 
757  using namespace RefreshCode;
759  }
760 }
int GetKind() const override
Definition: WaveTrack.h:121
bool isLinear() const
const WaveformSettings & GetWaveformSettings() const
Definition: WaveTrack.cpp:738
WaveformSettings & GetIndependentWaveformSettings()
Definition: WaveTrack.cpp:754
int WaveTrackDisplay
Definition: WaveTrack.h:531
TrackControls::InitMenuData * mpData
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
void SetDisplay(WaveTrackDisplay display)
Definition: WaveTrack.h:594
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
void ModifyState(bool bWantsAutoSave)
Definition: Project.cpp:4747
Track * GetLink() const
Definition: Track.cpp:269
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308
void SetLastScaleType() const
Definition: WaveTrack.cpp:315
WaveTrackDisplay GetDisplay() const
Definition: WaveTrack.h:593
void WaveTrackMenuTable::OnSpectrogramSettings ( wxCommandEvent &  event)
protected

Definition at line 762 of file WaveTrackControls.cpp.

References _(), AudacityMessageBox(), gAudioIO, GetActiveProject(), Track::GetName(), AudioIO::IsBusy(), AudacityProject::ModifyState(), WaveColorMenuTable::mpData, TrackControls::InitMenuData::pParent, TrackControls::InitMenuData::pTrack, AudacityProject::RebuildAllMenuBars(), RefreshCode::RefreshAll, and TrackControls::InitMenuData::result.

763 {
764  class ViewSettingsDialog final : public PrefsDialog
765  {
766  public:
767  ViewSettingsDialog
768  (wxWindow *parent, const wxString &title, PrefsDialog::Factories &factories,
769  int page)
770  : PrefsDialog(parent, title, factories)
771  , mPage(page)
772  {
773  }
774 
775  long GetPreferredPage() override
776  {
777  return mPage;
778  }
779 
780  void SavePreferredPage() override
781  {
782  }
783 
784  private:
785  const int mPage;
786  };
787 
788  if (gAudioIO->IsBusy()){
789  AudacityMessageBox(_("To change Spectrogram Settings, stop any\n"
790  "playing or recording first."),
791  _("Stop the Audio First"), wxOK | wxICON_EXCLAMATION | wxCENTRE);
792  return;
793  }
794 
795  WaveTrack *const pTrack = static_cast<WaveTrack*>(mpData->pTrack);
796  // WaveformPrefsFactory waveformFactory(pTrack);
797  // TracksBehaviorsPrefsFactory tracksBehaviorsFactory();
798  SpectrumPrefsFactory spectrumFactory(pTrack);
799 
800  PrefsDialog::Factories factories;
801  // factories.push_back(&waveformFactory);
802  factories.push_back(&spectrumFactory);
803  const int page =
804  // (pTrack->GetDisplay() == WaveTrack::Spectrum) ? 1 :
805  0;
806 
807  wxString title(pTrack->GetName() + wxT(": "));
808  ViewSettingsDialog dialog(mpData->pParent, title, factories, page);
809 
810  if (0 != dialog.ShowModal()) {
811  // Redraw
812  AudacityProject *const project = ::GetActiveProject();
813  project->ModifyState(true);
814  //Bug 1725 Toolbar was left greyed out.
815  //This solution is overkill, but does fix the problem and is what the
816  //prefs dialog normally does.
819  }
820 }
static void RebuildAllMenuBars()
Definition: Menus.cpp:4672
int AudacityMessageBox(const wxString &message, const wxString &caption=AudacityMessageBoxCaptionStr(), long style=wxOK|wxCENTRE, wxWindow *parent=NULL, int x=wxDefaultCoord, int y=wxDefaultCoord)
Definition: ErrorDialog.h:92
Dialog that shows the current PrefsPanel in a tabbed divider.
Definition: PrefsDialog.h:35
bool IsBusy()
Returns true if audio i/o is busy starting, stopping, playing, or recording.
Definition: AudioIO.cpp:2882
TrackControls::InitMenuData * mpData
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
std::vector< PrefsNode > Factories
Definition: PrefsDialog.h:50
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
wxString GetName() const
Definition: Track.h:271
void ModifyState(bool bWantsAutoSave)
Definition: Project.cpp:4747
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
AudioIO * gAudioIO
Definition: AudioIO.cpp:482
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308
void WaveTrackMenuTable::OnSplitStereo ( wxCommandEvent &  event)
protected

Split a stereo track into two tracks...

Definition at line 991 of file WaveTrackControls.cpp.

References _(), GetActiveProject(), Track::GetName(), WaveColorMenuTable::mpData, TrackControls::InitMenuData::pTrack, AudacityProject::PushState(), RefreshCode::RefreshAll, and TrackControls::InitMenuData::result.

992 {
993  SplitStereo(true);
994  WaveTrack *const pTrack = static_cast<WaveTrack*>(mpData->pTrack);
995  AudacityProject *const project = ::GetActiveProject();
996  /* i18n-hint: The string names a track */
997  project->PushState(wxString::Format(_("Split stereo track '%s'"),
998  pTrack->GetName()),
999  _("Split"));
1000 
1002 }
TrackControls::InitMenuData * mpData
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
wxString GetName() const
Definition: Track.h:271
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
void PushState(const wxString &desc, const wxString &shortDesc)
Definition: Project.cpp:4702
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308
void SplitStereo(bool stereo)
Split a stereo track into two tracks...
void WaveTrackMenuTable::OnSplitStereoMono ( wxCommandEvent &  event)
protected

Split a stereo track into two mono tracks...

Definition at line 1005 of file WaveTrackControls.cpp.

References _(), GetActiveProject(), Track::GetName(), WaveColorMenuTable::mpData, TrackControls::InitMenuData::pTrack, AudacityProject::PushState(), RefreshCode::RefreshAll, and TrackControls::InitMenuData::result.

1006 {
1007  SplitStereo(false);
1008  WaveTrack *const pTrack = static_cast<WaveTrack*>(mpData->pTrack);
1009  AudacityProject *const project = ::GetActiveProject();
1010  /* i18n-hint: The string names a track */
1011  project->PushState(wxString::Format(_("Split Stereo to Mono '%s'"),
1012  pTrack->GetName()),
1013  _("Split to Mono"));
1014 
1016 }
TrackControls::InitMenuData * mpData
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
wxString GetName() const
Definition: Track.h:271
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
void PushState(const wxString &desc, const wxString &shortDesc)
Definition: Project.cpp:4702
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308
void SplitStereo(bool stereo)
Split a stereo track into two tracks...
void WaveTrackMenuTable::OnSwapChannels ( wxCommandEvent &  event)
protected

Swap the left and right channels of a stero track...

Definition at line 956 of file WaveTrackControls.cpp.

References _(), GetActiveProject(), TrackPanel::GetFocusedTrack(), Track::GetLink(), AudacityProject::GetMixerBoard(), Track::GetName(), AudacityProject::GetTrackPanel(), AudacityProject::GetTracks(), Track::LeftChannel, TrackList::MoveUp(), WaveColorMenuTable::mpData, TrackControls::InitMenuData::pTrack, AudacityProject::PushState(), RefreshCode::RefreshAll, TrackControls::InitMenuData::result, Track::RightChannel, Track::SetChannel(), TrackPanel::SetFocusedTrack(), and MixerBoard::UpdateTrackClusters().

957 {
958  AudacityProject *const project = ::GetActiveProject();
959 
960  WaveTrack *const pTrack = static_cast<WaveTrack*>(mpData->pTrack);
961  // Assume partner is wave or null
962  const auto partner = static_cast<WaveTrack*>(pTrack->GetLink());
963  Track *const focused = project->GetTrackPanel()->GetFocusedTrack();
964  const bool hasFocus =
965  (focused == pTrack || focused == partner);
966 
967  SplitStereo(false);
969  partner->SetChannel(Track::LeftChannel);
970 
971  TrackList *const tracks = project->GetTracks();
972  (tracks->MoveUp(partner));
973  partner->SetLinked(true);
974 
975  MixerBoard* pMixerBoard = project->GetMixerBoard();
976  if (pMixerBoard)
977  pMixerBoard->UpdateTrackClusters();
978 
979  if (hasFocus)
980  project->GetTrackPanel()->SetFocusedTrack(partner);
981 
982  /* i18n-hint: The string names a track */
983  project->PushState(wxString::Format(_("Swapped Channels in '%s'"),
984  pTrack->GetName()),
985  _("Swap Channels"));
986 
988 }
A list of TrackListNode items.
Definition: Track.h:619
bool MoveUp(Track *t)
Definition: Track.cpp:1198
void SetChannel(int c)
Definition: Track.h:292
MixerBoard * GetMixerBoard()
Definition: Project.h:516
TrackControls::InitMenuData * mpData
void SetFocusedTrack(Track *t)
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
wxString GetName() const
Definition: Track.h:271
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
void PushState(const wxString &desc, const wxString &shortDesc)
Definition: Project.cpp:4702
Track * GetLink() const
Definition: Track.cpp:269
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308
Track * GetFocusedTrack()
TrackPanel * GetTrackPanel()
Definition: Project.h:307
TrackList * GetTracks()
Definition: Project.h:192
void SplitStereo(bool stereo)
Split a stereo track into two tracks...
void UpdateTrackClusters()
Definition: MixerBoard.cpp:973
void WaveTrackMenuTable::SplitStereo ( bool  stereo)
protected

Split a stereo track into two tracks...

Definition at line 907 of file WaveTrackControls.cpp.

References Track::GetHeight(), Track::GetLink(), Track::GetMinimizedHeight(), Track::GetName(), ODManager::Instance, ODManager::IsInstanceCreated(), ODManager::MakeWaveTrackIndependent(), Track::MonoChannel, WaveColorMenuTable::mpData, TrackControls::InitMenuData::pTrack, RefreshCode::RefreshAll, TrackControls::InitMenuData::result, Track::SetChannel(), Track::SetHeight(), Track::SetLinked(), WaveTrack::SetPanFromChannelType(), and Track::Wave.

908 {
909  WaveTrack *const pTrack = static_cast<WaveTrack*>(mpData->pTrack);
910  wxASSERT(pTrack);
911 
912  if (stereo)
913  pTrack->SetPanFromChannelType();
915 
916  // Assume partner is present, and is wave
917  const auto partner = static_cast<WaveTrack*>(pTrack->GetLink());
918  wxASSERT(partner);
919  if (!partner)
920  return;
921 
922  if (partner)
923  {
924  // Keep original stereo track name.
925  partner->SetName(pTrack->GetName());
926  if (stereo)
927  partner->SetPanFromChannelType();
928  partner->SetChannel(Track::MonoChannel);
929 
930  //On Demand - have each channel add its own.
931  if (ODManager::IsInstanceCreated() && partner->GetKind() == Track::Wave)
933  }
934 
935  pTrack->SetLinked(false);
936  //make sure neither track is smaller than its minimum height
937  if (pTrack->GetHeight() < pTrack->GetMinimizedHeight())
938  pTrack->SetHeight(pTrack->GetMinimizedHeight());
939  if (partner)
940  {
941  if (partner->GetHeight() < partner->GetMinimizedHeight())
942  partner->SetHeight(partner->GetMinimizedHeight());
943 
944  // Make tracks the same height
945  if (pTrack->GetHeight() != partner->GetHeight())
946  {
947  pTrack->SetHeight((pTrack->GetHeight() + partner->GetHeight()) / 2.0);
948  partner->SetHeight(pTrack->GetHeight());
949  }
950  }
951 
953 }
static bool IsInstanceCreated()
returns whether or not the singleton instance was created yet
Definition: ODManager.cpp:205
static ODManager *(* Instance)()
Definition: ODManager.h:49
void SetLinked(bool l)
Definition: Track.cpp:244
void SetHeight(int h)
Definition: Track.cpp:189
virtual int GetMinimizedHeight() const
Definition: Track.cpp:129
void SetChannel(int c)
Definition: Track.h:292
virtual void SetPanFromChannelType() override
Definition: WaveTrack.cpp:248
void MakeWaveTrackIndependent(WaveTrack *track)
if it shares a queue/task, creates a NEW queue/task for the track, and removes it from any previously...
Definition: ODManager.cpp:395
TrackControls::InitMenuData * mpData
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
wxString GetName() const
Definition: Track.h:271
Track * GetLink() const
Definition: Track.cpp:269
int GetHeight() const
Definition: Track.cpp:180

Member Data Documentation

TrackControls::InitMenuData* WaveTrackMenuTable::mpData
protected

Definition at line 567 of file WaveTrackControls.cpp.

Track* WaveTrackMenuTable::mpTrack

Definition at line 553 of file WaveTrackControls.cpp.

Referenced by Instance().


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