def test_noise(): N = 500 rate = 1.0 w = noise.white(N) b = noise.brown(N) v = noise.violet(N) p = noise.pink(N) assert len(w) == N assert len(b) == N assert len(v) == N - 1 # why? assert len(p) == N
def test_noise(): N = 500 rate = 1.0 w = noise.white(N) b = noise.brown(N) v = noise.violet(N) p = noise.pink(N) assert len(w) == N assert len(b) == N assert len(v) == N-1 # why? assert len(p) == N
def add_pink_noise(filename): print "Adding Pink Noise..." fps, snd_array = wavfile.read('../audio/transformed/' + filename) noise1 = noise.pink(len(snd_array)) noise1 = map(lambda x: int(x/.01), noise1) noise2 = np.array([noise1,noise1]).T noisy_array = noise2 + snd_array filename, file_extension = os.path.splitext(filename) filename = "../audio/transformed/"+filename+"pinknoise.wav" scaled = np.int16(noisy_array/np.max(np.abs(noisy_array)) * 32767) write(filename, 44100, scaled) return
def test_noise(): N = 500 #rate = 1.0 w = noise.white(N) b = noise.brown(N) v = noise.violet(N) p = noise.pink(N) # check output length assert len(w) == N assert len(b) == N assert len(v) == N assert len(p) == N # check output type for x in [w, b, v, p]: assert type(x) == numpy.ndarray, "%s is not numpy.ndarray" % (type(x))
plt.subplot(111, xscale="log", yscale="log") N = 100000 # Colors: http://en.wikipedia.org/wiki/Colors_of_noise # Brownian a.k.a random walk frequency => sqrt(tau) ADEV print("Random Walk frequency noise - should have sqrt(tau) ADEV") freq_rw = noise.brown(N) phase_rw_rw = numpy.cumsum(noise.brown(N)) # integrate to get phase plotallan(plt, freq_rw, 1, t, 'm.') plotallan_phase(plt, phase_rw_rw, 1, t, 'mo',label='random walk frequency') plotline(plt, +0.5, t, 'm',label="f^(+1/2)") # pink frequency noise => constant ADEV print("Pink frequency noise - should have constant ADEV") freq_pink = noise.pink(N) phase_p = numpy.cumsum(noise.pink(N)) # integrate to get phase, color?? plotallan_phase(plt, phase_p, 1, t, 'co',label="pink/flicker frequency noise") plotallan(plt, freq_pink, 1, t, 'c.') plotline(plt, 0, t, 'c',label="f^0") # white frequency modulation => 1/sqrt(tau) ADEV print("White frequency noise - should have 1/sqrt(tau) ADEV") freq_white = noise.white(N) phase_rw = noise.brown(N) # integrate to get Brownian, or random walk phase plotallan(plt, freq_white, 1, t, 'b.') plotallan_phase(plt, phase_rw, 1, t, 'bo',label='random walk phase a.k.a. white frequency noise') plotline(plt, -0.5, t, 'b',label="f^(-1/2)") # pink phase noise => 1/tau ADEV and MDEV print("Pink phase noise - should tau^(-3/2) MDEV")
# Brownian a.k.a random walk frequency => sqrt(tau) ADEV print("Random Walk frequency noise - should have sqrt(tau) ADEV") freq_rw = noise.brown(N) phase_rw_rw = numpy.cumsum(noise.brown(N)) # integrate to get phase plotallan(plt, freq_rw, 1, t, 'm.') plotallan_phase(plt, phase_rw_rw, 1, t, 'mo', label='random walk frequency') plotline(plt, +0.5, t, 'm', label="f^(+1/2)") # pink frequency noise => constant ADEV print("Pink frequency noise - should have constant ADEV") freq_pink = noise.pink(N) phase_p = numpy.cumsum(noise.pink(N)) # integrate to get phase, color?? plotallan_phase(plt, phase_p, 1, t, 'co', label="pink/flicker frequency noise") plotallan(plt, freq_pink, 1, t, 'c.') plotline(plt, 0, t, 'c', label="f^0") # white frequency modulation => 1/sqrt(tau) ADEV print("White frequency noise - should have 1/sqrt(tau) ADEV") freq_white = noise.white(N) phase_rw = noise.brown( N) # integrate to get Brownian, or random walk phase