Audacity  2.3.1
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
TranscriptionToolBar Class Referencefinal

A kind of ToolBar used to help with analysing voice recordings. More...

#include <TranscriptionToolBar.h>

Inheritance diagram for TranscriptionToolBar:
ToolBar wxPanelWrapper wxTabTraversalWrapper< wxPanel >

Public Member Functions

 TranscriptionToolBar ()
 
virtual ~TranscriptionToolBar ()
 
void Create (wxWindow *parent) override
 
void OnKeyEvent (wxKeyEvent &event)
 
void OnPlaySpeed (wxCommandEvent &event)
 
void OnSpeedSlider (wxCommandEvent &event)
 
void Populate () override
 
void Repaint (wxDC *WXUNUSED(dc)) override
 
void EnableDisableButtons () override
 
void UpdatePrefs () override
 
int GetInitialWidth () override
 Resizable toolbars should implement these. More...
 
int GetMinToolbarWidth () override
 
void OnFocus (wxFocusEvent &event)
 
void OnCaptureKey (wxCommandEvent &event)
 
void PlayAtSpeed (bool looped, bool cutPreview)
 
void ShowPlaySpeedDialog ()
 
void AdjustPlaySpeed (float adj)
 
void SetEnabled (bool enabled)
 
void SetPlaying (bool down, bool looped, bool cutPreview)
 
double GetPlaySpeed () const
 
- Public Member Functions inherited from ToolBar
 ToolBar (int type, const wxString &label, const wxString &section, bool resizable=false)
 
virtual ~ToolBar ()
 
bool AcceptsFocus () const override
 
void SetToDefaultSize ()
 
virtual void ReCreateButtons ()
 
int GetType ()
 
wxString GetTitle ()
 
wxString GetLabel ()
 
wxString GetSection ()
 
ToolDockGetDock ()
 
void SetLabel (const wxString &label) override
 
virtual void SetDocked (ToolDock *dock, bool pushed)
 
virtual bool Expose (bool show=true)
 
bool IsResizable () const
 
bool IsVisible () const
 
bool IsDocked () const
 
bool IsPositioned ()
 
void SetVisible (bool bVisible)
 
void SetPositioned ()
 
virtual wxSize GetDockedSize ()
 
