Hi again,
Davide Morelli wrote:
I googled a bit and I always found that deltime should be deltime (sec) = 1/Freq(Hz)
example: to get a A440 sound I should deltime (msec) = (1/440)*1000
I can't remember where I found this formula, but most of the Karplus-Strong algorithms I've looked up account for the sampling rate. Those that don't assume a fixed sampling rate. The algorithm you found is one of those that assume a fixed rate of 44100:
deltime (sec) = 1/Freq(Hz)
MIDI note 45 = 110 Hz
(1 / 110 Hz) = 0.00909 0.00909 * 1000 = 9.09 ms
why must we do deltime (msec) = (samplerate~ / Freq(Hz)) / 1000 instead?
Sorry, I misread my own patch! The proper version is below, and you will happily note it gives the same result as yours given a sampling rate of 44100:
deltime (msec) = (samplerate~ / Freq in Hz) / (samplerate~ / 1000)
MIDI note 45 = 110 Hz
(44100 Hz / 110 Hz) = 400.9 (44100 Hz / 1000) = 44.1 400.9 / 44.1 = 9.09 ms
The benefit of this method is that other sampling rates can be used. Higher sampling rates allow for higher frequencies to be generated, as is usually the case in DSP.
best, derek