本文整理汇总了Python中transmitter.Transmitter.add_preamble方法的典型用法代码示例。如果您正苦于以下问题:Python Transmitter.add_preamble方法的具体用法?Python Transmitter.add_preamble怎么用?Python Transmitter.add_preamble使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类transmitter.Transmitter
的用法示例。
在下文中一共展示了Transmitter.add_preamble方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Source
# 需要导入模块: from transmitter import Transmitter [as 别名]
# 或者: from transmitter.Transmitter import add_preamble [as 别名]
print '\tSamples per bit:', opt.spb
print '\tChannel type:', ('Audio' if not opt.bypass else 'Bypass')
if opt.bypass:
print '\t Noise:', opt.noise, ' lag:', opt.lag, 'h: [', opt.h, ']'
print '\tFrequency:', fc, 'Hz'
print '\tHamming code n :', opt.cc_len
########################################################
#instantiate and run the source block
src = Source(opt.monotone, opt.fname)
src_payload, databits = src.process()
# instantiate and run the transmitter block
xmitter = Transmitter(fc, opt.samplerate, opt.one, opt.spb, opt.silence, opt.cc_len)
coded_bits = xmitter.encode(databits)
coded_bits_with_preamble = xmitter.add_preamble(coded_bits)
samples = xmitter.bits_to_samples(coded_bits_with_preamble)
mod_samples = xmitter.modulate(samples)
####################################
# create channel instance
if opt.bypass:
h = [float(x) for x in opt.h.split(' ')]
channel = bch.BypassChannel(opt.noise, opt.lag, h)
else:
channel = ach.AudioChannel(opt.samplerate, opt.chunksize, opt.prefill)
# transmit the samples, and retrieve samples back from the channel
try:
samples_rx = channel.xmit_and_recv(mod_samples)
except ZeroDivisionError:
示例2: Source
# 需要导入模块: from transmitter import Transmitter [as 别名]
# 或者: from transmitter.Transmitter import add_preamble [as 别名]
print 'Parameters in experiment:'
print '\tSamples per bit:', opt.spb
print '\tChannel type:', ('Audio' if not opt.bypass else 'Bypass')
if opt.bypass:
print '\t Noise:', opt.noise, ' lag:', opt.lag, 'h: [', opt.h, ']'
print '\tFrequency:', fc, 'Hz'
########################################################
#instantiate and run the source block
src = Source(opt.monotone, opt.fname)
src_payload, databits = src.process()
# instantiate and run the transmitter block
xmitter = Transmitter(fc, opt.samplerate, opt.one, opt.spb, opt.silence)
databits_with_preamble = xmitter.add_preamble(databits)
samples = xmitter.bits_to_samples(databits_with_preamble)
mod_samples = xmitter.modulate(samples)
####################################
# create channel instance
if opt.bypass:
h = [float(x) for x in opt.h.split(' ')]
channel = bch.BypassChannel(opt.noise, opt.lag, h)
else:
channel = ach.AudioChannel(opt.samplerate, opt.chunksize, opt.prefill)
# transmit the samples, and retrieve samples back from the channel
try:
samples_rx = channel.xmit_and_recv(mod_samples)
except ZeroDivisionError: