Smaller version of this is 1kilobyte, can be found here: khoin/1kfm
This is a FM (PM) synthesizer that runs in your web browser. Its file size is 2048bytes (index.html). You can check out the commented source in uncompressed.html.
- 6 Operators
- ADS (Attack, Decay, Sustain) Envelope
- Theoretical 32-voice polyphony (on my computer, no keyboard events fired after holding down 6 keys)
- Arbitrary operator routing. Any operators can route to any other operators, even self. They can be carriers and/or modulators.
- Saving and loading patches
- C4-A5 keyboard (corresponding to 2 top rows on your keyboard, Q to backslash).
- Bitmap font 0-9ADSICTO at 160 bytes + 59 bytes (for pixel drawing)
- Bresenham line drawing at 159 bytes + 59 bytes (for pixel drawing)
- DSP + keyboard mapping is at 668 bytes
- The rest: GUI, mouse, patch save/load 754 bytes
- It is not possible for modulators (that does not go directly to output) to be silent. I did this so that we can skip calculations if an operator have zero volume.
- No release envelope stage :c
- No fixed frequency mode.
- It is not a DX7 emulator :c I first wanted it to be one.
- On my machine, if you don't have any modulation, it doesn't lag. But if you do, it usually lags out at 3-4 voices. On my machine, it appears that Firefox's script processor isn't as fast.
<meta charset=utf8>
was added so the GUI would render correctly in Firefox and Edge.
This part assumes you know synthesis concepts. Here's a diagram:
- Glass Keys
- Saw Bass
- Chord Brass-like Synth
- Organ
- Flute (You have to turn the Tune parameter to some other value, then back to 0 again to feed the noise)
- Thanks Werner for showing me more efficient way of PM/FM synthesis
- p01 for such awesome 1k demos that got me into this.
Public Domain.