Audacity 3.2.0
Public Member Functions | Static 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:
[legend]
Collaboration diagram for TranscriptionToolBar:
[legend]

Public Member Functions

 TranscriptionToolBar (AudacityProject &project)
 
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 (AudacityProject &project, int type, const TranslatableString &label, const wxString &section, bool resizable=false)
 
virtual ~ToolBar ()
 
bool AcceptsFocus () const override
 
bool AcceptsFocusFromKeyboard () const override
 
virtual void SetToDefaultSize ()
 
virtual void Create (wxWindow *parent)
 
virtual void EnableDisableButtons ()=0
 
virtual void ReCreateButtons ()
 
void UpdatePrefs () override
 
virtual void RegenerateTooltips ()=0
 
int GetType ()
 
TranslatableString GetTitle ()
 
TranslatableString GetLabel ()
 
wxString GetSection ()
 
ToolDockGetDock ()
 
void SetLabel (const TranslatableString &label)
 
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 int GetInitialWidth ()
 Resizable toolbars should implement these. More...
 
virtual int GetMinToolbarWidth ()
 
virtual wxSize GetDockedSize ()
 
wxSize GetSmartDockedSize ()
 
virtual void ResizingDone ()
 
- Public Member Functions inherited from wxPanelWrapper
 wxPanelWrapper ()
 
 wxPanelWrapper (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
void SetLabel (const TranslatableString &label)
 
void SetName (const TranslatableString &name)
 
void SetToolTip (const TranslatableString &toolTip)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Static Public Member Functions

static TranscriptionToolBarGet (AudacityProject &project)
 
static const TranscriptionToolBarGet (const AudacityProject &project)
 
- 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 AButtonMakeButton (ToolBar *parent, teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled, int id, bool processdownevents, const TranslatableString &label)
 
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 (AudacityProject &project, AButton &button, const ComponentInterfaceSymbol commands[], size_t nCommands)
 
static void MakeButtonBackgroundsSmall ()
 
static void MakeButtonBackgroundsLarge ()
 

Private Member Functions

void SetPlaySpeed (double value)
 
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 TranslatableString &label)
 

Private Attributes

AButtonmButtons [TTBNumButtons]
 
wxImageupImage
 
wxImagedownImage
 
wxImagehiliteImage
 
ASlidermPlaySpeedSlider
 
double mPlaySpeed
 
ASlidermSensitivitySlider
 
int mBackgroundWidth
 
int mBackgroundHeight
 
std::shared_ptr< BoundedEnvelopemEnvelope
 

Additional Inherited Members

- Public Types inherited from ToolBar
using Holder = wxWindowPtr< ToolBar >
 
- Protected Member Functions inherited from ToolBar
void SetButton (bool down, AButton *button)
 
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 Populate ()=0
 
virtual void Repaint (wxDC *dc)=0
 
void OnErase (wxEraseEvent &event)
 
void OnPaint (wxPaintEvent &event)
 
void OnMouseEvents (wxMouseEvent &event)
 
- Protected Member Functions inherited from PrefsListener
virtual void UpdateSelectedPrefs (int id)
 
 PrefsListener ()
 
virtual ~PrefsListener ()
 
virtual void UpdatePrefs ()=0
 
- Static Protected Member Functions inherited from ToolBar
static void MakeMacRecoloredImage (teBmps eBmpOut, teBmps eBmpIn)
 
static void MakeMacRecoloredImageSize (teBmps eBmpOut, teBmps eBmpIn, const wxSize &size)
 
static void MakeRecoloredImage (teBmps eBmpOut, teBmps eBmpIn)
 
static void MakeRecoloredImageSize (teBmps eBmpOut, teBmps eBmpIn, const wxSize &size)
 
- Static Protected Member Functions inherited from PrefsListener
static void Broadcast (int id=0)
 Call this static function to notify all PrefsListener objects. More...
 
- Protected Attributes inherited from ToolBar
AudacityProjectmProject
 
TranslatableString mLabel
 
wxString mSection
 
int mType
 

Detailed Description

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

Definition at line 61 of file TranscriptionToolBar.h.

Constructor & Destructor Documentation

◆ TranscriptionToolBar()

TranscriptionToolBar::TranscriptionToolBar ( AudacityProject project)

Definition at line 97 of file TranscriptionToolBar.cpp.

