noise_generator
noise_generator copied to clipboard
noise generator developed in C99 (white, brown)
noise_generator
Noise generator developed in C, allow to play in backgroun White and Brown noise.
-
White 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
; -
Brown Noise
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.
Stack
System requirements
Linux Ubuntu/Debian
# 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
MacOS with Homebrew
brew install cmocka
brew install portaudio
BUILD
git clone https://github.com/alessandrocuda/noise_generator
cd noise_generator
make
Run
# Player
./white_noise #run white_noise player
./brown_noise #run brown_noise player
# unit_test
./white_noise_utest #run unit test for white_noise
TODO
- [x] add Brown Noise
- [ ] add Pink Noise
- [ ] make a noises player with parameter to select the noise
Support
Reach out to me at one of the following places!
- Website at Alessandro Cudazzo.
- Twitter at
@alessandrocuda
License
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.