diff --git a/_audio_effect_8h_source.html b/_audio_effect_8h_source.html index 234a95671e..fa3833f693 100644 --- a/_audio_effect_8h_source.html +++ b/_audio_effect_8h_source.html @@ -395,198 +395,202 @@
396  void keyOff() { adsr->keyOff(); }
397 
398  effect_t process(effect_t input) {
-
399  effect_t result = factor * adsr->tick() * input;
-
400  return result;
-
401  }
-
402 
-
403  bool isActive() { return adsr->isActive(); }
+
399  if (!active())
+
400  return input;
+
401  effect_t result = factor * adsr->tick() * input;
+
402  return result;
+
403  }
404 
-
405  ADSRGain *clone() { return new ADSRGain(*this); }
+
405  bool isActive() { return adsr->isActive(); }
406 
-
407 protected:
-
408  ADSR *adsr;
-
409  float factor;
-
410 };
-
411 
-
418 class PitchShift : public AudioEffect {
-
419 public:
-
422  PitchShift(float shift_value = 1.0, int buffer_size = 1000) {
-
423  effect_value = shift_value;
-
424  size = buffer_size;
-
425  buffer.resize(buffer_size);
-
426  buffer.setIncrement(shift_value);
-
427  }
-
428 
-
429  PitchShift(const PitchShift &ref) {
-
430  size = ref.size;
-
431  effect_value = ref.effect_value;
-
432  buffer.resize(size);
-
433  buffer.setIncrement(effect_value);
-
434  };
-
435 
-
436  float value() { return effect_value; }
+
407  ADSRGain *clone() { return new ADSRGain(*this); }
+
408 
+
409 protected:
+
410  ADSR *adsr;
+
411  float factor;
+
412 };
+
413 
+
420 class PitchShift : public AudioEffect {
+
421 public:
+
424  PitchShift(float shift_value = 1.0, int buffer_size = 1000) {
+
425  effect_value = shift_value;
+
426  size = buffer_size;
+
427  buffer.resize(buffer_size);
+
428  buffer.setIncrement(shift_value);
+
429  }
+
430 
+
431  PitchShift(const PitchShift &ref) {
+
432  size = ref.size;
+
433  effect_value = ref.effect_value;
+
434  buffer.resize(size);
+
435  buffer.setIncrement(effect_value);
+
436  };
437 
-
438  void setValue(float value) {
-
439  effect_value = value;
-
440  buffer.setIncrement(value);
-
441  }
-
442 
-
443  effect_t process(effect_t input) {
-
444  if (!active())
-
445  return input;
-
446  buffer.write(input);
-
447  return buffer.read();
-
448  }
-
449 
-
450  PitchShift *clone() { return new PitchShift(*this); }
+
438  float value() { return effect_value; }
+
439 
+
440  void setValue(float value) {
+
441  effect_value = value;
+
442  buffer.setIncrement(value);
+
443  }
+
444 
+
445  effect_t process(effect_t input) {
+
446  if (!active())
+
447  return input;
+
448  buffer.write(input);
+
449  return buffer.read();
+
450  }
451 
-
452 protected:
-
453  VariableSpeedRingBuffer<int16_t> buffer;
-
454  float effect_value;
-
455  int size;
-
456 };
-
457 
-
458 
-
466 class Compressor : public AudioEffect {
-
467 public:
-
469  Compressor(const Compressor &copy) = default;
-
470 
-
472  Compressor(uint32_t sampleRate = 44100, uint16_t attackMs=30, uint16_t releaseMs=20, uint16_t holdMs=10, uint8_t thresholdPercent=10, float compressionRatio=0.5){
-
473  //assuming 1 sample = 1/96kHz = ~10us
-
474  //Attack -> 30 ms -> 3000
-
475  //Release -> 20 ms -> 2000
-
476  //Hold -> 10ms -> 1000
-
477  sample_rate = sample_rate * attackMs / 1000;
-
478  attack_count = sample_rate * attackMs / 1000;
-
479  release_count = sample_rate * releaseMs / 1000;
-
480  hold_count = sample_rate * holdMs / 1000;
-
481 
-
482  //threshold -20dB below limit -> 0.1 * 2^31
-
483  threshold = 0.01f * thresholdPercent * NumberConverter::maxValueT<effect_t>();
-
484  //compression ratio: 6:1 -> -6dB = 0.5
-
485  gainreduce = compressionRatio;
-
486  //initial gain = 1.0 -> no compression
-
487  gain = 1.0f;
-
488  recalculate();
-
489  }
-
490 
-
492  void setAttack(uint16_t attackMs){
-
493  attack_count = sample_rate * attackMs / 1000;
-
494  recalculate();
-
495  }
-
496 
-
498  void setRelease(uint16_t releaseMs){
-
499  release_count = sample_rate * releaseMs / 1000;
-
500  recalculate();
-
501  }
-
502 
-
504  void setHold(uint16_t holdMs){
-
505  hold_count = sample_rate * holdMs / 1000;
-
506  recalculate();
-
507  }
-
508 
-
510  void setThresholdPercent(uint8_t thresholdPercent){
-
511  threshold = 0.01f * thresholdPercent * NumberConverter::maxValueT<effect_t>();
-
512  }
-
513 
-
515  void setCompressionRatio(float compressionRatio){
-
516  if (compressionRatio<1.0){
-
517  gainreduce = compressionRatio;
-
518  }
-
519  recalculate();
-
520  }
-
521 
-
523  effect_t process(effect_t inSample) {
-
524  return compress(inSample);
-
525  }
-
526 
-
527  Compressor *clone() { return new Compressor(*this); }
-
528 
-
529 protected:
-
530  enum CompStates {S_NoOperation, S_Attack, S_GainReduction, S_Release };
-
531  enum CompStates state = S_NoOperation;
+
452  PitchShift *clone() { return new PitchShift(*this); }
+
453 
+
454 protected:
+
455  VariableSpeedRingBuffer<int16_t> buffer;
+
456  float effect_value;
+
457  int size;
+
458 };
+
459 
+
460 
+
468 class Compressor : public AudioEffect {
+
469 public:
+
471  Compressor(const Compressor &copy) = default;
+
472 
+
474  Compressor(uint32_t sampleRate = 44100, uint16_t attackMs=30, uint16_t releaseMs=20, uint16_t holdMs=10, uint8_t thresholdPercent=10, float compressionRatio=0.5){
+
475  //assuming 1 sample = 1/96kHz = ~10us
+
476  //Attack -> 30 ms -> 3000
+
477  //Release -> 20 ms -> 2000
+
478  //Hold -> 10ms -> 1000
+
479  sample_rate = sample_rate * attackMs / 1000;
+
480  attack_count = sample_rate * attackMs / 1000;
+
481  release_count = sample_rate * releaseMs / 1000;
+
482  hold_count = sample_rate * holdMs / 1000;
+
483 
+
484  //threshold -20dB below limit -> 0.1 * 2^31
+
485  threshold = 0.01f * thresholdPercent * NumberConverter::maxValueT<effect_t>();
+
486  //compression ratio: 6:1 -> -6dB = 0.5
+
487  gainreduce = compressionRatio;
+
488  //initial gain = 1.0 -> no compression
+
489  gain = 1.0f;
+
490  recalculate();
+
491  }
+
492 
+
494  void setAttack(uint16_t attackMs){
+
495  attack_count = sample_rate * attackMs / 1000;
+
496  recalculate();
+
497  }
+
498 
+
500  void setRelease(uint16_t releaseMs){
+
501  release_count = sample_rate * releaseMs / 1000;
+
502  recalculate();
+
503  }
+
504 
+
506  void setHold(uint16_t holdMs){
+
507  hold_count = sample_rate * holdMs / 1000;
+
508  recalculate();
+
509  }
+
510 
+
512  void setThresholdPercent(uint8_t thresholdPercent){
+
513  threshold = 0.01f * thresholdPercent * NumberConverter::maxValueT<effect_t>();
+
514  }
+
515 
+
517  void setCompressionRatio(float compressionRatio){
+
518  if (compressionRatio<1.0){
+
519  gainreduce = compressionRatio;
+
520  }
+
521  recalculate();
+
522  }
+
523 
+
525  effect_t process(effect_t input) {
+
526  if (!active())
+
527  return input;
+
528  return compress(input);
+
529  }
+
530 
+
531  Compressor *clone() { return new Compressor(*this); }
532 
-
533  int32_t attack_count, release_count, hold_count, timeout;
-
534  float gainreduce, gain_step_attack, gain_step_release, gain, threshold;
-
535  uint32_t sample_rate;
+
533 protected:
+
534  enum CompStates {S_NoOperation, S_Attack, S_GainReduction, S_Release };
+
535  enum CompStates state = S_NoOperation;
536 
-
537  void recalculate() {
-
538  gain_step_attack = (1.0f - gainreduce) / attack_count;
-
539  gain_step_release = (1.0f - gainreduce) / release_count;
-
540  }
-
541 
-
542  float compress(float inSampleF){
-
543  if (fabs(inSampleF) > threshold) {
-
544  if (gain >= gainreduce) {
-
545  if (state==S_NoOperation) {
-
546  state=S_Attack;
-
547  timeout = attack_count;
-
548  }
-
549  else if (state==S_Release) {
+
537  int32_t attack_count, release_count, hold_count, timeout;
+
538  float gainreduce, gain_step_attack, gain_step_release, gain, threshold;
+
539  uint32_t sample_rate;
+
540 
+
541  void recalculate() {
+
542  gain_step_attack = (1.0f - gainreduce) / attack_count;
+
543  gain_step_release = (1.0f - gainreduce) / release_count;
+
544  }
+
545 
+
546  float compress(float inSampleF){
+
547  if (fabs(inSampleF) > threshold) {
+
548  if (gain >= gainreduce) {
+
549  if (state==S_NoOperation) {
550  state=S_Attack;
551  timeout = attack_count;
552  }
-
553  }
-
554  if (state==S_GainReduction) timeout = hold_count;
-
555 
-
556  }
-
557 
-
558  if (fabs(inSampleF) < threshold && gain <= 1.0f) {
-
559  if ( timeout==0 && state==S_GainReduction) {
-
560  state=S_Release;
-
561  timeout = release_count;
-
562  }
-
563  }
-
564 
-
565  switch (state) {
-
566  case S_Attack:
-
567  if ( timeout>0 && gain > gainreduce) {
-
568  gain -= gain_step_attack;
-
569  timeout--;
-
570  }
-
571  else {
-
572  state=S_GainReduction;
-
573  timeout = hold_count;
+
553  else if (state==S_Release) {
+
554  state=S_Attack;
+
555  timeout = attack_count;
+
556  }
+
557  }
+
558  if (state==S_GainReduction) timeout = hold_count;
+
559 
+
560  }
+
561 
+
562  if (fabs(inSampleF) < threshold && gain <= 1.0f) {
+
563  if ( timeout==0 && state==S_GainReduction) {
+
564  state=S_Release;
+
565  timeout = release_count;
+
566  }
+
567  }
+
568 
+
569  switch (state) {
+
570  case S_Attack:
+
571  if ( timeout>0 && gain > gainreduce) {
+
572  gain -= gain_step_attack;
+
573  timeout--;
574  }
-
575  break;
-
576 
-
577 
-
578  case S_GainReduction:
-
579  if ( timeout>0) timeout--;
-
580  else {
-
581  state=S_Release;
-
582  timeout = release_count;
-
583  }
-
584  break;
-
585 
-
586 
-
587  case S_Release:
-
588  if ( timeout>0 && gain<1.0f) {
-
589  timeout--;
-
590  gain += gain_step_release;
-
591  }
-
592  else {
-
593  state=S_NoOperation;
-
594  }
-
595  break;
-
596 
-
597  case S_NoOperation:
-
598  if (gain < 1.0f) gain = 1.0f;
+
575  else {
+
576  state=S_GainReduction;
+
577  timeout = hold_count;
+
578  }
+
579  break;
+
580 
+
581 
+
582  case S_GainReduction:
+
583  if ( timeout>0) timeout--;
+
584  else {
+
585  state=S_Release;
+
586  timeout = release_count;
+
587  }
+
588  break;
+
589 
+
590 
+
591  case S_Release:
+
592  if ( timeout>0 && gain<1.0f) {
+
593  timeout--;
+
594  gain += gain_step_release;
+
595  }
+
596  else {
+
597  state=S_NoOperation;
+
598  }
599  break;
600 
-
601  default:
-
602  break;
-
603 
-
604  }
-
605 
-
606  float outSampleF = gain * inSampleF;
-
607  return outSampleF;
-
608  }
+
601  case S_NoOperation:
+
602  if (gain < 1.0f) gain = 1.0f;
+
603  break;
+
604 
+
605  default:
+
606  break;
+
607 
+
608  }
609 
-
610 };
-
611 
-
612 
-
613 } // namespace audio_tools
+
610  float outSampleF = gain * inSampleF;
+
611  return outSampleF;
+
612  }
+
613 
+
614 };
+
615 
+
616 
+
617 } // namespace audio_tools
audio_tools::ADSRGain
ADSR Envelope: Attack, Decay, Sustain and Release. Attack is the time taken for initial run-up oeffec...
Definition: AudioEffect.h:362
audio_tools::ADSRGain::process
effect_t process(effect_t input)
calculates the effect output from the input
Definition: AudioEffect.h:398
audio_tools::ADSR
Generates ADSR values between 0.0 and 1.0.
Definition: AudioParameters.h:51
@@ -600,15 +604,15 @@
audio_tools::Boost
Boost AudioEffect.
Definition: AudioEffect.h:73
audio_tools::Boost::process
effect_t process(effect_t input)
calculates the effect output from the input
Definition: AudioEffect.h:85
audio_tools::Boost::Boost
Boost(float volume=1.0)
Definition: AudioEffect.h:77
-
audio_tools::Compressor
Compressor inspired by https://github.com/YetAnotherElectronicsChannel/STM32_DSP_COMPRESSOR/blob/mast...
Definition: AudioEffect.h:466
-
audio_tools::Compressor::setAttack
void setAttack(uint16_t attackMs)
Defines the attack duration in ms.
Definition: AudioEffect.h:492
-
audio_tools::Compressor::setRelease
void setRelease(uint16_t releaseMs)
Defines the release duration in ms.
Definition: AudioEffect.h:498
-
audio_tools::Compressor::Compressor
Compressor(uint32_t sampleRate=44100, uint16_t attackMs=30, uint16_t releaseMs=20, uint16_t holdMs=10, uint8_t thresholdPercent=10, float compressionRatio=0.5)
Default Constructor.
Definition: AudioEffect.h:472
-
audio_tools::Compressor::setHold
void setHold(uint16_t holdMs)
Defines the hold duration in ms.
Definition: AudioEffect.h:504
+
audio_tools::Compressor
Compressor inspired by https://github.com/YetAnotherElectronicsChannel/STM32_DSP_COMPRESSOR/blob/mast...
Definition: AudioEffect.h:468
+
audio_tools::Compressor::setAttack
void setAttack(uint16_t attackMs)
Defines the attack duration in ms.
Definition: AudioEffect.h:494
+
audio_tools::Compressor::process
effect_t process(effect_t input)
Processes the sample.
Definition: AudioEffect.h:525
+
audio_tools::Compressor::setRelease
void setRelease(uint16_t releaseMs)
Defines the release duration in ms.
Definition: AudioEffect.h:500
+
audio_tools::Compressor::Compressor
Compressor(uint32_t sampleRate=44100, uint16_t attackMs=30, uint16_t releaseMs=20, uint16_t holdMs=10, uint8_t thresholdPercent=10, float compressionRatio=0.5)
Default Constructor.
Definition: AudioEffect.h:474
+
audio_tools::Compressor::setHold
void setHold(uint16_t holdMs)
Defines the hold duration in ms.
Definition: AudioEffect.h:506
audio_tools::Compressor::Compressor
Compressor(const Compressor &copy)=default
Copy Constructor.
-
audio_tools::Compressor::setCompressionRatio
void setCompressionRatio(float compressionRatio)
Defines the compression ratio from 0 to 1.
Definition: AudioEffect.h:515
-
audio_tools::Compressor::process
effect_t process(effect_t inSample)
Processes the sample.
Definition: AudioEffect.h:523
-
audio_tools::Compressor::setThresholdPercent
void setThresholdPercent(uint8_t thresholdPercent)
Defines the threshod in %.
Definition: AudioEffect.h:510
+
audio_tools::Compressor::setCompressionRatio
void setCompressionRatio(float compressionRatio)
Defines the compression ratio from 0 to 1.
Definition: AudioEffect.h:517
+
audio_tools::Compressor::setThresholdPercent
void setThresholdPercent(uint8_t thresholdPercent)
Defines the threshod in %.
Definition: AudioEffect.h:512
audio_tools::Delay
Delay/Echo AudioEffect. See https://wiki.analog.com/resources/tools-software/sharc-audio-module/barem...
Definition: AudioEffect.h:253
audio_tools::Delay::Delay
Delay(uint16_t duration_ms=1000, float depth=0.5, float feedbackAmount=1.0, uint32_t sampleRate=44100, bool zeroIfBufferEmpty=false)
e.g. depth=0.5, ms=1000, sampleRate=44100
Definition: AudioEffect.h:256
audio_tools::Delay::process
effect_t process(effect_t input)
calculates the effect output from the input
Definition: AudioEffect.h:306
@@ -618,9 +622,9 @@
audio_tools::Fuzz
Fuzz AudioEffect.
Definition: AudioEffect.h:146
audio_tools::Fuzz::process
effect_t process(effect_t input)
calculates the effect output from the input
Definition: AudioEffect.h:164
audio_tools::Fuzz::Fuzz
Fuzz(float fuzzEffectValue=6.5, uint16_t maxOut=300)
Fuzz Constructor: use e.g. effectValue=6.5; maxOut = 300.
Definition: AudioEffect.h:149
-
audio_tools::PitchShift
Shifts the pitch by the indicated step size: e.g. 2 doubles the pitch.
Definition: AudioEffect.h:418
-
audio_tools::PitchShift::process
effect_t process(effect_t input)
calculates the effect output from the input
Definition: AudioEffect.h:443
-
audio_tools::PitchShift::PitchShift
PitchShift(float shift_value=1.0, int buffer_size=1000)
Definition: AudioEffect.h:422
+
audio_tools::PitchShift
Shifts the pitch by the indicated step size: e.g. 2 doubles the pitch.
Definition: AudioEffect.h:420
+
audio_tools::PitchShift::process
effect_t process(effect_t input)
calculates the effect output from the input
Definition: AudioEffect.h:445
+
audio_tools::PitchShift::PitchShift
PitchShift(float shift_value=1.0, int buffer_size=1000)
Definition: AudioEffect.h:424
audio_tools::Tremolo
Tremolo AudioEffect.
Definition: AudioEffect.h:186
audio_tools::Tremolo::process
effect_t process(effect_t input)
calculates the effect output from the input
Definition: AudioEffect.h:212
audio_tools::Tremolo::Tremolo
Tremolo(int16_t duration_ms=2000, uint8_t depthPercent=50, uint32_t sampleRate=44100)
Definition: AudioEffect.h:190
diff --git a/classaudio__tools_1_1_compressor-members.html b/classaudio__tools_1_1_compressor-members.html index 4f8343cf09..71fd8318b0 100644 --- a/classaudio__tools_1_1_compressor-members.html +++ b/classaudio__tools_1_1_compressor-members.html @@ -90,7 +90,7 @@ hold_count (defined in Compressor)Compressorprotected id()AudioEffectinline id_value (defined in AudioEffect)AudioEffectprotected - process(effect_t inSample)Compressorinlinevirtual + process(effect_t input)Compressorinlinevirtual recalculate() (defined in Compressor)Compressorinlineprotected release_count (defined in Compressor)Compressorprotected S_Attack enum value (defined in Compressor)Compressorprotected diff --git a/classaudio__tools_1_1_compressor.html b/classaudio__tools_1_1_compressor.html index 4dce9ed0d5..ca1a1dbdc7 100644 --- a/classaudio__tools_1_1_compressor.html +++ b/classaudio__tools_1_1_compressor.html @@ -111,10 +111,10 @@ int id ()  Allows to identify an effect.
  - -effect_t process (effect_t inSample) - Processes the sample.
-  + +effect_t process (effect_t input) + Processes the sample.
virtual void setActive (bool value)  sets the effect active/inactive
diff --git a/functions_func_p.html b/functions_func_p.html index 4e273b2a32..8392a45c90 100644 --- a/functions_func_p.html +++ b/functions_func_p.html @@ -174,7 +174,7 @@

- p -