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
|
Convert chord string to audio. |
|
Convert chord string to MIDI data. |
|
Convert chord string or ChordSequence to resolved MIDI notes. |
|
Parse a chord string into a ChordSequence. |
|
Convert an iReal Pro HTML/URL file to audio. |
|
Convert an iReal Pro HTML/URL file to MIDI. |
List all available converters organized by pipeline stage. |
|
|
Convert MidiData to audio. |
|
Convert chords to audio using a rhythmic skeleton for restrike timing. |
|
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 ChordSequenceresolver (
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’)tempo (
int) – BPMsr (
int) – Sample rateoutput_path (
Optional[str]) – Optional path to write WAV file
- Return type:
- 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 ChordSequenceresolver (
Optional[str]) – Resolver name (‘pychord’, ‘music21’, ‘mingus’, ‘tonal’)midi_gen (
Optional[str]) – MIDI generator name (‘pretty_midi’, ‘midiutil’, ‘mido’)tempo (
int) – BPMoutput_path (
Optional[str]) – Optional path to write MIDI file
- Return type:
- 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 ChordSequenceresolver (
Optional[str]) – Resolver name (‘pychord’, ‘music21’, ‘mingus’, ‘tonal’)tempo (
int) – BPM (used if chords is a string)
- Return type:
- 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:
- Return type:
- 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 fileoutput_path (
str|None) – Where to write audio. If None, uses filepath with .wav extensionn_repeats (
int) – Number of times to repeat the progression (default 1)transpose (
int) – Semitones to transpose (positive=up, negative=down)tempo (
int|None) – Override BPM (None = use file’s tempo or 120)sr (
int) – Sample rate
- Return type:
- 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:
- Return type:
- Returns:
MidiData
- accompy.pipeline.list_available_converters()[source]#
List all available converters organized by pipeline stage.
>>> 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:
- Return type:
- 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:
- Return type:
- 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:
- Returns:
MidiData object.
Example
>>> md = rhythm_to_midi("| C | Am | F | G |", skeleton="tresillo") >>> md.to_bytes()[:4] b'MThd'