Generating music

using tiny programs

provod/jetlag, me@provod.gl

https://provod.gl/talks/2023-synthfest/

v1.1

How to make sound with a computer?

Just use 512 floppy drives, some scanners, and what else

Floppotron3

Or you don't need a computer at all

Freespin by Reflex, C64 floppy drive, (2021)

Jokes aside

  • This is special hardware
  • It is old
  • We need something more modern
  • Like GPUs

And their coil whine

Coil whine music test by Optimus6128

For real this time

  • There are dedicated hardware sound chips and sound cards
  • Feed them with right controls → get desired sound
  • People have been abusing these devices creatively
  • particularly (but not limited to) the Demoscene community
  • Here we'll focus on the size aspect of creativity:
    Creating more in fewer bytes.

Oldschool

  • Early 1980s home computers
  • Sound chips which made simple waveforms
  • Example: MOS 6581 (SID)
    • 3x triangle, saw, pulse, noise
    • ADSR, simple filters

Some chips didn't even have that and were simple beepers.

Megademica 4K by Serzhsoft (2019)

4KiB intro for ZX Spectrum 48K + AY

Mus1k by Orb (2008)

1KiB musicdisk for Commodore 64 (SID)

MIDI

  • Sequencer for a hardware sampler
  • Pre-recorded set of "natural instruments" samples
  • Different hardware, different quality and timbres
  • Sounds "rigid", not super popular
  • But very size efficient: a note is just three bytes: instrument, note, velocity (volume)
  • Many 256 bytes intros use it for music

Function(20) by Abaddon (2022)

256 bytes intro for PC/MS-DOS

Farewell by Desire (2023)

256 bytes intro for PC/MS-DOS

Trackers

  • Amiga computer, late 1980s
  • 4 channels of 8bit PCM sound @ 28kHz
  • No more limited waveforms fixed in hardware!
  • Can make arbitrary sounds and use samples!
  • Tracker is sequencer for pre-recorded samples
  • By early 1990 there are lots of trackers for everything
  • Majority of computer music until 2000s

Small tracker music example

-- c h i p -- by cueder (1995), 12.3KiB, 4 channels, MOD
Usva by Little Bitchard (2003), 12KiB, 8 channels, XM
Fast Tracker II for PC/MS-DOS (1997)

Making sound with math™

  • No prerecorded samples or builtin waveforms
  • Make a function 𝑓(𝑡) returning signal at time 𝑡
  • Generate a stream of numbers (samples)
  • Typically signed 16 bit integers at 44100Hz
  • (but can be 32 bit floating point at 48kHz as well)

Making music is just producing 44 thousands numbers per second

Bytebeat

  • Is a surprising way to synthesize sounds using just a few integer operations. Discovered/popularized around 2011 by viznut.
  • Seemingly random sequence of bitwise ops can get rich timbres, melodies and rhythm structures.
  • There's no strong comprehensive theory about it yet, this space is still being explored.

Sierpinski harmony by miiro

CA98 by rrrola & ryg

Reverse of "rrrola"

"Running man"

Fractalized past

incoming Transmission by Citavia

64 bytes intro for PC/MS-DOS, (2022)

Learn more about bytebeat

Bespoke softsynths

Traditional synthesis is also not that complex.
For example:
  • Sine wave is
    sin(time * frequency * pi * 2)
  • Taking fractional part of time * frequency you get a phase that goes from 0 to 1 frequency times per second
  • Then sawtooth is just the phase itself
  • Square is getting -1 for phase < 0.5 and 1 otherwise
  • graphtoy.com is very useful!

live demo time!

ikubun by fsqrt&jetlag (2018)

256 bytes for PC/MS-DOS

Generating audio using video cards

  • The live demo was done using shadertoy.com
  • It was written in GLSL, and ran as a fragment shader
  • Shaders were designed for computing pixel colors
  • Pixels are drawn offsreen and then their numeric values are interpreted as audio samples
  • One Full HD 1920x1080 screen is roughly 2M pixels
  • If each pixel is 4 color values then for 2 channels it is 2M*2/48000 = 86 seconds of music

Shader music caveats

  • Cannot directly read previous values. Therefore no feedback, no easy delay/reverb, no IIR filters, etc
  • 32 bit floating point precision for time is not enough, audible artifacts after 30 seconds
  • Music length is limited to 60 seconds on shadertoy.

sampler by w23 (2015)

WebGL GLSL shader on shadertoy

SHTOY128 by and (2015)

WebGL GLSL shader on shadertoy

final stage by 0x4015 (2017)

4 KiB intro for modern PC/Windows
GLSL softsynth + bytebeat

Softsynths for producers

  • Not everyone is happy coding their own softsynth from scratch with raw math
  • Plug-and-Play synthesizers for small intros, full with VST and DAW support exist!
  • There are many:

4klang

  • Softsynth for 4 KiB intros
  • VST module for any DAW plus assembly source for an intro
  • VST module has an export button that writes track data file
  • 1 KiB synth code + 1 KiB music data
  • 2 KiB is left for visuals

Typical 4klang window

Absolute Territory by Prismbeings

4 KiB for modern PC/Windows, 4klang, (2017)

Transient by LJ & Virgill (2018)

4 KiB for modern PC/Windows, 4klang

trashpanda by Logicoma (2018)

64 KiB for modern PC/Windows, wavesabre
...

A mind is born by lft (2017)

256 bytes intro for Commodore 64

Thank you!

greetings:
abaddon, alcatraz, and, citavia, cueder, desire, farbrausch, ferris, frag, gopher, hellmood, iq, keen, lft, little bitchard, lj, logicoma, macau exports, marquee design, miiro, monad, noby, ob5vr, optimus, orb, prismbeings, reflex, rrrola, ryg, serzhsoft, silent, sthephan.shi, virgill, viznut
all sizecoders and bytebeat musicians

Extras

More bytebeat

More bytebeat

More bytebeat

More MIDI in 256 bytes

More MIDI in 256 bytes

More MIDI in 256 bytes

More MIDI in 128 bytes

64k, wavesabre

64k, wavesabre

64k, glsl, javascript