# Noise filtering in audio

I was given audio with white Gaussian noise and i have to implement two types of filter: Rectangle and Triangle that filter out redundant frequencies and reduce the amount of noise

Here is the code for the audio with the noise

SetDirectory[NotebookDirectory[]];
Print["Original File:"]
suite = Import["bach_suite_cello.mp3"]
suite // Options;
samples = AudioData[AudioTrim[suite, {2, 13}]][[1]];
Print["44k Sampling:"]
samples44k = Audio[samples, SampleRate -> 44100]
audioData44k = Flatten[AudioData[samples44k]];
samples44kWithNoise = audioData44k + RandomVariate[NormalDistribution[0, 0.1], Length[audioData44k]];
audioWithNoise = Audio[samples44kWithNoise]


Here's a link to the original audio bach suite cello.

So i want to filter out the noise using Rectangle and Triangle filters

Thanks for all those who help

a = ExampleData[{"Audio", "Clapping"}, "Audio"]
(* NOTE: this is mono data.
For stereo you must apply filtering to both channels [[1]] and [[2]] *)
dat = AudioData[a][[1]];

(* Convolve with your own kernels *)
rectangleFiltered = ListConvolve[{1, 1, 1, 1, 1, 1, 1}/7., dat];
triangleFiltered = ListConvolve[{1, 2, 3, 4, 3, 2, 1}/16., dat];
Audio[rectangleFiltered, SampleRate -> AudioSampleRate[a]]
Audio[triangleFiltered, SampleRate -> AudioSampleRate[a]]


• That's what these are: {1, 1, 1, 1, 1, 1, 1}/7. and {1, 2, 3, 4, 3, 2, 1}/16.. I've also normalized them hence the /7 and /16. The first is flat (rectangular) and the second runs up and then back down (triangular). Jun 7 '20 at 16:27