Csound Csound-dev Csound-tekno Search About

[Csnd] snap to nearest 8th tone

Date2012-10-22 09:22
Frompeiman khosravi
Subject[Csnd] snap to nearest 8th tone
Dear all,

I have modified Joachim's UDO to return midi values in cents rather than semitones:

 opcode F2MC, k, k
kfq xin
knotenum = round(1200 * (log(kfq/220)/log(2)) + 5700)
xout knotenum
  endop

Now I am wondering what is the simplest and most efficient way to snap these values to the nearest 8th tone? I suppose I only want to allow steps of 25cents. Is there a known formula for this?

Many Thanks
Peiman