diff --git a/example/example_tx.cpp b/example/example_tx.cpp index 02664d4..fa6d8be 100644 --- a/example/example_tx.cpp +++ b/example/example_tx.cpp @@ -3,6 +3,7 @@ * * Original author: David Banas
* Original date: May 8, 2015 + * Initial conversion to EmPy template format: Feb 25, 2016 * * Copyright (c) 2015 David Banas; all rights reserved World wide. */ @@ -30,40 +31,56 @@ class MyTx : public AmiTx { // Grab our parameters and configure things accordingly. std::vector node_names; node_names.clear(); - int taps[4], tap_units; - node_names.push_back("tx_tap_units"); - tap_units = get_param_int(node_names, 27); + std::ostringstream msg; + + msg << "Initializing Tx...\n"; + + int taps[4]; + int tx_tap_nm2 ; + node_names.push_back("tx_tap_nm2"); + tx_tap_nm2 = get_param_int(node_names, 0 ); + taps[3] = tx_tap_nm2; node_names.pop_back(); - node_names.push_back("tx_tap_np1"); // pre-tap - taps[0] = get_param_int(node_names, 0); + int tx_tap_np1 ; + node_names.push_back("tx_tap_np1"); + tx_tap_np1 = get_param_int(node_names, 0 ); + taps[0] = tx_tap_np1; node_names.pop_back(); - node_names.push_back("tx_tap_nm1"); // post-tap1 - taps[2] = get_param_int(node_names, 0); + int tx_tap_units ; + node_names.push_back("tx_tap_units"); + tx_tap_units = get_param_int(node_names, 27 ); node_names.pop_back(); - node_names.push_back("tx_tap_nm2"); // post-tap2 - taps[3] = get_param_int(node_names, 0); - taps[1] = tap_units - 2 * (taps[0] + taps[2] + taps[3]); + int tx_tap_nm1 ; + node_names.push_back("tx_tap_nm1"); + tx_tap_nm1 = get_param_int(node_names, 0 ); + taps[2] = tx_tap_nm1; + node_names.pop_back(); + + taps[1] = tx_tap_units - 2 * (taps[0] + taps[2] + taps[3]); + if (taps[1] < 0) + msg << "WARNING: Illegal Tx pre-emphasis tap configuration!\n"; // Fill in params_. std::ostringstream params; params << "(example_tx"; - params << " (tap_units " << tap_units << ")"; + params << " (tx_tap_units " << tx_tap_units << ")"; params << " (taps[0] " << taps[0] << ")"; params << " (taps[1] " << taps[1] << ")"; params << " (taps[2] " << taps[2] << ")"; params << " (taps[3] " << taps[3] << ")"; + tap_weights_.clear(); int samples_per_bit = int(bit_time / sample_interval); int tap_signs[] = {-1, 1, -1, -1}; have_preemph_ = true; - for (auto i = 0; i < 4; i++) { + for (auto i = 0; i <= 3; i++) { tap_weights_.push_back(taps[i] * TAP_SCALE * tap_signs[i]); params << " (tap_weights_[" << i << "] " << tap_weights_.back() << ")"; for (auto j = 1; j < samples_per_bit; j++) tap_weights_.push_back(0.0); } param_str_ = params.str() + "\n"; - msg_ = "Hello, World!"; + msg_ = msg.str() + "\n"; } } my_tx;