use const int rather than macro

This commit is contained in:
Paul Davis 2019-07-11 09:15:42 -06:00
parent b84c99639f
commit cbb7f6d863

View file

@ -1454,21 +1454,22 @@ DiskReader::DeclickAmp::apply_gain (AudioBuffer& buf, samplecnt_t n_samples, con
const float a = _a; const float a = _a;
Sample* const buffer = buf.data (); Sample* const buffer = buf.data ();
#define MAX_NPROC 16 const int max_nproc = 16;
uint32_t remain = n_samples; uint32_t remain = n_samples;
uint32_t offset = 0; uint32_t offset = 0;
while (remain > 0) { while (remain > 0) {
uint32_t n_proc = remain > MAX_NPROC ? MAX_NPROC : remain; uint32_t n_proc = remain > max_nproc ? max_nproc : remain;
std::cerr << "g = " << g << std::endl;
for (uint32_t i = 0; i < n_proc; ++i) { for (uint32_t i = 0; i < n_proc; ++i) {
buffer[offset + i] *= g; buffer[offset + i] *= g;
} }
#if 1 #if 1
g += a * (target - g); g += a * (target - g);
#else /* accurate exponential fade */ #else /* accurate exponential fade */
if (n_proc == MAX_NPROC) { if (n_proc == max_nproc) {
g += a * (target - g); g += a * (target - g);
} else { } else {
g = target - (target - g) * expf (_l * n_proc / MAX_NPROC); g = target - (target - g) * expf (_l * n_proc / max_nproc);
} }
#endif #endif
remain -= n_proc; remain -= n_proc;