Preimage::Collision
Deterministic musical suggestions from a hash digest with Web Audio rendering of hash-derived samples in C4.
Digest
Musical Suggestions
Example Lines (first N steps)
How variables are derived
Overview — The application deterministically maps pieces of the hex digest into musical parameters. Different bytes and nibbles control different aspects (tempo, key, scale, instruments, drum patterns and velocities). The same input and algorithm will always produce the same suggestions.
Tempo — Suggested tempo is based on digest length: short digests → faster tempos, longer digests → slower tempos. This gives shorter hashes a quicker, loop-like feel and longer digests a more spacious tempo.
Key / Root — The root note is derived by folding a few representative bytes (first, middle, last) and mapping the result into a circle-of-fifths table. This biases roots toward musically useful tonal centers while still depending on the digest bits.
Scale — Scale selection mixes the digest "brightness" (average nibble value) with byte-derived offsets to pick a scale from a pre-defined list (major, minor, modal, pentatonic, maqams, ragas, etc.). Brighter digests tend to choose "brighter" scales.
Instruments & Timbres — Specific bytes (early bytes in the digest) select instrument families and timbral presets: e.g., kit type (acoustic/electronic/glitch), bass wave shape, lead timbre and solo characteristics. Small changes in those bytes will yield different synth waveforms, envelopes and effects (reverb/delay).
Velocities — Velocity is computed from adjacent hex characters (pairs of nibbles). These pairs are scaled into a 0–1 range and binned into marks like pp/p/mf/f/ff. The example lines show those marks; the volume key gives approximate percentages.
Drum patterns — Drum patterns are generated by splitting the digest into sections and using bits/nibbles to decide hits on a 16-step grid. The first half of the digest controls Pattern A and the second half controls Pattern B; bit masks create variation while preserving rhythmic logic (downbeats/backbeats/fills).
Hats mask — The hi-hat mask is taken from a specific byte and used as an 8-bit pattern; each set bit becomes a hat hit in that position, giving deterministic syncopation from the digest bits.
Melody mapping — Letters and digits in the hex digest are mapped to different voices: digits tend to generate bass notes, letters generate lead notes. Mapping functions place values into the chosen scale's pool (across several octaves), with phrasing decided by small phrase sums and rests derived from hash arithmetic.
Phrasing & Rests — The solo melody is phrase-based (for example, 4-step phrases). The generator sums small sections of the digest to decide whether each phrase is active, and certain two-hex-character combinations produce rests to create natural-sounding gaps.
WAV Audio Synthesis — The "Render" buttons create actual audio samples using Web Audio API's OfflineAudioContext. Each instrument (bass, lead, solo) uses hash-derived parameters to configure oscillators, filters, envelopes, and effects. For example: bass waveform (sine/triangle/square/saw) from byte 1, filter cutoff frequency from byte 2, envelope shape from specific nibbles. The solo instrument adds modulation (vibrato/tremolo/FM) and delay based on additional hash bytes. Drum samples use similar synthesis with noise generators and filters tuned by kit type and character bytes.
Deterministic Audio — All synthesis parameters come directly from the digest bytes, so the same hash always produces identical WAV files. The C4 samples are rendered at 44.1kHz with fade-in/out to avoid clicks, then encoded as downloadable WAV blobs. Each instrument gets 2-3 seconds of audio to showcase its hash-derived timbre and envelope characteristics.
Why multiple algorithms/scales matter — Choosing a different hash algorithm or scale changes which bits are where and how they map into parameters; the UI exposes many algorithms and scales so you can explore a wide palette of musical impressions from the same input text.
The debug panel below shows the exact bytes/nibbles used for each decision for the last generated digest (helpful for tuning and learning how small changes affect the music).
Last digest debug (show bytes/nibbles used)
Render Hash-Derived Audio Samples
Melodic Instruments
Drum Kit
Exact WAV Synthesis Mapping
Bass Instrument (C4 @ 261.6 Hz):
- Byte 1 (hex pair 2-3) → Waveform: <64=sine, 64-127=triangle, 128-191=square, ≥192=sawtooth
- Byte 2 (hex pair 4-5) → LPF Cutoff: 60 + (2000-60) × (byte/255) Hz
- Nibble 4 (hex char 5) → Envelope: contains letter (a-f) = plucky (attack=5ms, decay=200ms, sustain=15%), else sustain (attack=10ms, decay=400ms, sustain=70%)
- Filter Q: plucky=0.4, sustain=0.2
Lead Instrument (C4 @ 261.6 Hz):
- Nibble 5 (hex char 6) → Timbre: 0-3=mellow(triangle), 4-7=synth(sawtooth), 8-11=driven(sawtooth+distortion), 12-15=airy(sine)
- Nibble 6 (hex char 7) → Envelope: ≤7=staccato (attack=5ms, decay=150ms, sustain=30%), else swell (attack=250ms, decay=400ms, sustain=80%)
- Nibble 7 (hex char 8) → Glide: (nibble/15) × 200ms portamento (ignored for single C4)
- Byte 3 (hex pair 6-7) → Reverb: 0.10 + 0.50 × (byte/255) wet mix
- Driven distortion: tanh(2.5x) waveshaping when timbre=driven
Solo Instrument (C4 @ 261.6 Hz):
- Byte 4 (hex pair 8-9) → Character: <64=melodic, 64-127=percussive, 128-191=ambient, ≥192=aggressive
- Byte 5 (hex pair 10-11) → Waveform: <64=sine, 64-127=triangle, 128-191=sawtooth, ≥192=square
- Byte 6 (hex pair 12-13) → Modulation: <64=none, 64-127=vibrato(5.5Hz, depth=8), 128-191=tremolo(7Hz, depth=0.3), ≥192=FM(ratio=2.1, index=200)
- Byte 7 (hex pair 14-15) → Delay: 0.05 + 0.45 × (byte/255) seconds, feedback=0.3, wet=0.4
- Character envelopes: melodic(100ms attack), percussive(10ms attack), ambient(800ms attack), aggressive(20ms attack + tanh(4x) distortion)
Drum Synthesis:
- Kick: Sine/triangle oscillator, pitch envelope (2×base→base freq), amp envelope, LPF. Base freq: acoustic=50Hz, electronic=65Hz, glitch=45Hz
- Snare: Triangle oscillator + white noise, HPF + LPF. Dry: 200Hz tone, 300Hz HPF, 4kHz LPF. Bright: 250Hz tone, 500Hz HPF, 8kHz LPF
- HiHat: White noise through HPF + LPF. Acoustic: 8-12kHz. Electronic: 10-15kHz. Glitch: 6-18kHz with Q=2.0
All WAVs: 44.1kHz, 16-bit PCM, 512-sample fade in/out, encoded as downloadable .wav blobs