98: ToolBar( project,
99 TranscriptionBarID, XO("Play-at-Speed"), wxT("Transcription"), true )
100{
101 SetPlaySpeed( 1.0 * 100.0 );
102#ifdef EXPERIMENTAL_VOICE_DETECTION
103 mVk = std::make_unique<VoiceKey>();
104#endif
105}
wxT("CloseDown"))
#define XO(s)
Definition: Internat.h:31
@ TranscriptionBarID
Definition: ToolBar.h:78
ToolBar(AudacityProject &project, int type, const TranslatableString &label, const wxString &section, bool resizable=false)
Definition: ToolBar.cpp:330
void SetPlaySpeed(double value)

References SetPlaySpeed().

Here is the call graph for this function:

◆ ~TranscriptionToolBar()

TranscriptionToolBar::~TranscriptionToolBar ( )
virtual

Definition at line 107 of file TranscriptionToolBar.cpp.

108{
109}

Member Function Documentation

◆ AddButton()

AButton * TranscriptionToolBar::AddButton ( TranscriptionToolBar pBar,
teBmps  eFore,
teBmps  eDisabled,
int  id,
const TranslatableString 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 166 of file TranscriptionToolBar.cpp.

171{
172 AButton *&r = pBar->mButtons[id];
173
174 r = ToolBar::MakeButton(pBar,
175 bmpRecoloredUpSmall, bmpRecoloredDownSmall, bmpRecoloredUpHiliteSmall,bmpRecoloredHiliteSmall,
176 eFore, eFore, eDisabled,
177 wxWindowID(id),
178 wxDefaultPosition,
179 false,
180 theTheme.ImageSize( bmpRecoloredUpSmall ));
181
182 r->SetLabel(label);
183// JKC: Unlike ControlToolBar, does not have a focus rect. Shouldn't it?
184// r->SetFocusRect( r->GetRect().Deflate( 4, 4 ) );
185
186 pBar->Add( r, 0, wxALIGN_CENTER );
187
188 return r;
189}
TranslatableString label
Definition: TagsEditor.cpp:163
THEME_API Theme theTheme
Definition: Theme.cpp:82
int id
A wxButton with mouse-over behaviour.
Definition: AButton.h:104
void SetLabel(const TranslatableString &label)
Definition: AButton.cpp:192
wxSize ImageSize(int iIndex)
void Add(wxWindow *window, int proportion=0, int flag=wxALIGN_TOP, int border=0, wxObject *userData=NULL)
Definition: ToolBar.cpp:695
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:861
AButton * mButtons[TTBNumButtons]

References ToolBar::Add(), id, ThemeBase::ImageSize(), label, ToolBar::MakeButton(), mButtons, AButton::SetLabel(), and theTheme.

Referenced by Populate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AdjustPlaySpeed()

void TranscriptionToolBar::AdjustPlaySpeed ( float  adj)

Definition at line 1043 of file TranscriptionToolBar.cpp.

1044{
1045 if (adj < 0) {
1047 }
1048 else {
1050 }
1051 wxCommandEvent e;
1052 OnSpeedSlider(e);
1053}
void Increase(float steps)
Definition: ASlider.cpp:1859
void Decrease(float steps)
Definition: ASlider.cpp:1864
void OnSpeedSlider(wxCommandEvent &event)

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

Here is the call graph for this function:

◆ Create()

void TranscriptionToolBar::Create ( wxWindow *  parent)
overridevirtual

Reimplemented from ToolBar.

Definition at line 122 of file TranscriptionToolBar.cpp.

123{
124 ToolBar::Create(parent);
125
128
129#ifdef EXPERIMENTAL_VOICE_DETECTION
130 mButtons[TTB_StartOn]->Disable();
131 mButtons[TTB_StartOff]->Disable();
132 mButtons[TTB_EndOn]->Disable();
133 mButtons[TTB_EndOff]->Disable();
134 mButtons[TTB_SelectSound]->Disable();
135 mButtons[TTB_SelectSilence]->Disable();
136 mButtons[TTB_Calibrate]->Enable();
137 mButtons[TTB_AutomateSelection]->Disable();
138 mButtons[TTB_MakeLabel]->Enable();
139#endif
140
141 //Old code...
142 //Process a dummy event to set up mPlaySpeed
143 //wxCommandEvent dummy;
144 //OnSpeedSlider(dummy);
145
146 //JKC: Set speed this way is better, as we don't
147 //then stop Audio if it is playing, so we can be playing
148 //audio and open a second project.
149 SetPlaySpeed( (mPlaySpeedSlider->Get()) * 100 );
150
151 // Simulate a size event to set initial placement/size
152 wxSizeEvent event(GetSize(), GetId());
153 event.SetEventObject(this);
154 GetEventHandler()->ProcessEvent(event);
155}
void Disable()
Definition: AButton.cpp:563
void Enable()
Definition: AButton.cpp:554
float Get(bool convert=true)
Definition: ASlider.cpp:1849
virtual void Create(wxWindow *parent)
Definition: ToolBar.cpp:484

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

Here is the call graph for this function:

◆ EnableDisableButtons()

void TranscriptionToolBar::EnableDisableButtons ( )
overridevirtual

Implements ToolBar.

Definition at line 297 of file TranscriptionToolBar.cpp.

298{
300
301 auto gAudioIO = AudioIO::Get();
302 bool canStopAudioStream = (!gAudioIO->IsStreamActive() ||
303 gAudioIO->IsMonitoring() ||
304 gAudioIO->GetOwningProject().get() == p );
305 bool recording = gAudioIO->GetNumCaptureChannels() > 0;
306
307 // Only interested in audio type tracks
308 bool tracks = p && TrackList::Get( *p ).Any<AudioTrack>(); // PRL: PlayableTrack ?
309 SetEnabled( canStopAudioStream && tracks && !recording );
310
311#ifdef EXPERIMENTAL_VOICE_DETECTION
312 if (!p)
313 return;
314 // Is anything selected?
315 const auto &selectedRegion = ViewInfo::Get( *p ).selectedRegion;
316 auto selection = !selectedRegion.isPoint() &&
317 !TrackList::Get( *p ).Selected().empty();
318
319 mButtons[TTB_Calibrate]->SetEnabled(selection);
320#endif
321}
void SetEnabled(bool state)
Definition: AButton.h:182
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:89
static AudioIO * Get()
Definition: AudioIO.cpp:133
Track subclass holding data representing sound (as notes, or samples, or ...)
Definition: Track.h:897
bool isPoint() const
Definition: ViewInfo.h:39
AudacityProject & mProject
Definition: ToolBar.h:251
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:1437
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:486
auto Selected() -> TrackIterRange< TrackType >
Definition: Track.h:1454
void SetEnabled(bool enabled)
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:216
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235

References TrackList::Any(), AudioIO::Get(), ViewInfo::Get(), TrackList::Get(), NotifyingSelectedRegion::isPoint(), mButtons, ToolBar::mProject, TrackList::Selected(), ViewInfo::selectedRegion, SetEnabled(), and AButton::SetEnabled().

Here is the call graph for this function:

◆ Get() [1/2]

TranscriptionToolBar & TranscriptionToolBar::Get ( AudacityProject project)
static

Definition at line 111 of file TranscriptionToolBar.cpp.

112{
113 auto &toolManager = ToolManager::Get( project );
114 return *static_cast<TranscriptionToolBar*>( toolManager.GetToolBar(TranscriptionBarID) );
115}
static ToolManager & Get(AudacityProject &project)
A kind of ToolBar used to help with analysing voice recordings.

References ToolManager::Get(), and TranscriptionBarID.

Referenced by Get(), TransportActions::Handler::OnPlayAtSpeed(), TransportActions::Handler::OnPlayAtSpeedCutPreview(), TransportActions::Handler::OnPlayAtSpeedLooped(), TransportActions::Handler::OnPlaySpeedDec(), TransportActions::Handler::OnPlaySpeedInc(), and TransportActions::Handler::OnSetPlaySpeed().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Get() [2/2]

const TranscriptionToolBar & TranscriptionToolBar::Get ( const AudacityProject project)
static

Definition at line 117 of file TranscriptionToolBar.cpp.

118{
119 return Get( const_cast<AudacityProject&>( project )) ;
120}
static TranscriptionToolBar & Get(AudacityProject &project)

References Get().

Here is the call graph for this function:

◆ GetInitialWidth()

int TranscriptionToolBar::GetInitialWidth ( )
inlineoverridevirtual

Resizable toolbars should implement these.

Reimplemented from ToolBar.

Definition at line 81 of file TranscriptionToolBar.h.

81{ return 191; }

◆ GetMinToolbarWidth()

int TranscriptionToolBar::GetMinToolbarWidth ( )
inlineoverridevirtual

Reimplemented from ToolBar.

Definition at line 82 of file TranscriptionToolBar.h.

82{ return 125; }

◆ GetPlaySpeed()

double TranscriptionToolBar::GetPlaySpeed ( ) const
inline

Definition at line 117 of file TranscriptionToolBar.h.

117{ return mPlaySpeed / 100.0; }

References mPlaySpeed.

Referenced by SetPlaySpeed().

Here is the caller graph for this function:

◆ GetSamples()

void TranscriptionToolBar::GetSamples ( const WaveTrack t,
sampleCount s0,
sampleCount slen 
)
private

Definition at line 431 of file TranscriptionToolBar.cpp.

433{
434 // GetSamples attempts to translate the start and end selection markers into sample indices
435 // These selection numbers are doubles.
436
438 if (!p) {
439 return;
440 }
441
442 //First, get the current selection. It is part of the mViewInfo, which is
443 //part of the project
444
445 const auto &selectedRegion = ViewInfo::Get( *p ).selectedRegion;
446 double start = selectedRegion.t0();
447 double end = selectedRegion.t1();
448
449 auto ss0 = sampleCount( (start - t->GetOffset()) * t->GetRate() );
450 auto ss1 = sampleCount( (end - t->GetOffset()) * t->GetRate() );
451
452 if (start < t->GetOffset()) {
453 ss0 = 0;
454 }
455
456#if 0
457 //This adjusts the right samplecount to the maximum sample.
458 if (ss1 >= t->GetNumSamples()) {
459 ss1 = t->GetNumSamples();
460 }
461#endif
462
463 if (ss1 < ss0) {
464 ss1 = ss0;
465 }
466
467 *s0 = ss0;
468 *slen = ss1 - ss0;
469}
double t0() const
Definition: ViewInfo.h:34
double GetOffset() const override
Definition: WaveTrack.cpp:237
double GetRate() const override
Definition: WaveTrack.cpp:479
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:19
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:159

References PackedArray::end(), ViewInfo::Get(), WaveTrack::GetOffset(), WaveTrack::GetRate(), ToolBar::mProject, ViewInfo::selectedRegion, and NotifyingSelectedRegion::t0().

Here is the call graph for this function:

◆ MakeAlternateImages()

void TranscriptionToolBar::MakeAlternateImages ( teBmps  eFore,
teBmps  eDisabled,
int  id,
unsigned  altIdx 
)
private

Definition at line 191 of file TranscriptionToolBar.cpp.

194{
196 bmpRecoloredUpSmall, bmpRecoloredDownSmall, bmpRecoloredUpHiliteSmall,bmpRecoloredHiliteSmall,
197 eFore, eFore, eDisabled,
198 theTheme.ImageSize( bmpRecoloredUpSmall ));
199}
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:931

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

Referenced by Populate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnCaptureKey()

void TranscriptionToolBar::OnCaptureKey ( wxCommandEvent &  event)

Definition at line 382 of file TranscriptionToolBar.cpp.

383{
384 wxKeyEvent *kevent = (wxKeyEvent *)event.GetEventObject();
385 int keyCode = kevent->GetKeyCode();
386
387 // Pass LEFT/RIGHT/UP/DOWN/PAGEUP/PAGEDOWN through for input/output sliders
388 if (FindFocus() == mPlaySpeedSlider && (keyCode == WXK_LEFT || keyCode == WXK_RIGHT
389 || keyCode == WXK_UP || keyCode == WXK_DOWN
390 || keyCode == WXK_PAGEUP || keyCode == WXK_PAGEDOWN)) {
391 return;
392 }
393
394 event.Skip();
395
396 return;
397}

References mPlaySpeedSlider.

◆ OnFocus()

void TranscriptionToolBar::OnFocus ( wxFocusEvent &  event)

Definition at line 377 of file TranscriptionToolBar.cpp.

378{
379 KeyboardCapture::OnFocus( *this, event );
380}
void OnFocus(wxWindow &window, wxFocusEvent &event)
a function useful to implement a focus event handler The window releases the keyboard if the event is...

References KeyboardCapture::OnFocus().

Referenced by Populate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnKeyEvent()

void TranscriptionToolBar::OnKeyEvent ( wxKeyEvent &  event)

Definition at line 400 of file TranscriptionToolBar.cpp.

401{
402 if (event.ControlDown()) {
403 event.Skip();
404 return;
405 }
406
407 if (event.GetKeyCode() == WXK_SPACE) {
408 auto gAudioIO = AudioIOBase::Get();
409 if (gAudioIO->IsBusy()) {
410 /*Do Stuff Here*/
411 }
412 else {
413 /*Do other stuff Here*/
414 }
415 }
416}
static AudioIOBase * Get()
Definition: AudioIOBase.cpp:91

References AudioIOBase::Get().

Here is the call graph for this function:

◆ OnPlaySpeed()

void TranscriptionToolBar::OnPlaySpeed ( wxCommandEvent &  event)

Definition at line 548 of file TranscriptionToolBar.cpp.

549{
550 auto button = mButtons[TTB_PlaySpeed];
551
552 // Let control have precedence over shift
553 const bool cutPreview = mButtons[TTB_PlaySpeed]->WasControlDown();
554 const bool looped = !cutPreview &&
555 !button->WasShiftDown();
556 OnSpeedSlider(event);
557 PlayAtSpeed(looped, cutPreview);
558}
@ TTB_PlaySpeed
bool WasControlDown()
Definition: AButton.cpp:549
void PlayAtSpeed(bool looped, bool cutPreview)

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

