Audacity  2.2.2
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
 
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:311
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:768
void Add(wxWindow *window, int proportion=0, int flag=wxALIGN_TOP, int border=0, wxObject *userData=NULL)
Definition: ToolBar.cpp:614
AButton * mButtons[TTBNumButtons]
A wxButton with mouse-over behaviour.
Definition: AButton.h:28
void TranscriptionToolBar::AdjustPlaySpeed ( float  adj)

Definition at line 991 of file TranscriptionToolBar.cpp.

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

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

992 {
993  if (adj < 0) {
994  mPlaySpeedSlider->Decrease(-adj);
995  }
996  else {
998  }
999  wxCommandEvent e;
1000  OnSpeedSlider(e);
1001 }
void OnSpeedSlider(wxCommandEvent &event)
void Increase(float steps)
Definition: ASlider.cpp:1593
void Decrease(float steps)
Definition: ASlider.cpp:1598
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:1583
virtual void Create(wxWindow *parent)
Definition: ToolBar.cpp:441
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, and AButton::SetEnabled().

277 {
278 #ifdef EXPERIMENTAL_VOICE_DETECTION
280  if (!p) return;
281  // Is anything selected?
282  bool selection = false;
283  TrackListIterator iter(p->GetTracks());
284  for (Track *t = iter.First(); t; t = iter.Next())
285  if (t->GetSelected()) {
286  selection = true;
287  break;
288  }
289  selection &= (p->GetSel0() < p->GetSel1());
290 
291  mButtons[TTB_Calibrate]->SetEnabled(selection);
292 #endif
293 }
double GetSel0() const
Definition: Project.h:204
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
void SetEnabled(bool state)
Definition: AButton.h:98
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
An iterator for a TrackList.
Definition: Track.h:406
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:309
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 409 of file TranscriptionToolBar.cpp.

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

411 {
412  // GetSamples attempts to translate the start and end selection markers into sample indices
413  // These selection numbers are doubles.
414 
416  if (!p) {
417  return;
418  }
419 
420  //First, get the current selection. It is part of the mViewInfo, which is
421  //part of the project
422 
423  double start = p->GetSel0();
424  double end = p->GetSel1();
425 
426  auto ss0 = sampleCount( (start - t->GetOffset()) * t->GetRate() );
427  auto ss1 = sampleCount( (end - t->GetOffset()) * t->GetRate() );
428 
429  if (start < t->GetOffset()) {
430  ss0 = 0;
431  }
432 
433 #if 0
434  //This adjusts the right samplecount to the maximum sample.
435  if (ss1 >= t->GetNumSamples()) {
436  ss1 = t->GetNumSamples();
437  }
438 #endif
439 
440  if (ss1 < ss0) {
441  ss1 = ss0;
442  }
443 
444  *s0 = ss0;
445  *slen = ss1 - ss0;
446 }
double GetSel0() const
Definition: Project.h:204
double GetOffset() const override
Definition: WaveTrack.cpp:219
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:309
double GetRate() const
Definition: WaveTrack.cpp:398
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:801
AButton * mButtons[TTBNumButtons]
void TranscriptionToolBar::OnCaptureKey ( wxCommandEvent &  event)

Definition at line 361 of file TranscriptionToolBar.cpp.

References mPlaySpeedSlider.

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

Definition at line 347 of file TranscriptionToolBar.cpp.

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

Referenced by Populate().

348 {
349  if (event.GetEventType() == wxEVT_KILL_FOCUS) {
351  }
352  else {
354  }
355 
356  Refresh(false);
357 
358  event.Skip();
359 }
static void CaptureKeyboard(wxWindow *handler)
Definition: Project.cpp:5985
static void ReleaseKeyboard(wxWindow *handler)
Definition: Project.cpp:5996
void TranscriptionToolBar::OnKeyEvent ( wxKeyEvent &  event)

Definition at line 379 of file TranscriptionToolBar.cpp.

