accompy.pipeline#

High-level pipeline API — one-call chord-to-audio conversion.

This module provides convenience functions that compose the registered converters into complete pipelines. It’s the simplest entry point.

Usage:

>>> from accompy.wips.pipeline import chords_to_midi, chords_to_audio
>>> midi_data = chords_to_midi("| Dm7 | G7 | Cmaj7 |")
>>> midi_data.write("output.mid")

>>> audio = chords_to_audio("| C | Am | F | G |")
>>> audio.write("output.wav")

>>> # Or with explicit control over which backend to use at each step
>>> midi_data = chords_to_midi("| C | Am |", resolver="music21", midi_gen="mido")

Functions

chords_to_audio(chords, *[, resolver, ...])

Convert chord string to audio.

chords_to_midi(chords, *[, resolver, ...])

Convert chord string to MIDI data.

chords_to_notes(chords, *[, resolver, tempo])

Convert chord string or ChordSequence to resolved MIDI notes.

chords_to_sequence(chords, *[, parser, ...])

Parse a chord string into a ChordSequence.

file_to_audio(filepath, *[, output_path, ...])

Convert an iReal Pro HTML/URL file to audio.

file_to_midi(filepath, *[, output_path, ...])

Convert an iReal Pro HTML/URL file to MIDI.

list_available_converters()

List all available converters organized by pipeline stage.

midi_to_audio(midi_data, *[, ...])

Convert MidiData to audio.

rhythm_to_audio(chords, *[, skeleton, ...])

Convert chords to audio using a rhythmic skeleton for restrike timing.

rhythm_to_midi(chords, *[, skeleton, ...])

Convert chords to MIDI using a rhythmic skeleton for restrike timing.

accompy.pipeline.chords_to_audio(chords, *, resolver=None, midi_gen=None, audio_renderer=None, soundfont=None, tempo=120, sr=44100, output_path=None)[source]#

Convert chord string to audio.

This is the complete pipeline: parse -> resolve -> MIDI -> audio.

Parameters:
  • chords (str | ChordSequence) – Chord string or ChordSequence

  • resolver (Optional[str]) – Chord resolver (‘pychord’, ‘music21’, ‘mingus’, ‘tonal’)

  • midi_gen (Optional[str]) – MIDI generator (‘pretty_midi’, ‘midiutil’, ‘mido’)

  • audio_renderer (Optional[str]) – Audio renderer (‘pretty_midi’, ‘fluidsynth’, ‘tonal’)

  • soundfont (Optional[str]) – Path to SoundFont file

  • tempo (int) – BPM

  • sr (int) – Sample rate

  • output_path (Optional[str]) – Optional path to write WAV file

Return type:

AudioData

Returns:

AudioData with waveform and sample rate

>>> audio = chords_to_audio("| C | Am | F | G |")
>>> audio.write("output.wav")
accompy.pipeline.chords_to_midi(chords, *, resolver=None, midi_gen=None, tempo=120, output_path=None)[source]#

Convert chord string to MIDI data.

Parameters:
  • chords (str | ChordSequence) – Chord string or ChordSequence

  • resolver (Optional[str]) – Resolver name (‘pychord’, ‘music21’, ‘mingus’, ‘tonal’)

  • midi_gen (Optional[str]) – MIDI generator name (‘pretty_midi’, ‘midiutil’, ‘mido’)

  • tempo (int) – BPM

  • output_path (Optional[str]) – Optional path to write MIDI file

Return type:

MidiData

Returns:

MidiData object

>>> md = chords_to_midi("| C | Am | F | G |")
>>> md.to_bytes()[:4]
b'MThd'
accompy.pipeline.chords_to_notes(chords, *, resolver=None, tempo=120)[source]#

Convert chord string or ChordSequence to resolved MIDI notes.

Parameters:
  • chords (str | ChordSequence) – Chord string or ChordSequence

  • resolver (Optional[str]) – Resolver name (‘pychord’, ‘music21’, ‘mingus’, ‘tonal’)

  • tempo (int) – BPM (used if chords is a string)

Return type:

NoteSequence

Returns:

NoteSequence with MIDI note numbers

>>> ns = chords_to_notes("| C | Am |")
>>> len(ns)
2
>>> all(0 <= n <= 127 for notes, _ in ns for n in notes)
True
accompy.pipeline.chords_to_sequence(chords, *, parser=None, tempo=120, title='', key='C', time_signature=(4, 4))[source]#

Parse a chord string into a ChordSequence.

Parameters:
  • chords (str) – Chord string in any supported format

  • parser (Optional[str]) – Parser name (‘auto_detect’, ‘plain_text’, ‘chordpro’, ‘musicgen_chord’)

  • tempo (int) – BPM (default 120)

  • title (str) – Song title

  • key (str) – Key signature

  • time_signature (tuple[int, int]) – Time signature tuple

Return type:

ChordSequence

Returns:

ChordSequence with parsed chords

>>> cs = chords_to_sequence("| Dm7 | G7 | Cmaj7 |", tempo=140)
>>> cs.symbols
['Dm7', 'G7', 'Cmaj7']
>>> cs.tempo
140
accompy.pipeline.file_to_audio(filepath, *, output_path=None, n_repeats=1, transpose=0, resolver=None, midi_gen=None, audio_renderer=None, soundfont=None, tempo=None, sr=44100)[source]#

Convert an iReal Pro HTML/URL file to audio.

Handles:

  • iReal Pro HTML files (exported from the app)

  • iReal Pro URL strings

  • Plain chord text files

Supports repeating the progression and transposing.

Parameters:
  • filepath (str) – Path to an iReal HTML file, or a chord text file

  • output_path (str | None) – Where to write audio. If None, uses filepath with .wav extension

  • n_repeats (int) – Number of times to repeat the progression (default 1)

  • transpose (int) – Semitones to transpose (positive=up, negative=down)

  • resolver (str | None) – Chord resolver backend

  • midi_gen (str | None) – MIDI generator backend

  • audio_renderer (str | None) – Audio renderer backend

  • soundfont (str | None) – Path to SoundFont file

  • tempo (int | None) – Override BPM (None = use file’s tempo or 120)

  • sr (int) – Sample rate

Return type:

AudioData

Returns:

AudioData

Example:

>>> file_to_audio("/path/to/song.html")
>>> file_to_audio("/path/to/song.html", n_repeats=40)
>>> file_to_audio("/path/to/song.html", transpose=5)
accompy.pipeline.file_to_midi(filepath, *, output_path=None, n_repeats=1, transpose=0, resolver=None, midi_gen=None, tempo=None)[source]#

Convert an iReal Pro HTML/URL file to MIDI.

Same as file_to_audio but outputs MIDI instead.

Parameters:
  • filepath (str) – Path to an iReal HTML file, or a chord text file

  • output_path (str | None) – Where to write MIDI. If None, uses filepath with .mid extension

  • n_repeats (int) – Number of times to repeat the progression

  • transpose (int) – Semitones to transpose

  • resolver (str | None) – Chord resolver backend

  • midi_gen (str | None) – MIDI generator backend

  • tempo (int | None) – Override BPM

Return type:

MidiData

Returns:

MidiData

accompy.pipeline.list_available_converters()[source]#

List all available converters organized by pipeline stage.

Return type:

dict[str, list[str]]

Returns:

Dict mapping stage names to lists of converter names.

>>> info = list_available_converters()
>>> 'parsers' in info
True
>>> 'resolvers' in info
True
accompy.pipeline.midi_to_audio(midi_data, *, audio_renderer=None, soundfont=None, sr=44100, output_path=None)[source]#

Convert MidiData to audio.

Parameters:
  • midi_data (MidiData) – MidiData object

  • audio_renderer (Optional[str]) – Audio renderer name

  • soundfont (Optional[str]) – Path to SoundFont file

  • sr (int) – Sample rate

  • output_path (Optional[str]) – Optional path to write WAV file

Return type:

AudioData

Returns:

AudioData

>>> audio = midi_to_audio(some_midi_data)
accompy.pipeline.rhythm_to_audio(chords, *, skeleton='whole_note', resolver=None, midi_gen=None, audio_renderer=None, soundfont=None, tempo=120, sr=44100, output_path=None)[source]#

Convert chords to audio using a rhythmic skeleton for restrike timing.

Same as rhythm_to_midi() but renders all the way to audio.

Parameters:
  • chords (str | ChordSequence) – Chord string or ChordSequence.

  • skeleton (str | tuple[float, ...]) – Skeleton key, name, style, or duration tuple.

  • resolver (str | None) – Chord resolver name.

  • midi_gen (str | None) – MIDI generator name.

  • audio_renderer (str | None) – Audio renderer name.

  • soundfont (str | None) – Path to SoundFont file.

  • tempo (int) – BPM.

  • sr (int) – Sample rate.

  • output_path (str | None) – Optional path to write WAV file.

Return type:

AudioData

Returns:

AudioData with waveform and sample rate.

Example

>>> audio = rhythm_to_audio("| C | Am |", skeleton="half_notes")
accompy.pipeline.rhythm_to_midi(chords, *, skeleton='whole_note', resolver=None, midi_gen=None, tempo=120, output_path=None)[source]#

Convert chords to MIDI using a rhythmic skeleton for restrike timing.

The skeleton defines when chords are struck within each measure. Each chord is sustained for the skeleton’s duration at that beat position.

Parameters:
  • chords (str | ChordSequence) – Chord string (e.g., "| Dm7 | G7 | Cmaj7 |") or ChordSequence.

  • skeleton (str | tuple[float, ...]) – Skeleton key, name, style, or duration tuple. Defaults to "whole_note" (one strike per measure).

  • resolver (str | None) – Chord resolver name (e.g., "pychord", "tonal").

  • midi_gen (str | None) – MIDI generator name (e.g., "pretty_midi", "midiutil").

  • tempo (int) – BPM (used if chords is a string).

  • output_path (str | None) – Optional path to write MIDI file.

Return type:

MidiData

Returns:

MidiData object.

Example

>>> md = rhythm_to_midi("| C | Am | F | G |", skeleton="tresillo")
>>> md.to_bytes()[:4]
b'MThd'