1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-08 16:11:14 +02:00

Make sure the envelope buffer is completely set

This should correct at least one of the situations where
folks have complained about crackling when the first clip
of the first track does not start at zero.
This commit is contained in:
lllucius 2014-12-22 05:03:08 +00:00
parent 86a71bd71b
commit 65088dc4d2

View File

@ -1851,16 +1851,24 @@ void WaveTrack::GetEnvelopeValues(double *buffer, int bufferLen,
if( bufferLen <= 0 ) if( bufferLen <= 0 )
return; return;
// This is useful in debugging, to easily find null envelope settings, but // The output buffer corresponds to an unbroken span of time which the callers expect
// should not be necessary in Release build. // to be fully valid. As clips are processed below, the output buffer is updated with
// If we were going to set it to failsafe values in Release build, better to set each element to 1.0. // envelope values from any portion of a clip, start, end, middle, or none at all.
#ifdef __WXDEBUG__ // Since this does not guarantee that the entire buffer is filled with values we need
memset(buffer, 0, sizeof(double)*bufferLen); // to initialize the entire buffer to a default value.
#endif //
// This does mean that, in the cases where a usuable clip is located, the buffer value will
// be set twice. Unfortunately, there is no easy way around this since the clips are not
// stored in increasing time order. If they were, we could just track the time as the
// buffer is filled.
for (int i = 0; i < bufferLen; i++)
{
buffer[i] = 1.0;
}
double startTime = t0; double startTime = t0;
double endTime = t0+tstep*bufferLen; double endTime = t0+tstep*bufferLen;
bool processed = false;
for (WaveClipList::compatibility_iterator it=GetClipIterator(); it; it=it->GetNext()) for (WaveClipList::compatibility_iterator it=GetClipIterator(); it; it=it->GetNext())
{ {
WaveClip *clip = it->GetData(); WaveClip *clip = it->GetData();