def generate(self, n_noise_samples=1):
        """Generate noise samples.

        The type of the noise that will be generated, and the size of the noise array are defined by the argument given
        to the constructor.

        :param n_noise_samples: The number of noise samples to be generated.

        :return: an np.array with the specified noise
        """

        n = n_noise_samples * self.noise_size[0] * self.noise_size[1]
        s = concat([n_noise_samples], list(self.noise_size))
        if self.noise_type == 'simplistic':
            return np.random.uniform(0, 1, size=concat([n_noise_samples], list(self.noise_size)))
        elif self.noise_type.lower() in {'gaussian', 'white', 'normal'}:
            return np.reshape(white(n), s)
        elif self.noise_type.lower() == 'pink':
            return np.reshape(pink(n), s)
        elif self.noise_type.lower() == 'blue':
            return np.reshape(blue(n), s)
        elif self.noise_type.lower() == 'brown':
            return np.reshape(brown(n), s)
        elif self.noise_type.lower() == 'violet':
            return np.reshape(violet(n), s)
        else:
            print("WARNING: noise type " + self.noise_type + " not defined. Returning 0")
            return np.reshape(np.zeros(n), s)
def noise_make(sound, numbers_of_samples, factor):
    noise = generator.brown(numbers_of_samples)
    noise = noise * factor
    low = 0.23
    high = 0.8
    b, a = signal.butter(4, (low, high),
                         btype="bandpass")  ## filtr pasmowo przepustowy
    output_signal = signal.filtfilt(b, a, noise)
    #output_signal += sound
    return output_signal
Example #3
0
 def test_power(self):
     fs = 44100
     samples = 44100 * 10
     _, L = octaves(brown(samples), fs)
     change = np.diff(L).mean().round(0)
     assert (change == -3.)
Example #4
0
 def test_length(self):
     N = 1000
     assert (len(brown(N)) == N)
Example #5
0
 def test_power_density(self):
     fs = 44100
     samples = 44100 * 10
     _, L = octaves(brown(samples), fs, density=True)
     change = np.diff(L).mean().round(0)
     assert (change == -6.)
 def test_length(self):
     N = 1000
     assert(len(brown(N))==N)
 def test_power_density(self):
     fs = 44100
     samples = 44100 * 10
     _, L = octaves(brown(samples), fs, density=True); 
     change = np.diff(L).mean().round(0)
     assert(change==-6.)
 def test_power(self):
     fs = 44100
     samples = 44100 * 10
     _, L = octaves(brown(samples), fs); 
     change = np.diff(L).mean().round(0)
     assert(change==-3.)