Atari and basic based games of old literally just used circuitry to do it. If you want to be able to control all of this stuff in real time, you really need a decent threaded, real time sample generator to feed your game's audio based off of messages sent to it. Quite a bit more complex than would really be worth it, unless the music is a major component of your game. If this is in fact what you're after, my suggestion would be PortAudio, a library for C/C++ that allows for such fine grained, real time audio, in a cross platform library.
If you just want retro audio, grab any number of free synthesizer software that's out there, and fiddle around until you get sound effects you can save as wav, mp3 or ogg vorbis audio, then simply load that and play them at the right times. Just about any synthesizer software has this stuff, though, understandably, you won't be able to do much with changing how long a note is sustained, since the results would be pre-recorded.