ModalJazz

Recipes

A recipe gives an agent the steps of a larger job, for example the copy of a PDF score. The guide tool of the MCP server gives the agent the same text as this page.

An agent can make mistakes. Check its work against the original.

Use a recipe

Name the recipe in your request, for example: "Use the transcribe-pdf recipe to copy ~/Downloads/minuet.pdf to ~/Scores/minuet.mj." The agent then gets the steps from guide.

In Claude Code, each recipe is also a slash command: /mcp__modaljazz__transcribe-pdf, and so on.

  • transcribe-pdf: Copy the music of a PDF score into a ModalJazz score.
  • import-musicxml: Make a ModalJazz score from a MusicXML file, and check it.
  • fix-measures: Read, change, and check a range of measures.
  • make-book: Put several pieces, each in its own `.mj` file, into one book PDF.

Programs that a recipe can use

Some recipes use other programs if they are installed. The guide tool tells the agent which of them are on your Mac. You do not need them, but a recipe works better with them.

ProgramForInstall with Homebrew
pdftoppm (poppler)Pictures of the pages of a PDFbrew install poppler
gs (Ghostscript)Pictures of the pages of a PDF, if pdftoppm is not installedbrew install ghostscript

An agent does not install a program without your permission.

transcribe-pdf

Copy the music of a PDF score into a ModalJazz score.

Can use: pdftoppm, gs

  1. Ask the user if the program that made the PDF can export MusicXML. If it can, use that file and follow the import-musicxml recipe. MusicXML is more exact than a picture of the page.

  2. Make a PNG image of each page at about 150 dpi:

    • With pdftoppm (poppler): pdftoppm -png -r 150 score.pdf page.
    • With gs (Ghostscript), if pdftoppm is not installed: gs -dNOPAUSE -dBATCH -sDEVICE=png16m -r150 -sOutputFile=page-%d.png score.pdf.
    • If neither program is installed, tell the user. Do not install software without asking the user.
  3. Look at the first page. Find the title, the composer, the parts, the key, the time, and the tempo.

  4. Make the score:

    • new_score with a new path and the nearest template, for example piano. The new score has eight empty measures.
    • run_command with :instrument to add, remove, move, or rename parts. Put the label of the part in front, as score_summary shows it: :P3 instrument rename "Tenor", :P5 instrument brace off. With no label, :instrument acts on P1. In a name, | starts a new line: :P1 instrument rename "S|A" stacks "S" over "A".
    • run_command with :title, :composer, :key, :time, and :tempo.
    • run_command with :bars +N to get the number of measures of the PDF.

    Then call score_summary to see the staff labels.

  5. Call text_format once and read it before you write.

  6. Write one page, or one system, with each write_measures call. Large writes are fast and correct, so do not cut the music into small steps of a few measures.

  7. After each write, read the same measures back with read_measures. Compare the text with the page image: the notes, the rhythm, the ties, the accidentals, the dynamics, and the marks. Fix each error before you write the next page. This check is the most important step.

  8. At the end, call score_summary, and compare the number of measures with the PDF. Call check_collisions: for each line, look at the measure in the page image, and write the measure again with the mark where the PDF has it (another side, as !p:above, or another time). Call save.

import-musicxml

Make a ModalJazz score from a MusicXML file, and check it.

  1. Call score_summary with the MusicXML file (.musicxml, .xml, or .mxl). The tools read the file. The reply shows the import warnings, if there are any.
  2. Read the measures that the warnings name with read_measures. Fix them with write_measures or run_command.
  3. Read some measures from the start, the middle, and the end of the score. Compare them with the original, if the user can show it.
  4. Call save with to set to a path that ends in .mj. The MusicXML file does not change.

fix-measures

Read, change, and check a range of measures.

  1. Call score_summary to see the staff labels and the number of measures.
  2. Read the measures with read_measures. Give staves to read only some staves.
  3. Make the change:
    • Use run_command for a change that a : command can make, for example :5-8 transpose +P8 or :5 key D. list_commands shows the commands.
    • Use write_measures for other changes. Write all the lines of a staff for each measure in the range. A staff with no line in the text does not change.
  4. Read the same measures again, and check that the change is correct. If it is not correct, call undo and try again.
  5. Call save when the user wants the change in the file.

make-book

Put several pieces, each in its own `.mj` file, into one book PDF.

Can use: mj

  1. Keep each piece in its own .mj file, with its own title block, copyright, tempo and page settings. Fix each piece alone first, and check its pages with mj info <file> --layout.
  2. Write a book file next to the pieces, with the extension .mjbook. One setting on each line; # starts a comment line:
    • title In Your Head: the title on the cover. No title, no cover.
    • line Six pieces for piano: a line under the title. Use one line for each: subtitle, composer.
    • copyright: a copyright (imprint) page after the cover. The line settings just after it are its lines: the copyright line, the rights notice, the ISBN, the credits, the publisher. They print small, in a block near the foot of the page. line with no text is a blank line, and a long line wraps.
    • contents: a table of contents after the cover.
    • firstpage left: page 1, the first page of music, is a left-hand page, as in many printed books (right for a right-hand page). The cover is a right-hand page; blank pages fill the gap.
    • piece daydreaming.mj: a piece, on the next page. Add left or right to start it on the next left-hand or right-hand page. A path is relative to the book file; put a path with spaces in quotes.
  3. Run mj export book.mjbook --to pdf. It writes book.pdf and lists the first page number of each piece.
  4. In the book, each piece keeps the pages of its own file: the music of one piece does not change the pages of another. The cover, the copyright page and the contents have no page numbers. Page 1 is the first page of music, and each page of music shows its number, the first page of each piece too.
  5. The cover, the copyright page and the contents take no font from the pieces: they are in Times New Roman, with a bold title and no small caps. To change their look, add a style block to the book (see mj help). For small caps, use font-variant: small-caps.