My intention was to build an end-user application.
One plays notes on the keyboard and it memorizes and shows them on a
staff. There you can modify the duration of a note and other things
and then playback.
I wanted to implement some other functions: for example, one before
choose the notes on the staff, the program plays it but with no sound
and you have to follow the note and it tells you the errors in playing
them. For example, wrong notes, bad timing...
And well, I don't know yet what else. I have to think.
ad 1) see the other answers
ad 2) use pd (pure data), supercollider or something similar
Another alternative, in case you like lisp (who knows), is to use snd with
the realtime extension:
I used it to make the san dysth softsynth:
Its performance is pretty good, but not perfect. So if that is
important, you can at least you can use snd to make a draft of your
program before you do some hardcore c or assembler programming.
(well, you can define your own functions in c though)