0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

pythonでgnuradio その2

Posted at

#概要

pythonでgnuradioやってみた。
サイン波をグラフ表示。

#写真

time0.jpg

#サンプルコード

from PyQt4 import Qt
from gnuradio import gr
from gnuradio import blocks
import sys
try:
    from gnuradio import qtgui
    from PyQt4 import QtGui, QtCore
    import sip
except ImportError:
    sys.stderr.write("Error: Program requires PyQt4 and gr-qtgui.\n")
    sys.exit(1)
try:
    from gnuradio import analog
except ImportError:
    sys.stderr.write("Error: Program requires gr-analog.\n")
    sys.exit(1)

class my_top_block(gr.top_block):
    def __init__(self):
        gr.top_block.__init__(self)
        Rs = 8000
        f1 = 100
        f2 = 20
        npts = 2048
        self.qapp = QtGui.QApplication(sys.argv)
        src1 = analog.sig_source_f(Rs, analog.GR_SIN_WAVE, f1, 0.3, 0)
        self.snk1 = qtgui.time_sink_f(npts, Rs, "Sin Time Example", 1)
        self.connect(src1, (self.snk1, 0))
        pyQt = self.snk1.pyqwidget()
        pyWin = sip.wrapinstance(pyQt, QtGui.QWidget)
        self.top_widget = Qt.QWidget()
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_layout.addWidget(pyWin)
        self.top_widget.show()

if __name__ == "__main__":
    tb = my_top_block();
    tb.start()
    tb.qapp.exec_()
    tb.stop()





以上。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?