Here is the call graph for this function:

◆ OnSpeedSlider()

void TranscriptionToolBar::OnSpeedSlider ( wxCommandEvent &  event)

Definition at line 560 of file TranscriptionToolBar.cpp.

561{
562 SetPlaySpeed( (mPlaySpeedSlider->Get()) * 100 );
564
565 // If IO is busy, abort immediately
566 // AWD: This is disabled to work around a hang on Linux when PulseAudio is
567 // used. If we figure that one out we can re-enable this code.
568 // auto gAudioIO = AudioIOBase::Get();
569 //if (gAudioIO->IsBusy()) {
570 // OnPlaySpeed(event);
571 //}
572}
void RegenerateTooltips() override

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

Referenced by AdjustPlaySpeed(), OnPlaySpeed(), and ShowPlaySpeedDialog().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PlayAtSpeed()

void TranscriptionToolBar::PlayAtSpeed ( bool  looped,
bool  cutPreview 
)

Definition at line 477 of file TranscriptionToolBar.cpp.

478{
479 // Can't do anything without an active project
481 if (!p) {
482 return;
483 }
484
485 auto &projectAudioManager = ProjectAudioManager::Get( mProject );
486
487 // Fixed speed play is the old method, that uses a time track.
488 // VariSpeed play reuses Scrubbing.
489 bool bFixedSpeedPlay = !gPrefs->ReadBool(wxT("/AudioIO/VariSpeedPlay"), true);
490 // Scrubbing doesn't support note tracks, but the fixed-speed method using time tracks does.
491 if ( TrackList::Get( *p ).Any< NoteTrack >() )
492 bFixedSpeedPlay = true;
493
494 // If cutPreview, we have to fall back to fixed speed.
495 if (newDefault)
496 cutPreview = false;
497 bFixedSpeedPlay = bFixedSpeedPlay || cutPreview;
498 if (bFixedSpeedPlay)
499 {
500 // Create a BoundedEnvelope if we haven't done so already
501 if (!mEnvelope) {
502 mEnvelope =
503 std::make_unique<BoundedEnvelope>(
504 true, TIMETRACK_MIN, TIMETRACK_MAX, 1.0);
505 // values as in the constructor for TimeTrack
506 mEnvelope->SetRangeLower( 0.9 );
507 mEnvelope->SetRangeUpper( 1.1 );
508 }
509 // Set the speed range
510 //mTimeTrack->SetRangeUpper((double)mPlaySpeed / 100.0);
511 //mTimeTrack->SetRangeLower((double)mPlaySpeed / 100.0);
512 mEnvelope->Flatten((double)mPlaySpeed / 100.0);
513 }
514
515 // Pop up the button
517
518 // If IO is busy, abort immediately
519 auto gAudioIO = AudioIOBase::Get();
520 if (gAudioIO->IsBusy())
521 projectAudioManager.Stop();
522
523 // Get the current play region
524 const auto &viewInfo = ViewInfo::Get( *p );
525 const auto &playRegion = viewInfo.playRegion;
526
527 // Start playing
528 if (playRegion.GetStart() < 0)
529 return;
530
531 {
532 auto options = DefaultPlayOptions( *p, newDefault );
533 // No need to set cutPreview options.
534 options.envelope = bFixedSpeedPlay ? mEnvelope.get() : nullptr;
535 options.variableSpeed = !bFixedSpeedPlay;
536 auto mode =
537 cutPreview ? PlayMode::cutPreviewPlay
538 : newDefault ? PlayMode::loopedPlay
540 projectAudioManager.PlayPlayRegion(
541 SelectedRegion(playRegion.GetStart(), playRegion.GetEnd()),
542 options,
543 mode);
544 }
545}
FileConfig * gPrefs
Definition: Prefs.cpp:71
AudioIOStartStreamOptions DefaultPlayOptions(AudacityProject &project, bool newDefault)
@ cutPreviewPlay
#define TIMETRACK_MAX
#define TIMETRACK_MIN
A Track that is used for Midi notes. (Somewhat old code).
Definition: NoteTrack.h:63
static ProjectAudioManager & Get(AudacityProject &project)
Defines a selected portion of a project.
std::shared_ptr< BoundedEnvelope > mEnvelope
void SetButton(bool newstate, AButton *button)

