mirror of
https://github.com/radio95-rnt/fm95.git
synced 2026-02-26 19:23:51 +01:00
fix preemphasis
This commit is contained in:
@@ -70,14 +70,16 @@ float get_next_sample(Oscillator *osc) {
|
|||||||
#ifdef PREEMPHASIS
|
#ifdef PREEMPHASIS
|
||||||
typedef struct {
|
typedef struct {
|
||||||
float prev_sample;
|
float prev_sample;
|
||||||
|
float alpha;
|
||||||
} PreEmphasis;
|
} PreEmphasis;
|
||||||
|
|
||||||
void init_pre_emphasis(PreEmphasis *pe) {
|
void init_pre_emphasis(PreEmphasis *pe) {
|
||||||
pe->prev_sample = 0.0f;
|
pe->prev_sample = 0.0f;
|
||||||
|
pe->alpha = exp(-1 / (PREEMPHASIS_TAU*SAMPLE_RATE));
|
||||||
}
|
}
|
||||||
float apply_pre_emphasis(PreEmphasis *pe, float sample) {
|
float apply_pre_emphasis(PreEmphasis *pe, float sample) {
|
||||||
float output = sample - pe->prev_sample * (1.0f - (1 - exp(-1.0 / (SAMPLE_RATE * PREEMPHASIS_TAU))));
|
float output = sample - pe->alpha * pe->prev_sample;
|
||||||
pe->prev_sample = sample;
|
pe->prev_sample = output;
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user