gen-chords
is a collection of Python programs that
- Generate PNG images of musical chords based on specified parameters such as clef type, root note range, and chord intervals.
- Produce an Anki package for spaced repetition.
The program uses
- The pymusictheory library to handle musical theory concepts.
- MuseScore to render the chords into images.
- genanki to create the Anki package.
Page 18 of Jeremy Siskind's Jazz Piano Fundamentals (Book 1) instructs the reader to generate flashcards for all major, minor, and dominant seventh chords in the F clef.
If you don't care about generating your own chord images and flashcards, you can simply download the assets
folder, which contains images of all seventh chords in the range E2–E3 on the F clef, and also a corresponding Anki package (chord_images.apkg
).
- Generate seventh chords (major, minor, dominant) in different clefs (e.g., G clef, F clef).
- Specify a range of root notes to generate chords for.
- Outputs PNG images of the generated chords, organized into subfolders by chord type.
- Takes the folder of PNG images as input and generates an Anki package from it.
- Python 3.13 or higher
- MuseScore installed and available in the system's PATH
-
Install uv
-
Clone the repository:
git clone <repository-url> cd gen-chords
-
Install the required Python dependencies using uv:
uv sync
-
Ensure MuseScore is installed and accessible via the
mscore
command.
Run the gen_chord_images
program with the following arguments:
uv run gen_chord_images --clef <clef> --root_range <root1,root2> --folder_path <output_folder>
--clef
: The clef type to use for the generated chords. Choices:G
,F
.--root_range
: The range of root notes to generate chords for, in the formatroot1,root2
(e.g.,E2,E3
).--folder_path
: The path to the folder where the generated images will be saved. Each chord type will be saved in a separate subfolder.
To generate chords in the F clef for root notes ranging from E2
to E3
and save them in the assets/images
folder:
uv run gen_chord_images --clef F --root_range E2,E3 --folder_path assets/images
Run the gen_anki_pkg
program with the following arguments:
uv run gen_anki_pkg --folder_path <input_folder> --pkg_path <output_file>
--folder_path
: The path to the folder containing the generated chord images. The same folder thatgen_chord_images
created.--pkg_path
: The path to the output Anki package file.
To create an Anki package from the chord images in the assets/images
folder and save it as assets/anki_packages/seventh_chords.apkg
:
uv run gen_anki_pkg --folder_path assets/images --pkg_path assets/anki_packages/seventh_chords.apkg
- Chord Generation: The program calculates all possible root notes within the specified range and generates chords by stacking intervals on top of each root.
- MusicXML Creation: For each chord, a MusicXML representation is created.
- Image Rendering: The MusicXML is passed to MuseScore to generate a PNG image of the chord.
- Anki Package Creation: The program takes the folder of generated chord images, organizes them into Anki notes, and creates an Anki package (
.apkg
) file. Each note contains a chord image and its corresponding name.
The program currently supports the following chord types:
- Major Seventh: Root, Major Third, Perfect Fifth, Major Seventh
- Dominant Seventh: Root, Major Third, Perfect Fifth, Minor Seventh
- Minor Seventh: Root, Minor Third, Perfect Fifth, Minor Seventh
Below is an example of a flashcard generated by the program. The front side of the card displays the chord image, while the back side reveals the chord name.
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Feel free to open issues or submit pull requests to improve the program.