moondsp is a score you can read, draw, and hear. Every phrase is code; the grid under your cursor edits that same code, even while it plays. Press Play, change a note, and listen. Undo always brings it back.
Play a starting sound
Place the code cursor in a note("…") phrase. Its note grid opens directly beneath the code. Rows are pitches; time runs left to right. Click a block to select its source note. Click or tap an empty source-rest interval to place a note at that pitch. Releasing the pointer commits; Escape cancels the preview and Undo restores the phrase.
note("…")
Drag a note up/down to change pitch and sideways to reorder it within its written sequence. Occupied steps shift rather than being overwritten; the moved note keeps its weight and repetitions. Horizontal movement follows source steps, not arbitrary time positions. Drag a note's left or right edge to trade time with its adjacent source step while keeping the other boundaries fixed. A dashed preview shows the result before release.
To edit several notes together, turn on Select and drag from the first source step to the last, or use Left/Right to extend or shrink the selection. Select again or Escape leaves selection mode. Drag a selected note to move the whole range; Up/Down transposes it and Alt+Left/Right moves it one sibling step. The same complete source range can be selected in code. Duplicate inserts an independent copy after the range, adding steps within the notation's existing cycle; Repeat keeps occurrences linked. Neither operation overwrites other notes. Ranges stay within one written sequence.
Shift-drag a note, or start drawing in empty grid space, to change a contour across existing notes in one edit without filling crossed rests. Open Structure for source steps and nested groups. Split divides one written step into two; Repeat edits its *n suffix. Repeated appearances stay linked to the same source step. Drag a source-strip boundary, or adjust Share, to trade time with the next sibling. Rest writes ~ without removing suffixes. On a selected rest, Add note or Add chord uses a neighboring value, or C4/C when the phrase is entirely rests.
*n
~
Use Play to hear your score, including its tempo, effects, and other parts. Editing never starts a separate preview. You can keep editing during playback; changes take effect at each part's next entry. Near an edited phrase, Queued and Sending mean the edit is not accepted yet. Accepted · score still updating reports score-wide pending material, not proof that this phrase is already sounding. The notice clears when the current score has no pending changes. Ctrl/⌘+Enter toggles Play/Pause from the code or drawing.
Tab focuses the grid. Left/Right selects a source step; Up/Down changes a note by one semitone. Alt+Left/Right moves the selected note one source step; Shift+Left/Right resizes its right boundary. Delete/Backspace clears it to a rest. Enter starts a drawing, arrows move its preview, and Enter commits. For a selected rest, Enter starts note entry, Up/Down chooses the pitch, and Enter commits. Escape cancels unfinished edits and returns to code. Ctrl/⌘+Z and Ctrl/⌘+Shift+Z share Undo and Redo.
Place the cursor in chord("C Am F G7") and select a numbered chord. Drag one of its tone blocks up or down to change that note. Drag Move chord to transpose all its notes together. Tap an empty pitch row or use Add tone to add a note; select a block and use Remove tone to remove it. Lower/Raise changes the selected tone, or the whole chord when Move chord is selected. The outlined source step is the one you are editing; filled steps and tones follow actual playback.
chord("C Am F G7")
Drag previews do not change the score until release. Escape cancels; each completed change shares Undo and the main Play transport. In the tone grid, Left/Right selects a tone, Up/Down changes its pitch, Shift+Up/Down moves an octave, and Delete removes it. Move chord also accepts Up/Down. Add tone supports keyboard entry into a rest. Notes already present and pitches outside MIDI 0–127 are rejected, not silently merged.
The source uses a chord name when it describes the exact notes; other voicings and inversions use explicit pitches such as chord("{64,67,72}"). Removing every tone writes ~. Weights, repetitions, and surrounding code stay intact. Choose by chord name offers optional Root/Type choices for named chords; these are unavailable for custom sets. View chord tones opens a separate inspection of the whole progression: its blocks select whole chords, not individual notes. Repeated occurrences stay linked to the same written chord. Slash-bass names are not supported; edit the tones directly instead.
chord("{64,67,72}")
In s("…"), rows choose Kick, Snare, Hi-hat, Open hat, or Clap. Tap an empty cell to set that sound; tap a filled cell to clear it to ~. Choosing another row replaces that step's sound. Click a column number to select without editing. Arrow keys move between cells; Space/Enter edits, and Escape returns to code.
s("…")
Each column is one written source step, not an equal slice of playback time. Weights, nested groups, and repeated occurrences stay linked to the source; open Structure for group and boundary edits. The matrix scrolls horizontally on narrow screens. Simultaneous layers remain in code. These are the existing built-in percussion sounds, not sample-file import.
s("bd ~ sd ~") plays a kick, a rest, a snare, then a rest. The spaces divide the pattern into equal steps.
s("bd ~ sd ~")
note("C4 E4 G4 ~") does the same with pitches. Numbered steps select without changing the score or starting playback. Choose a key to change the selected note. Rest clears it; Add note fills a selected rest. Undo restores the previous value.
note("C4 E4 G4 ~")
Pitch controls contains the chromatic keyboard and octave browsing. The keyboard runs from low to high; Octave −/+ browses without editing. Its open state follows the phrase for this session.
Left/Right moves between numbered steps or pitch keys; Space/Enter selects. On a numbered note step, Up/Down changes pitch by one semitone; Shift moves an octave. Escape returns to your code selection. The toolbar's Undo/Redo and their Ctrl/⌘+Z shortcuts act on both text and graphical edits.
bpm(96); sets the tempo. .slow(2) stretches a pattern to twice its length.
bpm(96);
.slow(2)
The drawing follows the notation inside quotes, including subdivisions, repetitions, parallel layers, chords, and rests. Its source strip selects the written step or group; an edit changes every linked occurrence, never just one repeated copy. Outer transformations, arrangements, and effects remain code and are not folded into this local drawing. Complex or oversized notation stays editable in code when a safe graphical edit is unavailable.
A block's left edge shows its start and its width shows its interval in the quoted notation, not the synth's gate or release. The ruler measures local cycles, before outer speed and song placement—not bars. Choose 4 divisions for quarter-cycle guides; labels such as 2.3 mean the third division of local cycle two, not a claimed time signature. Dashed edit previews include displaced neighboring notes. Chords appear as separate pitch blocks. Explicit note rests remain blank but accept note entry; silence from other notation operations is not an insertion target. Overlapping rest sources require selection in Structure rather than a guessed edit. The outline marks your selection; a solid fill marks the latest played notes.
Timing separates three operations. Weight changes a step's relative @1–@16 share and may move following onsets. Phrase stretch edits or adds .slow(n), including fractions. Phrase gate edits or adds .gate(n), changing sounding duration without moving onsets; explicit envelopes may determine the audible release instead. Existing transformations and formatting are preserved. Each committed edit is one Undo step.
@1
@16
.slow(n)
.gate(n)
The small knobs edit numeric gain and filter values. Gain affects every sound, including drums; filters shape note and chord voices only. Quoted step patterns and signals have no knob; a filter knob is marked overridden when a later modifier for the same control in the chain replaces its value. Repeated gains multiply, so every gain knob in a chain still counts. Drag vertically, use arrow keys, or press Enter to type a number.
Controls hides or shows both the drawing and sound controls without changing your music.
Import opens a plain-text score; Download saves a .mini file you can edit, share, or use with your own AI tools. Nothing is sent to an AI service.
.mini
Share copies a link that opens this score. The score travels inside the link itself; nothing is uploaded. Opening a link replaces your text once, and Undo restores it.
Each edited session saves a separate recovery copy before updating the shared saved score. Saved drafts contains recovery copies from other sessions. Restore supports Undo. If tabs save at the same time, both drafts remain available after reopening, even if one replaces the shared score. You can permanently delete a saved draft after confirmation. Copies stay in this browser until you delete them; Download keeps a separate file. If browser storage is full or unavailable, download your open score before leaving.
Play starts or resumes the accepted score; Pause freezes it. Restart applies the editor's score from the beginning. Use Ctrl/⌘+Enter for Play/Pause and Ctrl/⌘+Shift+Enter for Restart.
Updates take effect at each material's next entry. Pending changes wait while the current phrase finishes. Invalid code leaves Current song unchanged. Author tempo with bpm(90);; omitted tempo is 120 BPM, with four beats per cycle.
bpm(90);
Triggered notes, their source, and named references stay highlighted until the next note starts. Simultaneous notes light together; rests keep the previous highlight. Pause clears it. This shows the latest note starts, not note duration or proof that every edit has taken effect. After a notation edit, unchanged code atoms may stay highlighted even when the drawing cannot identify the older events.
Playback details counts cycles; each cycle is one four-beat bar, not a fixed number of seconds. Parts can have different cycle lengths. Accepted edits switch at each part's entry, not all at once.
Examples replace your score and play it from the beginning; Undo restores your score.
Each note takes the instrument at its onset and keeps it while it sounds. Drums have no instrument, so s("bd").s("bass") is a mistake; put .s on the notes inside a stack.
s("bd").s("bass")
.s
stack
Notes: C4 = MIDI 60. Use # or b for accidentals; octave defaults to 4.
C4
#
b
Chords: C major, Cm minor; also 7, maj7, m7, dim, aug, sus2, sus4, 6, add9, maj9, m9. Write an exact pitch set as {60,63,68}: braces contain one or more unique MIDI integers from 0 through 127 in strictly ascending order, with no spaces. In chord("C+7"), the quoted + is part of the chord name, not an overlay.
C
Cm
7
maj7
m7
dim
aug
sus2
sus4
6
add9
maj9
m9
{60,63,68}
chord("C+7")
+
Shape browser notes and chords with filters: LPF softens high frequencies, while HPF clears low frequencies. Add the optional second argument to emphasize the cutoff frequency.
s("bd hh").slow(2) +note("E4").slow(4).gain(0.6).lpf(1800, 2).hpf(80).room(0.35)
Resonance is the filter Q: it defaults to 0.707 when omitted and must be finite and above 0. Higher values create a stronger peak around the cutoff frequency.
0.707
.room(0) is dry and is the default; .room(1) is the maximum send. Here the drums stay dry and the note sends at 0.35. Both keep their dry signal.
.room(0)
.room(1)
Envelopes apply to notes and chords. Each time is in seconds, from 0 to 86400.
note("E4") .attack(0.01).hold(0.1) .release(0.2)
0.31 seconds total, independent of tempo. Omit hold to follow the pattern's note length. Omitted attack/release use the sound's defaults; release starts from the current level.
.gate(0.4) keeps every onset in place but shortens each note to 40% of its step, leaving the rest silent. .gate(0) is silent; .gate(1) keeps the full step. The gate follows tempo. Factors finer than one billionth are rounded to keep long-running timelines representable. An explicit .hold(s) instead uses physical seconds and overrides the event-derived ending.
.gate(0.4)
.gate(0)
.gate(1)
.hold(s)
Room is one shared stereo space for every part. Its tail continues across note endings, section changes, and live edits. Pause freezes playback and the room tail; Play resumes them. Restart clears the room state.
.gain(n), .pan(n), and .room(n) apply to every sound. .lpf(hz, resonance?) and .hpf(hz, resonance?) shape note and chord voices; drum templates keep their authored filter shape.
.gain(n)
.pan(n)
.room(n)
.lpf(hz, resonance?)
.hpf(hz, resonance?)
Every control above takes a number, a quoted pattern of numbers, or a signal. A sounding note follows the change, including its release.
note("...")
?
from
to
saw.range(1, 0)
note("C2").slow(4) .lpf(saw.range(200, 4000).slow(4)) .pan(sine)
A note starts from the value at its onset, then follows once per audio block. Limits such as room 0–1 apply to every value a pattern or signal can take.
note("C3").slow(4).release(2).fadeOut(4) .lpf(ramp.range(200, 4000).slow(4))
The other signals repeat every period. ramp runs once from the start of the section, or outside a song from where the pattern enters (playback, or the live edit that added or changed it), and then keeps its end value, through the release and the following cycles. .fadeIn(n) is .gain(ramp.slow(n)) and .fadeOut(n) is .gain(ramp.range(1, 0).slow(n)); both multiply any other gain.
ramp
.fadeIn(n)
.gain(ramp.slow(n))
.fadeOut(n)
.gain(ramp.range(1, 0).slow(n))
One cycle is one bar of four beats. BPM counts beats: at the default 120 BPM, one cycle lasts two seconds, so s("bd hh sd hh") plays quarter notes.
s("bd hh sd hh")
Direct .fast(n) and .slow(n) accept positive integers or representable decimal factors: .fast(1.5) is 1.5× faster and .slow(0.5) halves the duration. Decimals retain their exact rational value rather than truncating to integers. every and callback factors still require positive integers. Callback f is fast(n), slow(n), or rev without parentheses.
.fast(n)
.fast(1.5)
.slow(0.5)
every
f
fast(n)
slow(n)
rev
$: s("bd ~ sd ~")$: note("C3 ~ Eb3 ~").gate(0.35)
An unweighted ~ occupies the same share of the cycle as an unweighted sounding atom; duration weights make either share proportional to its weight. Replacing an atom with a rest preserves onsets. Changing its weight can move subsequent onsets; gate shortens only the sounding part without moving them. Hear rests and gates in Space in the groove.
@n gives an atom, rest, chord, or group a relative integer duration; omitted weights count as 1. For example, note("C4@2 Eb4 F4") divides one cycle into four units: C4 lasts 1/2, Eb4 1/4, and F4 1/4. Weights must be 1–16 and a sequence containing a weight may total at most 256 units, keeping exact rational event boundaries bounded. Unweighted sequences retain their existing equal-slot timing.
@n
note("C4@2 Eb4 F4")
$:
s("bd") + s("hh").fast(2)
(s("bd") + s("hh")).fast(2)
Hear the difference in the Grouping A/B example. Grouping also works with slow, rev, and other method chains.
+ works in named definitions, $: lines, and song sections. Ordinary newlines do not combine expressions: use +, stack, or a $: prefix on each top-level layer. Inside quoted notation, use commas to overlay items.
Define names with let before using them and keep them stable during live edits. Overlay adds events, not their control values.
let
Separate calls with commas. Section lengths and explicit starts accept integers or fractions such as 3/2; section lengths must be positive. Pattern expressions inside sections support + and parentheses.
3/2
The editor accepts patterns and song(...) without a mode selector. Set tempo in the score with bpm(96); before the pattern or song (default 120), or with bpm(96) inside song(...). Declare tempo only once; there is no separate header BPM control.
song(...)
bpm(96)
Position: 0.00 cycles