mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-12 22:57:43 +02:00
Bug 1932 - (Residual) Fix stopping behavior with Play-At-Speed.
1. The rate actually used by the sound card now sets the stopping sample number. 2. The tolerance in the 'stop position' is additionally trimmed to 20 samples.
This commit is contained in:
parent
aaad7dd08d
commit
3bb48a21df
src
@ -483,11 +483,6 @@ class AUDACITY_DLL_API AudioIO final {
|
|||||||
void SetCaptureMeter(AudacityProject *project, MeterPanel *meter);
|
void SetCaptureMeter(AudacityProject *project, MeterPanel *meter);
|
||||||
void SetPlaybackMeter(AudacityProject *project, MeterPanel *meter);
|
void SetPlaybackMeter(AudacityProject *project, MeterPanel *meter);
|
||||||
|
|
||||||
private:
|
|
||||||
/** \brief Set the current VU meters - this should be done once after
|
|
||||||
* each call to StartStream currently */
|
|
||||||
void SetMeters();
|
|
||||||
|
|
||||||
/** \brief Return a valid sample rate that is supported by the current I/O
|
/** \brief Return a valid sample rate that is supported by the current I/O
|
||||||
* device(s).
|
* device(s).
|
||||||
*
|
*
|
||||||
@ -500,6 +495,12 @@ private:
|
|||||||
* and playing is true if one or more channels are being played. */
|
* and playing is true if one or more channels are being played. */
|
||||||
double GetBestRate(bool capturing, bool playing, double sampleRate);
|
double GetBestRate(bool capturing, bool playing, double sampleRate);
|
||||||
|
|
||||||
|
private:
|
||||||
|
/** \brief Set the current VU meters - this should be done once after
|
||||||
|
* each call to StartStream currently */
|
||||||
|
void SetMeters();
|
||||||
|
|
||||||
|
|
||||||
/** \brief Opens the portaudio stream(s) used to do playback or recording
|
/** \brief Opens the portaudio stream(s) used to do playback or recording
|
||||||
* (or both) through.
|
* (or both) through.
|
||||||
*
|
*
|
||||||
|
@ -1306,6 +1306,20 @@ AudioIOStartStreamOptions AudacityProject::GetDefaultPlayOptions()
|
|||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AudioIOStartStreamOptions AudacityProject::GetSpeedPlayOptions()
|
||||||
|
{
|
||||||
|
auto PlayAtSpeedRate = gAudioIO->GetBestRate(
|
||||||
|
false, //not capturing
|
||||||
|
true, //is playing
|
||||||
|
GetRate() //suggested rate
|
||||||
|
);
|
||||||
|
AudioIOStartStreamOptions options{ PlayAtSpeedRate };
|
||||||
|
options.timeTrack = GetTracks()->GetTimeTrack();
|
||||||
|
options.listener = this;
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void AudacityProject::UpdatePrefsVariables()
|
void AudacityProject::UpdatePrefsVariables()
|
||||||
{
|
{
|
||||||
gPrefs->Read(wxT("/AudioFiles/ShowId3Dialog"), &mShowId3Dialog, true);
|
gPrefs->Read(wxT("/AudioFiles/ShowId3Dialog"), &mShowId3Dialog, true);
|
||||||
|
@ -188,6 +188,7 @@ class AUDACITY_DLL_API AudacityProject final : public wxFrame,
|
|||||||
virtual void ApplyUpdatedTheme();
|
virtual void ApplyUpdatedTheme();
|
||||||
|
|
||||||
AudioIOStartStreamOptions GetDefaultPlayOptions();
|
AudioIOStartStreamOptions GetDefaultPlayOptions();
|
||||||
|
AudioIOStartStreamOptions GetSpeedPlayOptions();
|
||||||
|
|
||||||
TrackList *GetTracks() { return mTracks.get(); }
|
TrackList *GetTracks() { return mTracks.get(); }
|
||||||
const TrackList *GetTracks() const { return mTracks.get(); }
|
const TrackList *GetTracks() const { return mTracks.get(); }
|
||||||
|
@ -462,7 +462,7 @@ bool Scrubber::StartSpeedPlay(double speed, double time0, double time1)
|
|||||||
mMaxSpeed = speed;
|
mMaxSpeed = speed;
|
||||||
mDragging = false;
|
mDragging = false;
|
||||||
|
|
||||||
AudioIOStartStreamOptions options(mProject->GetDefaultPlayOptions());
|
AudioIOStartStreamOptions options(mProject->GetSpeedPlayOptions());
|
||||||
options.pScrubbingOptions = &mOptions;
|
options.pScrubbingOptions = &mOptions;
|
||||||
options.timeTrack = NULL;
|
options.timeTrack = NULL;
|
||||||
mOptions.startClockTimeMillis = ::wxGetLocalTimeMillis();
|
mOptions.startClockTimeMillis = ::wxGetLocalTimeMillis();
|
||||||
@ -499,11 +499,11 @@ bool Scrubber::StartSpeedPlay(double speed, double time0, double time1)
|
|||||||
});
|
});
|
||||||
|
|
||||||
mScrubSpeedDisplayCountdown = 0;
|
mScrubSpeedDisplayCountdown = 0;
|
||||||
// last buffer should not be any bigger than this.
|
// Aim to stop within 20 samples of correct position.
|
||||||
double lastBuffer = (2 * ScrubPollInterval_ms) / 1000.0;
|
double stopTolerance = 20.0 / options.rate;
|
||||||
mScrubToken =
|
mScrubToken =
|
||||||
// Reduce time by 'lastBuffer' fudge factor, so that the Play will stop.
|
// Reduce time by 'stopTolerance' fudge factor, so that the Play will stop.
|
||||||
ctb->PlayPlayRegion(SelectedRegion(time0, time1-lastBuffer), options,
|
ctb->PlayPlayRegion(SelectedRegion(time0, time1-stopTolerance), options,
|
||||||
PlayMode::normalPlay, appearance, backwards);
|
PlayMode::normalPlay, appearance, backwards);
|
||||||
|
|
||||||
if (mScrubToken >= 0) {
|
if (mScrubToken >= 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user