Fit a melody to a music box
fit_melody_to_boxAdjusts a melody so it can be played on a music box and lists every change. Strategies: "transpose" (shift the whole melody to the key that fits best), "nearest_note" (move each unplayable note to the closest playable one), "transpose_then_nearest" (default: both). Optionally snaps notes to a grid. Returns the new melody and its validation.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| box | Yes | Music box type: "15", "20", "30" (notes) or "freestyle" (digital only). See list_music_boxes. | |
| bpm | Yes | Tempo in beats per minute (30-300). | |
| notes | Yes | Notes in any order, at most 2000. Only onsets matter: music boxes have no note durations. | |
| strategy | No | ||
| target_box | No | Box to fit into. Defaults to the melody's box. | |
| quantize_beats | No | Snap every note to this grid in beats (e.g. 0.5 = eighth notes). | |
| illegal_threshold_ticks | No | Minimum gap between two identical notes, in ticks (default 384 = 2 beats). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| melody | Yes | ||
| changes | Yes | ||
| summary | Yes | ||
| semitones | Yes | ||
| validation | Yes |