mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-01 08:29:27 +02:00
Keyboard scrubbing: faster change of direction
If one of the keyboard scrubbing keys is being held down, and the other keyboard scrubbing key is pressed: 1. With current behaviour, scrubbing in the other direction only starts when the original key is released - scrubbing stops and then starts in the other direction. 2. With the new behaviour, scrubbing immediately changes direction, and does not stop when the original key is released - scrubbing does not stop and then start again. New behaviour: If one of the keyboard scrubbing keys is being held down,
This commit is contained in:
parent
6fd29ad863
commit
64079c3f55
@ -2827,14 +2827,13 @@ void AudioIO::FillBuffers()
|
|||||||
if (!mSilentScrub)
|
if (!mSilentScrub)
|
||||||
{
|
{
|
||||||
for (i = 0; i < mPlaybackTracks.size(); i++) {
|
for (i = 0; i < mPlaybackTracks.size(); i++) {
|
||||||
if (mPlaybackSchedule.mPlayMode == PlaybackSchedule::PLAY_AT_SPEED ||
|
if (mPlaybackSchedule.mPlayMode == PlaybackSchedule::PLAY_AT_SPEED)
|
||||||
mPlaybackSchedule.mPlayMode == PlaybackSchedule::PLAY_KEYBOARD_SCRUB) {
|
mPlaybackMixers[i]->SetSpeedForPlayAtSpeed(mScrubSpeed);
|
||||||
mPlaybackMixers[i]->SetSpeed(mScrubSpeed);
|
else if (mPlaybackSchedule.mPlayMode == PlaybackSchedule::PLAY_KEYBOARD_SCRUB)
|
||||||
}
|
mPlaybackMixers[i]->SetSpeedForKeyboardScrubbing(mScrubSpeed, startTime);
|
||||||
else {
|
else
|
||||||
mPlaybackMixers[i]->SetTimesAndSpeed(
|
mPlaybackMixers[i]->SetTimesAndSpeed(
|
||||||
startTime, endTime, fabs( mScrubSpeed ));
|
startTime, endTime, fabs( mScrubSpeed ));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mTimeQueue.mLastTime = startTime;
|
mTimeQueue.mLastTime = startTime;
|
||||||
|
25
src/Mix.cpp
25
src/Mix.cpp
@ -762,12 +762,35 @@ void Mixer::SetTimesAndSpeed(double t0, double t1, double speed)
|
|||||||
Reposition(t0);
|
Reposition(t0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mixer::SetSpeed(double speed)
|
void Mixer::SetSpeedForPlayAtSpeed(double speed)
|
||||||
{
|
{
|
||||||
wxASSERT(std::isfinite(speed));
|
wxASSERT(std::isfinite(speed));
|
||||||
mSpeed = fabs(speed);
|
mSpeed = fabs(speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Mixer::SetSpeedForKeyboardScrubbing(double speed, double startTime)
|
||||||
|
{
|
||||||
|
wxASSERT(std::isfinite(speed));
|
||||||
|
|
||||||
|
// Check if the direction has changed
|
||||||
|
if ((speed > 0.0 && mT1 < mT0) || (speed < 0.0 && mT1 > mT0)) {
|
||||||
|
// It's safe to use 0 and DBL_MAX, because Mixer::MixVariableRates()
|
||||||
|
// doesn't sample past the start or end of the audio in a track.
|
||||||
|
if (speed > 0.0 && mT1 < mT0) {
|
||||||
|
mT0 = 0;
|
||||||
|
mT1 = DBL_MAX;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mT0 = DBL_MAX;
|
||||||
|
mT1 = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Reposition(startTime, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
mSpeed = fabs(speed);
|
||||||
|
}
|
||||||
|
|
||||||
MixerSpec::MixerSpec( unsigned numTracks, unsigned maxNumChannels )
|
MixerSpec::MixerSpec( unsigned numTracks, unsigned maxNumChannels )
|
||||||
{
|
{
|
||||||
mNumTracks = mNumChannels = numTracks;
|
mNumTracks = mNumChannels = numTracks;
|
||||||
|
@ -134,7 +134,8 @@ class AUDACITY_DLL_API Mixer {
|
|||||||
|
|
||||||
// Used in scrubbing.
|
// Used in scrubbing.
|
||||||
void SetTimesAndSpeed(double t0, double t1, double speed);
|
void SetTimesAndSpeed(double t0, double t1, double speed);
|
||||||
void SetSpeed(double speed);
|
void SetSpeedForPlayAtSpeed(double speed);
|
||||||
|
void SetSpeedForKeyboardScrubbing(double speed, double startTime);
|
||||||
|
|
||||||
/// Current time in seconds (unwarped, i.e. always between startTime and stopTime)
|
/// Current time in seconds (unwarped, i.e. always between startTime and stopTime)
|
||||||
/// This value is not accurate, it's useful for progress bars and indicators, but nothing else.
|
/// This value is not accurate, it's useful for progress bars and indicators, but nothing else.
|
||||||
|
@ -198,7 +198,7 @@ void DoKeyboardScrub(AudacityProject& project, bool backwards, bool keyUp)
|
|||||||
|
|
||||||
if (keyUp) {
|
if (keyUp) {
|
||||||
auto &scrubber = Scrubber::Get(project);
|
auto &scrubber = Scrubber::Get(project);
|
||||||
if (scrubber.IsKeyboardScrubbing()) {
|
if (scrubber.IsKeyboardScrubbing() && scrubber.IsBackwards() == backwards) {
|
||||||
auto gAudioIO = AudioIOBase::Get();
|
auto gAudioIO = AudioIOBase::Get();
|
||||||
auto time = gAudioIO->GetStreamTime();
|
auto time = gAudioIO->GetStreamTime();
|
||||||
auto &viewInfo = ViewInfo::Get(project);
|
auto &viewInfo = ViewInfo::Get(project);
|
||||||
@ -221,7 +221,11 @@ void DoKeyboardScrub(AudacityProject& project, bool backwards, bool keyUp)
|
|||||||
else { // KeyDown
|
else { // KeyDown
|
||||||
auto gAudioIO = AudioIOBase::Get();
|
auto gAudioIO = AudioIOBase::Get();
|
||||||
auto &scrubber = Scrubber::Get(project);
|
auto &scrubber = Scrubber::Get(project);
|
||||||
if (!gAudioIO->IsBusy() && !scrubber.HasMark()) {
|
if (scrubber.IsKeyboardScrubbing() && scrubber.IsBackwards() != backwards) {
|
||||||
|
// change direction
|
||||||
|
scrubber.SetBackwards(backwards);
|
||||||
|
}
|
||||||
|
else if (!gAudioIO->IsBusy() && !scrubber.HasMark()) {
|
||||||
auto &viewInfo = ViewInfo::Get(project);
|
auto &viewInfo = ViewInfo::Get(project);
|
||||||
auto &selection = viewInfo.selectedRegion;
|
auto &selection = viewInfo.selectedRegion;
|
||||||
double endTime = TrackList::Get(project).GetEndTime();
|
double endTime = TrackList::Get(project).GetEndTime();
|
||||||
|
@ -82,6 +82,10 @@ public:
|
|||||||
{ return mKeyboardScrubbing; }
|
{ return mKeyboardScrubbing; }
|
||||||
bool IsKeyboardScrubbing() const
|
bool IsKeyboardScrubbing() const
|
||||||
{ return IsScrubbing() && mKeyboardScrubbing; }
|
{ return IsScrubbing() && mKeyboardScrubbing; }
|
||||||
|
void SetBackwards(bool backwards)
|
||||||
|
{ mBackwards = backwards;}
|
||||||
|
bool IsBackwards() const
|
||||||
|
{ return mBackwards;}
|
||||||
// True iff the user has clicked to start scrub and not yet stopped,
|
// True iff the user has clicked to start scrub and not yet stopped,
|
||||||
// but IsScrubbing() may yet be false
|
// but IsScrubbing() may yet be false
|
||||||
bool HasMark() const
|
bool HasMark() const
|
||||||
|
Loading…
x
Reference in New Issue
Block a user