Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

. (15 Points) A noise gate is a DSP algorithm that turns off the output when the

ID: 3726774 • Letter: #

Question

. (15 Points) A noise gate is a DSP algorithm that turns off the output when the input level (or amplitude) is below a given threshold. This algorithm can be used to eliminate the noise from a microphone when no one is talking into the microphone. Write a C language function called "noiseGate" whose output is zero if the absolute value of the input is less than the threshold, and the output equals the input when the absolute value of the input is greater than or equal to the threshold. Assume that the threshold and input and output signals are in Q15 format. Note that there is a function called "abs" that computes the absolute value and its prototype is in the header file stdlib.h. The noiseGate function does not return any value. The inputs to the function are as follows (in this order): threshold -threshold value (type Int16) input-pointer to a buffer for the input signal (type pointer to Intló) e output pointer to a buffer for the output signal (type pointer to Int16) bufferSize - size of the input and output buffers (type Int16) a. Write the contents of the header file noiseGate.h: b. re the tnts of the source file nose at

Explanation / Answer

PLEASE REFER BELOW CODE

1) noiseGate.h

#include<stdlib.h>
#include<stdio.h>

void noiseGate(short int, short int*, short int*, short int);

2) noiseGate.c

#include "noiseGate.h"

void noiseGate(short int threshold, short int *input, short int *output, short int bufferSize)
{
short int i;

for(i = 0; i < bufferSize; i++)
{
if(abs(input[i]) < threshold )
output[i] = 0;

else
output[i] = input[i];
}
}

3) TO TEST ABOVE CODE REFER BELOW DRIVER FILE test.c

#include "noiseGate.h"

int main()
{
short int buffersize,threshold,i;
short int *ip;
short int *op;

buffersize = 10;
threshold = 5;

ip = (short int*)malloc(buffersize * sizeof(short));
op = (short int*)malloc(buffersize * sizeof(short));

for(i = 0; i < buffersize; i++)
{
ip[i] = i;
}
noiseGate(threshold,ip,op,buffersize);

for(i = 0; i < buffersize; i++)
{
printf("%d ", op[i]);
}
return 0;
}

PLEASE REFER BELOW OUTPUT

0 0 0 0 0 5 6 7 8 9
Process returned 0 (0x0) execution time : 0.018 s
Press any key to continue.