References gAudioIO, and AudioIO::IsBusy().

380 {
381  if (event.ControlDown()) {
382  event.Skip();
383  return;
384  }
385 
386  if (event.GetKeyCode() == WXK_SPACE) {
387  if (gAudioIO->IsBusy()) {
388  /*Do Stuff Here*/
389  }
390  else {
391  /*Do other stuff Here*/
392  }
393  }
394 }
bool IsBusy() const
Returns true if audio i/o is busy starting, stopping, playing, or recording.
Definition: AudioIO.cpp:2852
AudioIO * gAudioIO
Definition: AudioIO.cpp:483
void TranscriptionToolBar::OnPlaySpeed ( wxCommandEvent &  event)

Definition at line 527 of file TranscriptionToolBar.cpp.

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

528 {
529  auto button = mButtons[TTB_PlaySpeed];
530 
531  // Let control have precedence over shift
532  const bool cutPreview = mButtons[TTB_PlaySpeed]->WasControlDown();
533  const bool looped = !cutPreview &&
534  button->WasShiftDown();
535  PlayAtSpeed(looped, cutPreview);
536 }
void PlayAtSpeed(bool looped, bool cutPreview)
bool WasControlDown()
Definition: AButton.cpp:490
AButton * mButtons[TTBNumButtons]
void TranscriptionToolBar::OnSpeedSlider ( wxCommandEvent &  event)

Definition at line 538 of file TranscriptionToolBar.cpp.

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

Referenced by AdjustPlaySpeed(), and ShowPlaySpeedDialog().

539 {
540  mPlaySpeed = (mPlaySpeedSlider->Get()) * 100;
542 
543  // If IO is busy, abort immediately
544  // AWD: This is disabled to work around a hang on Linux when PulseAudio is
545  // used. If we figure that one out we can re-enable this code.
546  //if (gAudioIO->IsBusy()) {
547  // OnPlaySpeed(event);
548  //}
549 }
float Get(bool convert=true)
Definition: ASlider.cpp:1583
void RegenerateTooltips() override
void TranscriptionToolBar::PlayAtSpeed ( bool  looped,
bool  cutPreview 
)

Definition at line 449 of file TranscriptionToolBar.cpp.

References 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 AudacityProject::OnPlayAtSpeed(), AudacityProject::OnPlayAtSpeedCutPreview(), AudacityProject::OnPlayAtSpeedLooped(), and OnPlaySpeed().

