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 ()
 
bool ShownByDefault () const override
 Whether the toolbar should be shown by default. Default implementation returns true. More...
 
DockID DefaultDockID () const override
 Which dock the toolbar defaults into. Default implementation chooses the top dock. More...
 
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, const TranslatableString &label, const Identifier &section, bool resizable=false)
 
virtual ~ToolBar ()
 
virtual bool ShownByDefault () const
 Whether the toolbar should be shown by default. Default implementation returns true. More...
 
virtual bool HideAfterReset () const
 Default implementation returns false. More...
 
virtual DockID DefaultDockID () const
 Which dock the toolbar defaults into. Default implementation chooses the top dock. More...
 
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 GetIndex () const
 Get a value used for computing cascading positions of undocked bars. More...
 
void SetIndex (int index)
 Set a value used for computing cascading positions of undocked bars. More...
 
TranslatableString GetTitle ()
 
TranslatableString GetLabel ()
 
Identifier GetSection ()
 
ToolDockGetDock ()
 
void SetPreferredNeighbors (Identifier left, Identifier top={})
 
void SetLabel (const TranslatableString &label)
 
virtual void SetDocked (ToolDock *dock, bool pushed)
 
std::pair< Identifier, IdentifierPreferredNeighbors () const noexcept
 Defaults to (NoBarID, NoBarId) More...
 
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 Identifier ID ()
 
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
enum  DockID { TopDockID = 1 , BotDockID = 2 }
 Identifies one of the docking areas for toolbars. More...
 
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
 
Identifier mSection
 
int mIndex {0}
 

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 100 of file TranscriptionToolBar.cpp.

101: ToolBar( project, XO("Play-at-Speed"), ID(), true )
102{
103 SetPlaySpeed( 1.0 * 100.0 );
104#ifdef EXPERIMENTAL_VOICE_DETECTION
105 mVk = std::make_unique<VoiceKey>();
106#endif
107}
XO("Cut/Copy/Paste")
const auto project
ToolBar(AudacityProject &project, const TranslatableString &label, const Identifier &section, bool resizable=false)
Definition: ToolBar.cpp:328
static Identifier ID()
void SetPlaySpeed(double value)

References SetPlaySpeed().

Here is the call graph for this function:

◆ ~TranscriptionToolBar()

TranscriptionToolBar::~TranscriptionToolBar ( )
virtual

Definition at line 109 of file TranscriptionToolBar.cpp.

110{
111}

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 184 of file TranscriptionToolBar.cpp.

189{
190 AButton *&r = pBar->mButtons[id];
191
192 r = ToolBar::MakeButton(pBar,
193 bmpRecoloredUpSmall, bmpRecoloredDownSmall, bmpRecoloredUpHiliteSmall,bmpRecoloredHiliteSmall,
194 eFore, eFore, eDisabled,
195 wxWindowID(id),
196 wxDefaultPosition,
197 false,
198 theTheme.ImageSize( bmpRecoloredUpSmall ));
199
200 r->SetLabel(label);
201// JKC: Unlike ControlToolBar, does not have a focus rect. Shouldn't it?
202// r->SetFocusRect( r->GetRect().Deflate( 4, 4 ) );
203
204 pBar->Add( r, 0, wxALIGN_CENTER );
205
206 return r;
207}
TranslatableString label
Definition: TagsEditor.cpp:165
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:189
wxSize ImageSize(int iIndex)
void Add(wxWindow *window, int proportion=0, int flag=wxALIGN_TOP, int border=0, wxObject *userData=NULL)
Definition: ToolBar.cpp:709
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:875
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 1058 of file TranscriptionToolBar.cpp.

1059{
1060 if (adj < 0) {
1062 }
1063 else {
1065 }
1066 wxCommandEvent e;
1067 OnSpeedSlider(e);
1068}
void Increase(float steps)
Definition: ASlider.cpp:1855
void Decrease(float steps)
Definition: ASlider.cpp:1860
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 140 of file TranscriptionToolBar.cpp.

