diff --git a/_audio_effect_8h_source.html b/_audio_effect_8h_source.html index f603d5cce4..587997c41e 100644 --- a/_audio_effect_8h_source.html +++ b/_audio_effect_8h_source.html @@ -497,94 +497,96 @@
520  }
521 
523  effect_t process(effect_t inSample) {
-
524  float inSampleF = (float)inSample;
-
525 
-
526  if (fabs(inSampleF) > threshold) {
-
527  if (gain >= gainreduce) {
-
528  if (state==S_NoOperation) {
-
529  state=S_Attack;
-
530  timeout = attack_count;
-
531  }
-
532  else if (state==S_Release) {
-
533  state=S_Attack;
-
534  timeout = attack_count;
-
535  }
-
536  }
-
537  if (state==S_GainReduction) timeout = hold_count;
-
538 
-
539  }
-
540 
-
541  if (fabs(inSampleF) < threshold && gain <= 1.0f) {
-
542  if ( timeout==0 && state==S_GainReduction) {
-
543  state=S_Release;
-
544  timeout = release_count;
-
545  }
-
546  }
-
547 
-
548  switch (state) {
-
549  case S_Attack:
-
550  if ( timeout>0 && gain > gainreduce) {
-
551  gain -= gain_step_attack;
-
552  timeout--;
-
553  }
-
554  else {
-
555  state=S_GainReduction;
-
556  timeout = hold_count;
-
557  }
-
558  break;
-
559 
-
560 
-
561  case S_GainReduction:
-
562  if ( timeout>0) timeout--;
-
563  else {
-
564  state=S_Release;
-
565  timeout = release_count;
-
566  }
-
567  break;
-
568 
-
569 
-
570  case S_Release:
-
571  if ( timeout>0 && gain<1.0f) {
-
572  timeout--;
-
573  gain += gain_step_release;
+
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;
+
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;
+
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) {
+
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;
574  }
-
575  else {
-
576  state=S_NoOperation;
-
577  }
-
578  break;
-
579 
-
580  case S_NoOperation:
-
581  if (gain < 1.0f) gain = 1.0f;
-
582  break;
-
583 
-
584  default:
-
585  break;
+
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  }
-
588 
-
589  float outSampleF = gain * inSample;
-
590  return outSampleF;
-
591  }
-
592 
-
593  Compressor *clone() { return new Compressor(*this); }
-
594 
-
595 protected:
-
596  enum CompStates {S_NoOperation, S_Attack, S_GainReduction, S_Release };
-
597  enum CompStates state = S_NoOperation;
-
598 
-
599  int32_t attack_count, release_count, hold_count, timeout;
-
600  float gainreduce, gain_step_attack, gain_step_release, gain, threshold;
-
601  uint32_t sample_rate;
-
602 
-
603  void recalculate() {
-
604  gain_step_attack = (1.0f - gainreduce) / attack_count;
-
605  gain_step_release = (1.0f - gainreduce) / release_count;
-
606  }
-
607 
-
608 };
+
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;
+
599  break;
+
600 
+
601  default:
+
602  break;
+
603 
+
604  }
+
605 
+
606  float outSampleF = gain * inSampleF;
+
607  return outSampleF;
+
608  }
609 
-
610 
-
611 } // namespace audio_tools
+
610 };
+
611 
+
612 
+
613 } // 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
diff --git a/classaudio__tools_1_1_compressor-members.html b/classaudio__tools_1_1_compressor-members.html index ba50428a57..e372aca1c9 100644 --- a/classaudio__tools_1_1_compressor-members.html +++ b/classaudio__tools_1_1_compressor-members.html @@ -78,36 +78,37 @@ AudioEffect()=default (defined in AudioEffect)AudioEffect clip(int32_t in, int16_t clipLimit=32767, int16_t resultLimit=32767)AudioEffectinlineprotected clone() (defined in Compressor)Compressorinlinevirtual - Compressor(const Compressor &copy)=defaultCompressor - Compressor(uint32_t sampleRate=44100, int32_t attackMs=30, int32_t releaseMs=20, int32_t holdMs=10, uint8_t thresholdPercent=10, float compressionRatio=0.5)Compressorinline - CompStates enum name (defined in Compressor)Compressorprotected - copyParent(AudioEffect *copy) (defined in AudioEffect)AudioEffectinlineprotected - gain (defined in Compressor)Compressorprotected - gain_step_attack (defined in Compressor)Compressorprotected - gain_step_release (defined in Compressor)Compressorprotected - gainreduce (defined in Compressor)Compressorprotected - hold_count (defined in Compressor)Compressorprotected - id()AudioEffectinline - id_value (defined in AudioEffect)AudioEffectprotected - process(effect_t inSample)Compressorinlinevirtual - recalculate() (defined in Compressor)Compressorinlineprotected - release_count (defined in Compressor)Compressorprotected - S_Attack enum value (defined in Compressor)Compressorprotected - S_GainReduction enum value (defined in Compressor)Compressorprotected - S_NoOperation enum value (defined in Compressor)Compressorprotected - S_Release enum value (defined in Compressor)Compressorprotected - sample_rate (defined in Compressor)Compressorprotected - setActive(bool value)AudioEffectinlinevirtual - setAttack(int32_t attackMs)Compressorinline - setCompressionRatio(float compressionRatio)Compressorinline - setHold(int32_t holdMs)Compressorinline - setId(int id)AudioEffectinline - setRelease(int32_t releaseMs)Compressorinline - setThresholdPercent(uint8_t thresholdPercent)Compressorinline - state (defined in Compressor)Compressorprotected - threshold (defined in Compressor)Compressorprotected - timeout (defined in Compressor)Compressorprotected - ~AudioEffect()=default (defined in AudioEffect)AudioEffectvirtual + compress(float inSampleF) (defined in Compressor)Compressorinlineprotected + Compressor(const Compressor &copy)=defaultCompressor + Compressor(uint32_t sampleRate=44100, int32_t attackMs=30, int32_t releaseMs=20, int32_t holdMs=10, uint8_t thresholdPercent=10, float compressionRatio=0.5)Compressorinline + CompStates enum name (defined in Compressor)Compressorprotected + copyParent(AudioEffect *copy) (defined in AudioEffect)AudioEffectinlineprotected + gain (defined in Compressor)Compressorprotected + gain_step_attack (defined in Compressor)Compressorprotected + gain_step_release (defined in Compressor)Compressorprotected + gainreduce (defined in Compressor)Compressorprotected + hold_count (defined in Compressor)Compressorprotected + id()AudioEffectinline + id_value (defined in AudioEffect)AudioEffectprotected + process(effect_t inSample)Compressorinlinevirtual + recalculate() (defined in Compressor)Compressorinlineprotected + release_count (defined in Compressor)Compressorprotected + S_Attack enum value (defined in Compressor)Compressorprotected + S_GainReduction enum value (defined in Compressor)Compressorprotected + S_NoOperation enum value (defined in Compressor)Compressorprotected + S_Release enum value (defined in Compressor)Compressorprotected + sample_rate (defined in Compressor)Compressorprotected + setActive(bool value)AudioEffectinlinevirtual + setAttack(int32_t attackMs)Compressorinline + setCompressionRatio(float compressionRatio)Compressorinline + setHold(int32_t holdMs)Compressorinline + setId(int id)AudioEffectinline + setRelease(int32_t releaseMs)Compressorinline + setThresholdPercent(uint8_t thresholdPercent)Compressorinline + state (defined in Compressor)Compressorprotected + threshold (defined in Compressor)Compressorprotected + timeout (defined in Compressor)Compressorprotected + ~AudioEffect()=default (defined in AudioEffect)AudioEffectvirtual