More sensible range for threshold, add post gain

This commit is contained in:
Aleks Rutins 2023-04-14 13:30:21 -04:00
parent a32ece06df
commit a4f63da955
3 changed files with 22 additions and 7 deletions

View file

@ -16,19 +16,24 @@ namespace Dynamite {
case THRESHOLD:
threshold = (const float *)data;
break;
case GAIN:
gain = (const float *)data;
}
}
void Drive::run(uint32_t n_samples) {
const float coeff = dbCo(*drive);
const float threshCoeff = dbCo(*threshold);
const float gainCoeff = dbCo(*gain);
for(uint32_t pos = 0; pos < n_samples; pos++) {
output[pos] = input[pos] * coeff;
if(output[pos] > *threshold) {
output[pos] = *threshold;
} else if (output[pos] < -*threshold) {
output[pos] = -*threshold;
if(output[pos] > threshCoeff) {
output[pos] = threshCoeff;
} else if (output[pos] < -threshCoeff) {
output[pos] = -threshCoeff;
}
output[pos] = output[pos] * gainCoeff;
}
}
}