Dogalog Manual

What is this?

A tiny, Prolog-ish livecoding playground in the browser. You write facts and rules; the engine queries event(Voice, Pitch, Vel, T) every step and plays matching sounds.

New to Prolog or livecoding? Start with the Full Tutorial for a comprehensive guide that teaches both!

Getting started

  1. Open the app (GitHub Pages link in the README).
  2. Click once on the page, then press Start to unlock audio.
  3. Edit rules in the editor — changes load automatically as you type.
  4. Use BPM, Swing, and Lookahead sliders to tweak feel and timing.

Core syntax

Built-ins (music + constraints)

Instruments (voices)

Examples

% Drums
kik(T) :- euc(T, 4, 16, 4, 0).
snr(T) :- euc(T, 2, 16, 4, 4).
hat(T) :- euc(T,11, 16, 4, 0).

event(kick, 36, 0.95, T) :- kik(T).
event(snare, 38, 0.85, T) :- snr(T).
event(hat, 42, 0.25, T) :- hat(T).

% Bass: choose notes every half beat
bass(T, N) :- every(T,0.5), pick([40,43,47,48], N).
event(sine, N, 0.55, T) :- bass(T, N).

% Lead using scale degrees
lead(T, N) :- every(T,0.25), scale(60, ionian, 1, 0, N).
lead(T, N) :- every(T,0.25), scale(60, ionian, 3, 0, N).
lead(T, N) :- every(T,0.25), scale(60, ionian, 5, 0, N).
event(sine, N, 0.4, T) :- lead(T, N).

% Recursive loop over time (bounded)
loop_hats(T, End) :-
  T =< End,
  event(hat, 42, 0.25, T),
  add(T, 0.125, T1),
  loop_hats(T1, End).

start_loop(T0) :-
  event(kick, 36, 0.95, T0),
  add(T0, 0.125, Tstart),
  add(T0, 2.0, Tend),
  loop_hats(Tstart, Tend).

% Recursive walk through a list (motif)
play_seq(T, Step, [N|Ns]) :-
  event(sine, N, 0.5, T),
  add(T, Step, T1),
  play_seq(T1, Step, Ns).
play_seq(_, _, []).
motif(T) :- play_seq(T, 0.25, [60,62,65,67]).

Tips

Dogalog Language Reference

Troubleshooting