Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C++ Commands and provide comments please Write a function add echo that adds an echo to the samples array. Your function should take four parameters
C++ Commands and provide comments please
Write a function add echo that adds an echo to the samples array. Your function should take four parameters the samples array, the size of the samples array the sampling rate (as an int) and the delay d in seconds (as a double), in this order. The function will not return any value. For each sample in the samples array, add the value from d seconds ago. Examples: add echo (15,8,3,10, 6,21,6,1,1) Sampling rate is 1 (meaning 1 sample per second) and the delay is 1 second. For the echo, we need to add the value from 1 second before, which means the previous position. [5, 8, 3, 10, 6, 2] [5, 8+5 3+8 10+3, 6+10, 2+6] [5, 13, 11, 13, 16, 8] add_echo (15, 8,3,10, 6, 21,6, 1, 2) Sampling rate is 1 (meaning 1 sample per second) and the delay is 2 seconds. For the echo, we need to add the value from the 2 seconds ago. Given the sampling rate of 1 sample per second, this means we need to add the value from two positions before ([5, 8, 3, 10, 6, 2] , 6, 1, 2) [5, 8, 3+5 10+8, 6+3, 2+10] [5, 8, 8, 18, 9, 12] add_echo (15, 8,3,10, 6,2],6,2,2) Sampling rate is 2 (meaning 2 samples per second) and the delay is 2 seconds. For the echo, we need to add the value from the 2 seconds ago. Given the sampling rate of 2 samples per second, this means we need to add the value from four positions before ([5, 8, 3, 10, 6, 2] , 6, 2, 2) [5, 8, 3, 10, 6+5,2+8] [5, 8, 3, 10, 11, 10]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