References TrackList::Any(), cutPreviewPlay, DefaultPlayOptions(), AudioIOBase::Get(), ViewInfo::Get(), TrackList::Get(), ProjectAudioManager::Get(), gPrefs, loopedPlay, mButtons, mEnvelope, mPlaySpeed, ToolBar::mProject, normalPlay, SetButton(), TIMETRACK_MAX, TIMETRACK_MIN, TTB_PlaySpeed, and wxT().

Referenced by OnPlaySpeed().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Populate()

void TranscriptionToolBar::Populate ( )
overridevirtual

Implements ToolBar.

Definition at line 201 of file TranscriptionToolBar.cpp.

202{
203 SetBackgroundColour( theTheme.Colour( clrMedium ) );
204// Very similar to code in ControlToolBar...
205// Very similar to code in EditToolBar
207
208 AddButton(this, bmpPlay, bmpPlayDisabled, TTB_PlaySpeed,
209 XO("Play at selected speed"));
210 // 3.1.0 abandoned distinct images for Shift
211 MakeAlternateImages(bmpPlay, bmpPlayDisabled, TTB_PlaySpeed, 1);
212 MakeAlternateImages(bmpCutPreview, bmpCutPreviewDisabled, TTB_PlaySpeed, 2);
214
215 //Add a slider that controls the speed of playback.
216 const int SliderWidth=100;
219 XO("Playback Speed"),
220 wxDefaultPosition,
221 wxSize(SliderWidth,25),
224 // 6 steps using page up/down, and 60 using arrow keys
225 .Line( 0.16667f )
226 .Page( 1.6667f )
227 );
228 mPlaySpeedSlider->SetSizeHints(wxSize(100, 25), wxSize(2000, 25));
230 mPlaySpeedSlider->SetLabel(_("Playback Speed"));
231 Add( mPlaySpeedSlider, 1, wxALIGN_CENTER );
232 mPlaySpeedSlider->Bind(wxEVT_SET_FOCUS,
234 this);
235 mPlaySpeedSlider->Bind(wxEVT_KILL_FOCUS,
237 this);
238
239#ifdef EXPERIMENTAL_VOICE_DETECTION
240// If we need these strings translated, then search and replace
241// YO by XO and remove this #define.
242#define YO( x ) Verbatim( x )
243 AddButton(this, bmpTnStartOn, bmpTnStartOnDisabled, TTB_StartOn,
244 YO("Adjust left selection to next onset"));
245 AddButton(this, bmpTnEndOn, bmpTnEndOnDisabled, TTB_EndOn,
246 YO("Adjust right selection to previous offset"));
247 AddButton(this, bmpTnStartOff, bmpTnStartOffDisabled, TTB_StartOff,
248 YO("Adjust left selection to next offset"));
249 AddButton(this, bmpTnEndOff, bmpTnEndOffDisabled, TTB_EndOff,
250 YO("Adjust right selection to previous onset"));
251 AddButton(this, bmpTnSelectSound, bmpTnSelectSoundDisabled, TTB_SelectSound,
252 YO("Select region of sound around cursor"));
253 AddButton(this, bmpTnSelectSilence, bmpTnSelectSilenceDisabled, TTB_SelectSilence,
254 YO("Select region of silence around cursor"));
255 AddButton(this, bmpTnAutomateSelection, bmpTnAutomateSelectionDisabled, TTB_AutomateSelection,
256 YO("Automatically make labels from words"));
257 AddButton(this, bmpTnMakeTag, bmpTnMakeTagDisabled, TTB_MakeLabel,
258 YO("Add label at selection"));
259 AddButton(this, bmpTnCalibrate, bmpTnCalibrateDisabled, TTB_Calibrate,
260 YO("Calibrate voicekey"));
261
263 TTB_SensitivitySlider,
264 YO("Adjust Sensitivity"),
265 wxDefaultPosition,
266 wxSize(SliderWidth,25),
268 .Style( SPEED_SLIDER ));
270 mSensitivitySlider->SetLabel(YO("Sensitivity").Translation());
271 Add( mSensitivitySlider, 0, wxALIGN_CENTER );
272
273 TranslatableStrings choices {
274 YO("Energy"),
275 YO("Sign Changes (Low Threshold)"),
276 YO("Sign Changes (High Threshold)"),
277 YO("Direction Changes (Low Threshold)"),
278 YO("Direction Changes (High Threshold)")
279 };
280
281 mKeyTypeChoice = safenew wxChoice(this, TTB_KeyType,
282 wxDefaultPosition,
283 wxDefaultSize,
284 transform_container<wxArrayStringEx>( choices,
285 std::mem_fn( &TranslatableString::Translation ) ) );
286 mKeyTypeChoice->SetName(YO("Key type").Translation());
287 mKeyTypeChoice->SetSelection(0);
288 Add( mKeyTypeChoice, 0, wxALIGN_CENTER );
289#endif
290
291 // Add a little space
292 Add(2, -1);
293
294 UpdatePrefs();
295}
#define SPEED_SLIDER
Definition: ASlider.h:35
#define _(s)
Definition: Internat.h:75
#define safenew
Definition: MemoryX.h:10
@ TTB_PlaySpeedSlider
std::vector< TranslatableString > TranslatableStrings
void FollowModifierKeys()
Definition: AButton.cpp:246
ASlider is a custom slider, allowing for a slicker look and feel.
Definition: ASlider.h:260
void Set(float value)
Definition: ASlider.cpp:1854
wxColour & Colour(int iIndex)
static void MakeButtonBackgroundsSmall()
Definition: ToolBar.cpp:823
static AButton * AddButton(TranscriptionToolBar *pBar, teBmps eFore, teBmps eDisabled, int id, const TranslatableString &label)
void OnFocus(wxFocusEvent &event)
void MakeAlternateImages(teBmps eFore, teBmps eDisabled, int id, unsigned altIdx)
wxString Translation() const
Options & Style(int s)
Definition: ASlider.h:280

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

