def test_001_t(self): src = dab.fib_source_b_make(1, 1, 'Galaxy_News', 'Wasteland_Radio', 'Country_Mix', 0x09, [0], [8]) fib_unpacked_to_packed = blocks.unpacked_to_packed_bb( 1, gr.GR_MSB_FIRST) s2v = blocks.stream_to_vector(gr.sizeof_char, 32) crc16 = dab.crc16_bb(32, 0x1021, 0xffff) fibsink = dab.fib_sink_vb() self.tb.connect(src, fib_unpacked_to_packed, blocks.head(gr.sizeof_char, 300), s2v, crc16, fibsink) self.tb.run() pass
def __init__(self, dab_params, sampling_rate, num_subch, ensemble_lable, service_label, service_comp_label, service_language, protection_mode, data_rate_n): gr.hier_block2.__init__( self, "transmitter_c", gr.io_signature(0, 0, gr.sizeof_char), # Input signature gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature self.dp = dab_params self.sampling_rate = sampling_rate # FIC self.fic_source = dab.fib_source_b_make(self.dp.mode, num_subch, ensemble_lable, service_label, service_comp_label, service_language, protection_mode, data_rate_n) self.fic_encode = dab.fic_encode(self.dp) # MSC self.msc_encoder() for i in range(0, num_subch): self.msc_encoder[i] = dab.msc_encode(self.dp, data_rate_n[i], protection_mode[i]) # MUX self.subch_size = 6 * data_rate_n self.mux = dab.dab_transmission_frame_mux_bb_make( self.dp.mode, num_subch, self.subch_size) # OFDM Modulator self.s2v = blocks.stream_to_vector(gr.sizeof_char, 384) self.mod = dab.ofdm_mod(self.dp) # connect everything self.connect(self.fic_source, self.fic_encode, (self.mux, 0)) for i in range(0, num_subch): self.connect((self, i), self.msc_encoder[i], (self.mux, i + 1)) self.connect((self.mux, 0), self.s2v, (self.mod, 0)) self.connect((self.mux, 1), (self.mod, 1)) self.connect(self.mod, self)
def test_001_t (self): self.symbol_length = 32*4 self.dab_params = dab.parameters.dab_parameters(1, 208.064e6, True) # source self.dp = dab.parameters.dab_parameters(1, 208.064e6, True) self.fib_src = dab.fib_source_b_make(1, 1, "ensemble1", "service1", "musicmix", 4, [2], [15]) # encoder self.fib_enc = dab.fic_encode(self.dab_params) self.unpack = blocks.packed_to_unpacked_bb_make(1, gr.GR_MSB_FIRST) # mapper self.map = dab.mapper_bc_make(self.dp.num_carriers) # demapper self.s2v = blocks.stream_to_vector_make(gr.sizeof_gr_complex, self.dp.num_carriers) self.soft_interleaver = dab.complex_to_interleaved_float_vcf_make(self.dp.num_carriers) # decode self.fic_decoder = dab.fic_decode(self.dab_params) # control stream self.trigger_src = blocks.vector_source_b([1] + [0]*74, True) self.tb.connect(self.fib_src, blocks.head_make(gr.sizeof_char, 100000), self.fib_enc, self.unpack, self.map, self.s2v, self.soft_interleaver, self.fic_decoder ) self.tb.connect(self.trigger_src, (self.fic_decoder, 1)) self.tb.run () pass
def __init__(self, frequency, num_subch, ensemble_label, service_label, language, protections, data_rates_n, src_paths, selected_audio, use_usrp, sink_path="dab_iq_generated.dat"): gr.top_block.__init__(self) self.dab_mode = 1 self.frequency = frequency interp = 64 self.sample_rate = 128e6 / interp self.dp = dab.parameters.dab_parameters(self.dab_mode, 2000000, False) self.num_subch = num_subch self.ensemble_label = ensemble_label self.service_label = service_label self.language = language self.protections = protections self.data_rates_n = data_rates_n self.subch_sizes = np.multiply(self.data_rates_n, 6) self.src_paths = src_paths self.use_usrp = use_usrp self.sink_path = sink_path self.selected_audio = selected_audio self.volume = 80 ######################## # FIC ######################## # source self.fic_src = dab.fib_source_b_make(self.dab_mode, self.num_subch, self.ensemble_label, self.service_label, "", self.language, self.protections, self.data_rates_n) # encoder self.fic_enc = dab.fic_encode(self.dp) ######################## # MSC ######################## self.msc_sources = [None] * self.num_subch self.f2s_left_converters = [None] * self.num_subch self.f2s_right_converters = [None] * self.num_subch self.mp4_encoders = [None] * self.num_subch self.rs_encoders = [None] * self.num_subch self.msc_encoders = [None] * self.num_subch for i in range(0, self.num_subch): # source self.msc_sources[i] = blocks.wavfile_source_make( self.src_paths[i], True) # float to short self.f2s_left_converters[i] = blocks.float_to_short_make(1, 32767) self.f2s_right_converters[i] = blocks.float_to_short_make(1, 32767) # mp4 encoder and Reed-Solomon encoder self.mp4_encoders[i] = dab.mp4_encode_sb_make( self.data_rates_n[i], 2, 32000, 1) self.rs_encoders[i] = dab.reed_solomon_encode_bb_make( self.data_rates_n[i]) # encoder self.msc_encoders[i] = dab.msc_encode(self.dp, self.data_rates_n[i], self.protections[i]) ######################## # MUX ######################## self.mux = dab.dab_transmission_frame_mux_bb_make( self.dab_mode, self.num_subch, self.subch_sizes) #self.mux = dab.dab_transmission_frame_mux_bb_make(1, 1, [84, 84]) self.trigsrc = blocks.vector_source_b([1] + [0] * 74, True) ######################## # Modulator ######################## self.s2v_mod = blocks.stream_to_vector(gr.sizeof_char, 384) self.mod = dab.ofdm_mod(self.dp) ######################## # Sink ######################## if self.use_usrp: self.sink = uhd.usrp_sink("", uhd.io_type.COMPLEX_FLOAT32, 1) self.sink.set_samp_rate(self.sample_rate) self.sink.set_antenna("TX/RX") self.sink.set_center_freq(self.frequency) else: self.sink = blocks.file_sink_make(gr.sizeof_gr_complex, self.sink_path) # audio sink self.audio = audio.sink_make(32000) self.gain_left = blocks.multiply_const_ff_make(1, 1) self.gain_right = blocks.multiply_const_ff_make(1, 1) ######################## # Connections ######################## self.connect(self.fic_src, self.fic_enc, (self.mux, 0)) for i in range(0, self.num_subch): self.connect((self.msc_sources[i], 0), self.f2s_left_converters[i], (self.mp4_encoders[i], 0), self.rs_encoders[i], self.msc_encoders[i], (self.mux, i + 1)) self.connect((self.msc_sources[i], 1), self.f2s_right_converters[i], (self.mp4_encoders[i], 1)) self.connect((self.mux, 0), self.s2v_mod, (self.mod, 0)) self.connect(self.trigsrc, (self.mod, 1)) self.connect(self.mod, self.sink) self.connect((self.msc_sources[self.selected_audio - 1], 0), self.gain_left, (self.audio, 0)) self.connect((self.msc_sources[self.selected_audio - 1], 1), self.gain_right, (self.audio, 1))
def test_001_t(self): log = gr.logger("log") if os.path.exists("debug/rs_encoded.dat") and os.path.exists( "debug/rs_encoded.dat"): self.dp = dab.parameters.dab_parameters(1, 208.064e6, True) # sources self.fib_src = dab.fib_source_b_make(1, 1, 'Galaxy_News', 'Wasteland_Radio', 'Country_Mix01', 0x09, [2], [14]) self.fib_pack = blocks.unpacked_to_packed_bb_make( 1, gr.GR_MSB_FIRST) self.subch_src01 = blocks.file_source_make(gr.sizeof_char, "debug/rs_encoded.dat", True) self.subch_src02 = blocks.file_source_make( gr.sizeof_char, "debug/rs_encoded_2.dat", True) # encoder self.fib_enc = dab.fic_encode(self.dp) self.msc_encoder = dab.msc_encode(self.dp, 14, 2) self.msc_encoder2 = dab.msc_encode(self.dp, 14, 2) # multiplexer self.mux = dab.dab_transmission_frame_mux_bb_make(1, 2, [84, 84]) # mapper self.unpack = blocks.packed_to_unpacked_bb_make(1, gr.GR_MSB_FIRST) self.map = dab.mapper_bc_make(self.dp.num_carriers) # demapper self.s2v = blocks.stream_to_vector_make(gr.sizeof_gr_complex, self.dp.num_carriers) self.soft_interleaver = dab.complex_to_interleaved_float_vcf_make( self.dp.num_carriers) # decode self.fic_decoder = dab.fic_decode(self.dp) self.msc_dec = dab.dabplus_audio_decoder_ff( self.dp, 112, 0, 84, 2, True) # audio sink self.audio = audio.sink_make(32000) # control stream self.trigger_src = blocks.vector_source_b([1] + [0] * 74, True) # connect everything self.tb.connect(self.fib_src, self.fib_enc, (self.mux, 0)) self.tb.connect(self.subch_src01, self.msc_encoder, (self.mux, 1)) self.tb.connect(self.subch_src02, self.msc_encoder2, (self.mux, 2)) self.tb.connect((self.mux, 0), self.unpack, self.map, self.s2v, self.soft_interleaver, (self.msc_dec, 0)) self.tb.connect(self.soft_interleaver, (self.fic_decoder, 0)) self.tb.connect(self.trigger_src, (self.fic_decoder, 1)) self.tb.connect(self.trigger_src, (self.msc_dec, 1)) self.tb.connect((self.msc_dec, 0), (self.audio, 0)) self.tb.connect((self.msc_dec, 1), (self.audio, 1)) self.tb.run() pass else: log.debug("debug file not found - skipped test") log.set_level("WARN") pass
def __init__(self, dab_mode, frequency, num_subch, ensemble_label, service_label, language, country_ID, protections, data_rates_n, stereo_flags, audio_sampling_rates, src_paths, selected_audio, use_usrp, dabplus_types, sink_path="dab_iq_generated.dat"): gr.top_block.__init__(self) self.dab_mode = dab_mode self.frequency = frequency interp = 64 self.sample_rate = 128e6 / interp self.dp = dab.parameters.dab_parameters(self.dab_mode, 2000000, False) self.num_subch = num_subch self.ensemble_label = ensemble_label self.service_label = service_label self.language = language self.protections = protections self.data_rates_n = data_rates_n self.src_paths = src_paths self.use_usrp = use_usrp self.dabplus_types = dabplus_types self.sink_path = sink_path self.selected_audio = selected_audio self.volume = 80 sizes = {0: 12, 1: 8, 2: 6, 3: 4} self.subch_sizes = [None] * len(self.data_rates_n) for i in range(0, len(self.data_rates_n)): self.subch_sizes[i] = self.data_rates_n[i] * sizes[protections[i]] ######################## # FIC ######################## # source self.fic_src = dab.fib_source_b_make( self.dab_mode, country_ID, self.num_subch, self.ensemble_label, self.service_label, "", self.language, self.protections, self.data_rates_n, self.dabplus_types) # encoder self.fic_enc = dab.fic_encode(self.dp) ######################## # MSC ######################## self.recorder = audio.source_make(32000) self.msc_sources = [None] * self.num_subch self.f2s_left_converters = [None] * self.num_subch self.f2s_right_converters = [None] * self.num_subch self.mp4_encoders = [None] * self.num_subch self.mp2_encoders = [None] * self.num_subch self.rs_encoders = [None] * self.num_subch self.msc_encoders = [None] * self.num_subch for i in range(0, self.num_subch): if not self.src_paths[i] is "mic": # source self.msc_sources[i] = blocks.wavfile_source_make( self.src_paths[i], True) # float to short self.f2s_left_converters[i] = blocks.float_to_short_make(1, 32767) self.f2s_right_converters[i] = blocks.float_to_short_make(1, 32767) if self.dabplus_types[i] is 1: # mp4 encoder and Reed-Solomon encoder self.mp4_encoders[i] = dab.mp4_encode_sb_make( self.data_rates_n[i], 2, audio_sampling_rates[i], 1) self.rs_encoders[i] = dab.reed_solomon_encode_bb_make( self.data_rates_n[i]) else: # mp2 encoder self.mp2_encoders[i] = dab.mp2_encode_sb_make( self.data_rates_n[i], 2, audio_sampling_rates[i]) # encoder self.msc_encoders[i] = dab.msc_encode(self.dp, self.data_rates_n[i], self.protections[i]) ######################## # MUX ######################## self.mux = dab.dab_transmission_frame_mux_bb_make( self.dab_mode, self.num_subch, self.subch_sizes) self.trigsrc = blocks.vector_source_b( [1] + [0] * (self.dp.symbols_per_frame - 2), True) ######################## # Modulator ######################## self.s2v_mod = blocks.stream_to_vector(gr.sizeof_char, self.dp.num_carriers / 4) self.mod = dab.ofdm_mod(self.dp) ######################## # Sink ######################## if self.use_usrp: self.sink = uhd.usrp_sink("", uhd.io_type.COMPLEX_FLOAT32, 1) self.sink.set_samp_rate(self.sample_rate) self.sink.set_antenna("TX/RX") self.sink.set_center_freq(self.frequency) else: self.sink = blocks.file_sink_make(gr.sizeof_gr_complex, self.sink_path) # audio sink self.audio = audio.sink_make(32000) self.gain_left = blocks.multiply_const_ff_make(1, 1) self.gain_right = blocks.multiply_const_ff_make(1, 1) self.s2f_left = blocks.short_to_float_make(1, 32767) self.s2f_right = blocks.short_to_float_make(1, 32767) ######################## # Connections ######################## self.connect(self.fic_src, self.fic_enc, (self.mux, 0)) for i in range(0, self.num_subch): if self.dabplus_types[i] is 1: if self.src_paths[i] is "mic": self.connect( (self.recorder, 0), self.f2s_left_converters[i], (self.mp4_encoders[i], 0), self.rs_encoders[i], self.msc_encoders[i], (self.mux, i + 1)) if stereo_flags[i] == 0: self.connect((self.recorder, 1), self.f2s_right_converters[i], (self.mp4_encoders[i], 1)) else: self.connect(self.f2s_left_converters[i], (self.mp4_encoders[i], 1)) else: self.connect( (self.msc_sources[i], 0), self.f2s_left_converters[i], (self.mp4_encoders[i], 0), self.rs_encoders[i], self.msc_encoders[i], (self.mux, i + 1)) if stereo_flags[i] == 0: self.connect((self.msc_sources[i], 1), self.f2s_right_converters[i], (self.mp4_encoders[i], 1)) else: self.connect(self.f2s_left_converters[i], (self.mp4_encoders[i], 1)) else: self.connect((self.msc_sources[i], 0), self.f2s_left_converters[i], (self.mp2_encoders[i], 0), self.msc_encoders[i], (self.mux, i + 1)) if stereo_flags[i] == 0: self.connect((self.msc_sources[i], 1), self.f2s_right_converters[i], (self.mp2_encoders[i], 1)) else: self.connect(self.f2s_left_converters[i], (self.mp2_encoders[i], 1)) self.connect((self.mux, 0), self.s2v_mod, (self.mod, 0)) self.connect(self.trigsrc, (self.mod, 1)) if use_usrp: self.connect(self.mod, self.sink) else: self.connect(self.mod, blocks.throttle_make(gr.sizeof_gr_complex, 2e6), self.sink)