Noise generator developed in C, allow to play in backgroun White and Brown noise.
-
Whitenoise by definition contains all frequencies at a constant amplitude. To generate a white noise it is necessary to be able to generate a sequence a pseudo-random numbers in the range from [-1.0 .. 1.0) which are effectively distributed according to the standard uniform distribution.
NOTE: First, and perhaps most important: be very, very suspicious of a system-supplied rand(). System-supplied rand()s are almost always linear congruential generators that will eventually repeat itself, with a period.
That's why we need a better pseudo-random numbers generator. The white noise generator will use
randq.c
a better way to generate a random number. We will use the "Quick and Dirty" Generators, described in "Numerical Recipes in C" Second Edition at page 284, relies on 32-bit arithmetic and developed inrandq.c
through the following functions:srandqd
,randqd_uint32
andrandq_double
; -
White noise + digital low-pass filter
Digital Low-pass filter:
assume that samples of the input and output are taken at evenly spaced points in time separated by Delta_T time. Let the samples of v_in (the white noise) be represented by the sequence (x_1, x_2, ..., x_n), and let v_out (brown noise) be represented by the sequence (y_1, y_2, ..., y_n), which correspond to the same points in time.
therefore, to obtain the brown noise sequence it is sufficient to apply this equation to the white noise sequence.
# Requirements for white_noise_utest
sudo apt-get install libcmocka-dev
# Requirements for portaudio
sudo apt-get install libasound-dev
# Downlod and install portaudo lib
git clone https://git.assembla.com/portaudio.git
cd portaudio
./configure && make
sudo make install
brew install cmocka
brew install portaudio
git clone https://github.com/alessandrocuda/noise_generator
cd noise_generator
make
# Player
./white_noise #run white_noise player
./brown_noise #run brown_noise player
# unit_test
./white_noise_utest #run unit test for white_noise
- add Brown Noise
- add Pink Noise
- make a noises player with parameter to select the noise
Reach out to me at one of the following places!
- Website at Alessandro Cudazzo.
- Twitter at
@alessandrocuda
This library is free software; you can redistribute it and/or modify it under the terms of the MIT license.
- MIT license
- Copyright 2019 © Alessandro Cudazzo.