Commit 981faabd authored by Simon Morlat's avatar Simon Morlat
Browse files

improve calibrator. First tone frequency changed because it triggered false...

improve calibrator. First tone frequency changed because it triggered false detection due to harmonics.
parent b8537ffb
......@@ -36,41 +36,50 @@ static void ecc_init_filters(EcCalibrator *ecc){
ecc->sndread=ms_snd_card_create_reader(ecc->play_card);
ms_filter_call_method(ecc->sndread,MS_FILTER_SET_SAMPLE_RATE,&ecc->rate);
ms_filter_call_method(ecc->sndread,MS_FILTER_GET_SAMPLE_RATE,&rate);
ecc->read_resampler=ms_filter_new(MS_RESAMPLE_ID);
ms_filter_call_method(ecc->read_resampler,MS_FILTER_SET_SAMPLE_RATE,&rate);
ms_filter_call_method(ecc->read_resampler,MS_FILTER_SET_OUTPUT_SAMPLE_RATE,&ecc->rate);
ecc->det=ms_filter_new(MS_TONE_DETECTOR_ID);
ms_filter_call_method(ecc->det,MS_FILTER_SET_SAMPLE_RATE,&ecc->rate);
ecc->rec=ms_filter_new(MS_FILE_REC_ID);
ms_filter_link(ecc->sndread,0,ecc->det,0);
ms_filter_link(ecc->sndread,0,ecc->read_resampler,0);
ms_filter_link(ecc->read_resampler,0,ecc->det,0);
ms_filter_link(ecc->det,0,ecc->rec,0);
ecc->play=ms_filter_new(MS_FILE_PLAYER_ID);
ecc->gen=ms_filter_new(MS_DTMF_GEN_ID);
ms_filter_call_method(ecc->gen,MS_FILTER_SET_SAMPLE_RATE,&ecc->rate);
ecc->resampler=ms_filter_new(MS_RESAMPLE_ID);
ecc->write_resampler=ms_filter_new(MS_RESAMPLE_ID);
ecc->sndwrite=ms_snd_card_create_writer(ecc->capt_card);
ms_filter_link(ecc->play,0,ecc->gen,0);
ms_filter_link(ecc->gen,0,ecc->resampler,0);
ms_filter_link(ecc->resampler,0,ecc->sndwrite,0);
ms_filter_call_method(ecc->sndwrite,MS_FILTER_SET_SAMPLE_RATE,&ecc->rate);
ms_filter_call_method(ecc->sndwrite,MS_FILTER_GET_SAMPLE_RATE,&rate);
ms_filter_call_method(ecc->resampler,MS_FILTER_SET_SAMPLE_RATE,&ecc->rate);
ms_filter_call_method(ecc->resampler,MS_FILTER_SET_OUTPUT_SAMPLE_RATE,&rate);
ms_filter_call_method(ecc->write_resampler,MS_FILTER_SET_SAMPLE_RATE,&ecc->rate);
ms_filter_call_method(ecc->write_resampler,MS_FILTER_SET_OUTPUT_SAMPLE_RATE,&rate);
ms_filter_link(ecc->play,0,ecc->gen,0);
ms_filter_link(ecc->gen,0,ecc->write_resampler,0);
ms_filter_link(ecc->write_resampler,0,ecc->sndwrite,0);
ms_ticker_attach(ecc->ticker,ecc->play);
ms_ticker_attach(ecc->ticker,ecc->sndread);
ms_ticker_attach(ecc->ticker,ecc->play);
}
static void ecc_deinit_filters(EcCalibrator *ecc){
ms_ticker_detach(ecc->ticker,ecc->play);
ms_ticker_detach(ecc->ticker,ecc->sndread);
ms_ticker_detach(ecc->ticker,ecc->play);
ms_filter_unlink(ecc->play,0,ecc->gen,0);
ms_filter_unlink(ecc->gen,0,ecc->resampler,0);
ms_filter_unlink(ecc->resampler,0,ecc->sndwrite,0);
ms_filter_unlink(ecc->gen,0,ecc->write_resampler,0);
ms_filter_unlink(ecc->write_resampler,0,ecc->sndwrite,0);
ms_filter_unlink(ecc->sndread,0,ecc->det,0);
ms_filter_unlink(ecc->sndread,0,ecc->read_resampler,0);
ms_filter_unlink(ecc->read_resampler,0,ecc->det,0);
ms_filter_unlink(ecc->det,0,ecc->rec,0);
ms_filter_destroy(ecc->sndread);
......@@ -78,7 +87,8 @@ static void ecc_deinit_filters(EcCalibrator *ecc){
ms_filter_destroy(ecc->rec);
ms_filter_destroy(ecc->play);
ms_filter_destroy(ecc->gen);
ms_filter_destroy(ecc->resampler);
ms_filter_destroy(ecc->read_resampler);
ms_filter_destroy(ecc->write_resampler);
ms_filter_destroy(ecc->sndwrite);
ms_ticker_destroy(ecc->ticker);
......@@ -113,7 +123,7 @@ static void ecc_play_tones(EcCalibrator *ecc){
ms_filter_call_method (ecc->det,MS_TONE_DETECTOR_ADD_SCAN,&expected_tone);
tone.frequency=1000;
tone.frequency=1300;
tone.duration=1000;
tone.amplitude=1.0;
......
......@@ -592,7 +592,8 @@ struct _EcCalibrator{
ms_thread_t thread;
MSSndCard *play_card,*capt_card;
MSFilter *sndread,*det,*rec;
MSFilter *play, *gen, *sndwrite,*resampler;
MSFilter *play, *gen, *sndwrite;
MSFilter *read_resampler,*write_resampler;
MSTicker *ticker;
LinphoneEcCalibrationCallback cb;
void *cb_data;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment