I'm thinking about using a realtime FM synth for music and sound effects in my next game. I'd write a library myself, but I don't want to waste my time if there's already something good out there. The thing is, google turned up no results. Am I going to have to get cracking on my own?
Name:
Anonymous2009-12-13 18:27
OP here. Anyone who understand how FM synthesis works and doesn't just enjoy the way it sounds, please shed some light for me.
As I understand it, FM synthesis works as follows: Constantly output a sine wave (actual waveform doesn't matter, but I'll use it for simplicity's sake) of a certain frequency to your speaker. Use another sine wave to alter that sine wave's frequency. At low frequencies, it will sound like vibrato, but as up increase the frequency, the sound becomes distorted. Use more sine waves to alter that sine wave, route different sine waves to the speaker, etc, until you have a decent sounding instrument.
If that is true, it would not be terribly difficult to create an FM synthesizer. Samples are integers, correct? Therefore, all we would need would be a sample output library and a sine generating function. 48000 times per second (maybe more, I don't know much more than the basics of FM), we calculate a sine wave based off of the time elapsed. The value of this sine wave is then routed to another sine wave, and so on, until we reach the sine that will be heard by the speaker. The value of this sine we convert into a sample and forward to the sound output library.
Is that all that is needed to do FM synthesis on a modern computer? ADSR envelopes, filters, etc can be implemented as well. Don't bite my head off if I'm forgetting something stupid; all that I know about FM, I've learned from dicking around with Analog Box 2 and reading random articles on the internet.