Skip to content

Commit bf1f2c1

Browse files
committed
Updated depthPercent to a float
Noticed some performance issues when working with depthPercent as a uint8_t
1 parent 36fdfec commit bf1f2c1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/AudioEffects/AudioEffect.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ class Tremolo : public AudioEffect {
282282
class Delay : public AudioEffect {
283283
public:
284284
/// e.g. depthPercent=50, ms=1000, sampleRate=44100
285-
Delay(uint16_t duration_ms=1000, uint8_t depthPercent=50, uint32_t sampleRate=44100) {
285+
Delay(uint16_t duration_ms=1000, float depthPercent=50, uint32_t sampleRate=44100) {
286286
this->sampleRate = sampleRate;
287287
p_percent = depthPercent;
288288
p_ms = duration_ms;
@@ -298,7 +298,7 @@ class Delay : public AudioEffect {
298298
return p_ms;
299299
}
300300

301-
void setDepth(uint8_t percent){
301+
void setDepth(float percent){
302302
p_percent = percent;
303303
}
304304

@@ -315,7 +315,7 @@ class Delay : public AudioEffect {
315315
// add actual input value
316316
p_history->write(input);
317317
// mix input with result
318-
return (value * p_percent / 100) + (input * (100-p_percent)/100);
318+
return (value * p_percent) + (input * (1.0 - p_percent));
319319
}
320320

321321
Delay *clone() {
@@ -324,7 +324,7 @@ class Delay : public AudioEffect {
324324

325325
protected:
326326
RingBuffer<effect_t>* p_history=nullptr;
327-
uint8_t p_percent;
327+
float p_percent;
328328
uint16_t p_ms;
329329
uint16_t sampleCount=0;
330330
uint32_t sampleRate;

0 commit comments

Comments
 (0)