# @description A calculator boots clean, then corrupts into a neon glitch portal. Half-time dubstep with psy/goa acid lines. # @tags glitch, acid # dividebyzero.dmt - a calculator that boots clean, then corrupts into a neon # glitch portal. 140 BPM half-time dubstep with psy/goa acid lines. # Original code and music. title DIVIDE BY ZERO song bpm=140 speed=6 rpb=4 channels=8 loop=0 volume=0.62 dither=1 order 0 1 2 3 2 3 4 4 2 3 2 3 5 5 2 3 2 3 5 5 6 6 6 6 # ---------------------------------------------------------------- instruments inst kick { f = 48 + 240 * exp(-t * 34) $p = $p + f / sr body = sin($p * tau) * exp(-t * 6.5) click = hp(noise(), 2600) * exp(-t * 110) * 0.22 out(dist((body * 1.5 + click) * 0.62, 1.2)) } inst snare { n = svf(noise(), 1700 + 2400 * exp(-t * 20), 0.35) body = sin((210 - 90 * exp(-t * 24)) * t * tau) * exp(-t * 18) out((r2 * 0.55 + n * 0.75 + body * 0.3) * exp(-t * 9) * 0.75) } inst hat { n = hp(noise(), 8200 + 2200 * vel) out(n * exp(-t * (38 + 55 * (1 - vel))) * 0.50) } # wobble bass: LFO on the filter, then drive inst wobble { e = env(0.005, 0.12, 0.75, 0.12) rate = 3.2 + 3.8 * sin(t * 0.27 + 1.1) cut = 120 + 1100 * (0.5 + 0.5 * sin(t * rate)) s = saw(ph) + saw(ph * 1.007) * 0.7 s = svf(s, cut, 0.55) out(dist(s * e * 0.32, 2.2)) } inst sub { e = env(0.005, 0.18, 0.70, 0.15) out(sin(ph * tau) * e * 0.32) } # psy/goa acid line: resonant filter, fast decay inst acid { e = env(0.002, 0.06, 0.35, 0.04) s = svf(saw(ph), 280 + 2400 * e + 500 * sin(t * 0.7), 0.72) out(s * e * 0.65) } inst lead { e = env(0.03, 0.25, 0.55, 0.35) s = sin(ph * tau + 0.6 * sin(t * 6.0)) + 0.3 * saw(ph * 1.005) s = svf(s, 1200 + 700 * sin(t * 0.4), 0.3) out(s * e * 0.35) } inst glitch { n = noise() s = step(0.5, hash(floor(t * 90))) * n out(crush(s, 3) * exp(-t * 20) * 0.55) } master { dl = dly(l, 0.34, 0.30) dr = dly(r, 0.51, 0.30) vl = verb(l + dr * 0.18, 0.78, 0.45) vr = verb(r + dl * 0.18, 0.78, 0.45) ml = lp(l + dr * 0.22 + vl * 0.12, 15000) mr = lp(r + dl * 0.22 + vr * 0.12, 15000) out(dist(ml, 1.40), dist(mr, 1.40)) } # ---------------------------------------------------------------- score # channels: 0 kick 1 snare 2 hat 3 wobble 4 sub 5 acid 6 lead 7 glitch pattern 0 rows=16 { C-2 1 26 | . | . | . | D-1 4 32 | . | . | C-6 7 10 . | . | . | . | . | . | . | . . | . | C-6 2 7 | . | . | . | . | . . | . | . | . | . | D-4 5 20 | . | . . | . | . | . | . | . | . | C-6 7 8 . | . | C-6 2 6 | . | . | . | . | . . | . | . | . | . | F#4 5 18 | . | . . | . | . | . | . | . | . | . C-2 1 24 | . | . | . | D-1 4 30 | . | . | . . | . | C-6 2 7 | . | . | . | . | C-6 7 10 . | . | . | . | . | A-4 5 20 | . | . . | . | . | . | . | . | . | . . | . | C-6 2 6 | . | . | . | . | . . | . | . | . | . | C-5 5 18 | . | . . | . | . | . | . | . | . | . . | . | . | . | . | . | . | C-6 7 8 } pattern 1 rows=16 { C-2 1 36 | . | . | D-2 3 34 | D-1 4 36 | . | . | . . | . | C-6 2 10 | . | . | D-4 5 22 | . | . . | . | . | . | . | . | . | C-6 7 10 . | . | C-6 2 8 | . | . | . | . | . . | D-4 2 26 | . | . | . | F#4 5 20 | . | . . | . | C-6 2 9 | . | . | . | . | . . | . | . | . | . | . | . | C-6 7 8 . | . | C-6 2 7 | . | . | A-4 5 22 | . | . C-2 1 36 | . | . | D-2 3 34 | D-1 4 36 | . | . | . . | . | C-6 2 10 | . | . | . | . | C-6 7 10 . | . | . | . | . | C-5 5 20 | . | . . | . | C-6 2 8 | . | . | . | . | . . | D-4 2 26 | . | . | . | A-4 5 22 | . | . . | . | C-6 2 9 | . | . | . | . | C-6 7 8 . | . | . | . | . | F#4 5 20 | . | . . | . | C-6 2 7 | . | . | . | . | . } pattern 2 rows=16 { C-2 1 40 | . | . | D-2 3 40 | D-1 4 40 | . | . | . . | . | C-6 2 12 | . | . | D-4 5 22 | . | C-6 7 10 . | . | . | . | . | . | . | . . | . | C-6 2 9 | . | . | F#4 5 20 | . | . . | D-4 2 34 | . | . | . | . | . | . . | . | C-6 2 11 | . | . | A-4 5 20 | . | C-6 7 8 . | . | . | . | . | . | D-5 6 16 | . . | . | C-6 2 8 | . | . | . | . | . C-2 1 40 | . | . | D-2 3 38 | D-1 4 40 | . | . | . . | . | C-6 2 12 | . | . | C-5 5 22 | . | C-6 7 10 C-2 1 28 | . | . | . | . | . | . | . . | . | C-6 2 9 | . | . | A-4 5 20 | . | . . | D-4 2 34 | . | . | . | . | D-5 6 16 | . . | . | C-6 2 11 | . | . | F#4 5 20 | . | C-6 7 8 . | . | . | . | . | . | . | . . | . | C-6 2 8 | . | . | . | . | . } pattern 3 rows=16 { C-2 1 40 | . | . | A#1 3 40 | A#0 4 40 | . | . | . . | . | C-6 2 12 | . | . | A#4 5 22 | . | C-6 7 10 . | . | . | . | . | . | . | . . | . | C-6 2 9 | . | . | C-5 5 20 | . | . . | D-4 2 34 | . | . | . | . | . | . . | . | C-6 2 11 | . | . | D-5 5 20 | . | C-6 7 8 . | . | . | . | . | . | F-5 6 16 | . . | . | C-6 2 8 | . | . | . | . | . C-2 1 40 | . | . | A#1 3 38 | A#0 4 40 | . | . | . . | . | C-6 2 12 | . | . | A#4 5 22 | . | C-6 7 10 C-2 1 28 | . | . | . | . | . | . | . . | . | C-6 2 9 | . | . | C-5 5 20 | . | . . | D-4 2 34 | . | . | . | . | F-5 6 16 | . . | . | C-6 2 11 | . | . | A#4 5 22 | . | C-6 7 8 . | . | . | . | . | . | . | . . | . | C-6 2 8 | . | . | . | . | . } pattern 4 rows=16 { . | . | . | . | D-1 4 34 | D-4 5 24 | . | . . | . | C-6 2 7 | . | . | D#4 5 20 | . | C-6 7 8 . | . | . | . | . | F#4 5 22 | . | . . | . | C-6 2 6 | . | . | G-4 5 20 | . | . . | . | . | . | . | A-4 5 22 | D-5 6 16 | C-6 7 8 . | . | C-6 2 7 | . | . | A#4 5 20 | . | . . | . | . | . | . | C-5 5 22 | . | . . | . | C-6 2 6 | . | . | D-5 5 20 | . | C-6 7 8 . | . | . | . | D-1 4 34 | F#5 5 24 | . | . . | . | C-6 2 7 | . | . | D-5 5 20 | . | C-6 7 8 . | . | . | . | . | C-5 5 22 | . | . . | . | C-6 2 6 | . | . | A#4 5 20 | . | . . | . | . | . | . | A-4 5 22 | D-5 6 16 | C-6 7 8 . | . | C-6 2 7 | . | . | G-4 5 20 | . | . . | . | . | . | . | F#4 5 22 | . | . . | . | C-6 2 6 | . | . | D-4 5 20 | . | C-6 7 8 } pattern 5 rows=16 { C-2 1 40 | . | . | F-2 3 40 | F-1 4 40 | . | . | . . | . | C-6 2 12 | . | . | F-4 5 22 | . | C-6 7 10 . | . | . | . | . | . | . | . . | . | C-6 2 9 | . | . | G#4 5 20 | . | . . | D-4 2 34 | . | . | . | . | . | . . | . | C-6 2 11 | . | . | A#4 5 20 | . | C-6 7 8 . | . | . | . | . | . | C-5 6 16 | . . | . | C-6 2 8 | . | . | . | . | . C-2 1 40 | . | . | F-2 3 38 | F-1 4 40 | . | . | . . | . | C-6 2 12 | . | . | F-4 5 22 | . | C-6 7 10 C-2 1 28 | . | . | . | . | . | . | . . | . | C-6 2 9 | . | . | D#5 5 20 | . | . . | D-4 2 34 | . | . | . | . | C-5 6 16 | . . | . | C-6 2 11 | . | . | C-5 5 20 | . | C-6 7 8 . | . | . | . | . | . | . | . . | . | C-6 2 8 | . | . | . | . | . } pattern 6 rows=16 { C-2 1 40 | . | . | D-2 3 40 | D-1 4 40 | . | . | C-6 7 12 . | . | C-6 2 8 | . | . | . | . | . . | D-4 2 30 | . | . | . | . | . | C-6 7 10 . | . | . | . | . | . | . | . C-2 1 30 | . | . | . | . | . | . | . . | . | . | . | . | . | . | C-6 7 12 . | . | . | . | . | . | . | . . | . | . | . | . | . | . | . C-2 1 40 | . | . | D-2 3 40 | D-1 4 40 | . | . | . . | . | C-6 2 8 | . | . | . | . | C-6 7 12 . | D-4 2 30 | . | . | . | . | . | . . | . | . | . | . | . | . | . C-2 1 30 | . | . | . | . | . | . | . . | . | . | . | . | . | . | C-6 7 10 . | . | . | . | . | . | . | . . | . | . | . | . | . | . | . } # ---------------------------------------------------------------- visuals text BRAND "GLITCH-01" text KEYS "789+456-123*0.=C" text ERR "ERROR" text DIV "DIVIDE BY ZERO" uniform kickE snareE hatE bassE padE acidE glitchE chaos fn textline(s, px, py, sz) { cx = (u - px) / sz cy = (py - v) / sz i = floor(cx) return glyph(str(s, i), fract(cx), fract(cy)) * step(0, cx) * step(cx, strlen(s)) * step(0, cy) * step(cy, 1) } frame { kickE = exp(-trig(0) * 8) snareE = exp(-trig(1) * 10) hatE = exp(-trig(2) * 18) bassE = cenv(3) padE = cenv(4) acidE = cenv(5) glitchE = cenv(7) chaos = smooth(4.0, 36.0, t) + 0.25 * smooth(36.0, 44.0, t) } pixel { # psychedelic desk / portal behind the calculator rb = len(u, v + 0.02) + 0.03 ab = atan2(v, u) bh = fract(0.56 + 0.08 * sin(t * 0.15) + 0.10 * sin(ab * 3.0 + rb * 5.0 - t * 0.6)) hsv(bh, 0.72, 0.16 + 0.30 * chaos) br = cget(0) bg = cget(1) bb = cget(2) rings = pow(0.5 + 0.5 * sin(rb * 14.0 - t * 1.4 + 2.0 * sin(ab * 5.0 + t * 0.7)), 8) br = br + rings * 0.22 * chaos bg = bg + rings * 0.10 * chaos bb = bb + rings * 0.38 * chaos # calculator body, warped by chaos wob = 0.09 * chaos * sin(v * 13.0 + t * 3.0) + 0.04 * chaos * sin(u * 17.0 - t * 2.3) + 0.035 * chaos * sin(v * 31.0 + t * 7.0) cu = u + wob cv = v + 0.025 * chaos * cos(u * 11.0 + t * 1.7) qx = abs(cu) - 0.36 qy = abs(cv) - 0.52 dbody = len(max(qx, 0.0), max(qy, 0.0)) + min(max(qx, qy), 0.0) - 0.10 + 0.05 * chaos * sin(cu * 21.0 + t * 5.0) * sin(cv * 17.0 - t * 4.0) body = 1 - smooth(0.0, 0.014, dbody) edge = exp(-abs(dbody) * 90.0) * body # face: grey plastic, neon under chaos baseHue = fract(0.58 + 0.25 * chaos + 0.05 * sin(t * 0.4)) hsv(baseHue, 0.10 + 0.55 * chaos, 0.14 + 0.22 * chaos) cr = cget(0) cg = cget(1) cb = cget(2) br = mix(br, cr, body) bg = mix(bg, cg, body) bb = mix(bb, cb, body) br = br + edge * 0.35 bg = bg + edge * 0.32 bb = bb + edge * 0.30 # display window disp = (1 - smooth(0.34, 0.35, abs(cu))) * (1 - smooth(0.10, 0.11, abs(cv - 0.38))) if (disp > 0.001) { hsv(fract(0.30 + 0.08 * chaos), 0.55, 0.08 + 0.15 * chaos) dr = cget(0) dg = cget(1) db = cget(2) br = mix(br, dr, disp) bg = mix(bg, dg, disp) bb = mix(bb, db, disp) # eight digits across the display dcell = (cu + 0.30) / 0.075 di = floor(dcell) df = fract(dcell) dv = floor(hash(di * 17.0 + floor(t * (3.0 + 18.0 * chaos))) * 10.0) dgx = df dgy = (0.45 - cv) / 0.14 dgly = glyph(48 + dv, dgx, dgy) * step(0, dcell) * step(dcell, 8.0) * step(0, dgy) * step(dgy, 1) br = br + dgly * (0.55 + 0.45 * chaos) bg = bg + dgly * 0.85 bb = bb + dgly * (0.45 + 0.55 * chaos) dp = (1 - smooth(0.006, 0.0, len(cu + 0.26, cv - 0.36))) * 0.8 br = br + dp bg = bg + dp * 0.8 bb = bb + dp * 0.4 brd = textline(BRAND, -0.28, 0.53, 0.030) * (1 - 0.7 * chaos) br = br + brd * 0.35 bg = bg + brd * 0.38 bb = bb + brd * 0.40 er = textline(ERR, -0.14, 0.38, 0.070) * smooth(0.72, 0.90, chaos) br = br + er * 1.0 bg = bg + er * 0.15 bb = bb + er * 0.10 if (chaos > 0.55) { pr = len(cu, (cv - 0.38) * 1.5) + 0.03 pa = atan2(cv - 0.38, cu) prings = pow(0.5 + 0.5 * sin(pr * 38.0 - t * 4.0 + 3.0 * sin(pa * 5.0 + t * 0.8)), 8) br = br + disp * prings * 0.85 bg = bg + disp * prings * 0.25 bb = bb + disp * prings * 0.95 } } # keypad: 4 x 4 buttons kx = (cu + 0.36) / 0.18 ky = (cv + 0.50) / 0.125 kci = floor(kx) kcj = floor(ky) kfx = fract(kx) kfy = fract(ky + chaos * 0.45 * hash(kci * 3.1 + kcj * 5.7)) keyArea = step(0, kx) * step(kx, 4.0) * step(0, ky) * step(ky, 4.0) key = (1 - smooth(0.47, 0.49, abs(kfx - 0.5))) * (1 - smooth(0.45, 0.47, abs(kfy - 0.5))) * keyArea * body ksel = hash(kci * 7.1 + kcj * 13.7) kmove = step(ksel, chaos * 0.95) key = key * (1 - kmove) if (key > 0.001) { keyHue = fract(0.55 + 0.10 * kci + 0.06 * kcj + 0.18 * chaos) hsv(keyHue, 0.08 + 0.55 * chaos, 0.18 + 0.10 * chaos) kr = cget(0) kg = cget(1) kb = cget(2) br = mix(br, kr, key) bg = mix(bg, kg, key) bb = mix(bb, kb, key) br = br + key * 0.30 * kickE bg = bg + key * 0.10 * kickE bb = bb + key * 0.35 * kickE ki = kci + (3.0 - kcj) * 4.0 kgx = 0.10 + kfx * 0.80 kgy = 0.10 + (1.0 - kfy) * 0.80 kl = glyph(str(KEYS, floor(ki)), kgx, kgy) * key br = br + kl * 0.60 bg = bg + kl * 0.62 bb = bb + kl * 0.66 } # final split: the calculator itself starts to tear tear = step(0.55, hash(floor(u * 10.0) + floor(v * 12.0) * 17.0 + floor(t * 18.0))) * chaos if (tear > 0.5) { cadd(0.12, 0.02, 0.18) } # doom text at the meltdown dt = textline(DIV, -0.27, -0.02, 0.045) * smooth(0.85, 1.02, chaos) br = br + dt * 1.0 bg = bg + dt * 0.10 bb = bb + dt * 0.20 # white-hot overload br = br + chaos * kickE * 0.25 bg = bg + chaos * kickE * 0.10 bb = bb + chaos * kickE * 0.30 rgb(br, bg, bb) } post { cr = tap(0.0, 0.0) cg = r1 cb = r2 # block displacement / datamosh, stronger with chaos gx = floor(x * 26.0) gy = floor(y * 22.0) gl = step(0.50, hash(gx * 3.1 + gy * 7.7 + floor(t * 18.0))) * chaos ox = (hash(gx * 1.7 + gy * 9.1 + floor(t * 14.0)) - 0.5) * 0.10 * gl oy = (hash(gx * 8.3 + gy * 2.9 + floor(t * 14.0)) - 0.5) * 0.05 * gl tr = tap(ox, oy) tg = r1 tb = r2 cr = mix(cr, tr, gl * 0.85) cg = mix(cg, tg, gl * 0.70) cb = mix(cb, tb, gl * 0.90) # row tearing tear = step(0.82, hash(floor(y * 90.0) + floor(t * 22.0))) * chaos tr = tap(0.018 * tear, 0.0) cr = mix(cr, tr, tear * 0.7) # RGB split tr = tap(0.003 * gl, 0.0) cr = mix(cr, tr, gl * 0.7) tr = tap(-0.003 * gl, 0.0) cb = mix(cb, tr, gl * 0.7) # posterise and scanlines as it goes q = 4.0 + 28.0 * (1.0 - chaos) cr = floor(cr * q + 0.5) / q cg = floor(cg * q + 0.5) / q cb = floor(cb * q + 0.5) / q scan = 0.88 + 0.12 * sin(y * 900.0) cr = cr * scan cg = cg * scan cb = cb * scan # vignette and grain vg = 1.0 - 0.35 * smooth(0.45, 1.10, len(u * 0.9, v)) cr = cr * vg cg = cg * vg cb = cb * vg gr = hash(x * 911.0 + y * 277.0 + frame * 19.0) - 0.5 cr = cr + gr * 0.025 cg = cg + gr * 0.025 cb = cb + gr * 0.025 fl = smooth(40.0, 40.25, t) * (1.0 - smooth(40.35, 41.0, t)) cr = cr + fl * 1.4 cg = cg + fl * 1.3 cb = cb + fl * 1.5 rgb(cr, cg, cb) }