accompy.rendering#

High-quality chord rendering pipeline — from chord charts to AI-enhanced audio.

Collapses the multi-step workflow of rendering MIDI audio and enhancing it via AI music generation (e.g. Suno) into a single render_chords() call.

Pipeline:

chords + params → ChordSequence → MIDI audio (WAV) → AI-enhanced audio (MP3)

Quick start:

>>> from accompy.rendering import render_chords
>>> path = render_chords("| Dm7 | G7 | C^7 |", ai_enhance=False)

With AI enhancement (requires arioso and Suno API key):

>>> path = render_chords(
...     "| Dm7 | G7 | C^7 |",
...     genre="jazz",
...     instruments=["piano", "upright bass", "brushes"],
... )

Batch rendering:

>>> paths = render_chords_batch([
...     dict(chords="| Dm7 | G7 | C^7 |", genre="jazz"),
...     dict(chords="| Dm7 | G7 | C^7 |", genre="lofi chill hop"),
... ], bpm=100)

Functions

render_chords(chords, *[, ...])

Render chords to a high-quality audio file, optionally AI-enhanced.

render_chords_batch(configs, **shared_kwargs)

Run render_chords() for each config dict.

accompy.rendering.render_chords(chords, *, rhythmic_skeleton='whole_note', bpm=100, transpose=0, n_loops=None, max_seconds=None, ai_enhance=True, suno_mode='cover', prompt_template='{genre} backing track with {instruments}', genre='jazz', instruments=None, audio_weight=0.99, style_weight=0.51, weirdness=0.0, model='', instrumental=True, wait_for_completion=True, poll_interval=15.0, timeout=600.0, chords_to_midi_audio=None, audio_to_enhanced_audio=None, midi_store=None, midi_audio_store=None, enhanced_audio_store=None, resolver=None, midi_gen=None, audio_renderer=None, soundfont=None, sr=44100)[source]#

Render chords to a high-quality audio file, optionally AI-enhanced.

Parameters:
  • chords – Chord input — string ("| Dm7 | G7 | C^7 |"), iReal URL, ChordSequence, Score, or list of (chord, beats) tuples.

  • rhythmic_skeleton (str | tuple[float, ...]) – Restrike pattern within each measure.

  • bpm (int) – Tempo in beats per minute.

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

  • n_loops (int | None) – Explicit number of loops. Mutually exclusive with max_seconds.

  • max_seconds (float | None) – Target maximum duration; computes loop count automatically. Defaults to 210 (3.5 min) when neither n_loops nor max_seconds is given.

  • ai_enhance (Union[bool, Callable, None]) – True for default Suno enhancement, False/None to skip, or a callable (audio_path, prompt, **kw) → bytes.

  • suno_mode (str) – "cover" (default, re-generates in style) or "extend".

  • prompt_template (str) – Template with {genre} and {instruments} placeholders.

  • genre (str) – Genre/style tags for the AI prompt.

  • instruments (list[str] | None) – Instrument list for the AI prompt. Defaults to ["piano", "bass", "drums"].

  • audio_weight (float) – How much the source audio influences AI output (0–1).

  • style_weight (float) – How much the style prompt influences AI output (0–1).

  • weirdness (float) – Creative deviation for cover mode (0–1).

  • model (str) – Suno model version (e.g. "V4_5").

  • instrumental (bool) – If True, generate without vocals.

  • wait_for_completion (bool) – If True, poll until AI generation is ready.

  • poll_interval (float) – Seconds between AI status checks.

  • timeout (float) – Max seconds to wait for AI completion.

  • chords_to_midi_audio (Optional[Callable]) – Override for the MIDI audio rendering step. Callable: (ChordSequence, **kw) → AudioData.

  • audio_to_enhanced_audio (Optional[Callable]) – Override for the AI enhancement step. Callable: (audio_path, prompt, **kw) → bytes.

  • midi_store (MutableMapping | None) – Optional store for MIDI files. None = don’t persist MIDI.

  • midi_audio_store (MutableMapping | None) – Store for rendered MIDI audio. None = default file store under ~/.local/share/accompy/artifacts/midi_audio/.

  • enhanced_audio_store (MutableMapping | None) – Store for AI-enhanced audio. None = default file store under ~/.local/share/accompy/artifacts/enhanced_audio/.

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

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

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

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

  • sr (int) – Sample rate for MIDI audio rendering.

Return type:

str

Returns:

Filesystem path to the final audio file.

accompy.rendering.render_chords_batch(configs, **shared_kwargs)[source]#

Run render_chords() for each config dict.

Each dict in configs is merged with shared_kwargs (per-config values take priority over shared defaults).

Parameters:
  • configs (Iterable[dict]) – Iterable of dicts, each containing keyword arguments for render_chords().

  • **shared_kwargs – Default arguments applied to every config.

Return type:

list[str]

Returns:

List of filesystem paths to the final audio files.

Example:

>>> from itertools import product
>>> configs = [
...     dict(chords="| Dm7 | G7 | C^7 |", genre=g, bpm=b)
...     for g, b in product(["jazz", "lofi"], [100, 120])
... ]
>>> paths = render_chords_batch(configs, ai_enhance=False)