0
4

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 5 years have passed since last update.

pythonでgnuradio その5

0
Last updated at Posted at 2021-04-24

概要

pythonでgnuradioやってみた。
AM変調を表示。
信号は、440hzのサイン波、搬送波は、5KHZ。

写真

am0.jpg

サンプルコード

from gnuradio import gr, blocks, analog, filter
import sys
import sip
from gnuradio import qtgui
from PyQt4 import Qt, QtGui, QtCore

class my_top_block(gr.top_block):
	def __init__(self):
		gr.top_block.__init__(self)
		samp_rate = 32000
		self.qapp = QtGui.QApplication(sys.argv)
		self.sink1 = qtgui.sink_c(1024, filter.firdes.WIN_BLACKMAN_hARRIS, 0, samp_rate, "", True, True, True, True, )
		self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
		self.blocks_add_const_vxx_0 = blocks.add_const_vcc((1, ))
		self.analog_sig_source_x_1 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 5000, 1, 0)
		self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 440, 1, 0)
		self.connect((self.analog_sig_source_x_0, 0), (self.blocks_add_const_vxx_0, 0))
		self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_0, 1))
		self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_xx_0, 0))
		self.connect((self.blocks_multiply_xx_0, 0), (self.sink1, 0))
		pyQt = self.sink1.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
4
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
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?