aboutsummaryrefslogtreecommitdiffstats
path: root/host/examples/tx_waveforms.cpp
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2014-10-27 16:17:15 +0100
committerMartin Braun <martin.braun@ettus.com>2014-10-28 19:42:22 +0100
commit10ff484ccbba5c83d856949b9515f9130feaded3 (patch)
tree197901a785e98761e1de20bb44a82a99c8dfd894 /host/examples/tx_waveforms.cpp
parent91347ea2cbf7618d4439548210eec940c582cbb8 (diff)
downloaduhd-10ff484ccbba5c83d856949b9515f9130feaded3.tar.gz
uhd-10ff484ccbba5c83d856949b9515f9130feaded3.tar.bz2
uhd-10ff484ccbba5c83d856949b9515f9130feaded3.zip
examples: Whitespace and other cleanup
Diffstat (limited to 'host/examples/tx_waveforms.cpp')
-rw-r--r--host/examples/tx_waveforms.cpp49
1 files changed, 1 insertions, 48 deletions
diff --git a/host/examples/tx_waveforms.cpp b/host/examples/tx_waveforms.cpp
index a233cecb1..73bcb13ac 100644
--- a/host/examples/tx_waveforms.cpp
+++ b/host/examples/tx_waveforms.cpp
@@ -15,6 +15,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
+#include "wavetable.hpp"
#include <uhd/utils/thread_priority.hpp>
#include <uhd/utils/safe_main.hpp>
#include <uhd/utils/static.hpp>
@@ -28,9 +29,7 @@
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <iostream>
-#include <complex>
#include <csignal>
-#include <cmath>
namespace po = boost::program_options;
@@ -41,52 +40,6 @@ static bool stop_signal_called = false;
void sig_int_handler(int){stop_signal_called = true;}
/***********************************************************************
- * Waveform generators
- **********************************************************************/
-static const size_t wave_table_len = 8192;
-
-class wave_table_class{
-public:
- wave_table_class(const std::string &wave_type, const float ampl):
- _wave_table(wave_table_len)
- {
- //compute real wave table with 1.0 amplitude
- std::vector<double> real_wave_table(wave_table_len);
- if (wave_type == "CONST"){
- for (size_t i = 0; i < wave_table_len; i++)
- real_wave_table[i] = 1.0;
- }
- else if (wave_type == "SQUARE"){
- for (size_t i = 0; i < wave_table_len; i++)
- real_wave_table[i] = (i < wave_table_len/2)? 0.0 : 1.0;
- }
- else if (wave_type == "RAMP"){
- for (size_t i = 0; i < wave_table_len; i++)
- real_wave_table[i] = 2.0*i/(wave_table_len-1) - 1.0;
- }
- else if (wave_type == "SINE"){
- static const double tau = 2*std::acos(-1.0);
- for (size_t i = 0; i < wave_table_len; i++)
- real_wave_table[i] = std::sin((tau*i)/wave_table_len);
- }
- else throw std::runtime_error("unknown waveform type: " + wave_type);
-
- //compute i and q pairs with 90% offset and scale to amplitude
- for (size_t i = 0; i < wave_table_len; i++){
- const size_t q = (i+(3*wave_table_len)/4)%wave_table_len;
- _wave_table[i] = std::complex<float>(ampl*real_wave_table[i], ampl*real_wave_table[q]);
- }
- }
-
- inline std::complex<float> operator()(const size_t index) const{
- return _wave_table[index % wave_table_len];
- }
-
-private:
- std::vector<std::complex<float> > _wave_table;
-};
-
-/***********************************************************************
* Main function
**********************************************************************/
int UHD_SAFE_MAIN(int argc, char *argv[]){