accompy.base#
Core domain models for accompy.
Contains Score, ChordEvent, AccompanimentConfig and related data structures.
Functions
|
Coerce common chord-progression formats into a |
Classes
|
Configuration for accompaniment generation. |
|
A chord at a specific position in the progression. |
|
A single MIDI event. |
|
A musical score containing chord events and metadata. |
- class accompy.base.AccompanimentConfig(style='swing', tempo=120, repeats=2, instruments=<factory>, volumes=<factory>, soundfont=None, sample_rate=44100, output_format='wav', chord_resolver=None, pattern_source=None, synthesis_backend=None)[source]#
Bases:
objectConfiguration for accompaniment generation.
This is the single source of truth for all configuration options, including dependency injection hooks for extensibility.
- style#
Musical style (swing, bossa, rock, etc.)
- Type:
Literal['swing','bossa','rock','ballad','funk','latin','waltz','blues']
- class accompy.base.ChordEvent(symbol, beats=4)[source]#
Bases:
objectA chord at a specific position in the progression.
Example
>>> event = ChordEvent("Dm7", beats=4) >>> event.symbol 'D-7'
- class accompy.base.MidiEvent(time, channel, note, velocity, duration)[source]#
Bases:
objectA single MIDI event.
Used for event-based MIDI generation that enables both batch file creation and future real-time streaming.
- class accompy.base.Score(measures, title='Untitled', composer='', key='C', time_signature=(4, 4))[source]#
Bases:
objectA musical score containing chord events and metadata.
This is the domain model for chord progressions. It provides a unified representation regardless of input format (string, iReal URL, tuples, etc.).
Example
>>> score = Score.from_string("| C | Am | F | G |", time_signature=(4, 4)) >>> list(score.measures) [['C'], ['A-'], ['F'], ['G']]
- classmethod from_ireal_url(url)[source]#
Parse an iReal Pro URL into a Score.
- Example::
url = “irealb://Autumn%20Leaves=…” score = Score.from_ireal_url(url)
- Return type:
- classmethod from_string(chord_string, *, title='Untitled', key='C', time_signature=(4, 4))[source]#
Parse a chord string into a Score.
Supports formats:
Simple: “C Am F G” (space-separated, one chord per bar)
Bar lines: “| C | Am | F | G |”
Multi-chord bars: “| C Am | F G |” (chords split evenly)
iReal-style: “C-7 F7 | Bb^7 | Eh7 A7b9 |”
Example
>>> Score.from_string("| Dm7 | G7 | C^7 | % |").measures # % means repeat [['D-7'], ['G7'], ['C^7'], ['C^7']]
- Return type:
- accompy.base.ensure_score(chords, *, title='Untitled', key='C', time_signature=(4, 4))[source]#
Coerce common chord-progression formats into a
Score.Supported inputs:
Score: returned as-isstr: chord string (e.g."| C | Am | F | G |") OR iReal URL (irealbook://...)Iterable[tuple[str, int|float]]: list of(chord, beats)like inaccompanyIterable[str]: chord symbols, one per barlist[list[str]]: already-parsed measures
Notes
Score.measuresinaccompydoes not encode per-chord durations within a bar. For(chord, beats)inputs, durations not equal to whole bars are approximated by grouping chords into bars.
Examples
>>> ensure_score("| C | Am | F | G |", time_signature=(4, 4)).measures [['C'], ['A-'], ['F'], ['G']] >>> ensure_score([("F#m7b5", 4), ("B7", 4), ("Em", 8)], key="E").measures[:3] [['F#h7'], ['B7'], ['E-']]
- Return type: