How could add noise to a music file in a way that after a certain amount of time the music file become noise free?

1 visualizzazione (ultimi 30 giorni)
multiplier = 0.1;
noise = randn(length(y),1).*multiplier;
sound_w_noise = y+noise;
sound(sound_w_noise,Fs);
As of now, the noise lasts the entire music file. So far I have tried creating different arrays with different lengths then using that to create the noise, like here.
ys = y(1:57344);
multiplier = 0.1;
noise = randn(length(ys),1).*multiplier;
sound_w_noise = ys+noise;
sound(sound_w_noise,Fs);
But all that has done is cut short the music file itself. What could I do so that the noise only lasts for a certain amount of time of the total music file?

Risposte (1)

Thiago Henrique Gomes Lobato
You were almost there. The array you have to shorten is the noise one, while, at the same time, adding it only at the initial values of your sound:
LenNoise = 57344;
multiplier = 0.1;
noise = randn(LenNoise,1).*multiplier;
sound_w_noise = y;
sound_w_noise(1:LenNoise) = sound_w_noise(1:LenNoise)+noise;
sound(sound_w_noise,Fs);

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by