Here is the call graph for this function:

◆ RegenerateTooltips()

void TranscriptionToolBar::RegenerateTooltips ( )
overrideprivatevirtual

Implements ToolBar.

Definition at line 334 of file TranscriptionToolBar.cpp.

335{
336 // We could also mention the shift- and ctrl-modified versions in the
337 // tool tip... but it would get long
338
339 static const struct Entry {
340 int tool;
341 CommandID commandName;
342 TranslatableString untranslatedLabel;
343 CommandID commandName2;
344 TranslatableString untranslatedLabel2;
345 } table[] = {
347 wxT("PlayAtSpeedLooped"), XO("Play-at-Speed"),
348 wxT("PlayAtSpeed"), XO("Play-at-Speed Once"),
349 },
350 };
351
352 for (const auto &entry : table) {
353 ComponentInterfaceSymbol commands[] = {
354 { entry.commandName, entry.untranslatedLabel },
355 { entry.commandName2, entry.untranslatedLabel2 },
356 };
358 *mButtons[entry.tool], commands, 2u );
359 }
360
361#ifdef EXPERIMENTAL_VOICE_DETECTION
362 mButtons[TTB_StartOn]->SetToolTip(YO("Left-to-On"));
363 mButtons[TTB_EndOn]->SetToolTip( YO("Right-to-Off"));
364 mButtons[TTB_StartOff]->SetToolTip( YO("Left-to-Off"));
365 mButtons[TTB_EndOff]->SetToolTip( YO("Right-to-On"));
366 mButtons[TTB_SelectSound]->SetToolTip( YO("Select-Sound"));
367 mButtons[TTB_SelectSilence]->SetToolTip( YO("Select-Silence"));
368 mButtons[TTB_AutomateSelection]->SetToolTip( YO("Make Labels"));
369 mButtons[TTB_MakeLabel]->SetToolTip( YO("Add Label"));
370 mButtons[TTB_Calibrate]->SetToolTip( YO("Calibrate"));
371
372 mSensitivitySlider->SetToolTip(YO("Sensitivity").Translation());
373 mKeyTypeChoice->SetToolTip(YO("Key type").Translation());
374#endif
375}
static ProjectFileIORegistry::AttributeWriterEntry entry
void SetToolTip(const TranslatableString &toolTip)
Definition: AButton.cpp:187
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
static void SetButtonToolTip(AudacityProject &project, AButton &button, const ComponentInterfaceSymbol commands[], size_t nCommands)
Definition: ToolBar.cpp:956
Holds a msgid for the translation catalog; may also bind format arguments.

References entry, mButtons, ToolBar::mProject, mSensitivitySlider, ToolBar::SetButtonToolTip(), AButton::SetToolTip(), TTB_PlaySpeed, wxT(), and XO.

Referenced by OnSpeedSlider(), and UpdatePrefs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Repaint()

void TranscriptionToolBar::Repaint ( wxDC *  WXUNUSEDdc)
inlineoverride

Definition at line 78 of file TranscriptionToolBar.h.

78{};

◆ SetButton()

