本文整理匯總了Python中transmitter.Transmitter.encode方法的典型用法代碼示例。如果您正苦於以下問題:Python Transmitter.encode方法的具體用法?Python Transmitter.encode怎麽用?Python Transmitter.encode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類transmitter.Transmitter
的用法示例。
在下文中一共展示了Transmitter.encode方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Source
# 需要導入模塊: from transmitter import Transmitter [as 別名]
# 或者: from transmitter.Transmitter import encode [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'
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)
示例2: Source
# 需要導入模塊: from transmitter import Transmitter [as 別名]
# 或者: from transmitter.Transmitter import encode [as 別名]
print '\tFrequency:', fc, 'Hz'
print '\tSource coding:', ('On' if opt.compress else 'Off')
print '\tChannel coding:', ('n = %d' % opt.cc_len if opt.cc_len!=0 else 'Off')
print '\tEncryption:', ('On' if opt.encrypt else 'Off')
########################################################
#instantiate and run the source block
src = Source(opt.monotone, opt.fname, opt.compress, opt.encrypt)
src_bits, src_payload, databits, pubkey = src.process()
# instantiate and run the transmitter block
xmitter = Transmitter(fc, opt.samplerate, opt.one, opt.spb, opt.silence, opt.cc_len)
if opt.cc_len!=0:
databits = xmitter.encode(databits, opt.cc_len)
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)
#channel_2 = ach.AudioChannel(opt.samplerate, opt.chunksize, opt.prefill)
else:
channel = ach.AudioChannel(opt.samplerate, opt.chunksize, opt.prefill)
# transmit the samples, and retrieve samples back from the channel
try: