Skip to content

Instantly share code, notes, and snippets.

@nyanpasu64
Last active August 23, 2018 01:54
Show Gist options
  • Select an option

  • Save nyanpasu64/c1d1ff9c998865c3a659e36b82c616cf to your computer and use it in GitHub Desktop.

Select an option

Save nyanpasu64/c1d1ff9c998865c3a659e36b82c616cf to your computer and use it in GitHub Desktop.
FM synthesis

The human ear hears sine waves.

If you hear a complex waveform (like a square wave), the ear decomposes it into sine wave "harmonics", which are all multiples of a "fundamental" frequency.

The human ear identifies pitch as the "fundamental" frequency, AKA the GCD(sine harmonics), AKA period of a waveform.

VRC7 plays a carrier sine at f, and applies FM at g to create a series of sine "harmonics" at f ± y*g for integer y. Loudness decreases as abs(y) increases. If f is 8 and g is 1, the waveform will sound bright, piercing, and bassless (since it only has high frequencies around 8).

The resulting waveform has a period of gcd(f, g), and all "harmonics" are multiples of gcd(f, g), so the ear hears a tone at gcd(f, g).

The FDS plays a waveform containing sine harmonics at x*f, with loudness depending on waveform chosen. FM at g transforms all harmonics at x*f into more harmonics at x*f ± y*g. Loudness decreases as abs(y) increases.

Ixy controls g/f = x/(y+1), with I20 assigning g=f*2/1, and I11 assigning g=f*1/2, and I23 assigning g=f*2/4 ( @crummybowl#7233 ).

If g=f/2, the fundamental is f/2 and waveform is lowered by 1 octave, since harmonics are spaced with an interval of f/2.

Time Trax "bell song" bell is crazy shit.

It outputs two independent 2op tones, at harmonics 7±10n and 13±15n of a subsonic fundamental.

Throw in some detune for good measure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment