1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

pythonでgnuradio その6

Last updated at Posted at 2021-04-25

概要

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

サンプルコード

from gnuradio import gr, blocks, analog

class my_top_block(gr.top_block):
	def __init__(self):
		gr.top_block.__init__(self)
		samp_rate = 32000
		self.blocks_wavfile_sink_0 = blocks.wavfile_sink('a2.wav', 1, samp_rate, 8)
		self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
		self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((0.3, ))
		self.blocks_head_0 = blocks.head(gr.sizeof_gr_complex*1, 64000)
		self.blocks_complex_to_real_0 = blocks.complex_to_real(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_complex_to_real_0, 0), (self.blocks_multiply_const_vxx_0, 0))
		self.connect((self.blocks_head_0, 0), (self.blocks_complex_to_real_0, 0))
		self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_wavfile_sink_0, 0))
		self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_head_0, 0))

if __name__ == '__main__':
	try:
		my_top_block().run()
	except KeyboardInterrupt:
		pass


以上。

1
3
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
1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?