Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SlideGuide calculates ideal slide positions for trombone lines.

SlideGuide: a typed-in melody on the staff, with three slide-position policies compared below it

There's an online interactive version at https://dwiddows.github.io/slideguide/ (also embedded at https://www.puttypeg.net/music/slideguide/index.html) — it works on mobile too:

SlideGuide on a phone-sized screen, same melody and controls, laid out in a single column

The companion harmonic_theory.html page explains the physics behind the position model:

The 8th partial: a plain tube shows 8 clean standing-wave loops, while the same partial in a flared bell shows pressure fading out toward the open end instead of staying evenly rippled

Feel free to use any of the code in this repo for other projects, e.g., the music theory parts that generates the scales could easily be used in tools for other instruments.

How it works

The problem. Most notes on a trombone can be played in more than one slide position: a pitch comes from the slide length and which harmonic (partial) of that length's overtone series you buzz, so different combinations often land on the same note. Picking one changes how far the slide travels, how often it changes direction, and how close to the bell it sits.

The position model. Position 1's fundamental is the horn's pedal B♭; each position down lowers that fundamental by a semitone, and each fundamental carries its own harmonic series (trombone-positions.js). This is derived from the acoustics directly, not a lookup table -- including a physically motivated correction for the naturally flat 7th partial (shortening the slide about a quarter position to compensate, the same way a player would by ear), and excluding the one case where that correction can't actually happen (partial 7 at position 1, the slide fully closed, with nowhere left to shorten).

Music theory. Scales, arpeggios, and their key signatures (music-theory.js) are generated from formulas -- semitone/letter-offset pairs per degree -- rather than hardcoded per key. This is the general-purpose part that's likely reusable well beyond trombones.

The solver. Given a note with several playable positions, solver.js scores every candidate on four things:

Weight Meaning
Position Prefer a low position number ("closer to the bell")
Position exponent Makes 5th-7th position disproportionately costlier than 1st-4th, rather than everything scaling together
Position change Prefer less total slide travel between notes
Direction change Prefer fewer reversals of slide direction

A locally cheapest choice for one note can force an expensive one at the next, so it's a dynamic program over the whole passage, not a greedy note-by-note pick: it tracks the cheapest running total for every (position, incoming-direction) state reachable at each note, carrying forward whichever paths could still turn out cheapest overall.

Melody input. abc-import.js bridges ABC notation (parsed by abcjs) into the same note representation, so a typed-in tune plays through the identical position solver as a generated scale -- including real accidental resolution (key signature, then explicit-accidental-holds-till-the-barline) and per-note durations.

Tests. *.test.js files run directly under node (node music-theory.test.js, etc.) -- around 200 assertions covering the theory engine, the harmonic position model, the solver (including brute-force verification against the DP), and the ABC bridge.

The harmonic series and the bell (harmonic_theory.html). A companion page demonstrating the physics behind the position model: the pedal-to-high-B♭ natural harmonic series on a staff, an animated standing wave in a plain tube, and (pipe-bell.js/horn-equation.js) a numerical solution of the Webster horn equation showing how a flared bell pulls the even harmonics back into a tube that would otherwise, closed at one end, only resonate at odd multiples of its fundamental.

Choosing between positions (slide_theory.html). A companion page walking through the problem, position model, and solver above the same way, but browsable: the position/partial table, the note-to-positions table it inverts to, and how the solver's four weights combine into a total cost for a whole passage.

FAQ

Can I upload sheet music, a PDF, or a MuseScore file instead of typing ABC? We don't accept file uploads, since there's been no work done on copyright protection for that. You can try converting your file to ABC notation first -- MuseScore (free, can export a score straight to ABC notation) and EasyABC (a dedicated ABC editor that can also import MusicXML) both sometimes work easily. Either way, once it's ABC text, paste it into the melody box.

Author's Notes on AI Usage

I first imagined something like this application in the early 2000's, and never got round to building it in Java.

Then around 2024 my trombone teacher Colin wondered if there was an good computer algorithm to find shortest position paths. (Answer - yes, there are several depending on what we reckon is ideal.)

Then in 2026 I spent a few evenings coding this up using Claude Code, which I couldn't have done in previous years.

Cost Estimate

  • Total time: about 8 hours.
  • Cost to me: much less than $20 (one month's Claude Code subscription).

How do I know the AI generated code works?

  • It produces the modes, scales, and positions I've wanted for years, with tests to prove it.
  • If you find any mistaken trombone position pathways here and want to discuss them, I'd love to :)
    • Ideally - use the Issues tab to file an issue and we'll get improvements included in the code.

Couldn't you have done this without AI?

  • Given web search resources, yes, the basic version with no real fluid dynamics, in about a month.
  • It would probably have taken me another month to take on the more ambitious fluid dynamics solutions.
    • That's with a PhD in differential geometry and 25 years coding experience. And no guarantee of success.

Shouldn't developers be paid properly for work like this?

  • As far as I know, this is the first automatic trombone slide position calculator in the history of computing.
  • This project could have been done for decades - but it wasn't, and if it required paying developers, it still wouldn't be!

AI tools can help to support niche applications that only small groups (such as trombonists!) are interested in. Members of those communities often have a very good idea of what they want to see in applications. Sometimes AI assistance helps community members meet those requirements responsibly, correctly, and cost-effectively. (Thanks for reading this!)

Credits

Designed and tested by Dominic Widdows. Coded by Claude. Thanks for the encouragement to Colin Pulkrabek -- ask him about lessons.

Released under the MIT License. Melody parsing by abcjs (also MIT).

References

About

Trombone slide position calculator: computes playable slide positions for any scale, arpeggio, or ABC-notation melody

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages