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 * 1000.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 178 of file TranscriptionToolBar.cpp.

183{
184 AButton *&r = pBar->mButtons[id];
185
186 r = ToolBar::MakeButton(pBar,
187 bmpRecoloredUpSmall, bmpRecoloredDownSmall, bmpRecoloredUpHiliteSmall,bmpRecoloredHiliteSmall,
188 eFore, eFore, eDisabled,
189 wxWindowID(id),
190 wxDefaultPosition,
191 false,
192 theTheme.ImageSize( bmpRecoloredUpSmall ));
193
194 r->SetLabel(label);
195// JKC: Unlike ControlToolBar, does not have a focus rect. Shouldn't it?
196// r->SetFocusRect( r->GetRect().Deflate( 4, 4 ) );
197
198 pBar->Add( r, 0, wxALIGN_CENTER );
199
200 return r;
201}
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:205
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:839
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 1052 of file TranscriptionToolBar.cpp.

1053{
1054 if (adj < 0) {
1056 }
1057 else {
1059 }
1060 wxCommandEvent e;
1061 OnSpeedSlider(e);
1062}
void Increase(float steps)
Definition: ASlider.cpp:1869
void Decrease(float steps)
Definition: ASlider.cpp:1874
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 134 of file TranscriptionToolBar.cpp.

135{
136 ToolBar::Create(parent);
137
140
141#ifdef EXPERIMENTAL_VOICE_DETECTION
142 mButtons[TTB_StartOn]->Disable();
143 mButtons[TTB_StartOff]->Disable();
144 mButtons[TTB_EndOn]->Disable();
145 mButtons[TTB_EndOff]->Disable();
146 mButtons[TTB_SelectSound]->Disable();
147 mButtons[TTB_SelectSilence]->Disable();
148 mButtons[TTB_Calibrate]->Enable();
149 mButtons[TTB_AutomateSelection]->Disable();
150 mButtons[TTB_MakeLabel]->Enable();
151#endif
152
153 //Old code...
154 //Process a dummy event to set up mPlaySpeed
155 //wxCommandEvent dummy;
156 //OnSpeedSlider(dummy);
157
158 //JKC: Set speed this way is better, as we don't
159 //then stop Audio if it is playing, so we can be playing
160 //audio and open a second project.
161 SetPlaySpeed( (mPlaySpeedSlider->Get()) * 1000 );
162
163 // Simulate a size event to set initial placement/size
164 wxSizeEvent event(GetSize(), GetId());
165 event.SetEventObject(this);
166 GetEventHandler()->ProcessEvent(event);
167}
void Disable()
Definition: AButton.cpp:647
void Enable()
Definition: AButton.cpp:638
float Get(bool convert=true)
Definition: ASlider.cpp:1859
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 118 of file TranscriptionToolBar.cpp.

119{
120 return BotDockID;
121}
@ BotDockID
Definition: ToolBar.h:93

References ToolBar::BotDockID.

◆ EnableDisableButtons()

void TranscriptionToolBar::EnableDisableButtons ( )
overridevirtual

Implements ToolBar.

Definition at line 309 of file TranscriptionToolBar.cpp.

310{
312
313 auto gAudioIO = AudioIO::Get();
314 bool canStopAudioStream = (!gAudioIO->IsStreamActive() ||
315 gAudioIO->IsMonitoring() ||
316 gAudioIO->GetOwningProject().get() == p );
317 bool recording = gAudioIO->GetNumCaptureChannels() > 0;
318
319 // Only interested in audio type tracks
320 bool tracks = p && TrackList::Get(*p).Any<AudioTrack>(); // PRL: PlayableTrack ?
321 SetEnabled(canStopAudioStream && tracks && !recording);
322
323#ifdef EXPERIMENTAL_VOICE_DETECTION
324 if (!p)
325 return;
326 // Is anything selected?
327 const auto &selectedRegion = ViewInfo::Get( *p ).selectedRegion;
328 auto selection = !selectedRegion.isPoint() &&
329 !TrackList::Get( *p ).Selected().empty();
330
331 mButtons[TTB_Calibrate]->SetEnabled(selection);
332#endif
333}
const auto tracks
void SetEnabled(bool state)
Definition: AButton.h:201
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:247
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:950
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:314
auto Selected() -> TrackIterRange< TrackType >
Definition: Track.h:967
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(), AButton::SetEnabled(), and tracks.

Here is the call graph for this function:

◆ Get() [1/2]

TranscriptionToolBar & TranscriptionToolBar::Get ( AudacityProject project)
static

Definition at line 123 of file TranscriptionToolBar.cpp.

124{
125 auto &toolManager = ToolManager::Get( project );
126 return *static_cast<TranscriptionToolBar*>(toolManager.GetToolBar(ID()));
127}
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 129 of file TranscriptionToolBar.cpp.

130{
131 return Get( const_cast<AudacityProject&>( project )) ;
132}
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 / 1000.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 443 of file TranscriptionToolBar.cpp.

445{
446 // GetSamples attempts to translate the start and end selection markers into sample indices
447 // These selection numbers are doubles.
448
450 if (!p) {
451 return;
452 }
453
454 //First, get the current selection. It is part of the mViewInfo, which is
455 //part of the project
456
457 const auto &selectedRegion = ViewInfo::Get( *p ).selectedRegion;
458 double start = selectedRegion.t0();
459 double end = selectedRegion.t1();
460
461 auto ss0 = sampleCount( (start - t->GetStartTime()) * t->GetRate() );
462 auto ss1 = sampleCount( (end - t->GetStartTime()) * t->GetRate() );
463
464 if (start < t->GetStartTime()) {
465 ss0 = 0;
466 }
467
468#if 0
469 //This adjusts the right samplecount to the maximum sample.
470 if (ss1 >= t->GetNumSamples()) {
471 ss1 = t->GetNumSamples();
472 }
473#endif
474
475 if (ss1 < ss0) {
476 ss1 = ss0;
477 }
478
479 *s0 = ss0;
480 *slen = ss1 - ss0;
481}
double t0() const
Definition: ViewInfo.h:35
double GetStartTime() const override
Implement WideSampleSequence.
Definition: WaveTrack.cpp:2603
double GetRate() const override
Definition: WaveTrack.cpp:821
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:19
const char * end(const char *str) noexcept
Definition: StringUtils.h:106

References details::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 203 of file TranscriptionToolBar.cpp.

206{
208 bmpRecoloredUpSmall, bmpRecoloredDownSmall, bmpRecoloredUpHiliteSmall,bmpRecoloredHiliteSmall,
209 eFore, eFore, eDisabled,
210 theTheme.ImageSize( bmpRecoloredUpSmall ));
211}
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:909

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

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

References BasicUI::FindFocus(), and mPlaySpeedSlider.

Here is the call graph for this function:

◆ OnFocus()

void TranscriptionToolBar::OnFocus ( wxFocusEvent &  event)

Definition at line 389 of file TranscriptionToolBar.cpp.

390{
391 KeyboardCapture::OnFocus( *this, event );
392}
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 412 of file TranscriptionToolBar.cpp.

413{
414 if (event.ControlDown()) {
415 event.Skip();
416 return;
417 }
418
419 if (event.GetKeyCode() == WXK_SPACE) {
420 auto gAudioIO = AudioIOBase::Get();
421 if (gAudioIO->IsBusy()) {
422 /*Do Stuff Here*/
423 }
424 else {
425 /*Do other stuff Here*/
426 }
427 }
428}
static AudioIOBase * Get()
Definition: AudioIOBase.cpp:94

References AudioIOBase::Get().

Here is the call graph for this function:

◆ OnPlaySpeed()

void TranscriptionToolBar::OnPlaySpeed ( wxCommandEvent &  event)

Definition at line 560 of file TranscriptionToolBar.cpp.

561{
562 auto button = mButtons[TTB_PlaySpeed];
563
564 // Let control have precedence over shift
565 const bool cutPreview = mButtons[TTB_PlaySpeed]->WasControlDown();
566 const bool looped = !cutPreview &&
567 !button->WasShiftDown();
568 OnSpeedSlider(event);
569 PlayAtSpeed(looped, cutPreview);
570}
@ TTB_PlaySpeed
bool WasControlDown()
Definition: AButton.cpp:633
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 572 of file TranscriptionToolBar.cpp.

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

490{
491 // Can't do anything without an active project
493 if (!p) {
494 return;
495 }
496
497 auto &projectAudioManager = ProjectAudioManager::Get( mProject );
498
499 // Fixed speed play is the old method, that uses a time track.
500 // VariSpeed play reuses Scrubbing.
501 bool bFixedSpeedPlay = !gPrefs->ReadBool(wxT("/AudioIO/VariSpeedPlay"), true);
502 // Scrubbing doesn't support note tracks, but the fixed-speed method using time tracks does.
503 if (TrackList::Get(*p).Any<NoteTrack>())
504 bFixedSpeedPlay = true;
505
506 // If cutPreview, we have to fall back to fixed speed.
507 if (newDefault)
508 cutPreview = false;
509 bFixedSpeedPlay = bFixedSpeedPlay || cutPreview;
510 if (bFixedSpeedPlay)
511 {
512 // Create a BoundedEnvelope if we haven't done so already
513 if (!mEnvelope) {
514 mEnvelope =
515 std::make_unique<BoundedEnvelope>(
516 true, TIMETRACK_MIN, TIMETRACK_MAX, 1.0);
517 // values as in the constructor for TimeTrack
518 mEnvelope->SetRangeLower( 0.9 );
519 mEnvelope->SetRangeUpper( 1.1 );
520 }
521 // Set the speed range
522 //mTimeTrack->SetRangeUpper((double)mPlaySpeed / 100.0);
523 //mTimeTrack->SetRangeLower((double)mPlaySpeed / 100.0);
524 mEnvelope->Flatten((double)mPlaySpeed / 1000.0);
525 }
526
527 // Pop up the button
529
530 // If IO is busy, abort immediately
531 auto gAudioIO = AudioIOBase::Get();
532 if (gAudioIO->IsBusy())
533 projectAudioManager.Stop();
534
535 // Get the current play region
536 const auto &viewInfo = ViewInfo::Get( *p );
537 const auto &playRegion = viewInfo.playRegion;
538
539 // Start playing
540 if (playRegion.GetStart() < 0)
541 return;
542
543 {
544 auto options = ProjectAudioIO::GetDefaultOptions(*p, newDefault);
545 // No need to set cutPreview options.
546 options.envelope = bFixedSpeedPlay ? mEnvelope.get() : nullptr;
547 options.variableSpeed = !bFixedSpeedPlay;
548 auto mode =
549 cutPreview ? PlayMode::cutPreviewPlay
550 : newDefault ? PlayMode::loopedPlay
552 projectAudioManager.PlayPlayRegion(
553 SelectedRegion(playRegion.GetStart(), playRegion.GetEnd()),
554 options,
555 mode);
556 }
557}
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:78
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 213 of file TranscriptionToolBar.cpp.

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

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

434{
435 if (down) {
436 button->PushDown();
437 }
438 else {
439 button->PopUp();
440 }
441}
void PushDown()
Definition: AButton.cpp:664
void PopUp()
Definition: AButton.cpp:672

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

1035{
1037}

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

1040{
1041 AButton *const button = mButtons[TTB_PlaySpeed];
1042 if (down) {
1043 button->SetAlternateIdx(cutPreview ? 2 : looped ? 1 : 0);
1044 button->PushDown();
1045 }
1046 else {
1047 button->SetAlternateIdx(0);
1048 button->PopUp();
1049 }
1050}
void SetAlternateIdx(unsigned idx)
Definition: AButton.cpp:287

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

170{
171 mPlaySpeed = value;
173}
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 true;
116}

◆ ShowPlaySpeedDialog()

void TranscriptionToolBar::ShowPlaySpeedDialog ( )

Definition at line 1026 of file TranscriptionToolBar.cpp.

1027{
1029 mPlaySpeedSlider->Refresh();
1030 wxCommandEvent e;
1031 OnSpeedSlider(e);
1032}
bool ShowDialog(wxPoint pos=wxPoint(-1, -1))
Definition: ASlider.cpp:1879

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

336{
338
339 // Set label to pull in language change
340 SetLabel(XO("Play-at-Speed"));
341
342 // Give base class a chance
344}
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: