summaryrefslogtreecommitdiffstats
path: root/src/TII.cpp
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2018-02-07 11:44:43 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2018-02-07 11:44:43 +0100
commit96b1cbaa255b04a20d0f7ca6bda14fa87eb3ed62 (patch)
tree60d968dd5edd26d727f6f7e8ad85db5e825f32d8 /src/TII.cpp
parent05d2210e4336dc98966683b6e725c65e729b7216 (diff)
downloaddabmod-96b1cbaa255b04a20d0f7ca6bda14fa87eb3ed62.tar.gz
dabmod-96b1cbaa255b04a20d0f7ca6bda14fa87eb3ed62.tar.bz2
dabmod-96b1cbaa255b04a20d0f7ca6bda14fa87eb3ed62.zip
Fix offset in TII carriers
Diffstat (limited to 'src/TII.cpp')
-rw-r--r--src/TII.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/TII.cpp b/src/TII.cpp
index 09a4920..a9eee16 100644
--- a/src/TII.cpp
+++ b/src/TII.cpp
@@ -230,8 +230,16 @@ int TII::process(Buffer* dataIn, Buffer* dataOut)
return 1;
}
-void TII::enable_carrier(int k) {
- int ix = m_carriers/2 + k;
+void TII::enable_carrier(int k)
+{
+ /* The OFDMGenerator shifts all positive frequencies by one,
+ * i.e. index 0 is not the DC component, it's the first positive
+ * frequency. Because this is different from the definition of k
+ * from the spec, we need to compensate this here.
+ *
+ * Positive frequencies are k > 0
+ */
+ int ix = m_carriers/2 + k + (k>=0 ? -1 : 0);
if (ix < 0 or ix+1 >= (ssize_t)m_Acp.size()) {
throw TIIError("TII::enable_carrier invalid k!");
@@ -240,7 +248,8 @@ void TII::enable_carrier(int k) {
m_Acp[ix] = true;
}
-void TII::prepare_pattern() {
+void TII::prepare_pattern()
+{
int comb = m_conf.comb; // Convert from unsigned to signed
std::lock_guard<std::mutex> lock(m_enabled_carriers_mutex);