Minor fixes to compandor

This commit is contained in:
Andreas Eversberg
2017-06-24 10:09:22 +02:00
parent a12329a884
commit 085ceb9173
4 changed files with 44 additions and 29 deletions

View File

@@ -1,4 +1,4 @@
/* Compandor to use various networks like C-Netz / NMT / AMPS
/* Compandor to use various networks like C-Netz / NMT / AMPS / TACS
*
* (C) 2016 by Andreas Eversberg <jolly@eversberg.eu>
* All Rights Reserved
@@ -46,7 +46,7 @@ static double sqrt_tab[10000];
* Hopefully this is correct
*
*/
void init_compandor(compandor_t *state, int samplerate, double attack_ms, double recovery_ms, double unaffected_level)
void init_compandor(compandor_t *state, double samplerate, double attack_ms, double recovery_ms, double unaffected_level)
{
int i;
@@ -56,10 +56,10 @@ void init_compandor(compandor_t *state, int samplerate, double attack_ms, double
state->c.envelope = 1.0;
state->e.peak = 1.0;
state->e.envelope = 1.0;
state->c.step_up = pow(COMPRESS_ATTACK_FACTOR, 1000.0 / attack_ms / (double)samplerate);
state->c.step_down = pow(COMPRESS_RECOVERY_FACTOR, 1000.0 / recovery_ms / (double)samplerate);
state->e.step_up = pow(EXPAND_ATTACK_FACTOR, 1000.0 / attack_ms / (double)samplerate);
state->e.step_down = pow(EXPAND_RECOVERY_FACTOR, 1000.0 / recovery_ms / (double)samplerate);
state->c.step_up = pow(COMPRESS_ATTACK_FACTOR, 1000.0 / attack_ms / samplerate);
state->c.step_down = pow(COMPRESS_RECOVERY_FACTOR, 1000.0 / recovery_ms / samplerate);
state->e.step_up = pow(EXPAND_ATTACK_FACTOR, 1000.0 / attack_ms / samplerate);
state->e.step_down = pow(EXPAND_RECOVERY_FACTOR, 1000.0 / recovery_ms / samplerate);
state->c.unaffected = unaffected_level;
state->e.unaffected = unaffected_level;

View File

@@ -15,7 +15,7 @@ typedef struct compandor {
} e;
} compandor_t;
void init_compandor(compandor_t *state, int samplerate, double attack_ms, double recovery_ms, double unaffected_level);
void init_compandor(compandor_t *state, double samplerate, double attack_ms, double recovery_ms, double unaffected_level);
void compress_audio(compandor_t *state, sample_t *samples, int num);
void expand_audio(compandor_t *state, sample_t *samples, int num);