141{
142 ToolBar::Create(parent);
143
146
147#ifdef EXPERIMENTAL_VOICE_DETECTION
148 mButtons[TTB_StartOn]->Disable();
149 mButtons[TTB_StartOff]->Disable();
150 mButtons[TTB_EndOn]->Disable();
151 mButtons[TTB_EndOff]->Disable();
152 mButtons[TTB_SelectSound]->Disable();
153 mButtons[TTB_SelectSilence]->Disable();
154 mButtons[TTB_Calibrate]->Enable();
155 mButtons[TTB_AutomateSelection]->Disable();
156 mButtons[TTB_MakeLabel]->Enable();
157#endif
158
159 //Old code...
160 //Process a dummy event to set up mPlaySpeed
161 //wxCommandEvent dummy;
162 //OnSpeedSlider(dummy);
163
164 //JKC: Set speed this way is better, as we don't
165 //then stop Audio if it is playing, so we can be playing
166 //audio and open a second project.
167 SetPlaySpeed( (mPlaySpeedSlider->Get()) * 100 );
168
169 // Simulate a size event to set initial placement/size
170 wxSizeEvent event(GetSize(), GetId());
171 event.SetEventObject(this);
172 GetEventHandler()->ProcessEvent(event);
173}
void Disable()
Definition: AButton.cpp:560
void Enable()
Definition: AButton.cpp:551
float Get(bool convert=true)
Definition: ASlider.cpp:1845
virtual void Create(wxWindow *parent)
Definition: ToolBar.cpp:492

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

Here is the call graph for this function:

◆ DefaultDockID()

ToolBar::DockID TranscriptionToolBar::DefaultDockID ( ) const
overridevirtual

Which dock the toolbar defaults into. Default implementation chooses the top dock.

Reimplemented from ToolBar.

Definition at line 124 of file TranscriptionToolBar.cpp.

125{
126 return BotDockID;
127}
@ BotDockID
Definition: ToolBar.h:94

References ToolBar::BotDockID.

◆ EnableDisableButtons()

void TranscriptionToolBar::EnableDisableButtons ( )
overridevirtual

Implements ToolBar.

Definition at line 315 of file TranscriptionToolBar.cpp.

316{
318
319 auto gAudioIO = AudioIO::Get();
320 bool canStopAudioStream = (!gAudioIO->IsStreamActive() ||
321 gAudioIO->IsMonitoring() ||
322 gAudioIO->GetOwningProject().get() == p );
323 bool recording = gAudioIO->GetNumCaptureChannels() > 0;
324
325 // Only interested in audio type tracks
326 bool tracks = p && TrackList::Get(*p).Any<AudioTrack>(); // PRL: PlayableTrack ?
327 SetEnabled(canStopAudioStream && tracks && !recording);
328
329#ifdef EXPERIMENTAL_VOICE_DETECTION
330 if (!p)
331 return;
332 // Is anything selected?
333 const auto &selectedRegion = ViewInfo::Get( *p ).selectedRegion;
334 auto selection = !selectedRegion.isPoint() &&
335 !TrackList::Get( *p ).Selected().empty();
336
337 mButtons[TTB_Calibrate]->SetEnabled(selection);
338#endif
339}
const auto tracks
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:90
static AudioIO * Get()
Definition: AudioIO.cpp:126
Track subclass holding data representing sound (as notes, or samples, or ...)
Definition: PlayableTrack.h:21
bool isPoint() const
Definition: ViewInfo.h:40
AudacityProject & mProject
Definition: ToolBar.h:248
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:1079
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:347
auto Selected() -> TrackIterRange< TrackType >
Definition: Track.h:1096
void SetEnabled(bool enabled)
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:215
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(), AButton::SetEnabled(), and tracks.

Here is the call graph for this function:

◆ Get() [1/2]

TranscriptionToolBar & TranscriptionToolBar::Get ( AudacityProject project)
static

Definition at line 129 of file TranscriptionToolBar.cpp.

130{
131 auto &toolManager = ToolManager::Get( project );
132 return *static_cast<TranscriptionToolBar*>(toolManager.GetToolBar(ID()));
133}
static ToolManager & Get(AudacityProject &project)
A kind of ToolBar used to help with analysing voice recordings.

References ToolManager::Get(), ID(), and project.

Referenced by Get(), anonymous_namespace{TranscriptionToolBar.cpp}::OnPlayAtSpeed(), anonymous_namespace{TranscriptionToolBar.cpp}::OnPlayAtSpeedCutPreview(), anonymous_namespace{TranscriptionToolBar.cpp}::OnPlayAtSpeedLooped(), anonymous_namespace{TranscriptionToolBar.cpp}::OnPlaySpeedDec(), anonymous_namespace{TranscriptionToolBar.cpp}::OnPlaySpeedInc(), and anonymous_namespace{TranscriptionToolBar.cpp}::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 135 of file TranscriptionToolBar.cpp.

136{
137 return Get( const_cast<AudacityProject&>( project )) ;
138}
static TranscriptionToolBar & Get(AudacityProject &project)

References Get(), and project.

Here is the call graph for this function:

◆ GetInitialWidth()

int TranscriptionToolBar::GetInitialWidth ( )
inlineoverridevirtual

Resizable toolbars should implement these.

Reimplemented from ToolBar.

Definition at line 87 of file TranscriptionToolBar.h.

87{ return 191; }

◆ GetMinToolbarWidth()

int TranscriptionToolBar::GetMinToolbarWidth ( )
inlineoverridevirtual

Reimplemented from ToolBar.

Definition at line 88 of file TranscriptionToolBar.h.

88{ return 125; }

◆ GetPlaySpeed()

double TranscriptionToolBar::GetPlaySpeed ( ) const
inline

Definition at line 123 of file TranscriptionToolBar.h.

123{ 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 449 of file TranscriptionToolBar.cpp.

451{
452 // GetSamples attempts to translate the start and end selection markers into sample indices
453 // These selection numbers are doubles.
454
456 if (!p) {
457 return;
458 }
459
460 //First, get the current selection. It is part of the mViewInfo, which is
461 //part of the project
462
463 const auto &selectedRegion = ViewInfo::Get( *p ).selectedRegion;
464 double start = selectedRegion.t0();
465 double end = selectedRegion.t1();
466
467 auto ss0 = sampleCount( (start - t->GetStartTime()) * t->GetRate() );
468 auto ss1 = sampleCount( (end - t->GetStartTime()) * t->GetRate() );
469
470 if (start < t->GetStartTime()) {
471 ss0 = 0;
472 }
473
474#if 0
475 //This adjusts the right samplecount to the maximum sample.
476 if (ss1 >= t->GetNumSamples()) {
477 ss1 = t->GetNumSamples();
478 }
479#endif
480
481 if (ss1 < ss0) {
482 ss1 = ss0;
483 }
484
485 *s0 = ss0;
486 *slen = ss1 - ss0;
487}
double t0() const
Definition: ViewInfo.h:35
double GetStartTime() const override
Implement WideSampleSequence.
Definition: WaveTrack.cpp:3045
double GetRate() const override
Definition: WaveTrack.cpp:1085
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::GetRate(), WaveTrack::GetStartTime(), ToolBar::mProject, ViewInfo::selectedRegion, and NotifyingSelectedRegion::t0().

Here is the call graph for this function:

◆ ID()

Identifier TranscriptionToolBar::ID ( )
static

Definition at line 94 of file TranscriptionToolBar.cpp.

95{
96 return wxT("Transcription");
97}
wxT("CloseDown"))

References wxT().

Referenced by Get().

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

◆ MakeAlternateImages()

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

Definition at line 209 of file TranscriptionToolBar.cpp.

212{
214 bmpRecoloredUpSmall, bmpRecoloredDownSmall, bmpRecoloredUpHiliteSmall,bmpRecoloredHiliteSmall,
215 eFore, eFore, eDisabled,
216 theTheme.ImageSize( bmpRecoloredUpSmall ));
217}
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:945

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 400 of file TranscriptionToolBar.cpp.

401{
402 wxKeyEvent *kevent = (wxKeyEvent *)event.GetEventObject();
403 int keyCode = kevent->GetKeyCode();
404
405 // Pass LEFT/RIGHT/UP/DOWN/PAGEUP/PAGEDOWN through for input/output sliders
406 if (FindFocus() == mPlaySpeedSlider && (keyCode == WXK_LEFT || keyCode == WXK_RIGHT
407 || keyCode == WXK_UP || keyCode == WXK_DOWN
408 || keyCode == WXK_PAGEUP || keyCode == WXK_PAGEDOWN)) {
409 return;
410 }
411
412 event.Skip();
413
414 return;
415}
std::unique_ptr< WindowPlacement > FindFocus()
Find the window that is accepting keyboard input, if any.
Definition: BasicUI.h:373

