| I see now that what you are asking is about pitch detection. There are
a lot of different methods of pitch detection, all of which work better
on some material and not so well on others. One method that you could
implement in csound would be the following:
lets say your sample has a fundamental between 100 and 400 hz.
1.) pass your sample through a filter bank with bandpass filters at 100,
150, 200, 300, and 400 Hz, with a width of 1/2 octave.
2.) determine the power of each output. (power can be output * output here)
3.) choose the lowest frequency output which has a power over a
threshold. Your fundamental is within this band (because none of the
lower bands have significant energy).
4.) count each time this output waveform passes from positive to
negative. use delay1 to compare the present sample to the previous. If
the previous is > 0 and the present is < 0, then you have a downward
zero crossing. You are going to have to have kr=sr for the compare to work.
5.) also count the distance in samples between each downward zero
crossing. take sr/distance to give you frequency. Display that for
each zero crossing and you have a basic pitch tracker.
This will give you a very good estimation for a sine wave (obviously an
easy case). For most clearly pitched samples without vibrato this will
work. If you have two notes at 250 and 280 Hz., this will not work.
--
Mike Berry
mikeb@nmol.com
http://www.nmol.com/users/mikeb
|