accompy.main#
Main accompaniment generation module.
Integrates all components (patterns, chord resolution, MIDI rendering, synthesis) to provide the main accompy API.
Functions
Check which dependencies are available. |
|
|
Generate an accompaniment audio file from a chord progression. |
|
Play an audio file using the system's default audio player. |
Print installation instructions for missing dependencies. |
- accompy.main.check_dependencies()[source]#
Check which dependencies are available.
Example
>>> deps = check_dependencies() >>> 'midiutil' in deps True
- accompy.main.generate_accompaniment(chords, *, style='swing', tempo=120, repeats=1, output_path=None, output_format=None, config=None, use_mma=True, backend=None, autoplay=False)[source]#
Generate an accompaniment audio file from a chord progression.
This is the main entry point for accompy. It generates backing tracks with bass, drums, and piano from chord progressions.
- Parameters:
chords (
Any) – Chord progression (string, Score, list of tuples, iReal URL)style (
Literal['swing','bossa','rock','ballad','funk','latin','waltz','blues']) – Musical style (swing, bossa, rock, ballad, funk, latin, waltz, blues)tempo (
int) – Tempo in BPMrepeats (
int) – Number of times to repeat the progressionoutput_path (
Union[str,Path,None]) – Where to save the file (None = temp file)output_format (
Optional[Literal['wav','mp3','flac','midi','mid']]) – Output format (wav, mp3, flac, midi)config (
Optional[AccompanimentConfig]) – Full configuration object (overrides other params if provided)use_mma (
bool) – If True and MMA available, use MMA backendbackend (
Optional[Literal['auto','mma','builtin']]) – Explicitly select backend (‘auto’, ‘mma’, ‘builtin’)autoplay (
bool) – If True, automatically play the generated audio
- Return type:
- Returns:
Path to the generated audio/MIDI file
Example
>>> from accompy import generate_accompaniment >>> path = generate_accompaniment("| C | Am | F | G |", style="bossa", tempo=140) >>> print(f"Generated: {path}")
Note
Requires FluidSynth and a SoundFont for audio rendering. For MIDI-only output, use output_format=”midi”.