- 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 wxString &name=_("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const wxString &name=_("Panel"))
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&...args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Private Member Functions

void InitializeTranscriptionToolBar ()
 
void MakeAlternateImages (teBmps eFore, teBmps eDisabled, int id, unsigned altIdx)
 
void GetSamples (const WaveTrack *t, sampleCount *s0, sampleCount *slen)
 
void SetButton (bool newstate, AButton *button)
 
void RegenerateTooltips () override
 

Static Private Member Functions

static AButtonAddButton (TranscriptionToolBar *pBar, teBmps eFore, teBmps eDisabled, int id, const wxChar *label)
 

Private Attributes

AButtonmButtons [TTBNumButtons]
 
wxImage * upImage
 
wxImage * downImage
 
wxImage * hiliteImage
 
ASlidermPlaySpeedSlider
 
double mPlaySpeed
 
ASlidermSensitivitySlider
 
wxBrush mBackgroundBrush
 
wxPen mBackgroundPen
 
int mBackgroundWidth
 
int mBackgroundHeight
 
std::unique_ptr< TimeTrackmTimeTrack
 

Additional Inherited Members

- Public Types inherited from ToolBar
using Holder = Destroy_ptr< ToolBar >
 
- Static Public Member Functions inherited from ToolBar
static AButtonMakeButton (wxWindow *parent, teBmps eUp, teBmps eDown, teBmps eHilite, teBmps eDownHi, teBmps eStandardUp, teBmps eStandardDown, teBmps eDisabled, wxWindowID id, wxPoint placement, bool processdownevents, wxSize size)
 
static void MakeAlternateImages (AButton &button, int idx, teBmps eUp, teBmps eDown, teBmps eHilite, teBmps eDownHi, teBmps eStandardUp, teBmps eStandardDown, teBmps eDisabled, wxSize size)
 
static void SetButtonToolTip (AButton &button, const TranslatedInternalString commands[], size_t nCommands)
 
- Protected Member Functions inherited from ToolBar
void SetButton (bool down, AButton *button)
 
void MakeMacRecoloredImage (teBmps eBmpOut, teBmps eBmpIn)
 
void MakeRecoloredImage (teBmps eBmpOut, teBmps eBmpIn)
 
void MakeButtonBackgroundsLarge ()
 
void MakeButtonBackgroundsSmall ()
 
wxBoxSizer * GetSizer ()
 
void Add (wxWindow *window, int proportion=0, int flag=wxALIGN_TOP, int border=0, wxObject *userData=NULL)
 
void Add (wxSizer *sizer, int proportion=0, int flag=0, int border=0, wxObject *userData=NULL)
 
void Add (int width, int height, int proportion=0, int flag=0, int border=0, wxObject *userData=NULL)
 
void AddSpacer (int size=14)
 
void AddStretchSpacer (int prop=1)
 
void Detach (wxWindow *window)
 
void Detach (wxSizer *sizer)
 
void Updated ()
 
int GetResizeGrabberWidth ()
 Returns the width in pixels of the resizer element. More...
 
virtual void Repaint (wxDC *dc)=0
 
void OnErase (wxEraseEvent &event)
 
void OnPaint (wxPaintEvent &event)
 
void OnMouseEvents (wxMouseEvent &event)
 
- Protected Attributes inherited from ToolBar
wxString mLabel
 
wxString mSection
 
int mType
 

Detailed Description

A kind of ToolBar used to help with analysing voice recordings.

Definition at line 68 of file TranscriptionToolBar.h.

Constructor & Destructor Documentation

TranscriptionToolBar::TranscriptionToolBar ( )

Definition at line 92 of file TranscriptionToolBar.cpp.

References mPlaySpeed.

93 : ToolBar(TranscriptionBarID, _("Play-at-Speed"), wxT("Transcription"),true)
94 {
95  mPlaySpeed = 1.0 * 100.0;
96 #ifdef EXPERIMENTAL_VOICE_DETECTION
97  mVk = std::make_unique<VoiceKey>();
98 #endif
99 }
_("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
ToolBar(int type, const wxString &label, const wxString &section, bool resizable=false)
Definition: ToolBar.cpp:312
TranscriptionToolBar::~TranscriptionToolBar ( )
virtual

Definition at line 101 of file TranscriptionToolBar.cpp.

102 {
103 }

Member Function Documentation

AButton * TranscriptionToolBar::AddButton ( TranscriptionToolBar pBar,
teBmps  eFore,
teBmps  eDisabled,
int  id,
const wxChar *  label 
)
staticprivate

This is a convenience function that allows for button creation in MakeButtons() with fewer arguments Very similar to code in ControlToolBar...

Definition at line 146 of file TranscriptionToolBar.cpp.

References ToolBar::Add(), ThemeBase::ImageSize(), ToolBar::MakeButton(), mButtons, and theTheme.

Referenced by Populate().

151 {
152  AButton *&r = pBar->mButtons[id];
153 
154  r = ToolBar::MakeButton(pBar,
155  bmpRecoloredUpSmall, bmpRecoloredDownSmall, bmpRecoloredUpHiliteSmall,bmpRecoloredHiliteSmall,
156  eFore, eFore, eDisabled,
157  wxWindowID(id),
158  wxDefaultPosition,
159  false,
160  theTheme.ImageSize( bmpRecoloredUpSmall ));
161 
162  r->SetLabel(label);
163 // JKC: Unlike ControlToolBar, does not have a focus rect. Shouldn't it?
164 // r->SetFocusRect( r->GetRect().Deflate( 4, 4 ) );
165 
166  pBar->Add( r, 0, wxALIGN_CENTER );
167 
168  return r;
169 }
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
wxString label
Definition: Tags.cpp:733
wxSize ImageSize(int iIndex)
Definition: Theme.cpp:1257
static AButton * MakeButton(wxWindow *parent, teBmps eUp, teBmps eDown, teBmps eHilite, teBmps eDownHi, teBmps eStandardUp, teBmps eStandardDown, teBmps eDisabled, wxWindowID id, wxPoint placement, bool processdownevents, wxSize size)
Definition: ToolBar.cpp:782
void Add(wxWindow *window, int proportion=0, int flag=wxALIGN_TOP, int border=0, wxObject *userData=NULL)
Definition: ToolBar.cpp:628
AButton * mButtons[TTBNumButtons]
A wxButton with mouse-over behaviour.
Definition: AButton.h:28
void TranscriptionToolBar::AdjustPlaySpeed ( float  adj)

Definition at line 948 of file TranscriptionToolBar.cpp.

References ASlider::Decrease(), ASlider::Increase(), mPlaySpeedSlider, and OnSpeedSlider().

Referenced by MenuCommandHandler::OnPlaySpeedDec(), and MenuCommandHandler::OnPlaySpeedInc().

949 {
950  if (adj < 0) {
951  mPlaySpeedSlider->Decrease(-adj);
952  }
953  else {
955  }
956  wxCommandEvent e;
957  OnSpeedSlider(e);
958 }
void OnSpeedSlider(wxCommandEvent &event)
void Increase(float steps)
Definition: ASlider.cpp:1601
void Decrease(float steps)
Definition: ASlider.cpp:1606
void TranscriptionToolBar::Create ( wxWindow *  parent)
overridevirtual

Reimplemented from ToolBar.

Definition at line 105 of file TranscriptionToolBar.cpp.

References ToolBar::Create(), AButton::Disable(), AButton::Enable(), ASlider::Get(), mBackgroundBrush, mBackgroundHeight, mBackgroundPen, mBackgroundWidth, mButtons, mPlaySpeed, and mPlaySpeedSlider.

106 {
107  ToolBar::Create(parent);
108 
109  mBackgroundBrush.SetColour(wxColour(204, 204, 204));
110  mBackgroundPen.SetColour(wxColour(204, 204, 204));
111 
112  mBackgroundHeight = 0;
113  mBackgroundWidth = 0;
114 
115 #ifdef EXPERIMENTAL_VOICE_DETECTION
116  mButtons[TTB_StartOn]->Disable();
117  mButtons[TTB_StartOff]->Disable();
118  mButtons[TTB_EndOn]->Disable();
119  mButtons[TTB_EndOff]->Disable();
120  mButtons[TTB_SelectSound]->Disable();
121  mButtons[TTB_SelectSilence]->Disable();
122  mButtons[TTB_Calibrate]->Enable();
123  mButtons[TTB_AutomateSelection]->Disable();
124  mButtons[TTB_MakeLabel]->Enable();
125 #endif
126 
127  //Old code...
128  //Process a dummy event to set up mPlaySpeed
129  //wxCommandEvent dummy;
130  //OnSpeedSlider(dummy);
131 
132  //JKC: Set speed this way is better, as we don't
133  //then stop Audio if it is playing, so we can be playing
134  //audio and open a second project.
135  mPlaySpeed = (mPlaySpeedSlider->Get()) * 100;
136 
137  // Simulate a size event to set initial placement/size
138  wxSizeEvent event(GetSize(), GetId());
139  event.SetEventObject(this);
140  GetEventHandler()->ProcessEvent(event);
141 }
float Get(bool convert=true)
Definition: ASlider.cpp:1591
virtual void Create(wxWindow *parent)
Definition: ToolBar.cpp:442
void Disable()
Definition: AButton.cpp:502
void Enable()
Definition: AButton.cpp:495
AButton * mButtons[TTBNumButtons]
void TranscriptionToolBar::EnableDisableButtons ( )
overridevirtual

Implements ToolBar.

Definition at line 276 of file TranscriptionToolBar.cpp.

References GetActiveProject(), AudacityProject::GetSel0(), AudacityProject::GetSel1(), AudacityProject::GetTracks(), mButtons, TrackList::Selected(), and AButton::SetEnabled().

277 {
278 #ifdef EXPERIMENTAL_VOICE_DETECTION
280  if (!p) return;
281  // Is anything selected?
282  auto selection = p->GetSel0() < p->GetSel1() && p->GetTracks()->Selected();
283 
284  mButtons[TTB_Calibrate]->SetEnabled(selection);
285 #endif
286 }
double GetSel0() const
Definition: Project.h:204
auto Selected() -> TrackIterRange< TrackType >
Definition: Track.h:1212
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:175
void SetEnabled(bool state)
Definition: AButton.h:98
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:312
double GetSel1() const
Definition: Project.h:205
TrackList * GetTracks()
Definition: Project.h:192
AButton * mButtons[TTBNumButtons]
int TranscriptionToolBar::GetInitialWidth ( )
inlineoverridevirtual

Resizable toolbars should implement these.

Reimplemented from ToolBar.

Definition at line 85 of file TranscriptionToolBar.h.

85 { return 191; }
int TranscriptionToolBar::GetMinToolbarWidth ( )
inlineoverridevirtual

Reimplemented from ToolBar.

Definition at line 86 of file TranscriptionToolBar.h.

86 { return 125; }
double TranscriptionToolBar::GetPlaySpeed ( ) const
inline

Definition at line 122 of file TranscriptionToolBar.h.

References mPlaySpeed.

Referenced by Scrubber::ContinueScrubbingPoll(), Scrubber::MaybeStartScrubbing(), and PlayAtSpeed().

122 { return mPlaySpeed / 100.0; }
void TranscriptionToolBar::GetSamples ( const WaveTrack t,
sampleCount s0,
sampleCount slen 
)
private

Definition at line 402 of file TranscriptionToolBar.cpp.

References GetActiveProject(), WaveTrack::GetOffset(), WaveTrack::GetRate(), AudacityProject::GetSel0(), and AudacityProject::GetSel1().

404 {
405  // GetSamples attempts to translate the start and end selection markers into sample indices
406  // These selection numbers are doubles.
407 
409  if (!p) {
410  return;
411  }
412 
413  //First, get the current selection. It is part of the mViewInfo, which is
414  //part of the project
415 
416  double start = p->GetSel0();
417  double end = p->GetSel1();
418 
419  auto ss0 = sampleCount( (start - t->GetOffset()) * t->GetRate() );
420  auto ss1 = sampleCount( (end - t->GetOffset()) * t->GetRate() );
421 
422  if (start < t->GetOffset()) {
423  ss0 = 0;
424  }
425 
426 #if 0
427  //This adjusts the right samplecount to the maximum sample.
428  if (ss1 >= t->GetNumSamples()) {
429  ss1 = t->GetNumSamples();
430  }
431 #endif
432 
433  if (ss1 < ss0) {
434  ss1 = ss0;
435  }
436 
437  *s0 = ss0;
438  *slen = ss1 - ss0;
439 }
double GetSel0() const
Definition: Project.h:204
double GetOffset() const override
Definition: WaveTrack.cpp:218
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:175
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:312
double GetRate() const
Definition: WaveTrack.cpp:401
double GetSel1() const
Definition: Project.h:205
void TranscriptionToolBar::InitializeTranscriptionToolBar ( )
private
void TranscriptionToolBar::MakeAlternateImages ( teBmps  eFore,
teBmps  eDisabled,
int  id,
unsigned  altIdx 
)
private

Definition at line 171 of file TranscriptionToolBar.cpp.

References ThemeBase::ImageSize(), ToolBar::MakeAlternateImages(), mButtons, and theTheme.

Referenced by Populate().

174 {
176  bmpRecoloredUpSmall, bmpRecoloredDownSmall, bmpRecoloredUpHiliteSmall,bmpRecoloredHiliteSmall,
177  eFore, eFore, eDisabled,
178  theTheme.ImageSize( bmpRecoloredUpSmall ));
179 }
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
wxSize ImageSize(int iIndex)
Definition: Theme.cpp:1257
static void MakeAlternateImages(AButton &button, int idx, teBmps eUp, teBmps eDown, teBmps eHilite, teBmps eDownHi, teBmps eStandardUp, teBmps eStandardDown, teBmps eDisabled, wxSize size)
Definition: ToolBar.cpp:815
AButton * mButtons[TTBNumButtons]
void TranscriptionToolBar::OnCaptureKey ( wxCommandEvent &  event)

Definition at line 354 of file TranscriptionToolBar.cpp.

References mPlaySpeedSlider.

355 {
356  wxKeyEvent *kevent = (wxKeyEvent *)event.GetEventObject();
357  int keyCode = kevent->GetKeyCode();
358 
359  // Pass LEFT/RIGHT/UP/DOWN/PAGEUP/PAGEDOWN through for input/output sliders
360  if (FindFocus() == mPlaySpeedSlider && (keyCode == WXK_LEFT || keyCode == WXK_RIGHT
361  || keyCode == WXK_UP || keyCode == WXK_DOWN
362  || keyCode == WXK_PAGEUP || keyCode == WXK_PAGEDOWN)) {
363  return;
364  }
365 
366  event.Skip();
367 
368  return;
369 }
void TranscriptionToolBar::OnFocus ( wxFocusEvent &  event)

Definition at line 340 of file TranscriptionToolBar.cpp.

References AudacityProject::CaptureKeyboard(), and AudacityProject::ReleaseKeyboard().

Referenced by Populate().

341 {
342  if (event.GetEventType() == wxEVT_KILL_FOCUS) {
344  }
345  else {
347  }
348 
349  Refresh(false);
350 
351  event.Skip();
352 }
static void CaptureKeyboard(wxWindow *handler)
Definition: Project.cpp:5781
static void ReleaseKeyboard(wxWindow *handler)
Definition: Project.cpp:5792
void TranscriptionToolBar::OnKeyEvent ( wxKeyEvent &  event)

Definition at line 372 of file TranscriptionToolBar.cpp.

References gAudioIO, and AudioIO::IsBusy().

373 {
374  if (event.ControlDown()) {
375  event.Skip();
376  return;
377  }
378 
379  if (event.GetKeyCode() == WXK_SPACE) {
380  if (gAudioIO->IsBusy()) {
381  /*Do Stuff Here*/
382  }
383  else {
384  /*Do other stuff Here*/
385  }
386  }
387 }
bool IsBusy() const
Returns true if audio i/o is busy starting, stopping, playing, or recording.
Definition: AudioIO.cpp:2749
AudioIO * gAudioIO
Definition: AudioIO.cpp:492
void TranscriptionToolBar::OnPlaySpeed ( wxCommandEvent &  event)

Definition at line 516 of file TranscriptionToolBar.cpp.

References mButtons, PlayAtSpeed(), TTB_PlaySpeed, and AButton::WasControlDown().

517 {
518  auto button = mButtons[TTB_PlaySpeed];
519 
520  // Let control have precedence over shift
521  const bool cutPreview = mButtons[TTB_PlaySpeed]->WasControlDown();
522  const bool looped = !cutPreview &&
523  button->WasShiftDown();
524  PlayAtSpeed(looped, cutPreview);
525 }
void PlayAtSpeed(bool looped, bool cutPreview)
bool WasControlDown()
Definition: AButton.cpp:490
AButton * mButtons[TTBNumButtons]
void TranscriptionToolBar::OnSpeedSlider ( wxCommandEvent &  event)

Definition at line 527 of file TranscriptionToolBar.cpp.

References ASlider::Get(), mPlaySpeed, mPlaySpeedSlider, and RegenerateTooltips().

Referenced by AdjustPlaySpeed(), and ShowPlaySpeedDialog().

528 {
529  mPlaySpeed = (mPlaySpeedSlider->Get()) * 100;
531 
532  // If IO is busy, abort immediately
533  // AWD: This is disabled to work around a hang on Linux when PulseAudio is
534  // used. If we figure that one out we can re-enable this code.
535  //if (gAudioIO->IsBusy()) {
536  // OnPlaySpeed(event);
537  //}
538 }
float Get(bool convert=true)
Definition: ASlider.cpp:1591
void RegenerateTooltips() override
void TranscriptionToolBar::PlayAtSpeed ( bool  looped,
bool  cutPreview 
)

Definition at line 442 of file TranscriptionToolBar.cpp.

References TrackList::Any(), ControlToolBar::CutPreview, gAudioIO, GetActiveProject(), AudacityProject::GetControlToolBar(), AudacityProject::GetDefaultPlayOptions(), AudacityProject::GetPlayRegion(), GetPlaySpeed(), AudacityProject::GetScrubber(), AudacityProject::GetTrackFactory(), AudacityProject::GetTracks(), gPrefs, AudioIO::IsBusy(), ControlToolBar::Looped, mButtons, mPlaySpeed, mTimeTrack, TrackFactory::NewTimeTrack(), normalPlay, AudioIOStartStreamOptions::playLooped, ControlToolBar::PlayPlayRegion(), SetButton(), Scrubber::StartSpeedPlay(), ControlToolBar::StopPlaying(), and ControlToolBar::Straight.

Referenced by MenuCommandHandler::OnPlayAtSpeed(), MenuCommandHandler::OnPlayAtSpeedCutPreview(), MenuCommandHandler::OnPlayAtSpeedLooped(), and OnPlaySpeed().

443 {
444  // Can't do anything without an active project
446  if (!p) {
447  return;
448  }
449 
450  // Fixed speed play is the old method, that uses a time track.
451  // VariSpeed play reuses Scrubbing.
452  bool bFixedSpeedPlay = !gPrefs->ReadBool(wxT("/AudioIO/VariSpeedPlay"), true);
453  // Scrubbing doesn't support note tracks, but the fixed-speed method using time tracks does.
454  if (p->GetTracks()->Any<NoteTrack>())
455  bFixedSpeedPlay = true;
456 
457  // Scrubbing only supports straight through play.
458  // So if looped or cutPreview, we have to fall back to fixed speed.
459  bFixedSpeedPlay = bFixedSpeedPlay || looped || cutPreview;
460  if (bFixedSpeedPlay)
461  {
462  // Create a TimeTrack if we haven't done so already
463  if (!mTimeTrack) {
465  if (!mTimeTrack) {
466  return;
467  }
468  }
469  // Set the speed range
470  //mTimeTrack->SetRangeUpper((double)mPlaySpeed / 100.0);
471  //mTimeTrack->SetRangeLower((double)mPlaySpeed / 100.0);
472  mTimeTrack->GetEnvelope()->Flatten((double)mPlaySpeed / 100.0);
473  }
474 
475  // Pop up the button
477 
478  // If IO is busy, abort immediately
479  if (gAudioIO->IsBusy()) {
481  }
482 
483  // Get the current play region
484  double playRegionStart, playRegionEnd;
485  p->GetPlayRegion(&playRegionStart, &playRegionEnd);
486 
487  // Start playing
488  if (playRegionStart < 0)
489  return;
490  if (bFixedSpeedPlay)
491  {
493  options.playLooped = looped;
494  // No need to set cutPreview options.
495  // Due to a rather hacky approach, the appearance is used
496  // to signal use of cutpreview to code below.
497  options.timeTrack = mTimeTrack.get();
498  ControlToolBar::PlayAppearance appearance =
503  (SelectedRegion(playRegionStart, playRegionEnd),
504  options,
506  appearance);
507  }
508  else
509  {
510  Scrubber &Scrubber = p->GetScrubber();
511  Scrubber.StartSpeedPlay(GetPlaySpeed(), playRegionStart, playRegionEnd);
512  }
513 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
AudioIOStartStreamOptions GetDefaultPlayOptions()
Definition: Project.cpp:1300
Scrubber & GetScrubber()
Definition: Project.h:804
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:1195
void StopPlaying(bool stopStream=true)
void SetButton(bool newstate, AButton *button)
bool IsBusy() const
Returns true if audio i/o is busy starting, stopping, playing, or recording.
Definition: AudioIO.cpp:2749
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:175
std::unique_ptr< TimeTrack > NewTimeTrack()
Definition: TimeTrack.cpp:35
double GetPlaySpeed() const
Defines a selected portion of a project.
struct holding stream options, including a pointer to the TimeTrack and AudioIOListener and whether t...
Definition: AudioIO.h:124
std::unique_ptr< TimeTrack > mTimeTrack
AudioIO * gAudioIO
Definition: AudioIO.cpp:492
int PlayPlayRegion(const SelectedRegion &selectedRegion, const AudioIOStartStreamOptions &options, PlayMode playMode, PlayAppearance appearance=PlayAppearance::Straight, bool backwards=false, bool playWhiteSpace=false)
ControlToolBar * GetControlToolBar()
Definition: Project.cpp:4909
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:312
TrackList * GetTracks()
Definition: Project.h:192
void GetPlayRegion(double *playRegionStart, double *playRegionEnd)
Definition: Project.cpp:5337
AButton * mButtons[TTBNumButtons]
bool StartSpeedPlay(double speed, double time0, double time1)
Definition: Scrubbing.cpp:451
TrackFactory * GetTrackFactory()
Definition: Project.cpp:1442
A Track that is used for Midi notes. (Somewhat old code).
void TranscriptionToolBar::Populate ( )
overridevirtual

Implements ToolBar.

Definition at line 181 of file TranscriptionToolBar.cpp.

References _(), ToolBar::Add(), AddButton(), ThemeBase::Colour(), AButton::FollowModifierKeys(), ASlider::Options::Line(), MakeAlternateImages(), ToolBar::MakeButtonBackgroundsSmall(), mButtons, mPlaySpeed, mPlaySpeedSlider, mSensitivitySlider, OnFocus(), ASlider::Options::Page(), safenew, ASlider::Set(), SPEED_SLIDER, ASlider::Options::Style(), theTheme, TTB_PlaySpeed, and UpdatePrefs().

182 {
183  SetBackgroundColour( theTheme.Colour( clrMedium ) );
184 // Very similar to code in ControlToolBar...
185 // Very similar to code in EditToolBar
187 
188  AddButton(this, bmpPlay, bmpPlayDisabled, TTB_PlaySpeed,
189  _("Play at selected speed"));
190  MakeAlternateImages(bmpLoop, bmpLoopDisabled, TTB_PlaySpeed, 1);
191  MakeAlternateImages(bmpCutPreview, bmpCutPreviewDisabled, TTB_PlaySpeed, 2);
193 
194  //Add a slider that controls the speed of playback.
195  const int SliderWidth=100;
198  _("Playback Speed"),
199  wxDefaultPosition,
200  wxSize(SliderWidth,25),
202  .Style( SPEED_SLIDER )
203  // 6 steps using page up/down, and 60 using arrow keys
204  .Line( 0.16667f )
205  .Page( 1.6667f )
206  );
207  mPlaySpeedSlider->SetSizeHints(wxSize(100, 25), wxSize(2000, 25));
208  mPlaySpeedSlider->Set(mPlaySpeed / 100.0);
209  mPlaySpeedSlider->SetLabel(_("Playback Speed"));
210  Add( mPlaySpeedSlider, 1, wxALIGN_CENTER );
211  mPlaySpeedSlider->Bind(wxEVT_SET_FOCUS,
213  this);
214  mPlaySpeedSlider->Bind(wxEVT_KILL_FOCUS,
216  this);
217 
218 #ifdef EXPERIMENTAL_VOICE_DETECTION
219 // If we need these strings translated, then search and replace
220 // TRANSLATBLE by _ and remove this #define.
221 #define TRANSLATABLE( x ) wxT( x )
222  AddButton(this, bmpTnStartOn, bmpTnStartOnDisabled, TTB_StartOn,
223  TRANSLATABLE("Adjust left selection to next onset"));
224  AddButton(this, bmpTnEndOn, bmpTnEndOnDisabled, TTB_EndOn,
225  TRANSLATABLE("Adjust right selection to previous offset"));
226  AddButton(this, bmpTnStartOff, bmpTnStartOffDisabled, TTB_StartOff,
227  TRANSLATABLE("Adjust left selection to next offset"));
228  AddButton(this, bmpTnEndOff, bmpTnEndOffDisabled, TTB_EndOff,
229  TRANSLATABLE("Adjust right selection to previous onset"));
230  AddButton(this, bmpTnSelectSound, bmpTnSelectSoundDisabled, TTB_SelectSound,
231  TRANSLATABLE("Select region of sound around cursor"));
232  AddButton(this, bmpTnSelectSilence, bmpTnSelectSilenceDisabled, TTB_SelectSilence,
233  TRANSLATABLE("Select region of silence around cursor"));
234  AddButton(this, bmpTnAutomateSelection, bmpTnAutomateSelectionDisabled, TTB_AutomateSelection,
235  TRANSLATABLE("Automatically make labels from words"));
236  AddButton(this, bmpTnMakeTag, bmpTnMakeTagDisabled, TTB_MakeLabel,
237  TRANSLATABLE("Add label at selection"));
238  AddButton(this, bmpTnCalibrate, bmpTnCalibrateDisabled, TTB_Calibrate,
239  TRANSLATABLE("Calibrate voicekey"));
240 
242  TTB_SensitivitySlider,
243  TRANSLATABLE("Adjust Sensitivity"),
244  wxDefaultPosition,
245  wxSize(SliderWidth,25),
246  SPEED_SLIDER);
247  mSensitivitySlider->Set(.5);
248  mSensitivitySlider->SetLabel(TRANSLATABLE("Sensitivity"));
249  Add( mSensitivitySlider, 0, wxALIGN_CENTER );
250 
251  wxString choices[] =
252  {
253  TRANSLATABLE("Energy"),
254  TRANSLATABLE("Sign Changes (Low Threshold)"),
255  TRANSLATABLE("Sign Changes (High Threshold)"),
256  TRANSLATABLE("Direction Changes (Low Threshold)"),
257  TRANSLATABLE("Direction Changes (High Threshold)")
258  };
259 
260  mKeyTypeChoice = safenew wxChoice(this, TTB_KeyType,
261  wxDefaultPosition,
262  wxDefaultSize,
263  5,
264  choices );
265  mKeyTypeChoice->SetName(TRANSLATABLE("Key type"));
266  mKeyTypeChoice->SetSelection(0);
267  Add( mKeyTypeChoice, 0, wxALIGN_CENTER );
268 #endif
269 
270  // Add a little space
271  Add(2, -1);
272 
273  UpdatePrefs();
274 }
void MakeButtonBackgroundsSmall()
Definition: ToolBar.cpp:744
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
void MakeAlternateImages(teBmps eFore, teBmps eDisabled, int id, unsigned altIdx)
#define SPEED_SLIDER
Definition: ASlider.h:47
void FollowModifierKeys()
Definition: AButton.cpp:258
#define safenew
Definition: Audacity.h:230
Options & Page(float p)
Definition: ASlider.h:268
void OnFocus(wxFocusEvent &event)
static AButton * AddButton(TranscriptionToolBar *pBar, teBmps eFore, teBmps eDisabled, int id, const wxChar *label)
void Add(wxWindow *window, int proportion=0, int flag=wxALIGN_TOP, int border=0, wxObject *userData=NULL)
Definition: ToolBar.cpp:628
void Set(float value)
Definition: ASlider.cpp:1596
Options & Line(float l)
Definition: ASlider.h:267
_("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
ASlider is a custom slider, allowing for a slicker look and feel.
Definition: ASlider.h:243
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1225
AButton * mButtons[TTBNumButtons]
Options & Style(int s)
Definition: ASlider.h:260
void TranscriptionToolBar::RegenerateTooltips ( )
overrideprivatevirtual

Implements ToolBar.

Definition at line 299 of file TranscriptionToolBar.cpp.

References mButtons, mSensitivitySlider, ToolBar::SetButtonToolTip(), TTB_PlaySpeed, and XO.

Referenced by OnSpeedSlider(), and UpdatePrefs().

300 {
301  // We could also mention the shift- and ctrl-modified versions in the
302  // tool tip... but it would get long
303 
304  static const struct Entry {
305  int tool;
306  wxString commandName;
307  wxString untranslatedLabel;
308  wxString commandName2;
309  wxString untranslatedLabel2;
310  } table[] = {
311  { TTB_PlaySpeed, wxT("PlayAtSpeed"), XO("Play-at-Speed"),
312  wxT("PlayAtSpeedLooped"), XO("Looped-Play-at-Speed")
313  },
314  };
315 
316  for (const auto &entry : table) {
317  TranslatedInternalString commands[] = {
318  { entry.commandName, wxGetTranslation(entry.untranslatedLabel) },
319  { entry.commandName2, wxGetTranslation(entry.untranslatedLabel2) },
320  };
321  ToolBar::SetButtonToolTip( *mButtons[entry.tool], commands, 2u );
322  }
323 
324 #ifdef EXPERIMENTAL_VOICE_DETECTION
325  mButtons[TTB_StartOn]->SetToolTip(TRANSLATABLE("Left-to-On"));
326  mButtons[TTB_EndOn]->SetToolTip( TRANSLATABLE("Right-to-Off"));
327  mButtons[TTB_StartOff]->SetToolTip( TRANSLATABLE("Left-to-Off"));
328  mButtons[TTB_EndOff]->SetToolTip( TRANSLATABLE("Right-to-On"));
329  mButtons[TTB_SelectSound]->SetToolTip( TRANSLATABLE("Select-Sound"));
330  mButtons[TTB_SelectSilence]->SetToolTip( TRANSLATABLE("Select-Silence"));
331  mButtons[TTB_AutomateSelection]->SetToolTip( TRANSLATABLE("Make Labels"));
332  mButtons[TTB_MakeLabel]->SetToolTip( TRANSLATABLE("Add Label"));
333  mButtons[TTB_Calibrate]->SetToolTip( TRANSLATABLE("Calibrate"));
334 
335  mSensitivitySlider->SetToolTip(TRANSLATABLE("Sensitivity"));
336  mKeyTypeChoice->SetToolTip(TRANSLATABLE("Key type"));
337 #endif
338 }
#define XO(s)
Definition: Internat.h:33
AButton * mButtons[TTBNumButtons]
static void SetButtonToolTip(AButton &button, const TranslatedInternalString commands[], size_t nCommands)
Definition: ToolBar.cpp:840
void TranscriptionToolBar::Repaint ( wxDC *  WXUNUSEDdc)
inlineoverride

Definition at line 82 of file TranscriptionToolBar.h.

82 {};
void TranscriptionToolBar::SetButton ( bool  newstate,
AButton button 
)
private

Definition at line 392 of file TranscriptionToolBar.cpp.

References AButton::PopUp(), and AButton::PushDown().

Referenced by PlayAtSpeed().

393 {
394  if (down) {
395  button->PushDown();
396  }
397  else {
398  button->PopUp();
399  }
400 }
void PopUp()
Definition: AButton.cpp:525
void PushDown()
Definition: AButton.cpp:517
void TranscriptionToolBar::SetEnabled ( bool  enabled)

Definition at line 930 of file TranscriptionToolBar.cpp.

References mButtons, AButton::SetEnabled(), and TTB_PlaySpeed.

Referenced by ControlToolBar::EnableDisableButtons().

931 {
932  mButtons[TTB_PlaySpeed]->SetEnabled(enabled);
933 }
void SetEnabled(bool state)
Definition: AButton.h:98
AButton * mButtons[TTBNumButtons]
void TranscriptionToolBar::SetPlaying ( bool  down,
bool  looped,
bool  cutPreview 
)

Definition at line 935 of file TranscriptionToolBar.cpp.

References mButtons, AButton::PopUp(), AButton::PushDown(), AButton::SetAlternateIdx(), and TTB_PlaySpeed.

936 {
937  AButton *const button = mButtons[TTB_PlaySpeed];
938  if (down) {
939  button->SetAlternateIdx(cutPreview ? 2 : looped ? 1 : 0);
940  button->PushDown();
941  }
942  else {
943  button->SetAlternateIdx(0);
944  button->PopUp();
945  }
946 }
void SetAlternateIdx(unsigned idx)
Definition: AButton.cpp:248
void PopUp()
Definition: AButton.cpp:525
void PushDown()
Definition: AButton.cpp:517
AButton * mButtons[TTBNumButtons]
A wxButton with mouse-over behaviour.
Definition: AButton.h:28
void TranscriptionToolBar::ShowPlaySpeedDialog ( )

Definition at line 922 of file TranscriptionToolBar.cpp.

References mPlaySpeedSlider, OnSpeedSlider(), and ASlider::ShowDialog().

Referenced by MenuCommandHandler::OnSetPlaySpeed().

923 {
925  mPlaySpeedSlider->Refresh();
926  wxCommandEvent e;
927  OnSpeedSlider(e);
928 }
void OnSpeedSlider(wxCommandEvent &event)
bool ShowDialog(wxPoint pos=wxPoint(-1,-1))
Definition: ASlider.cpp:1611
void TranscriptionToolBar::UpdatePrefs ( )
overridevirtual

Reimplemented from ToolBar.

Definition at line 288 of file TranscriptionToolBar.cpp.

References _(), RegenerateTooltips(), ToolBar::SetLabel(), and ToolBar::UpdatePrefs().

Referenced by Populate().

289 {
291 
292  // Set label to pull in language change
293  SetLabel(_("Play-at-Speed"));
294 
295  // Give base class a chance
297 }
virtual void UpdatePrefs()
Definition: ToolBar.cpp:553
void SetLabel(const wxString &label) override
Definition: ToolBar.cpp:378
_("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 RegenerateTooltips() override

Member Data Documentation

wxImage* TranscriptionToolBar::downImage
private

Definition at line 141 of file TranscriptionToolBar.h.

wxImage* TranscriptionToolBar::hiliteImage
private

Definition at line 142 of file TranscriptionToolBar.h.

wxBrush TranscriptionToolBar::mBackgroundBrush
private

Definition at line 154 of file TranscriptionToolBar.h.

Referenced by Create().

int TranscriptionToolBar::mBackgroundHeight
private

Definition at line 157 of file TranscriptionToolBar.h.

Referenced by Create().

wxPen TranscriptionToolBar::mBackgroundPen
private

Definition at line 155 of file TranscriptionToolBar.h.

Referenced by Create().

int TranscriptionToolBar::mBackgroundWidth
private

Definition at line 156 of file TranscriptionToolBar.h.

Referenced by Create().

AButton* TranscriptionToolBar::mButtons[TTBNumButtons]
private
double TranscriptionToolBar::mPlaySpeed
private
ASlider* TranscriptionToolBar::mPlaySpeedSlider
private
ASlider* TranscriptionToolBar::mSensitivitySlider
private

Definition at line 146 of file TranscriptionToolBar.h.

Referenced by Populate(), and RegenerateTooltips().

std::unique_ptr<TimeTrack> TranscriptionToolBar::mTimeTrack
private

Definition at line 159 of file TranscriptionToolBar.h.

Referenced by PlayAtSpeed().

wxImage* TranscriptionToolBar::upImage
private

Definition at line 140 of file TranscriptionToolBar.h.


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