提交 9e4a7837 编写于 作者: D dev@dev.com

增加一个控制FFT频繁程度的参数 frame_span ,以解决在高采样率下,FFT用于频谱显示来不及处理的问题。

解决该问题终极手段是多线程,但多线程显著增加了复杂性,让代码用于教学不再合适。因此,通过简单的设置间隔来变相解决该问题。
上级 28ec8d6d
......@@ -24,9 +24,16 @@ const char * g_info = "{\n\
\"tooltip\":\"0=Real,1=Complex\",\n\
\"default\":0\n\
},\n\
\"mod:\":{\n\
\"frame_span\":{\n\
\"type\":\"int\",\n\
\"tooltip\":\"0=frame,1=continous\",\n\
\"tooltip\":\"Frame Span (count) between each fft calc. Slower CPU need larger spans.\",\n\
\"range\":\">=1\",\n\
\"default\":16\n\
},\n\
\"mod\":{\n\
\"type\":\"int\",\n\
\"tooltip\":\"WorkingMod\",\n\
\"range\":\"0=Frame,1=Continous\",\n\
\"default\":0\n\
},\n\
\"fftsize\":{\n\
......
......@@ -76,6 +76,7 @@ int do_fftw(const cmdlineParser & args)
unsigned int itmstamp_in = args.toUInt("tmstamp_in",0);
unsigned int itmstamp_out = args.toUInt("tmstamp_out",0);
unsigned int itypes = args.toUInt("input_type",0);//0=real,1=complex
const unsigned int frame_span = args.toInt("frame_span",1)>0?args.toInt("frame_span",1):1;
//工作模式
const int sptype = args.toInt("sptype",0); fprintf(stderr,"sptype is %d.",sptype);
......@@ -90,7 +91,6 @@ int do_fftw(const cmdlineParser & args)
fprintf(stderr,"fftsize must >16.");
return res;
}
fflush(stderr);
try{
......@@ -150,6 +150,9 @@ int do_fftw(const cmdlineParser & args)
}
}
if (map_tmst_inside[header.path_id]++%frame_span)
continue;
const unsigned char * pdta = packagedta.data();
//Normalizer
double nmr = fftsize;
......@@ -328,7 +331,6 @@ int do_fftw(const cmdlineParser & args)
push_subject(FFT,header.path_id,fftsize*sizeof(double)/(itypes==0?2:1),(const unsigned char *)vec_fft_abs.data());
if (Spec>0)
push_subject(Spec,header.path_id,fftsize*sizeof(double),(const unsigned char *)out);
++map_tmst_inside[header.path_id];
}
}
......@@ -359,6 +361,8 @@ int do_fftw_continous(const cmdlineParser & args)
unsigned int FFT = args.toInt("FFT",0);
unsigned int Spec = args.toInt("Spec",0);
unsigned int itmstamp_in = args.toUInt("tmstamp_in",0);
const unsigned int frame_span = args.toInt("frame_span",1)>0?args.toInt("frame_span",1):1;
unsigned int itypes = args.toUInt("input_type",0);//0=real,1=complex
//工作模式
const int sptype = args.toInt("sptype",0); fprintf(stderr,"sptype is %d.",sptype);
......@@ -394,6 +398,7 @@ int do_fftw_continous(const cmdlineParser & args)
//Ring buf
unordered_map<unsigned int, std::vector<double> > map_buf_inside;
unordered_map<unsigned int, long long > map_buf_pos,map_buf_deal;
unordered_map<unsigned int, long long > cal_cnt;
for (int i=0;i<fftsize;++i)
vec_fft_abs.push_back(0);
......@@ -427,7 +432,10 @@ int do_fftw_continous(const cmdlineParser & args)
map_buf_inside[header.path_id]=std::vector<double>(2*RingSize);
map_buf_pos[header.path_id] = 0;
map_buf_deal[header.path_id] = 0;
cal_cnt[header.path_id] = 0;
}
if (cal_cnt[header.path_id]++%frame_span)
continue;
const unsigned char * pdta = packagedta.data();
//Normalizer
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册