Andy Hulstkamp

about creating online experiences

21. August 2008

Frequency Modulation (FM) in Flash

Frequency Modulation was discovered by John Chowning back in the 60s, while experimenting with vibrato. Basically in FM-Synthesis the frequency of one oscillator (carrier) is modulated by the signal of another oscillator (modulator). The great thing about FM-Synthesis is that it can produce a wide range of sounds with relatively little computing cost, cause we only need to generate 2 basic waveforms to get started. Ideal for environments like flash where you have to watch your fps carefully.

Frequency Modulation in Flash

Here’s a little test. Please turn down volume first. Needs the latest Flash-Player 10 (rc of 091508).

Note: To get a constant timbre over different notes (pitch) we’d need to control the modulation index. This might follow in another post.

If you want to have a look at the source, here it is (flex sdk 4.0.0). UPDATE: Adobe changed the sound api. Use SampleDataEvent.SAMPLE_DATA instead of Event.SAMPLE_DATA for the listener.

further reading

Generating Sounds. Waveforms, Timbre Loundness and Pitch.

Introduction to generating sounds covering samplerates, waveform, timbres and pitch. In Flash but should be applicable to any technology.

From cacophony to music - generative music

Experiment in generative music. Goal is to create a simple driver that produces an endless tune, which sounds better than a random mess.