diff options
author | Lars Amsel <lars.amsel@ni.com> | 2022-01-03 11:54:27 +0100 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2022-01-10 13:31:44 -0600 |
commit | d33deb3cae1f231000745dd077d339dcb004e97b (patch) | |
tree | e70714b2ca5e16e467f19c9603e786b193098e29 /host/python | |
parent | c891f2d8738bc1b73bb92d88623f4760f9e2bd1e (diff) | |
download | uhd-d33deb3cae1f231000745dd077d339dcb004e97b.tar.gz uhd-d33deb3cae1f231000745dd077d339dcb004e97b.tar.bz2 uhd-d33deb3cae1f231000745dd077d339dcb004e97b.zip |
uhd: Allow pass raw IQ data array to tone generator
Instead of calculating a tone from its parameter it is also useful
to pass an precalculated signal to be played. This change modifies
the __init__ to take an iq_data as parameter for the internal buffer
and moves the generation of the tone from rate, frequency and amplitude
into a class method. The streamer parameter was deleted (never used).
Diffstat (limited to 'host/python')
-rw-r--r-- | host/python/uhd/usrp/cal/tone_gen.py | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/host/python/uhd/usrp/cal/tone_gen.py b/host/python/uhd/usrp/cal/tone_gen.py index b9d986132..3234e5bf1 100644 --- a/host/python/uhd/usrp/cal/tone_gen.py +++ b/host/python/uhd/usrp/cal/tone_gen.py @@ -11,13 +11,14 @@ import threading import numpy import uhd -class ToneGenerator: +class WaveformGenerator: """ - Class that can output a tone from a different thread until told to stop + Class that can output arbitrary waveform + from a different thread until told to stop """ - def __init__(self, rate, freq, ampl, streamer=None): + def __init__(self, iq_data, streamer=None): + self._buffer = iq_data self._streamer = streamer - self._buffer = uhd.dsp.signals.get_continuous_tone(rate, freq, ampl) self._run = False self._thread = None @@ -59,3 +60,13 @@ class ToneGenerator: metadata.end_of_burst = True self._streamer.send( numpy.array([0], dtype=numpy.complex64), metadata, 0.1) + + +class ToneGenerator(WaveformGenerator): + """ + Class that can output a tone based on WaveformGenerator + """ + def __init__(rate, freq, ampl, streamer=None): + super().__init__( + uhd.dsp.signals.get_continuous_tone(rate, freq, ampl), + streamer) |