#概要
pythonでgnuradioやってみた。
サイン波をグラフ表示。
#写真
#サンプルコード
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()
以上。