1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-03 17:19:43 +02:00

Reimplement the insertion of zeroes at drop-outs...

... and correct for latency only when there is at least one playback track
This commit is contained in:
Paul Licameli 2018-01-17 11:18:00 -05:00
parent be0e6cd605
commit 81b22a2b2b
3 changed files with 19 additions and 23 deletions

View File

@ -2716,10 +2716,6 @@ void AudioIO::StopStream()
double recordingOffset =
mLastRecordingOffset + latencyCorrection / 1000.0;
for (auto &interval : mLostCaptureIntervals)
interval.first += recordingOffset,
interval.second += recordingOffset;
for (unsigned int i = 0; i < mCaptureTracks.size(); i++) {
// The calls to Flush, and (less likely) Clear and InsertSilence,
// may cause exceptions because of exhaustion of disk space.
@ -2791,6 +2787,19 @@ void AudioIO::StopStream()
}
} );
}
for (auto &interval : mLostCaptureIntervals) {
auto &start = interval.first;
if (mPlaybackTracks.size() > 0)
// only do latency correction if some tracks are being played back
start += recordingOffset;
auto duration = interval.second;
for (auto &track : mCaptureTracks) {
GuardedCall([&] {
track->SyncLockAdjust(start, start + duration);
});
}
}
}
}
@ -5181,10 +5190,9 @@ int audacityAudioCallback(const void *inputBuffer, void *outputBuffer,
len < framesPerBuffer) ) {
// Assume that any good partial buffer should be written leftmost
// and zeroes will be padded after; label the zeroes.
auto start = gAudioIO->mTime;
auto end = start + framesPerBuffer / gAudioIO->mRate;
auto middle = start + len / gAudioIO->mRate;
auto interval = std::make_pair( middle, end );
auto start = gAudioIO->mTime + len / gAudioIO->mRate;
auto duration = (framesPerBuffer - len) / gAudioIO->mRate;
auto interval = std::make_pair( start, duration );
gAudioIO->mLostCaptureIntervals.push_back( interval );
}
@ -5239,20 +5247,6 @@ int audacityAudioCallback(const void *inputBuffer, void *outputBuffer,
wxUnusedVar(put);
}
}
if (gAudioIO->mDetectDropouts &&
len < framesPerBuffer) {
for(unsigned t = 0; t < numCaptureChannels; t++) {
// Get here probably because of failure to keep up with real
// time, causing loss of input samples.
// Pad with zeroes
const auto put = gAudioIO->mCaptureBuffers[t]->Clear(
gAudioIO->mCaptureFormat, framesPerBuffer - len);
// wxASSERT(put == len);
// but we can't assert in this thread
wxUnusedVar(put);
}
}
}
// Update the current time position if not scrubbing

View File

@ -801,6 +801,7 @@ private:
bool mDetectDropouts{ true };
public:
// Pairs of starting time and duration
const std::vector< std::pair<double, double> > &LostCaptureIntervals()
{ return mLostCaptureIntervals; }

View File

@ -5394,7 +5394,8 @@ void AudacityProject::OnAudioIOStopRecording()
long counter = 1;
for (auto &interval : intervals)
pTrack->AddLabel(
SelectedRegion{ interval.first, interval.second },
SelectedRegion{ interval.first,
interval.first + interval.second },
wxString::Format(wxT("%ld"), counter++),
-2 );
ShowWarningDialog(this, wxT("DropoutDetected"), _("\