Back to main page
Back to sound contents
This section shows how to add different types of noise to a waveform. Noise is controlled by sound option noise_generator.
Since we want to play the sound and draw the waveform everytime we call the play function, we set some sound options defaults to avoid rewriting them.
set_sound_defaults( player = "mplayer", draw_wave = true, draw_wave_options = [terminal = png, pic_height = 200, pic_width = 800] )$
This is a waveform with an additional noise generated by a continuous uniform distribution with support [-50, 100].
play( noise_generator = uniform(-50, 100), wave(1000 * sqrt(t) * sin(2 * %pi * 220 * t), t, 0, 1)) $
This is a waveform with an additional noise generated by a Gaussian (or normal) distribution with mean μ = -5 and standard deviation σ = 107. An additional ADSR envelope is also performed. Once the wave object is generated, the noise is added and then the envelope is applied in this order, which does not depend on the order the sound options noise_generator and envelope are given.
play( noise_generator = gaussian(-5, 107), envelope = adsr(0.01, 0.1, 0.8, 0.4), wave(1000 * sin(2 * %pi * 220 * t), t, 0, 1)) $
Gaussian noise with mean μ = 0 and standard deviation σ = 500. Note that the base signal is zero constant.
play( noise_generator = gaussian(0, 500), wave(0, t, 0, 1)) $
Back to main page
Back to sound contents