Open kronee0516 opened 1 day ago
void processData(void){
memcpy(LData, &LData[AUDIO_FRAME_LEN/2], AUDIO_FRAME_LEN/2*sizeof(int16_t));
for(uint16_t n = 0;n<AUDIO_FRAME_LEN/2;n++){
//RData[n]=*(inBufPtr+n*2);
LData[n+AUDIO_FRAME_LEN/2]=*(inBufPtr+n*2+1);
}
printf("Ldata : ");
for(uint8_t n = 0;n<10;n++){
//RData[n]=*(inBufPtr+n*2);
printf("%d ",LData[n+AUDIO_FRAME_LEN/2]);
}
printf("\r\n");
mfcc_compute(mfcc, LData, mfcc_feature);
for(uint32_t i=0; i< NUM_FEATURES; i++)
{
mfcc_feature_diff[i] = mfcc_feature[i] - mfcc_feature_prev[i];
mfcc_feature_diff1[i] = mfcc_feature_diff[i] - mfcc_feature_diff_prev[i];
}
memcpy(mfcc_feature_prev, mfcc_feature, NUM_FEATURES * sizeof(float));
memcpy(mfcc_feature_diff_prev, mfcc_feature_diff, NUM_FEATURES * sizeof(float));
// combine MFCC with derivatives for the NN features
memcpy(nn_features, mfcc_feature, NUM_FEATURES*sizeof(float));
memcpy(&nn_features[NUM_FEATURES], mfcc_feature_diff, 10*sizeof(float));
memcpy(&nn_features[NUM_FEATURES+10], mfcc_feature_diff1, 10*sizeof(float));
// quantise them using the same scale as training data (in keras), by 2^n.
quantize_data(nn_features, nn_features_q7, NUM_FEATURES+20, 3);
// run the mode with the new input
memcpy(nnom_input_data, nn_features_q7, sizeof(nnom_input_data));
model_run(model);
for(int i=0; i< NUM_FEATURES; i++){
band_gains[i] = (float)(nnom_output_data[i]) / 127.f;
}
// one more step, limit the change of gians, to smooth the speech, per RNNoise paper
for(int i=0; i< NUM_FEATURES; i++){
band_gains[i] = _MAX(band_gains_prev[i]*0.8f, band_gains[i]);
}
memcpy(band_gains_prev, band_gains, NUM_FEATURES *sizeof(float));
// update filter coefficient to applied dynamic gains to each frequency band
set_gains((float*)coeff_b, (float*)b_, band_gains, NUM_FILTER, NUM_ORDER);
// convert 16bit to float for equalizer
for (int i = 0; i < AUDIO_FRAME_LEN/2; i++){
audio_buffer[i] = LData[i+AUDIO_FRAME_LEN / 2] / 32768.f;
}
// finally, we apply the equalizer to this audio frame to denoise
equalizer(audio_buffer, &audio_buffer[AUDIO_FRAME_LEN / 2], AUDIO_FRAME_LEN/2, (float*)b_,(float*)coeff_a, NUM_FILTER, NUM_ORDER);
for (int i = 0; i < AUDIO_FRAME_LEN / 2; i++){
*(outBufPtr+i*2) = (int16_t)audio_buffer[i + AUDIO_FRAME_LEN / 2] * 32768.f *0.6f; // 0.7 is the filter band overlapping factor
}
printf("filter : ");
for(uint8_t n = 0;n<10;n++){
printf("%d ",(int16_t)audio_buffer[n + AUDIO_FRAME_LEN / 2] * 32768.f *0.6f);
}
printf("\r\n");
dataReadyflag=0;
}
i was testing with 512 double buffer(256 x 2) but since it is not quite identical to your parameter in arm_main.c , i changed to 1024( 512 x 2) to get one side of data(each side 512 len in total) only for process
Hi,
i tried to use nnom rnnoise on STM32F411CEU6(black pill) with i2s data from WM8978G the cmsis nn and dsp come from this repository i almost copied your code to run. but the output data are all zero
what do you think is the problem?
i just printed out the first ten data to compare their different but seems nothing change the output