450 {
451  // Can't do anything without an active project
453  if (!p) {
454  return;
455  }
456 
457  // Fixed speed play is the old method, that uses a time track.
458  // VariSpeed play reuses Scrubbing.
459  bool bFixedSpeedPlay = !gPrefs->ReadBool(wxT("/AudioIO/VariSpeedPlay"), true);
460  // Scrubbing doesn't support note tracks, but the fixed-speed method using time tracks does.
461  TrackListIterator iter(p->GetTracks());
462  for (Track *t = iter.First(); t; t = iter.Next()) {
463  if (t->GetKind() == Track::Note) {
464  bFixedSpeedPlay = true;
465  break;
466  }
467  }
468  // Scrubbing only supports straight through play.
469  // So if looped or cutPreview, we have to fall back to fixed speed.
470  bFixedSpeedPlay = bFixedSpeedPlay || looped || cutPreview;
471  if (bFixedSpeedPlay)
472  {
473  // Create a TimeTrack if we haven't done so already
474  if (!mTimeTrack) {
476  if (!mTimeTrack) {
477  return;
478  }
479  }
480  // Set the speed range
481  //mTimeTrack->SetRangeUpper((double)mPlaySpeed / 100.0);
482  //mTimeTrack->SetRangeLower((double)mPlaySpeed / 100.0);
483  mTimeTrack->GetEnvelope()->Flatten((double)mPlaySpeed / 100.0);
484  }
485 
486  // Pop up the button
488 
489  // If IO is busy, abort immediately
490  if (gAudioIO->IsBusy()) {
492  }
493 
494  // Get the current play region
495  double playRegionStart, playRegionEnd;
496  p->GetPlayRegion(&playRegionStart, &playRegionEnd);
497 
498  // Start playing
499  if (playRegionStart < 0)
500  return;
501  if (bFixedSpeedPlay)
502  {
504  options.playLooped = looped;
505  // No need to set cutPreview options.
506  // Due to a rather hacky approach, the appearance is used
507  // to signal use of cutpreview to code below.
508  options.timeTrack = mTimeTrack.get();
509  ControlToolBar::PlayAppearance appearance =
514  (SelectedRegion(playRegionStart, playRegionEnd),
515  options,
517  appearance);
518  }
519  else
520  {
521  Scrubber &Scrubber = p->GetScrubber();
522  Scrubber.StartSpeedPlay(GetPlaySpeed(), playRegionStart, playRegionEnd);
523  }
524 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
AudioIOStartStreamOptions GetDefaultPlayOptions()
Definition: Project.cpp:1301
Scrubber & GetScrubber()
Definition: Project.h:804
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:2852
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
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
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
std::unique_ptr< TimeTrack > mTimeTrack
An iterator for a TrackList.
Definition: Track.h:406
AudioIO * gAudioIO
Definition: AudioIO.cpp:483
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:5015
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:309
TrackList * GetTracks()
Definition: Project.h:192
void GetPlayRegion(double *playRegionStart, double *playRegionEnd)
Definition: Project.cpp:5472
AButton * mButtons[TTBNumButtons]
bool StartSpeedPlay(double speed, double time0, double time1)
Definition: Scrubbing.cpp:445
TrackFactory * GetTrackFactory()
Definition: Project.cpp:1437
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( 0.16667f )
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:730
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:614
void Set(float value)
Definition: ASlider.cpp:1588
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 306 of file TranscriptionToolBar.cpp.

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

Referenced by OnSpeedSlider(), and UpdatePrefs().

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

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

Referenced by PlayAtSpeed().

400 {
401  if (down) {
402  button->PushDown();
403  }
404  else {
405  button->PopUp();
406  }
407 }
void PopUp()
Definition: AButton.cpp:525
void PushDown()
Definition: AButton.cpp:517
void TranscriptionToolBar::SetEnabled ( bool  enabled)

Definition at line 973 of file TranscriptionToolBar.cpp.

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

Referenced by ControlToolBar::EnableDisableButtons().

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

Definition at line 978 of file TranscriptionToolBar.cpp.

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

979 {
980  AButton *const button = mButtons[TTB_PlaySpeed];
981  if (down) {
982  button->SetAlternateIdx(cutPreview ? 2 : looped ? 1 : 0);
983  button->PushDown();
984  }
985  else {
986  button->SetAlternateIdx(0);
987  button->PopUp();
988  }
989 }
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 965 of file TranscriptionToolBar.cpp.

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

Referenced by AudacityProject::OnSetPlaySpeed().

966 {
968  mPlaySpeedSlider->Refresh();
969  wxCommandEvent e;
970  OnSpeedSlider(e);
971 }
void OnSpeedSlider(wxCommandEvent &event)
bool ShowDialog(wxPoint pos=wxPoint(-1,-1))
Definition: ASlider.cpp:1603
void TranscriptionToolBar::UpdatePrefs ( )
overridevirtual

Reimplemented from ToolBar.

Definition at line 295 of file TranscriptionToolBar.cpp.

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

Referenced by Populate().

296 {
298 
299  // Set label to pull in language change
300  SetLabel(_("Play-at-Speed"));
301 
302  // Give base class a chance
304 }
virtual void UpdatePrefs()
Definition: ToolBar.cpp:539
void SetLabel(const wxString &label) override
Definition: ToolBar.cpp:377
_("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: