mirror of
https://github.com/cookiengineer/audacity
synced 2025-12-21 16:11:11 +01:00
Scrubbing.cpp does not depend on TranscriptionToolBar...
... Freeing the latter from cycles, and also VoiceKey. As with ToolsToolBar, use low-level ProjectSettings as the chalkboard for sending a message.
This commit is contained in:
@@ -11,6 +11,7 @@ Paul Licameli split from AudacityProject.h
|
|||||||
#ifndef __AUDACITY_PROJECT_SETTINGS__
|
#ifndef __AUDACITY_PROJECT_SETTINGS__
|
||||||
#define __AUDACITY_PROJECT_SETTINGS__
|
#define __AUDACITY_PROJECT_SETTINGS__
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
#include <wx/event.h> // to declare custom event type
|
#include <wx/event.h> // to declare custom event type
|
||||||
|
|
||||||
#include "ClientData.h" // to inherit
|
#include "ClientData.h" // to inherit
|
||||||
@@ -88,6 +89,12 @@ public:
|
|||||||
void SetTool(int tool) { mCurrentTool = tool; }
|
void SetTool(int tool) { mCurrentTool = tool; }
|
||||||
int GetTool() const { return mCurrentTool; }
|
int GetTool() const { return mCurrentTool; }
|
||||||
|
|
||||||
|
// Speed play
|
||||||
|
double GetPlaySpeed() const {
|
||||||
|
return mPlaySpeed.load( std::memory_order_relaxed ); }
|
||||||
|
void SetPlaySpeed( double value ) {
|
||||||
|
mPlaySpeed.store( value, std::memory_order_relaxed ); }
|
||||||
|
|
||||||
// Selection Format
|
// Selection Format
|
||||||
|
|
||||||
void SetSelectionFormat(const NumericFormatSymbol & format);
|
void SetSelectionFormat(const NumericFormatSymbol & format);
|
||||||
@@ -121,6 +128,10 @@ private:
|
|||||||
|
|
||||||
double mRate;
|
double mRate;
|
||||||
|
|
||||||
|
// This is atomic because scrubber may read it in a separate thread from
|
||||||
|
// the main
|
||||||
|
std::atomic<double> mPlaySpeed{};
|
||||||
|
|
||||||
sampleFormat mDefaultFormat;
|
sampleFormat mDefaultFormat;
|
||||||
int mSnapTo;
|
int mSnapTo;
|
||||||
|
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ WaveTrack::WaveTrack(const std::shared_ptr<DirManager> &projDirManager, sampleFo
|
|||||||
PlayableTrack(projDirManager)
|
PlayableTrack(projDirManager)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
const auto settings = ProjectSettings::Get( *GetActiveProject() );
|
const auto &settings = ProjectSettings::Get( *GetActiveProject() );
|
||||||
if (format == (sampleFormat)0)
|
if (format == (sampleFormat)0)
|
||||||
{
|
{
|
||||||
format = settings.GetDefaultFormat();
|
format = settings.GetDefaultFormat();
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
#include "../KeyboardCapture.h"
|
#include "../KeyboardCapture.h"
|
||||||
#include "../Project.h"
|
#include "../Project.h"
|
||||||
#include "../ProjectAudioManager.h"
|
#include "../ProjectAudioManager.h"
|
||||||
|
#include "../ProjectSettings.h"
|
||||||
#include "../Envelope.h"
|
#include "../Envelope.h"
|
||||||
#include "../ViewInfo.h"
|
#include "../ViewInfo.h"
|
||||||
#include "../WaveTrack.h"
|
#include "../WaveTrack.h"
|
||||||
@@ -98,7 +99,7 @@ TranscriptionToolBar::TranscriptionToolBar( AudacityProject &project )
|
|||||||
: ToolBar( project,
|
: ToolBar( project,
|
||||||
TranscriptionBarID, _("Play-at-Speed"), wxT("Transcription"), true )
|
TranscriptionBarID, _("Play-at-Speed"), wxT("Transcription"), true )
|
||||||
{
|
{
|
||||||
mPlaySpeed = 1.0 * 100.0;
|
SetPlaySpeed( 1.0 * 100.0 );
|
||||||
#ifdef EXPERIMENTAL_VOICE_DETECTION
|
#ifdef EXPERIMENTAL_VOICE_DETECTION
|
||||||
mVk = std::make_unique<VoiceKey>();
|
mVk = std::make_unique<VoiceKey>();
|
||||||
#endif
|
#endif
|
||||||
@@ -146,7 +147,7 @@ void TranscriptionToolBar::Create(wxWindow * parent)
|
|||||||
//JKC: Set speed this way is better, as we don't
|
//JKC: Set speed this way is better, as we don't
|
||||||
//then stop Audio if it is playing, so we can be playing
|
//then stop Audio if it is playing, so we can be playing
|
||||||
//audio and open a second project.
|
//audio and open a second project.
|
||||||
mPlaySpeed = (mPlaySpeedSlider->Get()) * 100;
|
SetPlaySpeed( (mPlaySpeedSlider->Get()) * 100 );
|
||||||
|
|
||||||
// Simulate a size event to set initial placement/size
|
// Simulate a size event to set initial placement/size
|
||||||
wxSizeEvent event(GetSize(), GetId());
|
wxSizeEvent event(GetSize(), GetId());
|
||||||
@@ -154,6 +155,12 @@ void TranscriptionToolBar::Create(wxWindow * parent)
|
|||||||
GetEventHandler()->ProcessEvent(event);
|
GetEventHandler()->ProcessEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TranscriptionToolBar::SetPlaySpeed( double value )
|
||||||
|
{
|
||||||
|
mPlaySpeed = value;
|
||||||
|
ProjectSettings::Get( mProject ).SetPlaySpeed( GetPlaySpeed() );
|
||||||
|
}
|
||||||
|
|
||||||
/// This is a convenience function that allows for button creation in
|
/// This is a convenience function that allows for button creation in
|
||||||
/// MakeButtons() with fewer arguments
|
/// MakeButtons() with fewer arguments
|
||||||
/// Very similar to code in ControlToolBar...
|
/// Very similar to code in ControlToolBar...
|
||||||
@@ -551,7 +558,7 @@ void TranscriptionToolBar::OnPlaySpeed(wxCommandEvent & WXUNUSED(event))
|
|||||||
|
|
||||||
void TranscriptionToolBar::OnSpeedSlider(wxCommandEvent& WXUNUSED(event))
|
void TranscriptionToolBar::OnSpeedSlider(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
mPlaySpeed = (mPlaySpeedSlider->Get()) * 100;
|
SetPlaySpeed( (mPlaySpeedSlider->Get()) * 100 );
|
||||||
RegenerateTooltips();
|
RegenerateTooltips();
|
||||||
|
|
||||||
// If IO is busy, abort immediately
|
// If IO is busy, abort immediately
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ class TranscriptionToolBar final : public ToolBar {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void InitializeTranscriptionToolBar();
|
void SetPlaySpeed( double value );
|
||||||
static AButton *AddButton(
|
static AButton *AddButton(
|
||||||
TranscriptionToolBar *pBar,
|
TranscriptionToolBar *pBar,
|
||||||
teBmps eFore, teBmps eDisabled,
|
teBmps eFore, teBmps eDisabled,
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ Paul Licameli split from TrackPanel.cpp
|
|||||||
#include "../../Project.h"
|
#include "../../Project.h"
|
||||||
#include "../../ProjectAudioIO.h"
|
#include "../../ProjectAudioIO.h"
|
||||||
#include "../../ProjectAudioManager.h"
|
#include "../../ProjectAudioManager.h"
|
||||||
|
#include "../../ProjectSettings.h"
|
||||||
#include "../../TrackPanel.h"
|
#include "../../TrackPanel.h"
|
||||||
#include "../../ViewInfo.h"
|
#include "../../ViewInfo.h"
|
||||||
#include "../../prefs/PlaybackPrefs.h"
|
#include "../../prefs/PlaybackPrefs.h"
|
||||||
@@ -28,12 +29,8 @@ Paul Licameli split from TrackPanel.cpp
|
|||||||
#include "../../toolbars/ControlToolBar.h"
|
#include "../../toolbars/ControlToolBar.h"
|
||||||
#include "../../toolbars/ScrubbingToolBar.h"
|
#include "../../toolbars/ScrubbingToolBar.h"
|
||||||
#include "../../toolbars/ToolManager.h"
|
#include "../../toolbars/ToolManager.h"
|
||||||
#include "../../toolbars/TranscriptionToolBar.h"
|
|
||||||
|
|
||||||
#undef USE_TRANSCRIPTION_TOOLBAR
|
#undef USE_TRANSCRIPTION_TOOLBAR
|
||||||
#ifdef USE_TRANSCRIPTION_TOOLBAR
|
|
||||||
#include "../../toolbars/TranscriptionToolBar.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@@ -397,7 +394,7 @@ bool Scrubber::MaybeStartScrubbing(wxCoord xx)
|
|||||||
// Take the starting speed limit from the transcription toolbar,
|
// Take the starting speed limit from the transcription toolbar,
|
||||||
// but it may be varied during the scrub.
|
// but it may be varied during the scrub.
|
||||||
mMaxSpeed = mOptions.maxSpeed =
|
mMaxSpeed = mOptions.maxSpeed =
|
||||||
TranscriptionToolBar::Get( *mProject ).GetPlaySpeed();
|
ProjectSettings::Get( *mProject ).GetPlaySpeed();
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
// That idea seems unpopular... just make it one for move-scrub,
|
// That idea seems unpopular... just make it one for move-scrub,
|
||||||
@@ -560,10 +557,8 @@ void Scrubber::ContinueScrubbingPoll()
|
|||||||
// default speed of 1.3 set, so that we can hear there is a problem
|
// default speed of 1.3 set, so that we can hear there is a problem
|
||||||
// when playAtSpeedTB not found.
|
// when playAtSpeedTB not found.
|
||||||
double speed = 1.3;
|
double speed = 1.3;
|
||||||
const auto playAtSpeedTB = &TranscriptionToolBar::Get( *mProject );
|
const auto &settings = ProjectSettings::Get( *mProject );
|
||||||
if (playAtSpeedTB) {
|
speed = settings.GetPlaySpeed();
|
||||||
speed = playAtSpeedTB->GetPlaySpeed();
|
|
||||||
}
|
|
||||||
mOptions.minSpeed = speed -0.01;
|
mOptions.minSpeed = speed -0.01;
|
||||||
mOptions.maxSpeed = speed +0.01;
|
mOptions.maxSpeed = speed +0.01;
|
||||||
mOptions.adjustStart = false;
|
mOptions.adjustStart = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user