Möbius Music Box

Ready · pass 1 of 2
Static preview. If the controls do not respond, this viewer is not running JavaScript. Download the HTML file and open it in a browser for editing, plotting, and sound.

Punch your strip

15 holes
15 lanes · C4–C6
Pass 1 · as punched →
y = note lanelane number · pitch
NOTE
0
0.5
1
1.5
2
2.5
3
3.5
4
4.5
5
5.5
6
6.5
7
7.5
8
8.5
9
9.5
10
10.5
11
11.5
12
12.5
13
13.5
14
14.5
15
15.5
OTHER
15C6
C4
14B5
D4
13A5
E4
12G5
F4
11F5
G4
10E5
A4
9D5
B4
8C5
C5
7B4
D5
6A4
E5
5G4
F5
4F4
G5
3E4
A5
2D4
B5
1C4
C6
BEATS →
bar 1
bar 2
bar 3
bar 4
TIME →
x = time (quarter-note beats) →0 ≤ x ≤ 15.5 · 1 ≤ y ≤ 15
Click to punch. Click again to remove.Arrow keys to move · Space to punch

What you’ll hear

Two passes · 8 bars · 19 seconds per cycle
01

As punched

original strip
1
2
3
4
02

Inverted lanes

same time order
5
6
7
8

4/4. Each note is a strike. The sound decays. Empty positions are rests.

Function keypad

Notation

x counts quarter-note beats. y counts lanes. The first lane is 1.

Use pi or π, and e. Angles are radians. Powers use ^ or **. Multiplication can be implicit: 2x.

Powers associate right: 2^3^2 = 2^(3^2). Unary signs follow powers: -x^2 = -(x^2). Multiplication and division go left to right: 2/3x = (2/3)*x.

ln and log are natural logarithms. log10 is base ten. mod(a,b) requires b > 0. round ties go toward +∞.

Also accepted: asin, acos, atan, ceil, round, sign, pow; and % for remainder. Function calls require parentheses. min, max, pow, and mod take two arguments.

Finite numerical samples approximate the function. Gold squares meet the displayed polyline. Very rapid oscillations can be missed.

A polynomial through your points

What you select

A square contributes its center, (xᵢ, yᵢ). If its zero-based column is tᵢ and there are s columns per quarter-note beat, xᵢ = tᵢ/s. The bottom lane has y = 1. Coordinates refer to the as-punched strip. On the inverted view, a clicked lane y corresponds to source lane L + 1 − y. Selecting a point does not punch a hole.

What “fit” means

For n ≥ 1 points with distinct x coordinates, there is exactly one polynomial p of degree at most n − 1 satisfying p(xᵢ) = yᵢ for every selected point. One point gives a constant. Collinear points give a line or a constant, even when n is larger. No points means no fit. The app permits one point per column, up to every column on the strip.

Different heights at the same x are inconsistent: a function cannot take two values there. Remove the old point before selecting another in its column. This is interpolation: every constraint is met, with no least-squares approximation or smoothing.

The formula

p(x)=∑i=0n−1yiℓi(x) ℓi(x)=∏0≤j<n,j≠ix−xjxi−xj

An empty product equals 1. At xᵢ, ℓᵢ equals 1; at every other selected xⱼ it equals 0. Thus p(xᵢ) = yᵢ. Each term has degree at most n − 1. This proves existence.

If two polynomials of degree at most n − 1 fit the points, their difference has n distinct roots. A nonzero polynomial of degree at most n − 1 cannot do that. Their difference is zero. This proves uniqueness.

The degree bound matters. Without it, every polynomial p(x) + q(x) ∏ᵢ(x − xᵢ) also fits, for any polynomial q. The app chooses the unique polynomial within the stated bound.

The interpolation formula and degree bound are given in NIST DLMF §3.3.

What the computer evaluates

The app uses the equivalent Newton form in column coordinates t = sx. Start with Dᵢ,₀ = yᵢ. Then Dᵢ,ₖ = (Dᵢ₊₁,ₖ₋₁ − Dᵢ,ₖ₋₁)/(tᵢ₊ₖ − tᵢ). Set cₖ = D₀,ₖ. The resulting polynomial is p(x) = c₀ + c₁(sx − t₀) + c₂(sx − t₀)(sx − t₁) + ⋯.

Column indices and lane numbers are integers. Divided differences are stored as exact fractions with arbitrary-size integer numerators and denominators. Evaluation also uses exact fractions at each represented sample x; only the final y is converted to floating point for drawing. The save code stores the selected points, so loading reconstructs the same polynomial.

What gets punched

The blue rings are selected centers. Gold squares meet the displayed curve. “Fit polynomial” draws; “Punch crossed squares” adds holes. The x range applies to both functions and polynomials. Beyond the leftmost or rightmost selected point, the polynomial is extrapolating.

The displayed curve is a polyline, sampled at least 32 intervals per grid column and refined at midpoints when their deviation exceeds 0.015 lane. Selected x coordinates inside the plotting range are included as samples. Intervals whose endpoints and midpoint all lie beyond the same edge are omitted. Refinement has finite limits; unresolved intervals are omitted. Selected centers remain represented even where an adjacent interval is unresolved. This is a numerical picture, not a proof that every crossing of the exact polynomial has been found. High-degree interpolation can oscillate severely, even between points. More points need not make a calmer curve.

For column t and lane y, its closed square spans (t − ½)/s ≤ x ≤ (t + ½)/s and y − ½ ≤ f ≤ y + ½. A shared boundary belongs to both squares. The intersection calculation uses a 10⁻⁹ tolerance in grid coordinates to absorb floating-point error. The plotted stroke’s thickness does not count.

On the second Möbius pass, the graph becomes L + 1 − p(x). Its time coordinate is unchanged. The same physical holes are heard in reflected lanes.

Functions

Save / load

Copy the code. Keep it. Paste it here later. It contains the holes, tuning, tempo, function, selected points, and playback settings. Browser storage is a convenience. The code is portable.

Note layout and settings

Melody sources

Ode to Joy: Beethoven, opening theme. Public-domain score. Twinkle, Twinkle and Frère Jacques: traditional melodies.

Flight of the Bumblebee: Rimsky-Korsakov, opening flute/violin line, original pitch and sixteenth-note onsets. Four 2/4 measures are displayed as two 4/4 bars. Source score, page 1.

Examples are melody-only music-box transcriptions. Holes trigger strikes; note lengths describe attack spacing. Original asymmetry is an original demonstration.

Match your music box

The starting layout is 15 notes in C major, C4–C6. The linked kit’s tuning could not be verified. Enter your strip’s actual lane pitches below; C4 is middle C.

Use spaces or commas. Sharps and flats work, for example F#4 or Bb4. Holes keep their lane positions when you change the tuning.

How the Möbius pass works

For L lanes, the second pass sends lane y to L + 1 − y. Time still goes forward. If L is odd, the middle lane stays put.

With this layout: C4 ↔ C6, with C5 fixed.

C4 ↔ C6D4 ↔ B5E4 ↔ A5F4 ↔ G5G4 ↔ F5A4 ↔ E5B4 ↔ D5C5 ↔ C5

The reflection acts on lane numbers. Uneven tuning need not give a fixed semitone sum. Two passes make one Möbius cycle.

Sound is synthesized. The simulation plays every hole; a real mechanism’s minimum repeat-hole spacing depends on the kit. The strip view is a composition grid, not a template at physical scale.

Chords

Separate chords with spaces or commas. Each chord strikes once.

Adds holes to the as-punched strip. Existing holes remain. Undo restores the previous strip.

Allowed chord forms

TypeExamples
Major / minorC, Cm, Cmin, C-
SeventhsC7, Cmaj7, CM7, Cm7, CmMaj7
Diminished / augmentedEdim, E°, Edim7, Em7b5, Caug, C+
Sixths / extensionsC6, Cm6, C9, Cmaj9, Cm11, C13
Suspended / addedCsus2, Csus4, C7sus4, Cadd9, Cmadd11
Altered degreesCm7b9, C7(b9), C7#9, C7b5, C7#11, C13b13
Slash bassC/E, Fmaj7/A, Dm7/C

Root: A–G, optionally followed by b or # (♭ and ♯ also work). Quality, then extension, then alterations or additions, then optional slash bass. Use spaces or commas between chords. Do not put spaces inside a symbol.

Extensions: 6, 7, 9, 11, 13. Alterations: b5, #5, b9, #9, b11, #11, b13, #13. Additions: add2, add4, add6, add9, add11, add13. Parentheses may group alterations. M and Δ mean major; m and - mean minor. Unrecognized suffixes are rejected.

C, Cm, Cmaj7, Cm7b9, C7, C9, C11, C13, Cdim, Cdim7, Cm7b5, Caug, Csus2, Csus4, Cadd9, C7#5, and C/E. Accidentals: b or #. M means major; m means minor.

Root-position voicing, with extensions above the octave. A slash bass is placed below the root. 9, 11, and 13 include the lower extensions and a minor seventh unless marked maj. dim7 uses a diminished seventh. Alterations replace the named degree; add does not imply a seventh. Enharmonic pitches may be shown with sharps.

Missing pitches are never silently omitted. Adding lanes preserves existing sounding pitches on the first pass, but changes the lane reflection on the Möbius pass. Your physical kit may not have those notes. Plot overlays are cleared when lanes change.