Here we will elaborate on how to use the results of the EDR for each frequency to compute the wanted gain at that frequency of our loop filter. For the fundamental, we want to match a straight line to the linear decay (in dB) for the plot. As shown, the segment we highlighted in green marks a good region for a linear fit. Since we know how many dBs the signal decays on this segment, we can compute the desired gain. We have provided the code segment in our Matlab program that does this:
%% here i corresponds to the index into our arrays for the fundamental freq (328.38Hz) curr_vals = B_EDRdbN(i,:); segmentFrames = startFrame:endFrame; curr_region = curr_vals(segmentFrames); P = polyfit(segmentFrames,curr_region,1); slopes(i) = P(1); offsets(i) = P(2); RT(i) = -60*overlapSamp/(slopes(i)*fs); g = 10.^(-3./(RT(i)*(FUND))); gdb = 20*log10(g); %% here gdb is in the format necessary for Matlab to fit a filter %% to a desired magnitude response
Figure 14 shows the line fit to the decay of the original signal at the fundamental.
Figure 15 shows the extrapolated delay beginning at 0dB to -100dB at the fundamental frequency.