void TranscriptionToolBar::SetButton ( bool  newstate,
AButton button 
)
private

Definition at line 421 of file TranscriptionToolBar.cpp.

422{
423 if (down) {
424 button->PushDown();
425 }
426 else {
427 button->PopUp();
428 }
429}
void PushDown()
Definition: AButton.cpp:580
void PopUp()
Definition: AButton.cpp:588

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

Referenced by PlayAtSpeed().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetEnabled()

void TranscriptionToolBar::SetEnabled ( bool  enabled)

Definition at line 1025 of file TranscriptionToolBar.cpp.

1026{
1028}

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

Referenced by EnableDisableButtons().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetPlaying()

void TranscriptionToolBar::SetPlaying ( bool  down,
bool  looped,
bool  cutPreview 
)

Definition at line 1030 of file TranscriptionToolBar.cpp.

1031{
1032 AButton *const button = mButtons[TTB_PlaySpeed];
1033 if (down) {
1034 button->SetAlternateIdx(cutPreview ? 2 : looped ? 1 : 0);
1035 button->PushDown();
1036 }
1037 else {
1038 button->SetAlternateIdx(0);
1039 button->PopUp();
1040 }
1041}
void SetAlternateIdx(unsigned idx)
Definition: AButton.cpp:235

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

Here is the call graph for this function:

◆ SetPlaySpeed()

void TranscriptionToolBar::SetPlaySpeed ( double  value)
private

Definition at line 157 of file TranscriptionToolBar.cpp.

158{
159 mPlaySpeed = value;
161}
void SetPlaySpeed(double value)
static ProjectAudioIO & Get(AudacityProject &project)

References ProjectAudioIO::Get(), GetPlaySpeed(), mPlaySpeed, ToolBar::mProject, and ProjectAudioIO::SetPlaySpeed().

Referenced by Create(), OnSpeedSlider(), and TranscriptionToolBar().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ShowPlaySpeedDialog()

void TranscriptionToolBar::ShowPlaySpeedDialog ( )

Definition at line 1017 of file TranscriptionToolBar.cpp.

1018{
1020 mPlaySpeedSlider->Refresh();
1021 wxCommandEvent e;
1022 OnSpeedSlider(e);
1023}
bool ShowDialog(wxPoint pos=wxPoint(-1, -1))
Definition: ASlider.cpp:1869

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

Here is the call graph for this function:

◆ UpdatePrefs()

void TranscriptionToolBar::UpdatePrefs ( )
overridevirtual

Reimplemented from ToolBar.

Definition at line 323 of file TranscriptionToolBar.cpp.

324{
326
327 // Set label to pull in language change
328 SetLabel(XO("Play-at-Speed"));
329
330 // Give base class a chance
332}
void SetLabel(const wxString &label) override
Definition: ToolBar.cpp:407
void UpdatePrefs() override
Definition: ToolBar.cpp:614

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

Referenced by Populate().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ downImage

wxImage* TranscriptionToolBar::downImage
private

Definition at line 136 of file TranscriptionToolBar.h.

◆ hiliteImage

wxImage* TranscriptionToolBar::hiliteImage
private

Definition at line 137 of file TranscriptionToolBar.h.

◆ mBackgroundHeight

int TranscriptionToolBar::mBackgroundHeight
private

Definition at line 150 of file TranscriptionToolBar.h.

Referenced by Create().

◆ mBackgroundWidth

int TranscriptionToolBar::mBackgroundWidth
private

Definition at line 149 of file TranscriptionToolBar.h.

Referenced by Create().

◆ mButtons

AButton* TranscriptionToolBar::mButtons[TTBNumButtons]
private

◆ mEnvelope

std::shared_ptr<BoundedEnvelope> TranscriptionToolBar::mEnvelope
private

Definition at line 152 of file TranscriptionToolBar.h.

Referenced by PlayAtSpeed().

◆ mPlaySpeed

double TranscriptionToolBar::mPlaySpeed
private

Definition at line 140 of file TranscriptionToolBar.h.

Referenced by GetPlaySpeed(), PlayAtSpeed(), Populate(), and SetPlaySpeed().

◆ mPlaySpeedSlider

ASlider* TranscriptionToolBar::mPlaySpeedSlider
private

◆ mSensitivitySlider

ASlider* TranscriptionToolBar::mSensitivitySlider
private

Definition at line 141 of file TranscriptionToolBar.h.

Referenced by Populate(), and RegenerateTooltips().

◆ upImage

wxImage* TranscriptionToolBar::upImage
private

Definition at line 135 of file TranscriptionToolBar.h.


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