Trying to get ntof and mtof opcodes to read notes from score p-field

Hi, I’m a semi skilled Csound user, trying to use a more musical notation like 4C, 2F#, etc. (or just midi note numbers) in my score file, rather than the more numeric approaches like octave.semitone or pitch in Hz.

I’ve tried to use the ntof opcode to read my p4 parameter column, to turn notenames into frequency in Hz, but it gives me chronic syntax errors.

The same for mtof, ie. read p4 to turn midi note numbers into Hz, unfortunately.

I would love it if someone could show me a working example of how to make these opcodes work please. I’ve been puzzling over whether their use in my instrument definition has been causing a type mismatch between i and k rates, but I’m running out of things to try.

Many thanks!


mtof and similar are relatively new opcodes, I don’t remeber since which version they are supported. Perhaps your Csound is a bit older? Or you use the Web IDE (I think that is based on an older Csound, too). Anyway there are equivalence amoung older opcodes like
cpsmidinn notnum etc - sorry, cannot check right now.

Hope it helps!


Kontakt Matt via The Csound Community (<>) kirjutas kuupäeval L, 23. oktoober 2021 kell 14:12:

1 Like

please post your code and your “chronic syntax errors” — then we can
try out and (hopefully) help!

1 Like

Hi! cpsmidinn does actually work! I just need to convert all the notes on my paper score to numbers now, and that will get me going. That’s tonight’s homework defined…

I’ll report back with my errors on the other stuff later. For all I know, it could well be that the Csound version used by the Web IDE isn’t implementing mtof/ntof, although the IDE does turn these opcodes purple when typed, as though it recognises them. Curious.

Thanks so much