• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python math.dB函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中shinysdr.math.dB函数的典型用法代码示例。如果您正苦于以下问题:Python dB函数的具体用法?Python dB怎么用?Python dB使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了dB函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, mode, input_rate=0, context=None):
        assert input_rate > 0
        self.__input_rate = input_rate
        gr.hier_block2.__init__(
            self, 'RTTY demodulator',
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
            gr.io_signature(1, 1, gr.sizeof_float * 1))
        
        channel_filter = self.__make_channel_filter()

        self.__text = u''
        self.__char_queue = gr.msg_queue(limit=100)
        self.__char_sink = blocks.message_sink(gr.sizeof_char, self.__char_queue, True)

        self.connect(
            self,
            channel_filter,
            self.__make_demodulator(),
            self.__char_sink)
        
        self.connect(
            channel_filter,
            self.__make_audio_filter(),
            blocks.rotator_cc(rotator_inc(self.__demod_rate, 2000 + self.__spacing / 2)),
            blocks.complex_to_real(vlen=1),
            analog.agc2_ff(
                reference=dB(-10),
                attack_rate=8e-1,
                decay_rate=8e-1),
            self)
开发者ID:bitglue,项目名称:shinysdr,代码行数:30,代码来源:__init__.py


示例2: __init__

    def __init__(self, mode, input_rate=0, context=None):
        assert input_rate > 0
        self.__input_rate = input_rate
        gr.hier_block2.__init__(
            self, type(self).__name__,
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
            gr.io_signature(1, 1, gr.sizeof_float * 1))
        
        channel_filter = self.__make_channel_filter()

        self.__text_cell = StringSinkCell(encoding='us-ascii')
        self.__text_sink = self.__text_cell.create_sink_internal()

        self.connect(
            self,
            channel_filter,
            self.__make_demodulator(),
            self.__text_sink)
        
        self.connect(
            channel_filter,
            self.__make_audio_filter(),
            blocks.rotator_cc(rotator_inc(self.__demod_rate, 2000 + self.__spacing / 2)),
            blocks.complex_to_real(vlen=1),
            analog.agc2_ff(
                reference=dB(-10),
                attack_rate=8e-1,
                decay_rate=8e-1),
            self)
开发者ID:kpreid,项目名称:shinysdr,代码行数:29,代码来源:__init__.py


示例3: __init__

 def __init__(self, modulator, audio_rate, rf_rate, freq):
     modulator = IModulator(modulator)
     
     gr.hier_block2.__init__(
         self, 'SimulatedChannel',
         gr.io_signature(1, 1, gr.sizeof_float * 1),
         gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
     )
     
     self.__freq = freq
     self.__rf_rate = rf_rate
     self.__modulator = modulator
     
     modulator_input_type = modulator.get_input_type()
     if modulator_input_type.get_kind() == 'MONO':
         audio_resampler = make_resampler(audio_rate, modulator_input_type.get_sample_rate())
         self.connect(self, audio_resampler, modulator)
     elif modulator_input_type.get_kind() == 'NONE':
         self.connect(self, blocks.null_sink(gr.sizeof_float))
     else:
         raise Exception('don\'t know how to supply input of type %s' % modulator_input_type)
     
     rf_resampler = rational_resampler.rational_resampler_ccf(
         interpolation=int(rf_rate),
         decimation=int(modulator.get_output_type().get_sample_rate()))
     self.__rotator = blocks.rotator_cc(rotator_inc(rate=rf_rate, shift=freq))
     self.__mult = blocks.multiply_const_cc(dB(-10))
     self.connect(modulator, rf_resampler, self.__rotator, self.__mult, self)
开发者ID:bitglue,项目名称:shinysdr,代码行数:28,代码来源:simulate.py


示例4: __update_audio_gain

 def __update_audio_gain(self):
     gain_lin = dB(self.audio_gain)
     if self.__audio_channels == 2:
         pan = self.audio_pan
         # TODO: Determine correct computation for panning. http://en.wikipedia.org/wiki/Pan_law seems relevant but was short on actual formulas. May depend on headphones vs speakers? This may be correct already for headphones -- it sounds nearly-flat to me.
         self.__audio_gain_blocks[0].set_k(gain_lin * (1 - pan))
         self.__audio_gain_blocks[1].set_k(gain_lin * (1 + pan))
     else:
         self.__audio_gain_blocks[0].set_k(gain_lin)
开发者ID:croutonage,项目名称:shinysdr,代码行数:9,代码来源:receiver.py


示例5: __update_audio_gain

 def __update_audio_gain(self):
     gain_lin = dB(self.audio_gain)
     if self.__audio_channels == 2:
         pan = self.audio_pan
         # TODO: Instead of left-to-left and right-to-right, panning other than center should mix left and right content. (A "pan law" defines the proper mix.) This implies a matrix multiplication type operation.
         self.__audio_gain_block.set_k([
             gain_lin * (1 - pan),
             gain_lin * (1 + pan),
         ])
     else:
         self.__audio_gain_block.set_k([gain_lin])
开发者ID:thefinn93,项目名称:shinysdr,代码行数:11,代码来源:receiver.py


示例6: __init__

    def __init__(self, mode, input_rate, context):
        channels = 2
        audio_rate = 10000
        
        gr.hier_block2.__init__(
            self, str('%s demodulator' % (mode,)),
            gr.io_signature(1, 1, gr.sizeof_gr_complex),
            gr.io_signature(1, 1, gr.sizeof_float * channels))

        self.__input_rate = input_rate
        self.__rec_freq_input = 0.0
        self.__signal_type = SignalType(kind='STEREO', sample_rate=audio_rate)

        # Using agc2 rather than feedforward AGC for efficiency, because this runs at the RF rate rather than the audio rate.
        agc_block = analog.agc2_cc(reference=dB(-8))
        agc_block.set_attack_rate(8e-3)
        agc_block.set_decay_rate(8e-3)
        agc_block.set_max_gain(dB(40))
        
        self.connect(
            self,
            agc_block)
        
        channel_joiner = blocks.streams_to_vector(gr.sizeof_float, channels)
        self.connect(channel_joiner, self)
        
        for channel in xrange(0, channels):
            self.connect(
                agc_block,
                grfilter.fir_filter_ccc(1, design_sawtooth_filter(decreasing=channel == 0)),
                blocks.complex_to_mag(1),
                blocks.float_to_complex(),  # So we can use the complex-input band filter. TODO eliminate this for efficiency
                MultistageChannelFilter(
                    input_rate=input_rate,
                    output_rate=audio_rate,
                    cutoff_freq=5000,
                    transition_width=5000),
                blocks.complex_to_real(),
                # assuming below 40Hz is not of interest
                grfilter.dc_blocker_ff(audio_rate // 40, False),
                (channel_joiner, channel))
开发者ID:bitglue,项目名称:shinysdr,代码行数:41,代码来源:basic_demod.py


示例7: __do_connect

 def __do_connect(self):
     inherent_gain = 0.5  # fudge factor so that our output is similar level to narrow FM
     if self.__demod_method != 'async':
         inherent_gain *= 2
     
     agc_block = analog.feedforward_agc_cc(int(.005 * self.__demod_rate), inherent_gain)
     
     # non-method-specific elements
     self.disconnect_all()
     self.connect(
         self,
         self.band_filter_block,  # from SimpleAudioDemodulator
         self.rf_squelch_block,  # from SquelchMixin
         agc_block)
     self.connect(self.band_filter_block, self.rf_probe_block)
     before_demod = agc_block
     
     if self.__demod_method == u'async':
         dc_blocker = self.__make_dc_blocker()
         self.connect(
             before_demod,
             blocks.complex_to_mag(1),
             dc_blocker)
         self.connect_audio_output(dc_blocker, dc_blocker)
         self.__pll = None
     else:
         # all other methods use carrier tracking
         # TODO: refine PLL parameters further
         pll = self.__pll = analog.pll_carriertracking_cc(.01 * pi, .1 * pi, -.1 * pi)
         pll.set_lock_threshold(dB(-20))
         # pll.squelch_enable(True)
         self.connect(before_demod, pll)
         
         if self.__demod_method == u'stereo':
             left_input, left_output = self.__make_sideband_demod(False)
             right_input, right_output = self.__make_sideband_demod(True)
             self.connect(pll, left_input)
             self.connect(pll, right_input)
             self.connect_audio_output(left_output, right_output)
         else:
             (demod_input, demod_output) = self.__make_sideband_demod(self.__demod_method == u'usb')
             self.connect(pll, demod_input)
             self.connect_audio_output(demod_output, demod_output)
开发者ID:bitglue,项目名称:shinysdr,代码行数:43,代码来源:basic_demod.py


示例8: __init__

    def __init__(self,
            input_rate,
            output_rate=12000,
            output_frequency=1500,
            transition_width=100,
            width=800):
        """Make a new WSPRFilter.

        input_rate: the incomming sample rate

        output_rate: output sample rate

        output_frequency: 0Hz in the complex input will be centered on this
        frequency in the real output

        width, transition_width: passband and transition band widths.
        """

        gr.hier_block2.__init__(
            self, type(self).__name__,
            gr.io_signature(1, 1, gr.sizeof_gr_complex),
            gr.io_signature(1, 1, gr.sizeof_float))

        self.connect(
            self,

            MultistageChannelFilter(
                input_rate=input_rate,
                output_rate=output_rate,
                cutoff_freq=width / 2,
                transition_width=transition_width),

            blocks.rotator_cc(2 * pi * output_frequency / output_rate),

            blocks.complex_to_real(vlen=1),

            analog.agc2_ff(
                reference=dB(-10),
                attack_rate=8e-1,
                decay_rate=8e-1),

            self)
开发者ID:bitglue,项目名称:shinysdr,代码行数:42,代码来源:blocks.py


示例9: set_gain

 def set_gain(self, value):
     self.__mult.set_k(dB(value))
开发者ID:bitglue,项目名称:shinysdr,代码行数:2,代码来源:simulate.py


示例10: set_noise_level

 def set_noise_level(self, value):
     self.__channel_model.set_noise_voltage(dB(value))
     self.__noise_level = value
开发者ID:bitglue,项目名称:shinysdr,代码行数:3,代码来源:simulate.py


示例11: __init__

 def __init__(self, mode='433', input_rate=0, context=None):
     assert input_rate > 0
     assert context is not None
     gr.hier_block2.__init__(
         self, type(self).__name__,
         gr.io_signature(1, 1, gr.sizeof_gr_complex),
         gr.io_signature(0, 0, 0))
     
     # The input bandwidth chosen is not primarily determined by the bandwidth of the input signals, but by the frequency error of the transmitters. Therefore it is not too critical, and we can choose the exact rate to make the filtering easy.
     if input_rate <= upper_preferred_demod_rate:
         # Skip having a filter at all.
         self.__band_filter = None
         demod_rate = input_rate
     else:
         # TODO: This gunk is very similar to the stuff that MultistageChannelFilter does. See if we can share some code.
         lower_rate = input_rate
         lower_rate_prev = None
         while lower_rate > upper_preferred_demod_rate and lower_rate != lower_rate_prev:
             lower_rate_prev = lower_rate
             if lower_rate % 5 == 0 and lower_rate > upper_preferred_demod_rate * 3:
                 lower_rate /= 5
             elif lower_rate % 2 == 0:
                 lower_rate /= 2
             else:
                 # non-integer ratio
                 lower_rate = upper_preferred_demod_rate
                 break
         demod_rate = lower_rate
         
         self.__band_filter = MultistageChannelFilter(
             input_rate=input_rate,
             output_rate=demod_rate,
             cutoff_freq=demod_rate * 0.4,
             transition_width=demod_rate * 0.2)
     
     # Subprocess
     # using /usr/bin/env because twisted spawnProcess doesn't support path search
     # pylint: disable=no-member
     process = the_reactor.spawnProcess(
         RTL433ProcessProtocol(context.output_message),
         '/usr/bin/env',
         env=None,  # inherit environment
         args=[
             'env', 'rtl_433',
             '-F', 'json',
             '-r', '-',  # read from stdin
             '-m', '3',  # complex float input
             '-s', str(demod_rate),
         ],
         childFDs={
             0: 'w',
             1: 'r',
             2: 2
         })
     sink = make_sink_to_process_stdin(process, itemsize=gr.sizeof_gr_complex)
     
     agc = analog.agc2_cc(reference=dB(-4))
     agc.set_attack_rate(200 / demod_rate)
     agc.set_decay_rate(200 / demod_rate)
     
     if self.__band_filter:
         self.connect(
             self,
             self.__band_filter,
             agc)
     else:
         self.connect(
             self,
             agc)
     self.connect(agc, sink)
开发者ID:bitglue,项目名称:shinysdr,代码行数:70,代码来源:rtl_433.py


示例12: dB

from gnuradio import analog
from gnuradio import gr
from gnuradio import blocks

from shinysdr.i.modes import get_modes, lookup_mode
from shinysdr.interfaces import IDemodulator, IDemodulatorContext, IDemodulatorModeChange, ITunableDemodulator
from shinysdr.math import dB, rotator_inc, to_dB
from shinysdr.signals import SignalType, no_signal
from shinysdr.types import EnumT, QuantityT, RangeT, ReferenceT
from shinysdr import units
from shinysdr.values import ExportedState, exported_value, setter, unserialize_exported_state


# arbitrary non-infinite limit
_audio_power_minimum_dB = -60
_audio_power_minimum_amplitude = dB(_audio_power_minimum_dB)


_dummy_audio_rate = 2000


class IReceiver(Interface):
    """
    Marker interface for receivers.
    
    (This exists even though Receiver has no class hierarchy because the client would like to know what's a receiver block, and interface information is automatically delivered to the client.)
    """


@implementer(IReceiver)
class Receiver(gr.hier_block2, ExportedState):
开发者ID:thefinn93,项目名称:shinysdr,代码行数:31,代码来源:receiver.py


示例13: __init__

    def __init__(self, mode, **kwargs):
        if mode == "LSB":
            lsb = True
            cw = False
        elif mode == "USB":
            lsb = False
            cw = False
        elif mode == "CW":
            lsb = False
            cw = True
        else:
            raise ValueError("Not an SSB mode: %r" % (mode,))

        demod_rate = 8000  # round number close to SSB bandwidth * 2

        SimpleAudioDemodulator.__init__(
            self,
            mode=mode,
            audio_rate=demod_rate,
            demod_rate=demod_rate,
            band_filter=demod_rate / 2,  # note narrower filter applied later
            band_filter_transition=demod_rate / 2,
            **kwargs
        )

        if cw:
            self.__offset = 1500  # CW beat frequency
            half_bandwidth = self.half_bandwidth = 500
            self.band_filter_width = 120
            band_mid = 0
            agc_reference = dB(-10)
            agc_rate = 1e-1
        else:
            self.__offset = 0
            half_bandwidth = self.half_bandwidth = 2800 / 2  # standard SSB bandwidth
            self.band_filter_width = half_bandwidth / 5
            if lsb:
                band_mid = -200 - half_bandwidth
            else:
                band_mid = 200 + half_bandwidth
            agc_reference = dB(-8)
            agc_rate = 8e-1

        self.band_filter_low = band_mid - half_bandwidth
        self.band_filter_high = band_mid + half_bandwidth
        sharp_filter_block = grfilter.fir_filter_ccc(
            1,
            firdes.complex_band_pass(
                1.0,
                demod_rate,
                self.band_filter_low + self.__offset,
                self.band_filter_high + self.__offset,
                self.band_filter_width,
                firdes.WIN_HAMMING,
            ),
        )

        self.agc_block = analog.agc2_cc(reference=agc_reference)
        self.agc_block.set_attack_rate(agc_rate)
        self.agc_block.set_decay_rate(agc_rate)
        self.agc_block.set_max_gain(dB(_ssb_max_agc))

        ssb_demod_block = blocks.complex_to_real(1)

        self.connect(
            self,
            self.band_filter_block,
            sharp_filter_block,
            # TODO: We would like to have an in
            self.rf_squelch_block,
            self.agc_block,
            ssb_demod_block,
        )
        self.connect(sharp_filter_block, self.rf_probe_block)
        self.connect_audio_output(ssb_demod_block)
开发者ID:langxj,项目名称:shinysdr,代码行数:75,代码来源:basic_demod.py



注:本文中的shinysdr.math.dB函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python top.Top类代码示例发布时间:2022-05-27
下一篇:
Python filters.MultistageChannelFilter类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap