diff options
author | Josh Blum <josh@joshknows.com> | 2011-11-10 10:23:05 -0800 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-11-10 10:23:05 -0800 |
commit | c29adad91e1987da63b11716156b86d237cfda82 (patch) | |
tree | da7636e22eba953f669c48c6da6ae3467e8f1e5a /host/examples | |
parent | 6f1f5f5fa2d044e4017be27ad5c1f67adbcea3f7 (diff) | |
download | uhd-c29adad91e1987da63b11716156b86d237cfda82.tar.gz uhd-c29adad91e1987da63b11716156b86d237cfda82.tar.bz2 uhd-c29adad91e1987da63b11716156b86d237cfda82.zip |
uhd: performance improvement for tx waveforms using integer table lookup
Diffstat (limited to 'host/examples')
-rw-r--r-- | host/examples/tx_waveforms.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/host/examples/tx_waveforms.cpp b/host/examples/tx_waveforms.cpp index 5b17e0595..a182f2d11 100644 --- a/host/examples/tx_waveforms.cpp +++ b/host/examples/tx_waveforms.cpp @@ -75,8 +75,9 @@ public: } } - inline std::complex<float> operator()(const double theta) const{ - return _wave_table[unsigned(theta*wave_table_len)%wave_table_len]; + inline std::complex<float> operator()(size_t &index) const{ + index %= wave_table_len; + return _wave_table[index]; } private: @@ -188,8 +189,8 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //pre-compute the waveform values const wave_table_class wave_table(wave_type, ampl); - const double cps = wave_freq/usrp->get_tx_rate(); - double theta = 0; + const size_t step = boost::math::iround(wave_freq/usrp->get_tx_rate() * wave_table_len); + size_t index = 0; //create a transmit streamer //linearly map channels (index0 = channel0, index1 = channel1, ...) @@ -240,12 +241,10 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ while(not stop_signal_called){ //fill the buffer with the waveform for (size_t n = 0; n < buff.size(); n++){ - buff[n] = wave_table(theta += cps); + buff[n] = wave_table(index); + index += step; } - //bring the theta back into range [0, 1) - theta = std::fmod(theta, 1); - //send the entire contents of the buffer tx_stream->send(buffs, buff.size(), md); |