Mechanical MusicBox Simulater [Super Detailed] with swappable Cylinders

TL;DR: Inspired by the video below, I created a simulation of the music box which you can play with here

  • 6 cylinders included as samples with three melodies for each
  • You can play it manually by clicking the rods
  • You can create your own custome cylinder with your fevorite melody tune. Compose it; load it and then play it

A few weeks ago, this video randomly popped up in my feed. And I have been mesmerized by the machine ever since. It’s music you can see. I think it’s one of the most visual ways to depict how data is stored.

Unfortunately, these boxes are pretty expensive and can go up to $11k, which makes them way out of my reach. So I thought I would create a simulation of one in my free time while burning some tokens.

The cylinders are interchangeable. You can upload your own cylinder to play your favorite melody on it. You can model the cylinder manually, but a more practical way to make a cylinder with your favorite melody is to use the compose feature in the app, which automatically converts the notes to a GLB file and mounts it on the machine. There is no metadata in the cylinder (well, except things like the title of the melody). The entire melody comes merely from the pins on the cylinder, so it just needs a cylinder model with pins.

The quickest way, however, is to generate the cylinder with AI. You just specify the properties of the cylinder and pins, ask it to generate your favorite melody cylinder, and upload it to the app.

Bonus: If you have a good eye, you might have wondered how it can pack 3 melodies, which span around 4 minutes in total, into such a small cylinder. This particular box implements an ingenious way of shifting the cylinder sideways when one revolution is completed to play the next melody. This allows it to pack so many notes into a very small space. On other boxes, you would have to manually swap the cylinder or disk to play the next one.

I will include other similar boxes in the comments. I will also include an AI prompt you can use to generate a cylinder.

Oh I forgot to link the repo. U can find it here

The Easiest way to generate a cylinder with your favorite Melody is to let AI(or SI ; )) genrate it for you.

Paste this prompt into an AI chat with web browsing, code execution and file downloads. Replace [MELODY NAME] with your favorite melody, or up to five titles separated by semicolons. The AI will research the notes and generate its best arrangement; a MIDI file is optional for later refinement.

Model testing: Testing to date covered higher-tier reasoning models. Free, non-reasoning models have not been tested.

"

Create and attach a playable binary glTF 2.0 music-box cylinder named my-cylinder.glb for the Crescendo simulator. Write and RUN Python or JavaScript to build the file, then provide its download link. The final deliverable must be the actual GLB file. If you cannot run code or attach files, tell me that this task needs those capabilities; do not invent a download link.

Melodies: [MELODY NAME]

Treat semicolon-separated titles as separate melodies, with one indexed turn per melody (maximum 5). Arrange each into a recognizable 30–90 second music-box passage, preserving its main melody and rhythm with gentle, sparse accompaniment.

RESEARCH AND BEST-EFFORT GENERATION

Search the internet for each requested melody's notes and rhythm before arranging it. Look for matching sheet music, MusicXML, ABC notation, MIDI files, or documented note transcriptions. Prefer clearly identified sources and compare versions when possible. If a title is ambiguous, choose the most likely well-known version and state which one you used.

Use the musical information you actually find. If it is incomplete or uncertain, combine it with your musical knowledge and infer missing details as reasonably as you can. Still generate and attach your best playable GLB in this response, clearly identifying any approximations.

Do not pause generation to request a MIDI file, note sequence, or clarification, and do not make user-supplied files a prerequisite. Complete the first arrangement with the information available.

In the delivery summary, link the sources you consulted and briefly identify uncertain passages or inferred details. Do not invent sources or claim an approximation is an exact transcription.

After attaching the GLB, if any melody remains uncertain, offer an optional follow-up: "If you have a MIDI file for this melody, send it and I can refine the cylinder for more accurate notes and timing." Do not wait for that file before delivering the first GLB.

MUSIC AND TIMING

Use 72 teeth tuned to integer MIDI notes 36 through 107 inclusive (C2–B7; middle C is 60). Tooth index i = midi - 36.

Choose one common duration T in seconds PER TURN, long enough for every arrangement, between 2 and 600 seconds. The full programme lasts T * N, where N is the number of melodies (1–5).

Each pluck has a MIDI pitch, a time t satisfying 0 <= t < T, a zero-based turn k from 0 to N-1, and a velocity greater than 0 and at most 1. Restart times at 0 for every turn. Chords are simultaneous pins; no note-length field is needed.

Include every note of the arrangement, with at most 6,000 pins total and no duplicate pitch/time/turn events.

REAL 3D PIN GEOMETRY
The app reads music from physical pin positions. Build a brass barrel and real, separate radial pin mesh nodes; melody metadata alone does not produce music.

Use metres and glTF coordinates. Center the barrel on the origin with its long axis along X, length 0.214 m and radius 0.024 m. Name its mesh node cylinder_body.

Use one shared, low-poly pin mesh: a symmetric cylinder centered on its local origin, long axis along local Y, length 0.0015 m, radius 0.00023 m, with 6–8 sides. Keep its mean vertex position at the local origin.

For each pluck, compute these values using radians:
theta = 2.0 - 2 * pi * t / T
x = -0.099 + i * 0.198 / 71 + k * 0.00055
y = 0.02475 * cos(theta)
z = 0.02475 * sin(theta)

Create one node per pin, named pin_00000, pin_00001, and so on, each referencing the shared pin mesh with a single triangle primitive. Set translation to [x, y, z] and rotation to the glTF quaternion [sin(theta/2), 0, 0, cos(theta/2)]. Put its velocity in node.extras.velocity.

Put the barrel and all pins under one root node named MusicCylinder. Keep the root transform at identity. The 0.00055 m turn offset is essential for indexed melodies.

Use uncompressed triangle meshes with FLOAT POSITION/NORMAL accessors and unsigned integer triangle indices, plus a brass PBR material. Keep the expanded vertex count across all instances below 700,000 and the file below 35 MB.

REQUIRED METADATA
Set MusicCylinder.extras.musicBox to an object with these fields:

schema: "crescendo-cylinder/v1"

title: the requested melody or collection title

composer: the original composer or songwriter

secondsPerTurn: T

turns: N

tunes: exactly N objects with title and composer, in the requested order

tuning: the complete array of all 72 integers from 36 to 107 inclusive

axis: "X"; units: "metres"

length: 0.214; radius: 0.024; minX: -0.099; maxX: 0.099

pinLength: 0.0015; pinRadius: 0.00023; contactAngle: 2.0; indexStep: 0.00055
Do not put a hidden note/time array or audio recording in the GLB. The separate pin meshes are the score.

PACKAGING AND VALIDATION

Write a self-contained, uncompressed GLB 2.0 with one embedded binary buffer, a default scene referencing MusicCylinder, valid accessors and POSITION min/max bounds. Use no external files, sparse accessors, Draco, Meshopt, or quantization extensions.

Use the little-endian GLB header (magic 0x46546C67, version 2, correct total byte length), followed by JSON and BIN chunks. Align buffer views and chunks to 4 bytes; pad the JSON chunk with spaces and the BIN chunk with zero bytes. buffers[0].byteLength must match the buffer payload.

Reopen the written file and check every chunk, accessor, node reference, pin count, and metadata value. Compute each pin's center from its transformed mesh vertices. Recover pitch/turn by matching X against all tooth/turn lane combinations, and recover time from atan2(z, y). Check these against the arrangement, accounting for the time wrap at 0/T.

Attach the verified my-cylinder.glb file with a short summary of the melodies, seconds per turn, research sources, and any approximations. Include the optional MIDI refinement offer after the download link when needed.
  • "

Here are other less sophisticated Music Boxes.

  1. https://www.youtube.com/watch?v=yUPrI6JHGgc this is actually the first one that poopedup in my feed. I was supprised the box kept playing without repeating after it made a full revolution. then in the video description, I saw The Youtuber actually edited the video stiching the three parts while manually changing the disks in between.

  2. a much more simplistic model: https://www.youtube.com/watch?v=goPK7Z72uF0