mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-02 08:59:28 +02:00
Fix bug 559 (P1), http://bugzilla.audacityteam.org/show_bug.cgi?id=559.
This commit is contained in:
parent
02c98b5eef
commit
94cc0f19ff
@ -1734,7 +1734,12 @@ void WaveTrack::GetEnvelopeValues(double *buffer, int bufferLen,
|
|||||||
if( bufferLen <= 0 )
|
if( bufferLen <= 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
memset(buffer, 0, sizeof(double)*bufferLen);
|
// This is useful in debugging, to easily find null envelope settings, but
|
||||||
|
// should not be necessary in release build.
|
||||||
|
// If we were going to set it to failsafe values, better to set each element to 1.0.
|
||||||
|
#ifdef __WXDEBUG__
|
||||||
|
memset(buffer, 0, sizeof(double)*bufferLen);
|
||||||
|
#endif
|
||||||
|
|
||||||
double startTime = t0;
|
double startTime = t0;
|
||||||
double endTime = t0+tstep*bufferLen;
|
double endTime = t0+tstep*bufferLen;
|
||||||
@ -1744,30 +1749,30 @@ void WaveTrack::GetEnvelopeValues(double *buffer, int bufferLen,
|
|||||||
WaveClip *clip = it->GetData();
|
WaveClip *clip = it->GetData();
|
||||||
|
|
||||||
// IF clip intersects startTime..endTime THEN...
|
// IF clip intersects startTime..endTime THEN...
|
||||||
if (clip->GetStartTime() < endTime && clip->GetEndTime() > startTime)
|
double dClipStartTime = clip->GetStartTime();
|
||||||
|
double dClipEndTime = clip->GetEndTime();
|
||||||
|
if ((dClipStartTime < endTime) && (dClipEndTime > startTime))
|
||||||
{
|
{
|
||||||
double* rbuf = buffer;
|
double* rbuf = buffer;
|
||||||
int rlen = bufferLen;
|
int rlen = bufferLen;
|
||||||
double rt0 = t0;
|
double rt0 = t0;
|
||||||
|
|
||||||
if (rt0 < clip->GetStartTime())
|
if (rt0 < dClipStartTime)
|
||||||
{
|
{
|
||||||
sampleCount start = clip->GetStartSample();
|
sampleCount nDiff = (sampleCount)floor((dClipStartTime - rt0) * mRate + 0.5);
|
||||||
rbuf += start;
|
rbuf += nDiff;
|
||||||
rlen -= start;
|
rlen -= nDiff;
|
||||||
rt0 = clip->GetStartTime();
|
rt0 = dClipStartTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rt0 + rlen*tstep > clip->GetEndTime())
|
if (rt0 + rlen*tstep > dClipEndTime)
|
||||||
{
|
{
|
||||||
int nClipLen = clip->GetEndSample() - clip->GetStartSample();
|
int nClipLen = clip->GetEndSample() - clip->GetStartSample();
|
||||||
|
|
||||||
// This check prevents problem cited in http://bugzilla.audacityteam.org/show_bug.cgi?id=528#c11,
|
// This check prevents problem cited in http://bugzilla.audacityteam.org/show_bug.cgi?id=528#c11,
|
||||||
// Gale's cross_fade_out project, which was already corrupted by bug 528.
|
// Gale's cross_fade_out project, which was already corrupted by bug 528.
|
||||||
//vvv Should really be checked earlier, in reading the project, and/or determining bufferLen
|
// This conditional prevents the previous write past the buffer end, in clip->GetEnvelope() call.
|
||||||
// passed in. But that needs much more debugging, and this conditional prevents the previous
|
if (nClipLen < rlen) // Never increase rlen here.
|
||||||
// write past the buffer end, in clip->GetEnvelope() call.
|
|
||||||
if (nClipLen < rlen)
|
|
||||||
rlen = nClipLen;
|
rlen = nClipLen;
|
||||||
}
|
}
|
||||||
clip->GetEnvelope()->GetValues(rbuf, rlen, rt0, tstep);
|
clip->GetEnvelope()->GetValues(rbuf, rlen, rt0, tstep);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user