commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 08/11: blocks: added I/Q swap option to int


From: git
Subject: [Commit-gnuradio] [gnuradio] 08/11: blocks: added I/Q swap option to interleaved_short_to_complex
Date: Fri, 13 Jun 2014 22:44:33 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

jcorgan pushed a commit to branch master
in repository gnuradio.

commit d2b51d8ff34380dbb8f5caefaa62483f13f10d26
Author: Balint Seeber <address@hidden>
Date:   Wed Jun 4 13:20:17 2014 -0700

    blocks: added I/Q swap option to interleaved_short_to_complex
---
 .../grc/blocks_interleaved_short_to_complex.xml    | 18 +++++++++++++++++-
 .../gnuradio/blocks/interleaved_short_to_complex.h |  4 +++-
 gr-blocks/lib/interleaved_short_to_complex_impl.cc | 22 ++++++++++++++++++----
 gr-blocks/lib/interleaved_short_to_complex_impl.h  |  5 ++++-
 4 files changed, 42 insertions(+), 7 deletions(-)

diff --git a/gr-blocks/grc/blocks_interleaved_short_to_complex.xml 
b/gr-blocks/grc/blocks_interleaved_short_to_complex.xml
index 712ba3a..2c4e153 100644
--- a/gr-blocks/grc/blocks_interleaved_short_to_complex.xml
+++ b/gr-blocks/grc/blocks_interleaved_short_to_complex.xml
@@ -8,7 +8,8 @@
        <name>IShort To Complex</name>
        <key>blocks_interleaved_short_to_complex</key>
        <import>from gnuradio import blocks</import>
-       <make>blocks.interleaved_short_to_complex($vector_input)</make>
+       <make>blocks.interleaved_short_to_complex($vector_input, $swap)</make>
+       <callback>set_swap($swap)</callback>
     <param>
         <name>Vector Input</name>
         <key>vector_input</key>
@@ -25,6 +26,21 @@
             <opt>vlen:2</opt>
         </option>
     </param>
+    <param>
+               <name>Swap</name>
+               <key>swap</key>
+               <value>False</value>
+               <type>enum</type>
+               <hide>part</hide>
+               <option>
+                       <name>Yes</name>
+                       <key>True</key>
+               </option>
+               <option>
+                       <name>No</name>
+                       <key>False</key>
+               </option>
+       </param>
        <sink>
                <name>in</name>
                <type>short</type>
diff --git a/gr-blocks/include/gnuradio/blocks/interleaved_short_to_complex.h 
b/gr-blocks/include/gnuradio/blocks/interleaved_short_to_complex.h
index 4f89e4d..39304e8 100644
--- a/gr-blocks/include/gnuradio/blocks/interleaved_short_to_complex.h
+++ b/gr-blocks/include/gnuradio/blocks/interleaved_short_to_complex.h
@@ -42,7 +42,9 @@ namespace gr {
       /*!
        * Build an interleaved short to complex block.
        */
-      static sptr make(bool vector_input=false);
+      static sptr make(bool vector_input=false, bool swap=false);
+      
+      virtual void set_swap(bool swap)=0;
     };
 
   } /* namespace blocks */
diff --git a/gr-blocks/lib/interleaved_short_to_complex_impl.cc 
b/gr-blocks/lib/interleaved_short_to_complex_impl.cc
index 962b29b..bb1e229 100644
--- a/gr-blocks/lib/interleaved_short_to_complex_impl.cc
+++ b/gr-blocks/lib/interleaved_short_to_complex_impl.cc
@@ -31,19 +31,24 @@
 namespace gr {
   namespace blocks {
 
-    interleaved_short_to_complex::sptr interleaved_short_to_complex::make(bool 
vector_input)
+    interleaved_short_to_complex::sptr interleaved_short_to_complex::make(bool 
vector_input, bool swap)
     {
-      return gnuradio::get_initial_sptr(new 
interleaved_short_to_complex_impl(vector_input));
+      return gnuradio::get_initial_sptr(new 
interleaved_short_to_complex_impl(vector_input, swap));
     }
 
-    interleaved_short_to_complex_impl::interleaved_short_to_complex_impl(bool 
vector_input)
+    interleaved_short_to_complex_impl::interleaved_short_to_complex_impl(bool 
vector_input, bool swap)
       : sync_decimator("interleaved_short_to_complex",
                       gr::io_signature::make (1, 1, 
(vector_input?2:1)*sizeof(short)),
                       gr::io_signature::make (1, 1, sizeof(gr_complex)),
                       vector_input?1:2),
-        d_vector_input(vector_input)
+        d_vector_input(vector_input), d_swap(swap)
     {
     }
+    
+    void interleaved_short_to_complex_impl::set_swap(bool swap)
+    {
+               d_swap = swap;
+       }
 
     int
     interleaved_short_to_complex_impl::work(int noutput_items,
@@ -55,6 +60,15 @@ namespace gr {
       
       interleaved_short_array_to_complex (in, out, 2 * noutput_items);
       
+      if (d_swap) {
+        float* p = (float*)output_items[0];
+        for (int i = 0; i < noutput_items; ++i) {
+          float f = p[2*i+1];
+          p[2*i+1] = p[2*i+0];
+          p[2*i+0] = f;
+        }
+      }
+      
       return noutput_items;
     }
 
diff --git a/gr-blocks/lib/interleaved_short_to_complex_impl.h 
b/gr-blocks/lib/interleaved_short_to_complex_impl.h
index 3280f89..c7669f1 100644
--- a/gr-blocks/lib/interleaved_short_to_complex_impl.h
+++ b/gr-blocks/lib/interleaved_short_to_complex_impl.h
@@ -32,8 +32,11 @@ namespace gr {
     {
     private:
       bool d_vector_input;
+      bool d_swap;
     public:
-      interleaved_short_to_complex_impl(bool vector_input=false);
+      interleaved_short_to_complex_impl(bool vector_input=false, bool 
swap=false);
+      
+      void set_swap(bool swap);
 
       int work(int noutput_items,
               gr_vector_const_void_star &input_items,



reply via email to

[Prev in Thread] Current Thread [Next in Thread]