コード例 #1
0
 def __init__(self, **kwargs: dict):
     """ Reset object attributes, to latest config values. """
     Coordinator.__init__(self, kwargs['config'], kwargs['channel_id'])
     frame_size = self.config.get_config('frames_per_sample')
     self.window = spectral.new_window(frame_size, 'hanning')
     self.spectrogram_resolution = 128
     self.timer = 0
コード例 #2
0
 def reset_attributes(self):
     """ Reset object attributes, to latest config values. """
     frequency_resolution = self.config.get_config('block_size')
     self.sampling_rate = self.config.get_config('sampling_rate')
     self.window = spectral.new_window(frequency_resolution, 'hanning')
     self.filter = spectral.butter_bandpass(60, 18000, self.sampling_rate,
                                            5)
コード例 #3
0
 def setUp(self):
     """ Perform setup of initial parameters. """
     self.sampling_rate = 100
     self.frequency = 5
     self.timestep = arange(self.sampling_rate)
     self.sin_wave = sin(2 * pi * self.frequency * self.timestep /
                         self.sampling_rate)
     bp_filter = spectral.butter_bandpass(1, 48, self.sampling_rate)
     window = spectral.new_window(len(self.sin_wave), 'blackmanharris')
     self.frequency_spectrum = spectral.spectrum(self.sin_wave, window,
                                                 bp_filter)
     self.convolved_signal = spectral.convolve_signal(self.sin_wave)
コード例 #4
0
    def setUp(self):
        """ Perform setup of initial parameters. """
        def generate_sine(frequency, sampling_rate, time_step):
            """ Generates a basic sine wave for testing. """
            return sin(2 * pi * frequency * time_step / sampling_rate)

        self.sampling_rate = 50
        time_step = arange(self.sampling_rate)
        self.low_frequency = generate_sine(5, self.sampling_rate, time_step)
        med_frequency = generate_sine(10, self.sampling_rate, time_step)
        self.high_frequency = generate_sine(20, self.sampling_rate, time_step)
        self.complex_wave = self.low_frequency + med_frequency + self.high_frequency
        self.window = spectral.new_window(self.sampling_rate, 'blackmanharris')
        bp_filter = spectral.butter_bandpass(1, 24, self.sampling_rate, 10)
        self.spectrum = spectral.spectrum(self.low_frequency, self.window, bp_filter)
        self.conv_signal = spectral.convolve_signal(self.low_frequency)
コード例 #5
0
    def setUp(self):
        """ Perform setup"""
        self.sampling_rate = 44100  # standard sampling rate.
        time_step = arange(self.sampling_rate)

        self.fundamental_freq = 5000
        low_frequency = generate_sine(200, self.sampling_rate, time_step)
        fundamental = generate_sine(self.fundamental_freq, self.sampling_rate,
                                    time_step) * 500  # Fundamental
        high_frequency = generate_sine(12000, self.sampling_rate, time_step)
        noise = normal(
            0, 1,
            self.sampling_rate)  # Add noise to make it harder to detect pitch.
        self.complex_wave = low_frequency + fundamental + high_frequency + noise

        # Pre-processing to setup signal.
        self.window = spectral.new_window(self.sampling_rate, 'blackmanharris')
        self.bp_filter = spectral.butter_bandpass(100, 20000,
                                                  self.sampling_rate, 5)
        self.spectrum = spectral.spectrum(self.complex_wave, self.window,
                                          self.bp_filter)
        self.conv_spectrum = spectral.convolve_signal(self.complex_wave)
コード例 #6
0
 def test_window_length(self):
     """ Test that generated window length is equal to sampling rate. """
     self.assertEqual(self.sampling_rate,
                      len(spectral.new_window(self.sampling_rate, 'blackmanharris')))