#概要
pythonでgnuradioやってみた。
AM変調を録音した、wavファイル読み込んでAM復調して、聞く。
信号は、440hzのサイン波、搬送波は、5KHZ。
#サンプルコード
from gnuradio import gr, blocks, analog
from gnuradio import audio
class my_top_block(gr.top_block):
def __init__(self):
gr.top_block.__init__(self)
samp_rate = 32000
self.blocks_wavfile_source_0 = blocks.wavfile_source('a2.wav', True)
self.blocks_magphase_to_complex_0 = blocks.magphase_to_complex(1)
self.blocks_add_const_vxx_0 = blocks.add_const_vff((2, ))
self.audio_sink_0 = audio.sink(samp_rate, '', True)
self.analog_am_demod_cf_0 = analog.am_demod_cf(channel_rate = 32000, audio_decim = 1, audio_pass = 5000, audio_stop = 5500, )
self.connect((self.analog_am_demod_cf_0, 0), (self.audio_sink_0, 0))
self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_magphase_to_complex_0, 0))
self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_magphase_to_complex_0, 1))
self.connect((self.blocks_magphase_to_complex_0, 0), (self.analog_am_demod_cf_0, 0))
self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_add_const_vxx_0, 0))
if __name__ == '__main__':
try:
my_top_block().run()
except KeyboardInterrupt:
pass
以上。