form Truncated-filter spectrum real Filter_width_/_F0 0 positive Maximum_frequency_(Hz) 5000 positive Frequency_step_(Hz) 10 endform Copy... sound tmin = Get starting time tmax = Get finishing time bandwidth = 'Filter_width_/_F0' / (tmax -tmin) fsamp = Get sample rate Copy... filtered nfreq = maximum_frequency div frequency_step + 1 Create Matrix... spectrum 0 maximum_frequency ... nfreq frequency_step 0 1 2 2 1 1 0 for ifreq to nfreq frequency = (ifreq -1) * frequency_step p = -2 * exp (- pi * bandwidth / fsamp) ... * cos (2 * pi * frequency / fsamp) q = exp (- 2 * pi * bandwidth / fsamp) select Sound filtered # Filter with a damped sine. Formula... Sound_sound [col] ... - p * self [col -1] - q * self [col - 2] Multiply... 2 * pi * frequency / fsamp energy_sin = Get energy... tmin tmax # Debugging trick for seeing the sine-filtered sound. ; Edit ;pause Frequency 'frequency' Hertz # Filter with a damped cosine. Formula... Sound_sound [col] - Sound_sound [col -1] ... - p * self [col -1] - q * self [col -2] energy_cos = Get energy... tmin tmax #Store the result. select Matrix spectrum Set value... 1 ifreq sqrt (energy_sin + energy_cos) endfor To Spectrum # The simplest debugging trick: # exit before the intermediate objects are thrown away ;exit # Clean up. select Sound sound plus Sound filtered plus Matrix spectrum Remove select Spectrum spectrum