Question
Question: You must implement each of the described methods and then in main method call it with test values in java eclipse. Don't forget to
Question: You must implement each of the described methods and then in main method call it with test values in java eclipse. Don't forget to test the methods in main and output stuff to the console.
MethodName: frequencyCount Parameter(s): An int array. The elements of the array can only be numbers from 0 to 9. Return value: A new int array of 10 integers. The value in the new array at index n is the number of times value n appears in the parameter array. Post-Condition: The array parameter is not changed. Example: Calling frequencyCount([0,0,1,1,1,7]) would return [2,3,0,0,0,0,0,1,0,0] since there are 2 zeroes and 3 ones and 1 seven, and no other digits in the parameter array.
Method name: reverseSound Parameter(s): A double array. Return value: Returns a double array that has its elements in reversed order from the parameter array. Post-Condition: The array parameter is not changed. Example: Calling reverseSound([0.1, 0.2, 0.3, 0.5]) should return a new array [0.5, 0.3, 0.2, 0.1]. You may not use Collections.reverse() for this.
Method name: scaleSound Parameter(s): A double array and a double value. Return value: Returns a double array that has as its elements each of the parameter array elements scaled by the second parameter. Post-Condition: The array parameter is not changed. Example: Calling scaleSound([0.0, -0.1, 0.3], 2.0) should return a new array [0.0, -0.2, 0.6]. Note: The play method for sounds keeps all values in the required -1.0 to 1.0 range, you do not need to test for this like you did in the Picture brightening.
Method name: echoSound Parameter(s): A double array, an int specifying how many samples offset the echo starts at, and a double giving a weight to the echo. The double array will have at least as many values as the offset. Return value: A double array as long as the array parameter plus the offset parameter. The first offset samples will be the same as the first offset samples as the parameter array. The last offset samples will be the same as the last offset samples from the parameter array scaled by the weight parameter. The middle samples will be the sample from the parameter array plus the sample from the parameter array back the offset amount scaled by the weight parameter. Here is the logic of it. An echo is a diminished sound delayed from bouncing off a distance object. So if you yell, I first hear your original signal. Then when the bounce comes back, I hear your original signal plus a scaled down signal from back in time. Then, when you stop, I only hear the scaled down signal from back in time. Post-Condition: The array parameter is not changed. Example: Calling echoSound([0.1, 0.2, 0.3, 0.4], 1, 0.5) should return a new array of length 5 (the original array plus the offset). The new array is [0.1, 0.25, 0.4, 0.55, 0.2]. The 0.1 is before the echo starts and is unchanged. The 0.25 comes from 0.2 + (0.1 * 0.5). The 0.4 comes from 0.3 + (0.2 * 0.5). The 0.55 comes from 0.4 + (0.3 * 0.5). The last value is all echo, and is 0.4 * 0.5.
Method name: smoothSound Parameter(s): A double array with at least 3 elements in it. Return value: Returns a double array that has as its elements a sliding average of the parameter array elements. More precisely: The first and last elements of the new array are the same as the average of the first two and last two elements of the parameter array, respectively. For the other elements of the new array, for an element at index i, it is equal to the average of elements from the parameter array at indices i-1, i, and i+1.
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