mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-16 15:41:11 +02:00
Fix bug 2328: Ensure fade out at end of each DTMF tone
This commit is contained in:
@@ -580,24 +580,21 @@ bool EffectDtmf::MakeDtmfTone(float *buffer, size_t len, float fs, wxChar tone,
|
|||||||
|
|
||||||
// generate a fade-in of duration 1/250th of second
|
// generate a fade-in of duration 1/250th of second
|
||||||
if (last == 0) {
|
if (last == 0) {
|
||||||
A = (fs / kFadeInOut);
|
A = wxMin(len, (fs / kFadeInOut));
|
||||||
for(size_t i = 0; i < A; i++) {
|
for(size_t i = 0; i < A; i++) {
|
||||||
buffer[i] *= i/A;
|
buffer[i] *= i/A;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate a fade-out of duration 1/250th of second
|
// generate a fade-out of duration 1/250th of second
|
||||||
if (last == total - len) {
|
if (last >= total - len) {
|
||||||
// we are at the last buffer of 'len' size, so, offset is to
|
// we are at the last buffer of 'len' size, so, offset is to
|
||||||
// backup 'A' samples, from 'len'
|
// backup 'A' samples, from 'len'
|
||||||
A = (fs / kFadeInOut);
|
A = wxMin(len, (fs / kFadeInOut));
|
||||||
auto offset = long(len) - long(fs / kFadeInOut);
|
size_t offset = len - A;
|
||||||
// protect against negative offset, which can occur if too a
|
wxASSERT(offset >= 0);
|
||||||
// small selection is made
|
for(size_t i = 0; i < A; i++) {
|
||||||
if (offset >= 0) {
|
buffer[i + offset] *= (1 - (i / A));
|
||||||
for(size_t i = 0; i < A; i++) {
|
|
||||||
buffer[i + offset] *= (1 - (i / A));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
Reference in New Issue
Block a user