aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSylvain Munaut <tnt@246tNt.com>2015-04-04 18:13:19 +0200
committerSylvain Munaut <tnt@246tNt.com>2015-04-04 18:13:19 +0200
commit31394e9be9cd5839a5a2b04a828de9a701c65953 (patch)
treec74cafea666d97243c08c06cfd0f68eb276eb578
parent7be39dc3b0fff33e4c1b231fde25cc90e9558440 (diff)
gr-gmr1: Make rach_detect_fft use sample_rate instead of fft_size as param
The is really no reason to use any other fft size than the auto computed one and having the sample_rate will allow the output frequency to be in hz rather than radian. Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
-rw-r--r--gr-gmr1/apps/gmr_rach_scan.grc4
-rw-r--r--gr-gmr1/grc/rach_detect_fft.xml10
-rw-r--r--gr-gmr1/include/gnuradio/gmr1/rach_detect_fft.h6
-rw-r--r--gr-gmr1/lib/rach_detect_fft_impl.cc23
-rw-r--r--gr-gmr1/lib/rach_detect_fft_impl.h7
5 files changed, 31 insertions, 19 deletions
diff --git a/gr-gmr1/apps/gmr_rach_scan.grc b/gr-gmr1/apps/gmr_rach_scan.grc
index eacc799..f5a3a44 100644
--- a/gr-gmr1/apps/gmr_rach_scan.grc
+++ b/gr-gmr1/apps/gmr_rach_scan.grc
@@ -283,8 +283,8 @@
<value>True</value>
</param>
<param>
- <key>fft_size</key>
- <value>1 &lt;&lt; int(round(math.log(samp_rate / 1e3) / math.log(2)))</value>
+ <key>samp_rate</key>
+ <value>samp_rate</value>
</param>
<param>
<key>overlap_ratio</key>
diff --git a/gr-gmr1/grc/rach_detect_fft.xml b/gr-gmr1/grc/rach_detect_fft.xml
index 406db06..1bc6f81 100644
--- a/gr-gmr1/grc/rach_detect_fft.xml
+++ b/gr-gmr1/grc/rach_detect_fft.xml
@@ -5,12 +5,12 @@
<category>GMR-1</category>
<import>import math</import>
<import>from gnuradio import gmr1</import>
- <make>gmr1.rach_detect_fft($fft_size, $overlap_ratio, $threshold, $burst_length, $burst_offset, $freq_offset, $len_tag_key)</make>
+ <make>gmr1.rach_detect_fft($samp_rate, $overlap_ratio, $threshold, $burst_length, $burst_offset, $freq_offset, $len_tag_key)</make>
<param>
- <name>FFT size</name>
- <key>fft_size</key>
- <value>1 &lt;&lt; int(round(math.log(samp_rate / 1e3) / math.log(2)))</value>
- <type>int</type>
+ <name>Sample Rate</name>
+ <key>samp_rate</key>
+ <value>samp_rate</value>
+ <type>real</type>
</param>
<param>
<name>Overlap ratio</name>
diff --git a/gr-gmr1/include/gnuradio/gmr1/rach_detect_fft.h b/gr-gmr1/include/gnuradio/gmr1/rach_detect_fft.h
index fbe3441..33c6f67 100644
--- a/gr-gmr1/include/gnuradio/gmr1/rach_detect_fft.h
+++ b/gr-gmr1/include/gnuradio/gmr1/rach_detect_fft.h
@@ -37,8 +37,10 @@ namespace gr {
public:
typedef boost::shared_ptr<rach_detect_fft> sptr;
- static sptr make(int fft_size, int overlap_ratio, float threshold,
- int burst_length, int burst_offset, float freq_offset,
+ static sptr make(const double sample_rate,
+ const int overlap_ratio, const float threshold,
+ const int burst_length, const int burst_offset,
+ const float freq_offset,
const std::string& len_tag_key);
};
diff --git a/gr-gmr1/lib/rach_detect_fft_impl.cc b/gr-gmr1/lib/rach_detect_fft_impl.cc
index b1552be..5e39b89 100644
--- a/gr-gmr1/lib/rach_detect_fft_impl.cc
+++ b/gr-gmr1/lib/rach_detect_fft_impl.cc
@@ -43,33 +43,40 @@ static const pmt::pmt_t TIME_KEY = pmt::string_to_symbol("time");
rach_detect_fft::sptr
rach_detect_fft::make(
- int fft_size, int overlap_ratio, float threshold,
- int burst_length, int burst_offset, float freq_offset,
+ const double sample_rate,
+ const int overlap_ratio, const float threshold,
+ const int burst_length, const int burst_offset,
+ const float freq_offset,
const std::string& len_tag_key)
{
return gnuradio::get_initial_sptr(
new rach_detect_fft_impl(
- fft_size, overlap_ratio, threshold,
- burst_length, burst_offset, freq_offset,
+ sample_rate,
+ overlap_ratio, threshold,
+ burst_length, burst_offset,
+ freq_offset,
len_tag_key
)
);
}
rach_detect_fft_impl::rach_detect_fft_impl(
- int fft_size, int overlap_ratio, float threshold,
- int burst_length, int burst_offset, float freq_offset,
+ const double sample_rate,
+ const int overlap_ratio, const float threshold,
+ const int burst_length, const int burst_offset,
+ const float freq_offset,
const std::string& len_tag_key)
: gr::block("rach_detect_fft",
io_signature::make(1, 1, sizeof(gr_complex)),
io_signature::make(1, 1, sizeof(gr_complex))),
- d_fft_size(fft_size), d_overlap_ratio(overlap_ratio),
- d_threshold(threshold),
+ d_sample_rate(sample_rate),
+ d_overlap_ratio(overlap_ratio), d_threshold(threshold),
d_burst_length(burst_length), d_burst_offset(burst_offset),
d_freq_offset(freq_offset),
d_len_tag_key(pmt::string_to_symbol(len_tag_key)),
d_burst_length_pmt(pmt::from_long(burst_length))
{
+ this->d_fft_size = 1 << (int)(round(log2(sample_rate / 1e3)));
this->d_fft = new gr::fft::fft_complex(this->d_fft_size, true, 1);
this->d_buf = (gr_complex *) volk_malloc(this->d_fft_size * sizeof(gr_complex), 128);
diff --git a/gr-gmr1/lib/rach_detect_fft_impl.h b/gr-gmr1/lib/rach_detect_fft_impl.h
index 0efcf0c..779d756 100644
--- a/gr-gmr1/lib/rach_detect_fft_impl.h
+++ b/gr-gmr1/lib/rach_detect_fft_impl.h
@@ -52,6 +52,7 @@ namespace gr {
float bin() const;
};
+ double d_sample_rate;
int d_fft_size;
int d_overlap_ratio;
float d_threshold;
@@ -79,8 +80,10 @@ namespace gr {
void peak_detect(uint64_t position);
public:
- rach_detect_fft_impl(int fft_size, int overlap_ratio, float threshold,
- int burst_length, int burst_offset, float freq_offset,
+ rach_detect_fft_impl(const double sample_rate,
+ const int overlap_ratio, const float threshold,
+ const int burst_length, const int burst_offset,
+ const float freq_offset,
const std::string& len_tag_key);
virtual ~rach_detect_fft_impl();