Question
*C++ Write a function normalize to normalize a sound. Its parameters should be the same as those for reverse() . Normalizing the sound samples array
*C++
Write a function normalize to normalize a sound. Its parameters should be the same as those for reverse() . Normalizing the sound samples array is a two step process. Find the maximum (highest) value in the samples array. Multiply all values in the samples array by 36773 and divide by the maximum value.
Examples
[0, 1, 2, 3] --> [0, 1*36773/3, 2*36773/3, 3*36773/3]
[3, 2, 1, 0] --> [3*36773/3, 2*36773/3, 1*36773/3, 0]
[5, 8, 10] --> [5*36773/10, 8*36773/10, 10*36773/10]
This is the reverse function:
void reverse(int* samples, int size)
{
int i=0, j=size-1;
while(i<=j)
{ int temp = samples[i];
samples[i] = samples[j];
samples[j] = temp; i++;
j--;
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started