References BasicUI::FindFocus(), and mPlaySpeedSlider.

Here is the call graph for this function:

◆ OnFocus()

void TranscriptionToolBar::OnFocus ( wxFocusEvent &  event)

Definition at line 395 of file TranscriptionToolBar.cpp.

396{
397 KeyboardCapture::OnFocus( *this, event );
398}
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 418 of file TranscriptionToolBar.cpp.

419{
420 if (event.ControlDown()) {
421 event.Skip();
422 return;
423 }
424
425 if (event.GetKeyCode() == WXK_SPACE) {
426 auto gAudioIO = AudioIOBase::Get();
427 if (gAudioIO->IsBusy()) {
428 /*Do Stuff Here*/
429 }
430 else {
431 /*Do other stuff Here*/
432 }
433 }
434}
static AudioIOBase * Get()
Definition: AudioIOBase.cpp:93

References AudioIOBase::Get().

Here is the call graph for this function:

◆ OnPlaySpeed()

void TranscriptionToolBar::OnPlaySpeed ( wxCommandEvent &  event)

Definition at line 566 of file TranscriptionToolBar.cpp.

567{
568 auto button = mButtons[TTB_PlaySpeed];
569
570 // Let control have precedence over shift
571 const bool cutPreview = mButtons[TTB_PlaySpeed]->WasControlDown();
572 const bool looped = !cutPreview &&
573 !button->WasShiftDown();
574 OnSpeedSlider(event);
575 PlayAtSpeed(looped, cutPreview);
576}
@ TTB_PlaySpeed
bool WasControlDown()
Definition: AButton.cpp:546
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 578 of file TranscriptionToolBar.cpp.

579{
580 SetPlaySpeed( (mPlaySpeedSlider->Get()) * 100 );
582
583 // If IO is busy, abort immediately
584 // AWD: This is disabled to work around a hang on Linux when PulseAudio is
585 // used. If we figure that one out we can re-enable this code.
586 // auto gAudioIO = AudioIOBase::Get();
587 //if (gAudioIO->IsBusy()) {
588 // OnPlaySpeed(event);
589 //}
590}
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 495 of file TranscriptionToolBar.cpp.

496{
497 // Can't do anything without an active project
499 if (!p) {
500 return;
501 }
502
503 auto &projectAudioManager = ProjectAudioManager::Get( mProject );
504
505 // Fixed speed play is the old method, that uses a time track.
506 // VariSpeed play reuses Scrubbing.
507 bool bFixedSpeedPlay = !gPrefs->ReadBool(wxT("/AudioIO/VariSpeedPlay"), true);
508 // Scrubbing doesn't support note tracks, but the fixed-speed method using time tracks does.
509 if (TrackList::Get(*p).Any<NoteTrack>())
510 bFixedSpeedPlay = true;
511
512 // If cutPreview, we have to fall back to fixed speed.
513 if (newDefault)
514 cutPreview = false;
515 bFixedSpeedPlay = bFixedSpeedPlay || cutPreview;
516 if (bFixedSpeedPlay)
517 {
518 // Create a BoundedEnvelope if we haven't done so already
519 if (!mEnvelope) {
520 mEnvelope =
521 std::make_unique<BoundedEnvelope>(
522 true, TIMETRACK_MIN, TIMETRACK_MAX, 1.0);
523 // values as in the constructor for TimeTrack
524 mEnvelope->SetRangeLower( 0.9 );
525 mEnvelope->SetRangeUpper( 1.1 );
526 }
527 // Set the speed range
528 //mTimeTrack->SetRangeUpper((double)mPlaySpeed / 100.0);
529 //mTimeTrack->SetRangeLower((double)mPlaySpeed / 100.0);
530 mEnvelope->Flatten((double)mPlaySpeed / 100.0);
531 }
532
533 // Pop up the button
535
536 // If IO is busy, abort immediately
537 auto gAudioIO = AudioIOBase::Get();
538 if (gAudioIO->IsBusy())
539 projectAudioManager.Stop();
540
541 // Get the current play region
542 const auto &viewInfo = ViewInfo::Get( *p );
543 const auto &playRegion = viewInfo.playRegion;
544
545 // Start playing
546 if (playRegion.GetStart() < 0)
547 return;
548
549 {
550 auto options = ProjectAudioIO::GetDefaultOptions(*p, newDefault);
551 // No need to set cutPreview options.
552 options.envelope = bFixedSpeedPlay ? mEnvelope.get() : nullptr;
553 options.variableSpeed = !bFixedSpeedPlay;
554 auto mode =
555 cutPreview ? PlayMode::cutPreviewPlay
556 : newDefault ? PlayMode::loopedPlay
558 projectAudioManager.PlayPlayRegion(
559 SelectedRegion(playRegion.GetStart(), playRegion.GetEnd()),
560 options,
561 mode);
562 }
563}
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
@ cutPreviewPlay
#define TIMETRACK_MAX
#define TIMETRACK_MIN
A Track that is used for Midi notes. (Somewhat old code).
Definition: NoteTrack.h:86
static AudioIOStartStreamOptions GetDefaultOptions(AudacityProject &project, bool newDefaults=false)
Invoke the global hook, supplying a default argument.
static ProjectAudioManager & Get(AudacityProject &project)
Defines a selected portion of a project.
std::shared_ptr< BoundedEnvelope > mEnvelope
void SetButton(bool newstate, AButton *button)
bool ReadBool(const wxString &key, bool defaultValue) const

References TrackList::Any(), cutPreviewPlay, AudioIOBase::Get(), ViewInfo::Get(), TrackList::Get(), ProjectAudioManager::Get(), ProjectAudioIO::GetDefaultOptions(), gPrefs, loopedPlay, mButtons, mEnvelope, mPlaySpeed, ToolBar::mProject, normalPlay, audacity::BasicSettings::ReadBool(), 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 219 of file TranscriptionToolBar.cpp.

220{
221 SetBackgroundColour( theTheme.Colour( clrMedium ) );
222// Very similar to code in ControlToolBar...
223// Very similar to code in EditToolBar
225
226 AddButton(this, bmpPlay, bmpPlayDisabled, TTB_PlaySpeed,
227 XO("Play at selected speed"));
228 // 3.1.0 abandoned distinct images for Shift
229 MakeAlternateImages(bmpPlay, bmpPlayDisabled, TTB_PlaySpeed, 1);
230 MakeAlternateImages(bmpCutPreview, bmpCutPreviewDisabled, TTB_PlaySpeed, 2);
232
233 //Add a slider that controls the speed of playback.
234 const int SliderWidth=100;
237 XO("Playback Speed"),
238 wxDefaultPosition,
239 wxSize(SliderWidth,25),
242 // 6 steps using page up/down, and 60 using arrow keys
243 .Line( 0.16667f )
244 .Page( 1.6667f )
245 );
246 mPlaySpeedSlider->SetSizeHints(wxSize(100, 25), wxSize(2000, 25));
248 mPlaySpeedSlider->SetLabel(_("Playback Speed"));
249 Add( mPlaySpeedSlider, 1, wxALIGN_CENTER );
250 mPlaySpeedSlider->Bind(wxEVT_SET_FOCUS,
252 this);
253 mPlaySpeedSlider->Bind(wxEVT_KILL_FOCUS,
255 this);
256
257#ifdef EXPERIMENTAL_VOICE_DETECTION
258// If we need these strings translated, then search and replace
259// YO by XO and remove this #define.
260#define YO( x ) Verbatim( x )
261 AddButton(this, bmpTnStartOn, bmpTnStartOnDisabled, TTB_StartOn,
262 YO("Adjust left selection to next onset"));
263 AddButton(this, bmpTnEndOn, bmpTnEndOnDisabled, TTB_EndOn,
264 YO("Adjust right selection to previous offset"));
265 AddButton(this, bmpTnStartOff, bmpTnStartOffDisabled, TTB_StartOff,
266 YO("Adjust left selection to next offset"));
267 AddButton(this, bmpTnEndOff, bmpTnEndOffDisabled, TTB_EndOff,
268 YO("Adjust right selection to previous onset"));
269 AddButton(this, bmpTnSelectSound, bmpTnSelectSoundDisabled, TTB_SelectSound,
270 YO("Select region of sound around cursor"));
271 AddButton(this, bmpTnSelectSilence, bmpTnSelectSilenceDisabled, TTB_SelectSilence,
272 YO("Select region of silence around cursor"));
273 AddButton(this, bmpTnAutomateSelection, bmpTnAutomateSelectionDisabled, TTB_AutomateSelection,
274 YO("Automatically make labels from words"));
275 AddButton(this, bmpTnMakeTag, bmpTnMakeTagDisabled, TTB_MakeLabel,
276 YO("Add label at selection"));
277 AddButton(this, bmpTnCalibrate, bmpTnCalibrateDisabled, TTB_Calibrate,
278 YO("Calibrate voicekey"));
279
281 TTB_SensitivitySlider,
282 YO("Adjust Sensitivity"),
283 wxDefaultPosition,
284 wxSize(SliderWidth,25),
286 .Style( SPEED_SLIDER ));
288 mSensitivitySlider->SetLabel(YO("Sensitivity").Translation());
289 Add( mSensitivitySlider, 0, wxALIGN_CENTER );
290
291 TranslatableStrings choices {
292 YO("Energy"),
293 YO("Sign Changes (Low Threshold)"),
294 YO("Sign Changes (High Threshold)"),
295 YO("Direction Changes (Low Threshold)"),
296 YO("Direction Changes (High Threshold)")
297 };
298
299 mKeyTypeChoice = safenew wxChoice(this, TTB_KeyType,
300 wxDefaultPosition,
301 wxDefaultSize,
302 transform_container<wxArrayStringEx>( choices,
303 std::mem_fn( &TranslatableString::Translation ) ) );
304 mKeyTypeChoice->SetName(YO("Key type").Translation());
305 mKeyTypeChoice->SetSelection(0);
306 Add( mKeyTypeChoice, 0, wxALIGN_CENTER );
307#endif
308
309 // Add a little space
310 Add(2, -1);
311
312 UpdatePrefs();
313}
#define SPEED_SLIDER
Definition: ASlider.h:35
#define _(s)
Definition: Internat.h:73
#define safenew
Definition: MemoryX.h:10
@ TTB_PlaySpeedSlider
std::vector< TranslatableString > TranslatableStrings
void FollowModifierKeys()
Definition: AButton.cpp:243
ASlider is a custom slider, allowing for a slicker look and feel.
Definition: ASlider.h:260
void Set(float value)
Definition: ASlider.cpp:1850
wxColour & Colour(int iIndex)
static void MakeButtonBackgroundsSmall()
Definition: ToolBar.cpp:837
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 352 of file TranscriptionToolBar.cpp.

353{
354 // We could also mention the shift- and ctrl-modified versions in the
355 // tool tip... but it would get long
356
357 static const struct Entry {
358 int tool;
359 CommandID commandName;
360 TranslatableString untranslatedLabel;
361 CommandID commandName2;
362 TranslatableString untranslatedLabel2;
363 } table[] = {
365 wxT("PlayAtSpeedLooped"), XO("Play-at-Speed"),
366 wxT("PlayAtSpeed"), XO("Play-at-Speed Once"),
367 },
368 };
369
370 for (const auto &entry : table) {
371 ComponentInterfaceSymbol commands[] = {
372 { entry.commandName, entry.untranslatedLabel },
373 { entry.commandName2, entry.untranslatedLabel2 },
374 };
376 *mButtons[entry.tool], commands, 2u );
377 }
378
379#ifdef EXPERIMENTAL_VOICE_DETECTION
380 mButtons[TTB_StartOn]->SetToolTip(YO("Left-to-On"));
381 mButtons[TTB_EndOn]->SetToolTip( YO("Right-to-Off"));
382 mButtons[TTB_StartOff]->SetToolTip( YO("Left-to-Off"));
383 mButtons[TTB_EndOff]->SetToolTip( YO("Right-to-On"));
384 mButtons[TTB_SelectSound]->SetToolTip( YO("Select-Sound"));
385 mButtons[TTB_SelectSilence]->SetToolTip( YO("Select-Silence"));
386 mButtons[TTB_AutomateSelection]->SetToolTip( YO("Make Labels"));
387 mButtons[TTB_MakeLabel]->SetToolTip( YO("Add Label"));
388 mButtons[TTB_Calibrate]->SetToolTip( YO("Calibrate"));
389
390 mSensitivitySlider->SetToolTip(YO("Sensitivity").Translation());
391 mKeyTypeChoice->SetToolTip(YO("Key type").Translation());
392#endif
393}
static ProjectFileIORegistry::AttributeWriterEntry entry
void SetToolTip(const TranslatableString &toolTip)
Definition: AButton.cpp:184
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:970
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 84 of file TranscriptionToolBar.h.

84{};

◆ SetButton()

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

Definition at line 439 of file TranscriptionToolBar.cpp.

440{
441 if (down) {
442 button->PushDown();
443 }
444 else {
445 button->PopUp();
446 }
447}
void PushDown()
Definition: AButton.cpp:577
void PopUp()
Definition: AButton.cpp:585

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 1040 of file TranscriptionToolBar.cpp.

1041{
1043}

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 1045 of file TranscriptionToolBar.cpp.

1046{
1047 AButton *const button = mButtons[TTB_PlaySpeed];
1048 if (down) {
1049 button->SetAlternateIdx(cutPreview ? 2 : looped ? 1 : 0);
1050 button->PushDown();
1051 }
1052 else {
1053 button->SetAlternateIdx(0);
1054 button->PopUp();
1055 }
1056}
void SetAlternateIdx(unsigned idx)
Definition: AButton.cpp:232

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 175 of file TranscriptionToolBar.cpp.

176{
177 mPlaySpeed = value;
179}
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:

◆ ShownByDefault()

bool TranscriptionToolBar::ShownByDefault ( ) const
overridevirtual

Whether the toolbar should be shown by default. Default implementation returns true.

Reimplemented from ToolBar.

Definition at line 113 of file TranscriptionToolBar.cpp.

114{
115 return
116#ifdef EXPERIMENTAL_DA
117 false
118#else
119 true
120#endif
121 ;
122}

◆ ShowPlaySpeedDialog()

void TranscriptionToolBar::ShowPlaySpeedDialog ( )

Definition at line 1032 of file TranscriptionToolBar.cpp.

1033{
1035 mPlaySpeedSlider->Refresh();
1036 wxCommandEvent e;
1037 OnSpeedSlider(e);
1038}
bool ShowDialog(wxPoint pos=wxPoint(-1, -1))
Definition: ASlider.cpp:1865

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 341 of file TranscriptionToolBar.cpp.

342{
344
345 // Set label to pull in language change
346 SetLabel(XO("Play-at-Speed"));
347
348 // Give base class a chance
350}
void SetLabel(const wxString &label) override
Definition: ToolBar.cpp:408
void UpdatePrefs() override
Definition: ToolBar.cpp:622

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 142 of file TranscriptionToolBar.h.

◆ hiliteImage

wxImage* TranscriptionToolBar::hiliteImage
private

Definition at line 143 of file TranscriptionToolBar.h.

◆ mBackgroundHeight

int TranscriptionToolBar::mBackgroundHeight
private

Definition at line 156 of file TranscriptionToolBar.h.

Referenced by Create().

◆ mBackgroundWidth

int TranscriptionToolBar::mBackgroundWidth
private

Definition at line 155 of file TranscriptionToolBar.h.

Referenced by Create().

◆ mButtons

AButton* TranscriptionToolBar::mButtons[TTBNumButtons]
private

◆ mEnvelope

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

Definition at line 158 of file TranscriptionToolBar.h.

Referenced by PlayAtSpeed().

◆ mPlaySpeed

double TranscriptionToolBar::mPlaySpeed
private

Definition at line 146 of file TranscriptionToolBar.h.

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

◆ mPlaySpeedSlider

ASlider* TranscriptionToolBar::mPlaySpeedSlider
private

◆ mSensitivitySlider

ASlider* TranscriptionToolBar::mSensitivitySlider
private

Definition at line 147 of file TranscriptionToolBar.h.

Referenced by Populate(), and RegenerateTooltips().

◆ upImage

wxImage* TranscriptionToolBar::upImage
private

Definition at line 141 of file TranscriptionToolBar.h.


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