mirror of https://github.com/lwvmobile/dsd-fme.git
Fix HPF_D so it actually works correctly;
This commit is contained in:
parent
e549b21497
commit
ee04d11116
|
|
@ -1342,6 +1342,8 @@ void lpf(dsd_state * state, short * input, int len);
|
|||
void hpf(dsd_state * state, short * input, int len);
|
||||
void pbf(dsd_state * state, short * input, int len);
|
||||
void nf(dsd_state * state, short * input, int len);
|
||||
void hpf_dL(dsd_state * state, short * input, int len);
|
||||
void hpf_dR(dsd_state * state, short * input, int len);
|
||||
//from: https://github.com/NedSimao/FilteringLibrary
|
||||
void LPFilter_Init(LPFilter *filter, float cutoffFreqHz, float sampleTimeS);
|
||||
float LPFilter_Update(LPFilter *filter, float v_in);
|
||||
|
|
|
|||
32
src/3.c
32
src/3.c
|
|
@ -479,10 +479,10 @@ void init_audio_filters (dsd_state * state)
|
|||
HPFilter_Init(&state->HRCFilter, 960, (float)1/(float)48000);
|
||||
|
||||
//left and right variants for stereo output testing on digital voice samples
|
||||
LPFilter_Init(&state->RCFilterL, 960, (float)1/(float)48000);
|
||||
HPFilter_Init(&state->HRCFilterL, 960, (float)1/(float)48000);
|
||||
LPFilter_Init(&state->RCFilterR, 960, (float)1/(float)48000);
|
||||
HPFilter_Init(&state->HRCFilterR, 960, (float)1/(float)48000);
|
||||
LPFilter_Init(&state->RCFilterL, 960, (float)1/(float)16000);
|
||||
HPFilter_Init(&state->HRCFilterL, 960, (float)1/(float)16000);
|
||||
LPFilter_Init(&state->RCFilterR, 960, (float)1/(float)16000);
|
||||
HPFilter_Init(&state->HRCFilterR, 960, (float)1/(float)16000);
|
||||
|
||||
//PBFilter_Init(PBFilter *filter, float HPF_cutoffFreqHz, float LPF_cutoffFreqHz, float sampleTimeS);
|
||||
//NOTCHFilter_Init(NOTCHFilter *filter, float centerFreqHz, float notchWidthHz, float sampleTimeS);
|
||||
|
|
@ -522,6 +522,30 @@ void hpf(dsd_state * state, short * input, int len)
|
|||
}
|
||||
}
|
||||
|
||||
//hpf digital left
|
||||
void hpf_dL(dsd_state * state, short * input, int len)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
// fprintf (stderr, "\n in: %05d", input[i]);
|
||||
input[i] = HPFilter_Update(&state->HRCFilterL, input[i]);
|
||||
// fprintf (stderr, "\n out: %05d", input[i]);
|
||||
}
|
||||
}
|
||||
|
||||
//hpf digital right
|
||||
void hpf_dR(dsd_state * state, short * input, int len)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
// fprintf (stderr, "\n in: %05d", input[i]);
|
||||
input[i] = HPFilter_Update(&state->HRCFilterR, input[i]);
|
||||
// fprintf (stderr, "\n out: %05d", input[i]);
|
||||
}
|
||||
}
|
||||
|
||||
//nf
|
||||
void nf(dsd_state * state, short * input, int len)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -306,9 +306,6 @@ processAudio (dsd_opts * opts, dsd_state * state)
|
|||
*state->audio_out_float_buf_p = -32768.0F;
|
||||
}
|
||||
*state->audio_out_buf_p = (short) *state->audio_out_float_buf_p;
|
||||
//hpf
|
||||
if (opts->use_hpf_d == 1)
|
||||
*state->audio_out_float_buf_p = HPFilter_Update(&state->HRCFilterL, *state->audio_out_float_buf_p);
|
||||
//tap the pointer here and store the short upsample buffer samples
|
||||
state->s_lu[n] = (short) *state->audio_out_float_buf_p;
|
||||
state->audio_out_buf_p++;
|
||||
|
|
@ -329,9 +326,6 @@ processAudio (dsd_opts * opts, dsd_state * state)
|
|||
*state->audio_out_temp_buf_p = -32768.0F;
|
||||
}
|
||||
*state->audio_out_buf_p = (short) *state->audio_out_temp_buf_p;
|
||||
//hpf
|
||||
if (opts->use_hpf_d == 1)
|
||||
*state->audio_out_float_buf_p = HPFilter_Update(&state->HRCFilterL, *state->audio_out_float_buf_p);
|
||||
//tap the pointer here and store the short buffer samples
|
||||
state->s_l[n] = (short) *state->audio_out_temp_buf_p;
|
||||
//debug
|
||||
|
|
@ -459,9 +453,6 @@ processAudioR (dsd_opts * opts, dsd_state * state)
|
|||
*state->audio_out_float_buf_pR = -32768.0F;
|
||||
}
|
||||
*state->audio_out_buf_pR = (short) *state->audio_out_float_buf_pR;
|
||||
//hpf
|
||||
if (opts->use_hpf_d == 1)
|
||||
*state->audio_out_float_buf_pR = HPFilter_Update(&state->HRCFilterR, *state->audio_out_float_buf_pR);
|
||||
//tap the pointer here and store the short upsample buffer samples
|
||||
state->s_ru[n] = (short) *state->audio_out_float_buf_pR;
|
||||
state->audio_out_buf_pR++;
|
||||
|
|
@ -482,9 +473,6 @@ processAudioR (dsd_opts * opts, dsd_state * state)
|
|||
*state->audio_out_temp_buf_pR = -32768.0F;
|
||||
}
|
||||
*state->audio_out_buf_pR = (short) *state->audio_out_temp_buf_pR;
|
||||
//hpf
|
||||
if (opts->use_hpf_d == 1)
|
||||
*state->audio_out_float_buf_pR = HPFilter_Update(&state->HRCFilterR, *state->audio_out_float_buf_pR);
|
||||
//tap the pointer here and store the short buffer samples
|
||||
state->s_r[n] = (short) *state->audio_out_temp_buf_pR;
|
||||
state->audio_out_buf_pR++;
|
||||
|
|
|
|||
|
|
@ -951,6 +951,18 @@ void playSynthesizedVoiceSS3 (dsd_opts * opts, dsd_state * state)
|
|||
if (state->tg_hold != 0 && state->tg_hold == TGL) encL = 0;
|
||||
if (state->tg_hold != 0 && state->tg_hold == TGR) encR = 0;
|
||||
|
||||
//test hpf
|
||||
if (opts->use_hpf_d == 1)
|
||||
{
|
||||
hpf_dL(state, state->s_l4[0], 160);
|
||||
hpf_dL(state, state->s_l4[1], 160);
|
||||
hpf_dL(state, state->s_l4[2], 160);
|
||||
|
||||
hpf_dR(state, state->s_r4[0], 160);
|
||||
hpf_dR(state, state->s_r4[1], 160);
|
||||
hpf_dR(state, state->s_r4[2], 160);
|
||||
}
|
||||
|
||||
//interleave left and right channels from the short storage area
|
||||
for (i = 0; i < 160; i++)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue