> built 2026-11-23 07:59 UTC from 5d5840a (main) · accompy 0.3.23. Details: build_info.json

# index.html.md

<!-- generated by epythet -->

# accompy 🎵

Generate backing track audio from chord charts in Python — like iReal Pro, but scriptable.

<!-- wads-docs: skip needs FluidSynth and a SoundFont -->
```python
from accompy import generate_accompaniment

# Generate a bossa nova backing track
audio = generate_accompaniment("| Dm7 | G7 | C^7 | A7b9 |", style="bossa", tempo=140)
print(f"Generated: {audio}")  # -> /tmp/xxx.wav
```

## Features

- **Simple API**: One function to generate complete backing tracks
- **Multiple styles**: Swing, bossa nova, rock, funk, ballad, latin, waltz, blues
- **Flexible chord inputs**: Strings, `Score`, iReal URLs, or `(chord, beats)` tuples
- **Backend selector**: `backend="auto"|"mma"|"builtin"` (with backwards-compatible `use_mma`)
- **iReal Pro compatible**: Parse iReal Pro URLs (`irealb://` and `irealbook://`) directly
- **Multi-instrument**: Drums, bass, piano with style-appropriate patterns
- **Audio output**: WAV, MP3, FLAC via FluidSynth
- **MIDI output**: Save `.mid` directly (skip audio rendering)
- **Extensible**: Add custom patterns and styles

## In the browser (TypeScript twin)

`ts/` holds `accompy` for JavaScript/TypeScript: the same chart parsing, chord resolution, styles and rhythmic skeletons, producing note events (no audio; the browser renders them). Both twins run the same golden cases. See [ts/README.md]().

```ts
import { generateEvents } from "accompy";
const events = generateEvents("| Dm7 | G7 | C^7 |", { style: "bossa" }); // [{ time, channel, note, velocity, duration }, ...]
```

The Python side of that surface is `accompy.generate_events` (events without writing a file) and `accompy.chord_events` (one chord).

## Quick Start

### Installation

```bash
pip install accompy

# Or install from source:
git clone https://github.com/thorwhalen/accompy
pip install -e accompy
```

### System Dependencies

accompy requires **FluidSynth** and a **SoundFont** for audio rendering.

#### Automated Setup (Recommended)

The easiest way to get started:

```bash
# Install accompy
pip install -e .

# Run automated setup (interactive)
python -c "from accompy import verify_and_setup; verify_and_setup()"

# This will:
# - Check all dependencies
# - Offer to install missing ones (with your permission)
# - Download and configure SoundFont files
# - Verify everything works
```

#### Manual Setup

If you prefer to install manually:

```bash
# macOS
brew install fluid-synth

# Ubuntu/Debian
sudo apt-get install fluidsynth fluid-soundfont-gm

# Install Python dependencies
pip install midiutil mingus

# Verify setup
python -m accompy --check-deps
```

#### SoundFont (important for sound quality!)

FluidSynth renders MIDI using **SoundFont** sample banks (`.sf2` files). The SoundFont determines the quality of every instrument you hear. FluidSynth’s bundled SoundFont (`VintageDreamsWaves-v2.sf2`, ~300 KB) is a bare-minimum placeholder made of basic waveforms — **it will sound terrible**.

For good results, install a full General MIDI SoundFont with real instrument samples:

```bash
mkdir -p ~/.fluidsynth

# MuseScore General (~200 MB, MIT license, good all-around quality)
curl -L -o ~/.fluidsynth/default_sound_font.sf2 \
  "https://ftp.osuosl.org/pub/musescore/soundfont/MuseScore_General/MuseScore_General.sf2"
```

Other recommended SoundFonts:

- **GeneralUser GS** (~30 MB) — excellent bass and drums, free for commercial use. Download from [https://schristiancollins.com/generaluser.php](https://schristiancollins.com/generaluser.php)
- **FluidR3_GM** (~140 MB) — the classic GM SoundFont, widely used.

Browse more at [https://musical-artifacts.com/artifacts?formats=sf2](https://musical-artifacts.com/artifacts?formats=sf2).

After downloading, place or symlink the file at `~/.fluidsynth/default_sound_font.sf2` (accompy looks there by default).

#### Check Your Setup

```bash
# Quick check
python -c "from accompy import check_dependencies; print(check_dependencies())"

# Detailed diagnostic report
python -c "from accompy import print_diagnostic_report; print_diagnostic_report()"
```

## Usage

### Basic Usage

<!-- wads-docs: skip needs FluidSynth and a SoundFont -->
```python
from accompy import generate_accompaniment

# Generate with default settings
audio = generate_accompaniment("| C | Am | F | G |")

# Specify style and tempo
audio = generate_accompaniment(
    "| Dm7 | G7 | Cmaj7 | Am7 |",
    style="swing",
    tempo=160,
    repeats=4,
    output_path="my_track.wav",
)

# Generate MIDI only (skip audio rendering)
midi = generate_accompaniment(
    "| Dm7 | G7 | Cmaj7 | Am7 |",
    output_path="my_track.mid",
)
```

### Using Score Objects

For more control, create a `Score` object:

<!-- wads-docs: skip needs FluidSynth and a SoundFont -->
```python
from accompy import Score, generate_accompaniment

# Parse chord string
score = Score.from_string(
    "| Dm7 | G7 | Cmaj7 | % |",  # % = repeat previous chord
    title="ii-V-I in C",
    key="C",
    time_signature=(4, 4)
)

# Generate audio
audio = generate_accompaniment(score, style="swing", tempo=120)

### Flexible Chord Inputs

`generate_accompaniment(...)` accepts several common chord progression formats.

```python
from accompy import ensure_score, generate_accompaniment

# 1) iReal-style chord strings
generate_accompaniment("| C | Am | F | G |")

# 2) iReal Pro URL strings (irealbook://... or irealb://...)
generate_accompaniment("irealbook://Autumn%20Leaves=...")

# 3) List of (chord, beats) tuples (like `accompany`)
chords = [("F#m7b5", 4), ("B7", 4), ("Em", 8)] score = ensure_score(chords, key="E") generate_accompaniment(score)
```

### Backend Selection

Choose which generator to use:

```python
from accompy import generate_accompaniment

# Auto: use MMA if available, else builtin
generate_accompaniment("| Dm7 | G7 | Cmaj7 | Am7 |", backend="auto")

# Force builtin generator
generate_accompaniment("| Dm7 | G7 | Cmaj7 | Am7 |", backend="builtin")

# Force MMA (errors if MMA isn't installed)
generate_accompaniment("| Dm7 | G7 | Cmaj7 | Am7 |", backend="mma")
```

```default

### Chord Notation

accompy supports flexible chord notation:

<!-- wads-docs: skip needs FluidSynth and a SoundFont -->
```python
# Jazz notation (iReal Pro style)
"| C^7 | D-7 | G7 | C^7 |"   # ^7=maj7, -7=min7

# Standard notation  
"| Cmaj7 | Dm7 | G7 | Cmaj7 |"

# Simple notation
"| C | Dm | G | C |"

# Multiple chords per bar
"| Dm7 G7 | Cmaj7 |"  # Two chords, split evenly

# Repeat symbols
"| C | G | % | F |"   # % repeats G
```

**Chord symbol reference:**

| Notation              | Meaning           |
|-----------------------|-------------------|
| `C`, `Cmaj`           | C major           |
| `C-`, `Cm`, `Cmin`    | C minor           |
| `C7`                  | C dominant 7      |
| `C^7`, `Cmaj7`        | C major 7         |
| `C-7`, `Cm7`, `Cmin7` | C minor 7         |
| `Co`, `Cdim`          | C diminished      |
| `Co7`, `Cdim7`        | C diminished 7    |
| `Ch7`, `Cm7b5`        | C half-diminished |
| `C+`, `Caug`          | C augmented       |
| `Csus`, `Csus4`       | C suspended 4th   |

### Styles

Available styles with characteristic patterns:

| Style    | Description                     | Typical Tempo   |
|----------|---------------------------------|-----------------|
| `swing`  | Jazz swing with walking bass    | 120-200 BPM     |
| `bossa`  | Bossa nova with syncopated feel | 100-150 BPM     |
| `rock`   | Straight 8ths rock beat         | 100-140 BPM     |
| `funk`   | Syncopated funk groove          | 90-120 BPM      |
| `ballad` | Slow, sustained ballad          | 60-90 BPM       |
| `latin`  | Latin/salsa with clave          | 100-130 BPM     |
| `waltz`  | 3/4 waltz pattern               | 90-150 BPM      |
| `blues`  | Blues shuffle                   | 80-120 BPM      |

### iReal Pro Integration

Parse and play iReal Pro chord charts:

<!-- wads-docs: skip needs FluidSynth and a SoundFont -->
```python
from accompy import Score, generate_accompaniment

# From iReal Pro URL (copy from app or forum)
url = "irealb://6dim=Composer%20Unknown==Medium%20Swing=C=7=1r34LbKcu7QyX%2DA6XyQ%7C%23G%7CQyXG%2F6C%7CQyXFo%7CQyXE%2F6C%7CQyXoDoXyQ%7CC44T%7BXQyXQQ%7DXyQQyXQyXQyXQyXQyQXyXQyXQyXQyXQyXXyQXyyXoB%7CQyXQyXyQXyyXQyXQyXQyXQyXyQXQyXQyXQyXQyXQQXyQXQyXQyyXQyXQXyQXXQyXQyXQyXQyXQXyQyXQyXQyXQyXQyyQXyQyXQyXQXyQXyQXyQXyQXyQ%20Z%20=Jazz%2DMedium%20Up%20Swing%202=118=21]6dim"
score = Score.from_ireal_url(url)

# Generate backing track
audio = generate_accompaniment(score, style="swing", tempo=140)
```

**Note:** iReal decoding is built in (`accompy.ireal`); no extra package is needed.

### Advanced Configuration

Full control with `AccompanimentConfig`:

<!-- wads-docs: skip needs FluidSynth and a SoundFont -->
```python
from accompy import AccompanimentConfig, generate_accompaniment

config = AccompanimentConfig(
    style="swing",
    tempo=160,
    repeats=4,
    instruments={
        "drums": True,
        "bass": True,
        "piano": True,
        "guitar": False,
    },
    volumes={
        "drums": 0.7,
        "bass": 1.0,
        "piano": 0.6,
    },
    sample_rate=44100,
    output_format="mp3",  # wav, mp3, flac, midi
)

audio = generate_accompaniment(
    "| Dm7 | G7 | Cmaj7 | A7 |", config=config, output_path="backing_track.mp3"
)
```

### Rhythmic Skeletons

For simple chord renderings (no drums or bass — just restriking chords with a rhythmic feel), use `rhythm_to_midi` or `rhythm_to_audio`:

<!-- wads-docs: skip needs FluidSynth and a SoundFont -->
```python
from accompy import rhythm_to_midi, rhythm_to_audio

# Tresillo feel (1.5 + 1.5 + 1 beats)
midi = rhythm_to_midi("| Dm7 | G7 | Cmaj7 |", skeleton="tresillo", tempo=120)
midi.write("tresillo.mid")

# Whole notes (one strike per measure) — the default
midi = rhythm_to_midi("| C | Am | F | G |")

# Charleston, bossa, waltz, and 25+ other built-in skeletons
midi = rhythm_to_midi("| C | Am | F | G |", skeleton="charleston")

# Or pass a raw duration tuple
midi = rhythm_to_midi("| C | Am |", skeleton=(1.5, 0.5, 1.5, 0.5))

# Render all the way to audio
audio = rhythm_to_audio("| C | Am |", skeleton="half_notes", tempo=100)
```

A rhythmic skeleton is just a tuple of durations that sum to the measure length — e.g. `(1.5, 1.5, 1)` says “hit, hold for a dotted quarter; hit again, hold for another dotted quarter; hit once more, hold for a quarter.” No pitches, no voicings, no velocities. The skeleton defines *when* you strike within a measure; the chord progression defines *what* you play.

<!-- wads-docs: skip needs FluidSynth and a SoundFont -->
```python
from accompy import resolve_skeleton, list_skeletons, register_skeleton

# Resolve by key, name, or style
resolve_skeleton("tresillo")  # (1.5, 1.5, 1)
resolve_skeleton("Dotted half + quarter")  # (3, 1)
resolve_skeleton("reggae")  # picks first skeleton for that style

# List available skeletons
list_skeletons()  # all keys
list_skeletons(beats_per_measure=3)  # waltz-family only
list_skeletons(style="jazz")  # jazz-associated skeletons

# Register your own
register_skeleton("my_groove", (1, 0.5, 0.5, 2), name="My Groove", styles=["custom"])
```

### Extensibility & Custom Patterns

**New in v0.2.0**: accompy now supports extensive customization through a protocol-based architecture.

#### Custom Chord Voicings

Provide your own chord-to-notes resolver:

<!-- wads-docs: skip needs FluidSynth and a SoundFont -->
```python
from accompy import set_chord_resolver, generate_accompaniment


def jazz_voicing_resolver(symbol: str) -> list[int]:
    """Custom jazz voicings with rootless chords, tensions, etc."""
    # Your custom chord resolution logic
    # Return list of MIDI note numbers
    return [55, 59, 62, 65, 69]  # Example: Dm9 voicing


# Set as default resolver
set_chord_resolver(jazz_voicing_resolver)

# Now all accompaniments use your custom voicings
audio = generate_accompaniment("| Dm7 | G7 | Cmaj7 |")
```

#### Custom Patterns

Register your own accompaniment patterns:

<!-- wads-docs: skip needs FluidSynth and a SoundFont -->
```python
from accompy import (
    register_style,
    DrumPattern,
    BassPattern,
    DrumHit,
    NoteEvent,
    KICK,
    SNARE,
    CLOSED_HIHAT,
)

# Define custom drum pattern
my_drum = DrumPattern(
    name="my_funk",
    beats_per_bar=4,
    hits=[
        DrumHit(0, KICK, 110),
        DrumHit(0.75, KICK, 85),
        DrumHit(1, SNARE, 105),
        DrumHit(2, KICK, 110),
        DrumHit(3, SNARE, 105),
        # ... more hits
    ],
)

# Define custom bass pattern
my_bass = BassPattern(
    name="my_funk",
    notes=[
        NoteEvent(0, 0, 0.4, 110),  # Root, short
        NoteEvent(0.75, 0, 0.2, 80),  # Root, ghostNote
        NoteEvent(1.5, 7, 0.3, 90),  # 5th
        # ... more notes
    ],
)

# Register the custom style
register_style("my_funk", drums=[my_drum], bass=[my_bass], comp=[])

# Use it
audio = generate_accompaniment("| C7 | F7 | C7 | G7 |", style="my_funk")
```

#### Pattern Registry

The pattern registry is a `MutableMapping`, making it Pythonic and extensible:

<!-- wads-docs: skip needs FluidSynth and a SoundFont -->
```python
from accompy import get_pattern_registry

registry = get_pattern_registry()

# Check available styles
print(registry.available_styles())  # ['swing', 'bossa', 'rock', ...]

# Access patterns like a dict
swing_patterns = registry["swing"]
print(swing_patterns["drums"])  # List of DrumPattern objects

# Add/modify styles at runtime
registry["custom_groove"] = {
    "drums": [custom_drum_pattern],
    "bass": [custom_bass_pattern],
    "comp": [custom_comp_pattern],
}
```

#### Real-Time Event Generation

For advanced use cases (future integration with `hum`/`pyo` for real-time synthesis):

<!-- wads-docs: skip needs FluidSynth and a SoundFont -->
```python
from accompy import RealtimeAccompaniment, AccompanimentConfig

# Create real-time player
config = AccompanimentConfig(tempo=120, style="swing")
player = RealtimeAccompaniment(config)

# Set chord progression
player.set_chords("| Dm7 | G7 | Cmaj7 | A7 |")

# Get event iterator (for future real-time playback)
for event in player.events():
    # event.time, event.note, event.velocity, event.duration
    # Future: send to real-time synth like hum/pyo
    pass
```

#### Protocol-Based Architecture

All major components implement protocols for maximum flexibility:

<!-- wads-docs: skip needs FluidSynth and a SoundFont -->
```python
from accompy.protocols import ChordResolver, PatternSource, SynthesizerBackend

# Implement custom components that satisfy these protocols
# See accompy/protocols.py for full definitions


# Example: Custom synthesis backend
class MySynthBackend(SynthesizerBackend):
    def render_to_file(self, midi_path, output_path, *, sample_rate=44100):
        # Your custom synthesis logic (e.g., using hum, pyo, etc.)
        pass

    @classmethod
    def is_available(cls):
        return True  # Check if dependencies are available


# Use with dependency injection
from accompy import AccompanimentConfig, generate_accompaniment

config = AccompanimentConfig(synthesis_backend=MySynthBackend())
audio = generate_accompaniment("| C | G | Am | F |", config=config)
```

### Command Line

```bash
# Generate backing track
python -m accompy "| C | Am | F | G |" -s bossa -t 120 -o track.wav

# Check dependencies
python -m accompy --check-deps

# Options
python -m accompy --help
```

## How It Works

1. **Parse chords**: Convert chord string → `Score` object with normalized chord symbols
2. **Generate MIDI**: Create multi-track MIDI with drums, bass, piano patterns
   - Uses **MMA** (Musical MIDI Accompaniment) if available for realistic tracks
   - Falls back to built-in pattern generator
3. **Render audio**: Convert MIDI → WAV using **FluidSynth** with SoundFont
4. **Convert format**: Optionally convert to MP3/FLAC via ffmpeg or pydub

### MMA (Musical MIDI Accompaniment)

For the best quality backing tracks, install [MMA](https://www.mellowood.ca/mma/):

```bash
# MMA provides 50+ professionally designed grooves
git clone https://github.com/infojunkie/mma
cd mma && python install  # Follow MMA installation instructions
```

MMA offers extensive groove libraries with realistic fills, variations, and transitions.

## Python Dependencies

Required:

- `midiutil` — MIDI file generation

Recommended:

- `mingus` — Music theory (better chord parsing)
- `midi2audio` — Optional Python wrapper for FluidSynth (can improve portability)
- `pydub` — Audio format conversion (if no ffmpeg)

```bash
pip install midiutil mingus midi2audio pydub
```

## API Reference

### `generate_accompaniment(chords, *, style, tempo, repeats, output_path, output_format, config, use_mma, backend)`

Generate accompaniment audio from chord progression.

**Parameters:**

- `chords` (str | Score | Iterable[tuple[str, int|float]] | Iterable[str] | list[list[str]]): Chord progression
- `style` (str): “swing”, “bossa”, “rock”, “ballad”, “funk”, “latin”, “waltz”, “blues”
- `tempo` (int): BPM (default: 120)
- `repeats` (int): Number of times through the form (default: 2)
- `output_path` (str | Path): Where to save audio (default: temp file)
- `output_format` (str | None): “wav”, “mp3”, “flac”, “midi” (optional; inferred from `output_path`)
- `config` (AccompanimentConfig): Full config (overrides style/tempo/repeats)
- `use_mma` (bool): Backwards-compatible MMA toggle (default: True)
- `backend` (str | None): “auto”, “mma”, “builtin” (optional)

**Returns:** Path to generated audio file

### `Score.from_string(chord_string, *, title, key, time_signature)`

Parse chord string into Score object.

### `Score.from_ireal_url(url)`

Parse iReal Pro URL into Score object.

### `check_dependencies()`

Returns dict of available dependencies.

### `print_setup_instructions()`

Print installation instructions for missing dependencies.

## Troubleshooting

### It sounds awful!

**Problem:** The generated audio plays but sounds robotic, hollow, or like cheap ringtones from 2003.

**Cause:** You’re using a tiny placeholder SoundFont. FluidSynth ships with `VintageDreamsWaves-v2.sf2` (~300 KB), which is made of basic sine waves — not real instrument samples. This is the #1 reason accompy output sounds bad.

**How to check:**

```bash
ls -lh ~/.fluidsynth/default_sound_font.sf2
# If it's under 1 MB, that's your problem.
```

**Fix — install a real SoundFont:**

```bash
# Download MuseScore General (~200 MB, real sampled instruments)
curl -L -o ~/.fluidsynth/default_sound_font.sf2 \
  "https://ftp.osuosl.org/pub/musescore/soundfont/MuseScore_General/MuseScore_General.sf2"
```

A proper SoundFont should be **30–200+ MB**. See the [SoundFont section](index.html.md#soundfont-important-for-sound-quality) above for more options, or browse [https://musical-artifacts.com/artifacts?formats=sf2](https://musical-artifacts.com/artifacts?formats=sf2).

> **Tip:** If you’re using an AI coding agent (Claude Code, Cursor, etc.),
> just tell it:  *“the accompy output sounds bad, find and install a good
> SoundFont”* — it can diagnose and fix this in seconds.

### Common Issues

#### “No SoundFont found” Error

**Problem:** `RuntimeError: No SoundFont found. Download FluidR3_GM.sf2 and place in ~/.fluidsynth/default_sound_font.sf2`

**Solutions:**

1. **Automated fix:**
   ```bash
   python -c "from accompy import setup_soundfont; setup_soundfont()"
   ```
2. **Check if FluidSynth includes a SoundFont:**
   ```bash
   # macOS with Homebrew
   find /opt/homebrew/Cellar/fluid-synth -name "*.sf2"
   ```

   If found, run the automated setup to link it.
3. **Manual download:**
   ```bash
   mkdir -p ~/.fluidsynth
   # Download MuseScore General (high quality, 35MB)
   curl -L -o ~/.fluidsynth/default_sound_font.sf2 \
     "https://ftp.osuosl.org/pub/musescore/soundfont/MuseScore_General/MuseScore_General.sf2"
   ```
4. **Verify the file:**
   ```bash
   ls -lh ~/.fluidsynth/default_sound_font.sf2
   # Should be several MB (not just a few bytes)
   ```

#### “FluidSynth not found” Error

**Problem:** `RuntimeError: FluidSynth not found. Install with: brew install fluidsynth`

**Solutions:**

1. **macOS:**
   ```bash
   brew install fluid-synth
   ```
2. **Ubuntu/Debian:**
   ```bash
   sudo apt-get update
   sudo apt-get install fluidsynth
   ```
3. **Windows:** Download from [FluidSynth releases](https://github.com/FluidSynth/fluidsynth/releases) and add to PATH
4. **Verify installation:**
   ```bash
   which fluidsynth
   fluidsynth --version
   ```

#### SoundFont File is Corrupted (255 bytes)

**Problem:** Downloaded SoundFont is tiny (255 bytes) and appears to be XML

**Cause:** Download URL redirected to an error page

**Solution:**

```bash
# Remove corrupted file
rm ~/.fluidsynth/default_sound_font.sf2

# Use automated setup
python -c "from accompy import setup_soundfont; setup_soundfont(force=True)"

# Or manually download from a reliable source
curl -L -o ~/.fluidsynth/default_sound_font.sf2 \
  "https://ftp.osuosl.org/pub/musescore/soundfont/MuseScore_General/MuseScore_General.sf2"
```

#### Import Warning About Missing Dependencies

**Problem:** Warning on import: `accompy setup incomplete - missing: fluidsynth, soundfont`

**Solutions:**

1. **Run setup:**
   ```bash
   python -c "from accompy import verify_and_setup; verify_and_setup()"
   ```
2. **Temporarily disable warning:**
   ```bash
   export ACCOMPY_SKIP_SETUP_CHECK=1
   python your_script.py
   ```
3. **Fix manually and verify:**
   ```bash
   # Install dependencies
   brew install fluid-synth  # or apt-get install fluidsynth
   pip install midiutil

   # Run diagnostic
   python -c "from accompy import print_diagnostic_report; print_diagnostic_report()"
   ```

#### “midiutil not found” Error

**Problem:** Missing Python dependency

**Solution:**

```bash
pip install midiutil mingus
```

### Diagnostic Tools

#### Run Full Diagnostic

Get a comprehensive report of your setup:

<!-- wads-docs: skip needs FluidSynth and a SoundFont -->
```python
from accompy import print_diagnostic_report

print_diagnostic_report()
```

This shows:

- System information
- Dependency status (✓ or ✗)
- Specific issues found
- Solutions for each issue

#### Check Specific Issues

<!-- wads-docs: skip needs FluidSynth and a SoundFont -->
```python
from accompy import diagnose_issues

for issue, description, solution in diagnose_issues():
    print(f"Issue: {issue}")
    print(f"Description: {description}")
    print(f"Solution: {solution}\n")
```

#### Verify Individual Dependencies

<!-- wads-docs: skip needs FluidSynth and a SoundFont -->
```python
from accompy import check_dependencies

deps = check_dependencies()
print(f"FluidSynth: {deps['fluidsynth']}")
print(f"SoundFont: {deps['soundfont']}")
print(f"midiutil: {deps['midiutil']}")
print(f"mingus: {deps['mingus']}")
print(f"MMA: {deps['mma']}")
```

### Getting Help

If you’re still having issues:

1. Run diagnostic report and save output:
   ```bash
   python -c "from accompy import print_diagnostic_report; print_diagnostic_report()" > diagnostic.txt
   ```
2. Check existing issues: [GitHub Issues](https://github.com/yourname/accompy/issues)
3. Create a new issue with:
   - Your diagnostic report
   - What you tried
   - Full error message

## Contributing

Contributions welcome! Areas of interest:

- Additional styles/grooves
- Better drum fills and variations
- Improved chord voicings
- More instrument parts (guitar, strings, horns)
- Web interface
- Better cross-platform setup automation

## AI agent skills

Two skills ship with this repository. Their real files live in `skills/`, with a relative symlink per skill in `.claude/skills/` so Claude Code finds them too — `gh skill` discovers non-hidden `skills/` directories and skips hidden ones, so one location plus a symlink serves both.

| Skill              | What it covers                                                                             |
|--------------------|--------------------------------------------------------------------------------------------|
| `accompy-patterns` | The conventions this codebase follows                                                      |
| `user-data-folder` | Where an app’s user data lives (XDG paths, `config2py.AppData`, seeding from package data) |
```bash
gh skill install thorwhalen/accompy user-data-folder
```

## License

MIT

## Acknowledgments

- [MMA - Musical MIDI Accompaniment](https://www.mellowood.ca/mma/) by Bob van der Poel
- [FluidSynth](https://www.fluidsynth.org/) team
- [pyRealParser](https://github.com/drs251/pyRealParser) (MIT), the starting point of `accompy.ireal`’s iReal Pro decoding
- [iReal Pro](https://www.irealpro.com/) for inspiration

<p class="epythet-aggregates">This documentation as a single file: <a href="accompy.md">accompy.md</a> (Markdown, for agents).</p>


# _autosummary/accompy.audio_renderers.html.md

# accompy.audio_renderers

Audio renderers — convert MidiData to AudioData.

Registered converters: MidiData -> AudioData

Backends:

- fluidsynth (via midi2audio): renders MIDI using SoundFont sample banks
- pretty_midi.fluidsynth: built-in FluidSynth integration in pretty_midi
- tonal.midi_to_wav: existing tonal package converter

Also provides end-to-end shortcuts: ChordSequence -> AudioData.

### Functions

| [`chordseq_to_audio_musicgen`](_autosummary/accompy.audio_renderers.html.md#accompy.audio_renderers.chordseq_to_audio_musicgen)(cs, \*[, prompt, ...])   | Generate audio directly from chords using MusicGen-Chord.             |
|------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------|
| [`midi_to_audio_dawdreamer`](_autosummary/accompy.audio_renderers.html.md#accompy.audio_renderers.midi_to_audio_dawdreamer)(md, \*[, vst_path, ...])   | Render MIDI to audio using DawDreamer with a VST plugin.              |
| [`midi_to_audio_fluidsynth`](_autosummary/accompy.audio_renderers.html.md#accompy.audio_renderers.midi_to_audio_fluidsynth)(md, \*[, soundfont, sr])   | Render MIDI to audio using FluidSynth CLI directly.                   |
| [`midi_to_audio_pretty_midi`](_autosummary/accompy.audio_renderers.html.md#accompy.audio_renderers.midi_to_audio_pretty_midi)(md, \*[, soundfont, sr])  | Render MIDI to audio using pretty_midi's built-in FluidSynth binding. |
| [`midi_to_audio_tonal`](_autosummary/accompy.audio_renderers.html.md#accompy.audio_renderers.midi_to_audio_tonal)(md, \*[, soundfont, sr])        | Render MIDI to audio using tonal.converters.midi_to_wav.              |

### accompy.audio_renderers.chordseq_to_audio_musicgen(cs, , prompt='smooth jazz trio', duration=None, sr=32000)

Generate audio directly from chords using MusicGen-Chord.

Uses Meta’s MusicGen model conditioned on chord progressions
to generate realistic audio without going through MIDI.

Requires: `pip install audiocraft` (or `pip install accompy[ai]`)

* **Parameters:**
  * **cs** ([`ChordSequence`](_autosummary/accompy.converters.html.md#accompy.converters.ChordSequence)) – Chord progression to render
  * **prompt** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Text description of desired musical style
  * **duration** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`float`](https://docs.python.org/3/builtins/functions.html#float)]) – Duration in seconds. If None, computed from tempo and beats.
  * **sr** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Sample rate (MusicGen default is 32000)
* **Return type:**
  [`AudioData`](_autosummary/accompy.converters.html.md#accompy.converters.AudioData)

```pycon
>>> cs = ChordSequence([("Dm7", 4.0), ("G7", 4.0), ("Cmaj7", 4.0)])
>>> audio = chordseq_to_audio_musicgen(cs, prompt="jazz piano trio")
```

### accompy.audio_renderers.midi_to_audio_dawdreamer(md, , vst_path=None, sr=44100, duration=None, buffer_size=512)

Render MIDI to audio using DawDreamer with a VST plugin.

DawDreamer can host VST2/VST3 plugins for high-quality instrument sounds.
Falls back to a simple sine-wave synth if no VST is specified.

Requires: `pip install dawdreamer` (or `pip install accompy[vst]`)

* **Parameters:**
  * **md** ([`MidiData`](_autosummary/accompy.converters.html.md#accompy.converters.MidiData)) – MIDI data to render
  * **vst_path** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – Path to a VST2/VST3 plugin (.so/.dylib/.dll/.vst3).
    If None, uses DawDreamer’s built-in synth.
  * **sr** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Sample rate
  * **duration** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`float`](https://docs.python.org/3/builtins/functions.html#float)]) – Duration in seconds. If None, computed from MIDI data.
  * **buffer_size** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Audio buffer size for rendering
* **Return type:**
  [`AudioData`](_autosummary/accompy.converters.html.md#accompy.converters.AudioData)

```pycon
>>> # md = MidiData(bytes_=some_midi_bytes)
>>> # audio = midi_to_audio_dawdreamer(md, vst_path="/path/to/plugin.vst3")
```

### accompy.audio_renderers.midi_to_audio_fluidsynth(md, , soundfont=None, sr=44100)

Render MIDI to audio using FluidSynth CLI directly.

Calls the `fluidsynth` binary via subprocess for maximum compatibility
across FluidSynth versions (midi2audio’s wrapper breaks on >=2.x).

Requires:

- FluidSynth installed (brew install fluidsynth / apt install fluidsynth)
- A SoundFont file (.sf2)

```pycon
>>> # md = MidiData(bytes_=some_midi_bytes)
>>> # audio = midi_to_audio_fluidsynth(md)
```

* **Return type:**
  [`AudioData`](_autosummary/accompy.converters.html.md#accompy.converters.AudioData)

### accompy.audio_renderers.midi_to_audio_pretty_midi(md, , soundfont=None, sr=44100)

Render MIDI to audio using pretty_midi’s built-in FluidSynth binding.

This calls pretty_midi’s .fluidsynth() method which uses pyfluidsynth.
Simpler setup than midi2audio but requires the FluidSynth C library.

```pycon
>>> # md = MidiData(pretty_midi_obj=pm)
>>> # audio = midi_to_audio_pretty_midi(md)
```

* **Return type:**
  [`AudioData`](_autosummary/accompy.converters.html.md#accompy.converters.AudioData)

### accompy.audio_renderers.midi_to_audio_tonal(md, , soundfont=None, sr=44100)

Render MIDI to audio using tonal.converters.midi_to_wav.

Uses the tonal package’s existing converter which wraps FluidSynth.

```pycon
>>> # md = MidiData(bytes_=some_midi_bytes)
>>> # audio = midi_to_audio_tonal(md)
```

* **Return type:**
  [`AudioData`](_autosummary/accompy.converters.html.md#accompy.converters.AudioData)


# _autosummary/accompy.base.html.md

# accompy.base

Core domain models for accompy.

Contains Score, ChordEvent, AccompanimentConfig and related data structures.

### Functions

| [`ensure_score`](_autosummary/accompy.base.html.md#accompy.base.ensure_score)(chords, \*[, title, key, ...])   | Coerce common chord-progression formats into a `Score`.   |
|------------------------------------------------------------------------------------------------|-----------------------------------------------------------|

### Classes

| [`AccompanimentConfig`](_autosummary/accompy.base.html.md#accompy.base.AccompanimentConfig)([style, tempo, repeats, ...])   | Configuration for accompaniment generation.           |
|------------------------------------------------------------------------------------------------------|-------------------------------------------------------|
| [`ChordEvent`](_autosummary/accompy.base.html.md#accompy.base.ChordEvent)(symbol[, beats])                         | A chord at a specific position in the progression.    |
| [`MidiEvent`](_autosummary/accompy.base.html.md#accompy.base.MidiEvent)(time, channel, note, velocity, ...)       | A single MIDI event.                                  |
| [`Score`](_autosummary/accompy.base.html.md#accompy.base.Score)(measures[, title, composer, key, ...])        | 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)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

Configuration 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`](https://docs.python.org/3/library/typing.html#typing.Literal)[`'swing'`, `'bossa'`, `'rock'`, `'ballad'`, `'funk'`, `'latin'`, `'waltz'`, `'blues'`]

#### tempo

Beats per minute

* **Type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int)

#### repeats

Number of times to play through the form

* **Type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int)

#### instruments

Which instruments to include

* **Type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`bool`](https://docs.python.org/3/builtins/functions.html#bool)]

#### volumes

Relative volume for each instrument (0.0-1.0)

* **Type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`float`](https://docs.python.org/3/builtins/functions.html#float)]

#### soundfont

Path to SoundFont file for synthesis

* **Type:**
  [`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)]

#### sample_rate

Audio sample rate

* **Type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int)

#### output_format

Output file format

* **Type:**
  [`Literal`](https://docs.python.org/3/library/typing.html#typing.Literal)[`'wav'`, `'mp3'`, `'flac'`, `'midi'`]

#### chord_resolver

Optional custom chord resolution function

* **Type:**
  [`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`Any`](https://docs.python.org/3/library/typing.html#typing.Any)]

#### pattern_source

Optional custom pattern provider

* **Type:**
  [`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`Any`](https://docs.python.org/3/library/typing.html#typing.Any)]

#### synthesis_backend

Optional custom synthesis backend

* **Type:**
  [`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`Any`](https://docs.python.org/3/library/typing.html#typing.Any)]

#### with_overrides(\*\*kwargs)

Create a new config with specified overrides.

This enables immutable updates to configuration.

### Example

```pycon
>>> config = AccompanimentConfig(tempo=120)
>>> fast_config = config.with_overrides(tempo=180)
>>> config.tempo, fast_config.tempo
(120, 180)
```

* **Return type:**
  [`AccompanimentConfig`](_autosummary/accompy.base.html.md#accompy.base.AccompanimentConfig)

### *class* accompy.base.ChordEvent(symbol, beats=4)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

A chord at a specific position in the progression.

### Example

```pycon
>>> event = ChordEvent("Dm7", beats=4)
>>> event.symbol
'D-7'
```

### *class* accompy.base.MidiEvent(time, channel, note, velocity, duration)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

A single MIDI event.

Used for event-based MIDI generation that enables both batch file creation
and future real-time streaming.

#### time

Event time in beats

* **Type:**
  [`float`](https://docs.python.org/3/builtins/functions.html#float)

#### channel

MIDI channel (0-15)

* **Type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int)

#### note

MIDI note number (0-127)

* **Type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int)

#### velocity

Note velocity (0-127)

* **Type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int)

#### duration

Note duration in beats

* **Type:**
  [`float`](https://docs.python.org/3/builtins/functions.html#float)

### *class* accompy.base.Score(measures, title='Untitled', composer='', key='C', time_signature=(4, 4))

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

A 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

```pycon
>>> score = Score.from_string("| C | Am | F | G |", time_signature=(4, 4))
>>> list(score.measures)
[['C'], ['A-'], ['F'], ['G']]
```

#### *classmethod* from_ireal_url(url)

Parse an iReal Pro URL into a Score.

Example::
: url = “irealb://Autumn%20Leaves=…”
  score = Score.from_ireal_url(url)

* **Return type:**
  [`Score`](_autosummary/accompy.base.html.md#accompy.base.Score)

#### *classmethod* from_string(chord_string, , title='Untitled', key='C', time_signature=(4, 4))

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

```pycon
>>> Score.from_string("| Dm7 | G7 | C^7 | % |").measures  # % means repeat
[['D-7'], ['G7'], ['C^7'], ['C^7']]
```

* **Return type:**
  [`Score`](_autosummary/accompy.base.html.md#accompy.base.Score)

#### to_chord_sequence(, tempo=120)

Convert Score to a ChordSequence (from the converter pipeline).

Each chord gets a duration proportional to its share of the bar.

### Example

```pycon
>>> score = Score.from_string("| Dm7 | G7 | C^7 |")
>>> cs = score.to_chord_sequence(tempo=160)
>>> len(cs)
3
```

### accompy.base.ensure_score(chords, , title='Untitled', key='C', time_signature=(4, 4))

Coerce common chord-progression formats into a `Score`.

Supported inputs:

- `Score`: returned as-is
- `str`: chord string (e.g. `"| C | Am | F | G |"`) OR iReal URL (`irealbook://...`)
- `Iterable[tuple[str, int|float]]`: list of `(chord, beats)` like in `accompany`
- `Iterable[str]`: chord symbols, one per bar
- `list[list[str]]`: already-parsed measures

### Notes

- `Score.measures` in `accompy` does 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

```pycon
>>> 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:**
  [`Score`](_autosummary/accompy.base.html.md#accompy.base.Score)


# _autosummary/accompy.chord_parsers.html.md

# accompy.chord_parsers

Chord sheet parsers — convert various text formats to ChordSequence.

Registered converters: ChordSheet -> ChordSequence

Supported formats:

- Plain text: “C Am F G” or “| Dm7 | G7 | Cmaj7 

  ```
  |
  ```

  ”
- iReal Pro URLs: “irealb://…”
- ChordPro: “[C]lyrics [Am]more lyrics”
- MusicGen-Chord format: “C D:min G:7 C” (space-separated bars)

Each parser is registered in the global converter registry so you can do:

```default
from accompy.wips.types import convert, ChordSheet, ChordSequence
cs = convert(ChordSheet("| Dm7 | G7 | Cmaj7 |"), ChordSequence)
```

### Functions

| [`parse_chord_sheet`](_autosummary/accompy.chord_parsers.html.md#accompy.chord_parsers.parse_chord_sheet)(sheet, \*[, beats_per_bar, ...])   | Auto-detect format and parse a chord sheet into ChordSequence.               |
|-------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------|
| [`parse_chordpro`](_autosummary/accompy.chord_parsers.html.md#accompy.chord_parsers.parse_chordpro)(sheet, \*[, beats_per_bar, tempo])    | Parse ChordPro format into a ChordSequence, keeping the section structure.   |
| [`parse_ireal_url`](_autosummary/accompy.chord_parsers.html.md#accompy.chord_parsers.parse_ireal_url)(url, \*[, beats_per_bar])            | Parse an iReal Pro URL into a ChordSequence; a bar's chords share it evenly. |
| [`parse_musicgen_chord_format`](_autosummary/accompy.chord_parsers.html.md#accompy.chord_parsers.parse_musicgen_chord_format)(sheet, \*[, ...])        | Parse MusicGen-Chord text format into ChordSequence.                         |
| [`parse_nashville`](_autosummary/accompy.chord_parsers.html.md#accompy.chord_parsers.parse_nashville)(sheet, \*[, key, ...])               | Parse Nashville number system notation into a ChordSequence.                 |
| [`parse_plain_text`](_autosummary/accompy.chord_parsers.html.md#accompy.chord_parsers.parse_plain_text)(sheet, \*[, beats_per_bar, ...])    | Parse a plain-text chord sheet into a ChordSequence.                         |
| [`parse_roman_numeral`](_autosummary/accompy.chord_parsers.html.md#accompy.chord_parsers.parse_roman_numeral)(sheet, \*[, key, ...])           | Parse Roman numeral notation into a ChordSequence.                           |

### accompy.chord_parsers.parse_chord_sheet(sheet, , beats_per_bar=None, tempo=120, title='', key='C', time_signature=(4, 4))

Auto-detect format and parse a chord sheet into ChordSequence.

`beats_per_bar` defaults to the tune’s time signature for an iReal URL, and to 4
for the other formats.

Detects:

- iReal Pro URLs (starts with ‘irealb://’ or ‘irealbook://’)
- ChordPro (contains ‘[’ chord brackets AND text between them)
- MusicGen-Chord format (contains ‘:’ colons in chord symbols)
- Roman numeral notation (tokens like I, ii, V7, bVII)
- Nashville number system (tokens like 1, 2m7, 5, b7)
- Plain text (everything else)

```pycon
>>> cs = parse_chord_sheet("| Dm7 | G7 | Cmaj7 |")
>>> cs.symbols
['Dm7', 'G7', 'Cmaj7']
```

```pycon
>>> cs = parse_chord_sheet("[Am]Hello [G]world")
>>> cs.symbols
['Am', 'G']
```

* **Return type:**
  [`ChordSequence`](_autosummary/accompy.converters.html.md#accompy.converters.ChordSequence)

### accompy.chord_parsers.parse_chordpro(sheet, , beats_per_bar=4, tempo=120)

Parse ChordPro format into a ChordSequence, keeping the section structure.

ChordPro embeds chords in brackets within lyrics:
“[Am]Hello [G]world [C]”

Extracts the chord symbols, one per bar by default. Sections come from the
`{start_of_verse}` / `{soc}` / `{start_of_bridge: label}` directives
(and `{comment: Chorus}`) or a bare `[Chorus]` line; they land in
`ChordSequence.sections` as `(label, start, stop)` ranges over the chords.

```pycon
>>> cs = parse_chordpro("[Am]Hello [G]world [C]")
>>> cs.symbols
['Am', 'G', 'C']
>>> cs = parse_chordpro("{sov}\n[Am]la [G]la\n{eov}\n[Chorus]\n[C]sing [F]out")
>>> cs.sections
[('Verse', 0, 2), ('Chorus', 2, 4)]
```

* **Return type:**
  [`ChordSequence`](_autosummary/accompy.converters.html.md#accompy.converters.ChordSequence)

### accompy.chord_parsers.parse_ireal_url(url, , beats_per_bar=None)

Parse an iReal Pro URL into a ChordSequence; a bar’s chords share it evenly.

Decoding is [`accompy.ireal.decode_ireal_url()`](_autosummary/accompy.ireal.html.md#accompy.ireal.decode_ireal_url); the first tune with chords is
used. Bars last `beats_per_bar` beats, by default the tune’s time-signature
numerator. Raises `ValueError` when no tune has chords.

```pycon
>>> cs = parse_ireal_url("irealbook://Blues=Me=Swing=F=n=[T34F7 |Bb7 Bo7 Z")
>>> cs.chords, cs.time_signature
([('F7', 3.0), ('Bb7', 1.5), ('Bo7', 1.5)], (3, 4))
```

* **Return type:**
  [`ChordSequence`](_autosummary/accompy.converters.html.md#accompy.converters.ChordSequence)

### accompy.chord_parsers.parse_musicgen_chord_format(sheet, , beats_per_bar=4, tempo=120)

Parse MusicGen-Chord text format into ChordSequence.

MusicGen-Chord uses space-separated bars with colon for quality:
“C D:min G:7 C” means C | Dm | G7 | C

Within a bar, comma separates chords:
“C:maj,G:maj E:min,A:min” means C G | Em Am

```pycon
>>> cs = parse_musicgen_chord_format("C D:min G:7 C")
>>> cs.symbols
['C', 'D:min', 'G:7', 'C']
>>> cs.durations
[4.0, 4.0, 4.0, 4.0]
```

```pycon
>>> cs = parse_musicgen_chord_format("C:maj,G:maj E:min")
>>> len(cs)
3
```

* **Return type:**
  [`ChordSequence`](_autosummary/accompy.converters.html.md#accompy.converters.ChordSequence)

### accompy.chord_parsers.parse_nashville(sheet, , key='C', beats_per_bar=4, tempo=120, title='', time_signature=(4, 4))

Parse Nashville number system notation into a ChordSequence.

Nashville numbers use scale degree numbers instead of note names:

- “1 4 5 1” in C = C F G C
- Quality suffixes: “2m7 5 1maj7”
- Accidentals: “b7” = flat seventh scale degree
- Bar lines supported: “| 2m7 | 5 | 1maj7 

  ```
  |
  ```

  ”

```pycon
>>> cs = parse_nashville("| 2m7 | 5 | 1maj7 |", key="C")
>>> cs.symbols
['Dm7', 'G', 'Cmaj7']
```

```pycon
>>> cs = parse_nashville("1 4 5 1", key="G")
>>> cs.symbols
['G', 'C', 'D', 'G']
```

```pycon
>>> cs = parse_nashville("| 2m7 | 57 | 1maj7 |", key="Bb")
>>> cs.symbols
['Cm7', 'F7', 'Bbmaj7']
```

* **Return type:**
  [`ChordSequence`](_autosummary/accompy.converters.html.md#accompy.converters.ChordSequence)

### accompy.chord_parsers.parse_plain_text(sheet, , beats_per_bar=4, tempo=120, title='', key='C', time_signature=(4, 4))

Parse a plain-text chord sheet into a ChordSequence.

Supports:

- Bar-line format: “| C | Am | F | G 

  ```
  |
  ```

  ”
- Multi-chord bars: “| C Am | F G 

  ```
  |
  ```

  ”
- Space-separated: “C Am F G”
- Repeat markers: “%” repeats previous chord/bar

```pycon
>>> cs = parse_plain_text("| Dm7 | G7 | Cmaj7 |")
>>> cs.symbols
['Dm7', 'G7', 'Cmaj7']
>>> cs.durations
[4.0, 4.0, 4.0]
```

```pycon
>>> cs = parse_plain_text("| C Am | F G |")
>>> cs.symbols
['C', 'Am', 'F', 'G']
>>> cs.durations
[2.0, 2.0, 2.0, 2.0]
```

```pycon
>>> cs = parse_plain_text("C Am F G")
>>> len(cs)
4
```

* **Return type:**
  [`ChordSequence`](_autosummary/accompy.converters.html.md#accompy.converters.ChordSequence)

### accompy.chord_parsers.parse_roman_numeral(sheet, , key='C', beats_per_bar=4, tempo=120, title='', time_signature=(4, 4))

Parse Roman numeral notation into a ChordSequence.

Supports:

- Upper case for major: I, IV, V
- Lower case for minor: ii, vi, iii
- Quality suffixes: ii7, V7, Imaj7, viidim, viio, iim7b5
- Accidentals: bVII, #IV
- Bar lines: “| ii7 | V7 | Imaj7 

  ```
  |
  ```

  ”
- Space-separated: “I IV V I”

```pycon
>>> cs = parse_roman_numeral("| ii7 | V7 | Imaj7 |", key="C")
>>> cs.symbols
['Dm7', 'G7', 'Cmaj7']
```

```pycon
>>> cs = parse_roman_numeral("I IV V I", key="G")
>>> cs.symbols
['G', 'C', 'D', 'G']
```

```pycon
>>> cs = parse_roman_numeral("| ii7 | V7 | Imaj7 |", key="F")
>>> cs.symbols
['Gm7', 'C7', 'Fmaj7']
```

* **Return type:**
  [`ChordSequence`](_autosummary/accompy.converters.html.md#accompy.converters.ChordSequence)


# _autosummary/accompy.chord_resolution.html.md

# accompy.chord_resolution

Chord symbol to MIDI notes resolution.

Provides pluggable chord resolution with multiple backends (tonal, music21).
Implements dependency injection pattern for flexibility.

### Functions

| [`chord_to_notes`](_autosummary/accompy.chord_resolution.html.md#accompy.chord_resolution.chord_to_notes)(symbol)                    | Convert chord symbol to MIDI notes using the current default resolver.   |
|--------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [`get_chord_resolver`](_autosummary/accompy.chord_resolution.html.md#accompy.chord_resolution.get_chord_resolver)()                      | Get the current default chord resolver.                                  |
| [`music21_resolver`](_autosummary/accompy.chord_resolution.html.md#accompy.chord_resolution.music21_resolver)(symbol, \*[, transpose]) | Resolve chord symbol using music21 library (alternative).                |
| [`set_chord_resolver`](_autosummary/accompy.chord_resolution.html.md#accompy.chord_resolution.set_chord_resolver)(resolver)              | Set the default chord resolver.                                          |
| [`tonal_resolver`](_autosummary/accompy.chord_resolution.html.md#accompy.chord_resolution.tonal_resolver)(symbol, \*[, transpose])   | Resolve chord symbol to MIDI notes using the tonal package (default).    |

### accompy.chord_resolution.chord_to_notes(symbol)

Convert chord symbol to MIDI notes using the current default resolver.

This is the main entry point for chord resolution in accompy.

* **Parameters:**
  **symbol** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Chord symbol (e.g., “Dm7”, “G7”)
* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`int`](https://docs.python.org/3/builtins/functions.html#int)]
* **Returns:**
  List of MIDI note numbers

### Example

```pycon
>>> notes = chord_to_notes("C")
>>> len(notes) > 0
True
```

### accompy.chord_resolution.get_chord_resolver()

Get the current default chord resolver.

* **Return type:**
  [`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)[[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)], [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`int`](https://docs.python.org/3/builtins/functions.html#int)]]
* **Returns:**
  The active chord resolution function

### Example

```pycon
>>> resolver = get_chord_resolver()
>>> notes = resolver("C")
>>> len(notes) > 0
True
```

### accompy.chord_resolution.music21_resolver(symbol, , transpose=-12)

Resolve chord symbol using music21 library (alternative).

Music21 is a comprehensive music analysis library. It provides more
sophisticated chord parsing but has heavier dependencies.

* **Parameters:**
  * **symbol** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Chord symbol
  * **transpose** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Semitone offset to apply (default: -12)
* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`int`](https://docs.python.org/3/builtins/functions.html#int)]
* **Returns:**
  List of MIDI note numbers

#### NOTE
Requires: pip install music21
This is provided as an alternative for advanced use cases.
Consider using tonal_resolver for standard accompaniment generation.

### accompy.chord_resolution.set_chord_resolver(resolver)

Set the default chord resolver.

This enables global customization of chord-to-notes resolution.

* **Parameters:**
  **resolver** ([`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)[[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)], [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`int`](https://docs.python.org/3/builtins/functions.html#int)]]) – A function that takes a chord symbol (str) and returns MIDI notes (list[int])
* **Return type:**
  [`None`](https://docs.python.org/3/builtins/constants.html#None)

### Example

```pycon
>>> def my_resolver(symbol: str) -> list[int]:
...     # Custom chord voicing logic
...     return [60, 64, 67]  # C major triad
>>> previous = get_chord_resolver()
>>> set_chord_resolver(my_resolver)
>>> chord_to_notes("Dm7")
[60, 64, 67]
>>> set_chord_resolver(previous)  # put the default back: the setting is process-global
```

### accompy.chord_resolution.tonal_resolver(symbol, , transpose=-12)

Resolve chord symbol to MIDI notes using the tonal package (default).

The tonal package is lightweight and designed for music theory operations.
It anchors chord roots around C4=60. We apply a default -12 semitone transpose
to voice chords closer to C3=48 for better bass/piano range.

* **Parameters:**
  * **symbol** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Chord symbol (e.g., “Dm7”, “G7”, “Cmaj7”)
  * **transpose** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Semitone offset to apply (default: -12)
* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`int`](https://docs.python.org/3/builtins/functions.html#int)]
* **Returns:**
  List of MIDI note numbers

### Example

```pycon
>>> notes = tonal_resolver("Cmaj7")
>>> len(notes) > 0
True
```

#### NOTE
Requires: pip install tonal
See: [https://github.com/thorwhalen/tonal](https://github.com/thorwhalen/tonal)


# _autosummary/accompy.chord_resolvers.html.md

# accompy.chord_resolvers

Chord resolvers — convert chord symbols to MIDI note numbers.

Registered converters: ChordSequence -> NoteSequence

Multiple backends, each wrapping a different music theory library:

- pychord: lightweight, good coverage of standard chord types
- music21: comprehensive, heavyweight, handles edge cases well
- mingus: pure Python music theory, no C dependencies
- tonal: the existing accompy dependency (thorwhalen/tonal)

Each resolver is a function: chord_symbol (str) -> list[int] (MIDI notes).
We also provide converters that operate on whole ChordSequences.

### Functions

| [`chordseq_to_noteseq_mingus`](_autosummary/accompy.chord_resolvers.html.md#accompy.chord_resolvers.chordseq_to_noteseq_mingus)(cs)                  | Convert ChordSequence to NoteSequence using mingus.           |
|--------------------------------------------------------------------------------------------------|---------------------------------------------------------------|
| [`chordseq_to_noteseq_music21`](_autosummary/accompy.chord_resolvers.html.md#accompy.chord_resolvers.chordseq_to_noteseq_music21)(cs)                 | Convert ChordSequence to NoteSequence using music21.          |
| [`chordseq_to_noteseq_pychord`](_autosummary/accompy.chord_resolvers.html.md#accompy.chord_resolvers.chordseq_to_noteseq_pychord)(cs)                 | Convert ChordSequence to NoteSequence using pychord.          |
| [`chordseq_to_noteseq_tonal`](_autosummary/accompy.chord_resolvers.html.md#accompy.chord_resolvers.chordseq_to_noteseq_tonal)(cs)                   | Convert ChordSequence to NoteSequence using tonal.            |
| [`resolve_with_mingus`](_autosummary/accompy.chord_resolvers.html.md#accompy.chord_resolvers.resolve_with_mingus)(symbol, \*[, root_octave])  | Resolve a chord symbol to MIDI notes using mingus.            |
| [`resolve_with_music21`](_autosummary/accompy.chord_resolvers.html.md#accompy.chord_resolvers.resolve_with_music21)(symbol, \*[, root_octave]) | Resolve a chord symbol to MIDI notes using music21.           |
| [`resolve_with_pychord`](_autosummary/accompy.chord_resolvers.html.md#accompy.chord_resolvers.resolve_with_pychord)(symbol, \*[, root_octave]) | Resolve a chord symbol to MIDI notes using pychord.           |
| [`resolve_with_tonal`](_autosummary/accompy.chord_resolvers.html.md#accompy.chord_resolvers.resolve_with_tonal)(symbol, \*[, transpose])     | Resolve a chord symbol to MIDI notes using the tonal package. |

### accompy.chord_resolvers.chordseq_to_noteseq_mingus(cs)

Convert ChordSequence to NoteSequence using mingus.

* **Return type:**
  [`NoteSequence`](_autosummary/accompy.converters.html.md#accompy.converters.NoteSequence)

### accompy.chord_resolvers.chordseq_to_noteseq_music21(cs)

Convert ChordSequence to NoteSequence using music21.

* **Return type:**
  [`NoteSequence`](_autosummary/accompy.converters.html.md#accompy.converters.NoteSequence)

### accompy.chord_resolvers.chordseq_to_noteseq_pychord(cs)

Convert ChordSequence to NoteSequence using pychord.

* **Return type:**
  [`NoteSequence`](_autosummary/accompy.converters.html.md#accompy.converters.NoteSequence)

### accompy.chord_resolvers.chordseq_to_noteseq_tonal(cs)

Convert ChordSequence to NoteSequence using tonal.

* **Return type:**
  [`NoteSequence`](_autosummary/accompy.converters.html.md#accompy.converters.NoteSequence)

### accompy.chord_resolvers.resolve_with_mingus(symbol, , root_octave=3)

Resolve a chord symbol to MIDI notes using mingus.

```pycon
>>> resolve_with_mingus("Cmaj7")
[36, 40, 43, 47]
```

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`int`](https://docs.python.org/3/builtins/functions.html#int)]

### accompy.chord_resolvers.resolve_with_music21(symbol, , root_octave=3)

Resolve a chord symbol to MIDI notes using music21.

Handles the widest range of chord types including altered chords.

```pycon
>>> resolve_with_music21("Cmaj7")
[48, 52, 55, 59]
```

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`int`](https://docs.python.org/3/builtins/functions.html#int)]

### accompy.chord_resolvers.resolve_with_pychord(symbol, , root_octave=3)

Resolve a chord symbol to MIDI notes using pychord.

```pycon
>>> resolve_with_pychord("Cmaj7")
[48, 52, 55, 59]
>>> resolve_with_pychord("Am")
[57, 60, 64]
```

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`int`](https://docs.python.org/3/builtins/functions.html#int)]

### accompy.chord_resolvers.resolve_with_tonal(symbol, , transpose=-12)

Resolve a chord symbol to MIDI notes using the tonal package.

This is accompy’s existing default resolver.

```pycon
>>> resolve_with_tonal("Cmaj7")
[48, 52, 55, 59]
```

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`int`](https://docs.python.org/3/builtins/functions.html#int)]


# _autosummary/accompy.converters.html.md

# accompy.converters

Core types for the chord-to-audio pipeline.

Defines the data types that flow through the pipeline, plus a converter
registry that maps (source_type, target_type) pairs to converter functions.

The key types form a DAG:

```default
ChordSheet --> ChordSequence --> NoteSequence --> MidiData --> AudioData

(Plus shortcut converters that skip intermediate steps.)
```

Usage:

```default
>>> from accompy.wips.types import converter, ChordSequence, MidiData
>>> # Get a specific converter
>>> to_midi = converter[ChordSequence, MidiData]
>>> # Or convert in one call
>>> midi = convert(chord_seq, MidiData)
```

### Functions

| [`convert`](_autosummary/accompy.converters.html.md#accompy.converters.convert)(source, target_type, \*[, via])   | Convert source to target_type using the registered converter.   |
|--------------------------------------------------------------------------------------------|-----------------------------------------------------------------|

### Classes

| [`AudioData`](_autosummary/accompy.converters.html.md#accompy.converters.AudioData)(waveform[, sr])                       | Container for audio data — numpy array + sample rate.                     |
|--------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------|
| [`ChordSequence`](_autosummary/accompy.converters.html.md#accompy.converters.ChordSequence)(chords[, title, key, tempo, ...]) | Ordered sequence of (chord_symbol, duration_beats) pairs with metadata.   |
| [`ConverterRegistry`](_autosummary/accompy.converters.html.md#accompy.converters.ConverterRegistry)()                             | Registry mapping (source_type, target_type) to named converter functions. |
| [`MidiData`](_autosummary/accompy.converters.html.md#accompy.converters.MidiData)([bytes_, pretty_midi_obj, tempo, ...]) | Container for MIDI data — either as bytes or as a pretty_midi object.     |
| [`NoteSequence`](_autosummary/accompy.converters.html.md#accompy.converters.NoteSequence)(notes[, tempo, time_signature])    | Ordered sequence of (midi_notes, duration_beats) with metadata.           |

### *class* accompy.converters.AudioData(waveform, sr=44100)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

Container for audio data — numpy array + sample rate.

```pycon
>>> import numpy as np
>>> ad = AudioData(waveform=np.zeros(44100), sr=44100)
>>> ad.duration_seconds
1.0
```

#### to_wav_bytes()

Convert to WAV file bytes.

* **Return type:**
  [`bytes`](https://docs.python.org/3/builtins/stdtypes.html#bytes)

#### write(path)

Write audio to a WAV file. Returns the path.

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### *class* accompy.converters.ChordSequence(chords, title='', key='C', tempo=120, time_signature=(4, 4), sections=list())

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

Ordered sequence of (chord_symbol, duration_beats) pairs with metadata.

This is the canonical internal representation of a chord progression.

```pycon
>>> cs = ChordSequence([("Dm7", 4.0), ("G7", 4.0), ("Cmaj7", 8.0)])
>>> len(cs)
3
>>> cs[0]
('Dm7', 4.0)
>>> cs.total_beats
16.0
```

#### *property* durations *: [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[float](https://docs.python.org/3/builtins/functions.html#float)]*

Just the durations, without symbols.

#### section_chords(label)

The chords of the first section called `label` (case-insensitive), or `[]`.

```pycon
>>> cs = ChordSequence([("C", 4.0), ("G", 4.0)], sections=[("Verse", 0, 1), ("Chorus", 1, 2)])
>>> cs.section_chords("chorus")
[('G', 4.0)]
```

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`float`](https://docs.python.org/3/builtins/functions.html#float)]]

#### sections *: [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), [int](https://docs.python.org/3/builtins/functions.html#int), [int](https://docs.python.org/3/builtins/functions.html#int)]]*

`(label, start, stop)` where
`chords[start:stop]` are the section’s chords (see [`section_chords()`](_autosummary/accompy.converters.html.md#accompy.converters.ChordSequence.section_chords)).

* **Type:**
  Song structure, when the source has it

#### *property* symbols *: [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[str](https://docs.python.org/3/builtins/stdtypes.html#str)]*

Just the chord symbols, without durations.

#### to_score()

Convert to an accompy Score for pattern-based accompaniment.

### Example

```pycon
>>> cs = ChordSequence([("Dm7", 4.0), ("G7", 4.0)])
>>> score = cs.to_score()
>>> len(score)
2
```

### *class* accompy.converters.ConverterRegistry

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

Registry mapping (source_type, target_type) to named converter functions.

Supports multiple converters for the same type pair, distinguished by name.
The first registered converter becomes the default.

```pycon
>>> reg = ConverterRegistry()
>>> reg.register(str, int, int, name='builtin')
>>> reg[str, int]('42')
42
>>> reg.list_converters(str, int)
['builtin']
```

#### get(source_type, target_type, name=None)

Get a specific named converter, or the default if name is None.

* **Return type:**
  [`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)

#### list_converters(source_type, target_type)

List available converter names for a type pair.

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

#### list_pairs()

List all registered (source, target) type name pairs.

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]]

#### register(source_type, target_type, func, , name='', is_default=False)

Register a converter function.

* **Parameters:**
  * **source_type** ([`type`](https://docs.python.org/3/builtins/functions.html#type)) – The input type
  * **target_type** ([`type`](https://docs.python.org/3/builtins/functions.html#type)) – The output type
  * **func** ([`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)) – The converter function (source -> target)
  * **name** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Name for this converter (defaults to func._\_name_\_)
  * **is_default** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – If True, make this the default converter for this pair
* **Return type:**
  [`None`](https://docs.python.org/3/builtins/constants.html#None)

#### set_default(source_type, target_type, name)

Change the default converter for a type pair.

* **Return type:**
  [`None`](https://docs.python.org/3/builtins/constants.html#None)

### *class* accompy.converters.MidiData(bytes_=None, pretty_midi_obj=None, tempo=120, time_signature=(4, 4))

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

Container for MIDI data — either as bytes or as a pretty_midi object.

Wraps MIDI content so converters have a uniform interface regardless
of which MIDI library produced the data.

```pycon
>>> import io
>>> md = MidiData(bytes_=b'MThd...', tempo=120)
>>> md.has_bytes
True
```

#### to_bytes()

Get MIDI as bytes, converting from pretty_midi if needed.

* **Return type:**
  [`bytes`](https://docs.python.org/3/builtins/stdtypes.html#bytes)

#### to_pretty_midi()

Get as pretty_midi.PrettyMIDI, converting from bytes if needed.

#### write(path)

Write MIDI to a file. Returns the path.

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### *class* accompy.converters.NoteSequence(notes, tempo=120, time_signature=(4, 4))

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

Ordered sequence of (midi_notes, duration_beats) with metadata.

Represents resolved chords — chord symbols have been converted to
concrete MIDI note numbers.

```pycon
>>> ns = NoteSequence([([60, 64, 67], 4.0), ([62, 65, 69], 4.0)])
>>> ns[0]
([60, 64, 67], 4.0)
```

### accompy.converters.convert(source, target_type, , via=None)

Convert source to target_type using the registered converter.

* **Parameters:**
  * **source** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any)) – The source data
  * **target_type** ([`type`](https://docs.python.org/3/builtins/functions.html#type)) – The desired output type
  * **via** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Optional converter name (uses default if None)
* **Return type:**
  [`Any`](https://docs.python.org/3/library/typing.html#typing.Any)
* **Returns:**
  Converted data of target_type

Example:

```default
>>> # After converters are registered:
>>> # audio = convert(chord_seq, AudioData)
```


# _autosummary/accompy.data_access.html.md

# accompy.data_access

Per-user data directory management for accompy.

Provides cross-platform access to:

- `~/.config/accompy/`  — user preferences and settings
- `~/.local/share/accompy/resources/` — editable reference data (seeded from package)
- `~/.local/share/accompy/artifacts/<kind>/` — runtime-generated files

Seed files ship inside `accompy/_seed_data/` and are copied to userspace on
first access (seed-on-missing pattern).  All XDG resolution and seeding logic
is delegated to `config2py.AppData`.

### Functions

| [`load_resource_json`](_autosummary/accompy.data_access.html.md#accompy.data_access.load_resource_json)(name)   | Read a resource file as JSON.                               |
|-----------------------------------------------------------------------------|-------------------------------------------------------------|
| [`load_resource_lines`](_autosummary/accompy.data_access.html.md#accompy.data_access.load_resource_lines)(name)  | Read a resource file as a list of non-empty stripped lines. |
| [`load_resource_text`](_autosummary/accompy.data_access.html.md#accompy.data_access.load_resource_text)(name)   | Read a resource file as text.                               |

### accompy.data_access.load_resource_json(name)

Read a resource file as JSON.

### accompy.data_access.load_resource_lines(name)

Read a resource file as a list of non-empty stripped lines.

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

### accompy.data_access.load_resource_text(name)

Read a resource file as text.

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)


# _autosummary/accompy.html.md

# accompy

accompy - Generate accompaniment audio from chord charts.

Generate backing tracks with bass, drums, piano from chord progressions,
similar to iReal Pro.

### Example

```pycon
>>> from accompy import generate_accompaniment, Score
>>>
>>> # Simple usage
>>> path = generate_accompaniment("| C | Am | F | G |", style="bossa", tempo=120)
>>>
>>> # With Score object for more control
>>> score = Score.from_string("| Dm7 | G7 | C^7 | A7b9 |", title="ii-V-I")
>>> path = generate_accompaniment(score, style="swing", tempo=160, repeats=4)
```

Available styles: swing, bossa, rock, ballad, funk, latin, waltz, blues

Converter Pipeline:

```pycon
>>> from accompy import converter, ChordSequence, MidiData, convert
>>> # List available converters for a given step
>>> converter.list_converters(ChordSequence, MidiData)
>>> # Convert using the default or a named converter
>>> midi = convert(chord_seq, MidiData)
>>> midi = convert(chord_seq, MidiData, via="midiutil")
```

Advanced Usage (Extensibility):

```pycon
>>> # Register custom patterns
>>> from accompy import get_pattern_registry
>>> registry = get_pattern_registry()
>>> # registry['my_style'] = {'drums': [...], 'bass': [...], 'comp': [...]}
>>>
>>> # Use custom chord resolver
>>> from accompy import set_chord_resolver
>>> # set_chord_resolver(my_custom_resolver)
>>>
>>> # Access protocol definitions for custom implementations
>>> from accompy.protocols import ChordResolver, PatternSource, SynthesizerBackend
```

### Functions

| [`generate_accompaniment`](_autosummary/accompy.html.md#accompy.generate_accompaniment)(chords, \*[, style, ...])   | Generate an accompaniment audio file from a chord progression.                                                                         |
|-----------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------|
| [`generate_events`](_autosummary/accompy.html.md#accompy.generate_events)(chords, \*[, style, repeats, ...]) | The note events the builtin backend plays for `chords`, without writing a file.                                                        |
| [`chord_events`](_autosummary/accompy.html.md#accompy.chord_events)(chord_notes, \*[, style, ...])        | The drum, bass and piano events `style` plays over one chord.                                                                          |
| [`select_patterns`](_autosummary/accompy.html.md#accompy.select_patterns)(patterns, beats_per_bar)           | The `(drum, bass, comp)` patterns the renderer plays from a style's pattern lists.                                                     |
| [`pitch_classes`](_autosummary/accompy.html.md#accompy.pitch_classes)(notes)                               | Return unique pitch classes (0-11) as a tuple.                                                                                         |
| [`resolve_pitch_offset`](_autosummary/accompy.html.md#accompy.resolve_pitch_offset)(\*, root_pc, chord_pcs, ...)  | Resolve a pitch offset against a chord.                                                                                                |
| [`bass_pitch`](_autosummary/accompy.html.md#accompy.bass_pitch)(root, chord_notes, pitch_offset)        | The bass note a pattern's `pitch_offset` plays over a chord.                                                                           |
| [`comp_voicing`](_autosummary/accompy.html.md#accompy.comp_voicing)(chord_notes)                          | The notes the piano plays for a chord: its first four notes moved into C4-B4.                                                          |
| [`ensure_score`](_autosummary/accompy.html.md#accompy.ensure_score)(chords, \*[, title, key, ...])        | Coerce common chord-progression formats into a `Score`.                                                                                |
| [`play_audio`](_autosummary/accompy.html.md#accompy.play_audio)(audio_path)                             | Play an audio file using the system's default audio player.                                                                            |
| [`check_dependencies`](_autosummary/accompy.html.md#accompy.check_dependencies)()                               | Check which dependencies are available.                                                                                                |
| [`print_setup_instructions`](_autosummary/accompy.html.md#accompy.print_setup_instructions)()                         | Print installation instructions for missing dependencies.                                                                              |
| [`song_to_chord_sequence`](_autosummary/accompy.html.md#accompy.song_to_chord_sequence)(song, \*[, ...])            | Convert a songleaf-shaped `song` to a [`ChordSequence`](_autosummary/accompy.converters.html.md#accompy.converters.ChordSequence). |
| [`convert`](_autosummary/accompy.html.md#accompy.convert)(source, target_type, \*[, via])            | Convert source to target_type using the registered converter.                                                                          |
| [`chords_to_sequence`](_autosummary/accompy.html.md#accompy.chords_to_sequence)(chords, \*[, parser, ...])      | Parse a chord string into a ChordSequence.                                                                                             |
| [`chords_to_notes`](_autosummary/accompy.html.md#accompy.chords_to_notes)(chords, \*[, resolver, tempo])     | Convert chord string or ChordSequence to resolved MIDI notes.                                                                          |
| [`chords_to_midi`](_autosummary/accompy.html.md#accompy.chords_to_midi)(chords, \*[, resolver, ...])        | Convert chord string to MIDI data.                                                                                                     |
| [`chords_to_audio`](_autosummary/accompy.html.md#accompy.chords_to_audio)(chords, \*[, resolver, ...])       | Convert chord string to audio.                                                                                                         |
| [`midi_to_audio`](_autosummary/accompy.html.md#accompy.midi_to_audio)(midi_data, \*[, ...])                | Convert MidiData to audio.                                                                                                             |
| [`file_to_audio`](_autosummary/accompy.html.md#accompy.file_to_audio)(filepath, \*[, output_path, ...])    | Convert an iReal Pro HTML/URL file to audio.                                                                                           |
| [`file_to_midi`](_autosummary/accompy.html.md#accompy.file_to_midi)(filepath, \*[, output_path, ...])     | Convert an iReal Pro HTML/URL file to MIDI.                                                                                            |
| [`list_available_converters`](_autosummary/accompy.html.md#accompy.list_available_converters)()                        | List all available converters organized by pipeline stage.                                                                             |
| [`rhythm_to_midi`](_autosummary/accompy.html.md#accompy.rhythm_to_midi)(chords, \*[, skeleton, ...])        | Convert chords to MIDI using a rhythmic skeleton for restrike timing.                                                                  |
| [`rhythm_to_audio`](_autosummary/accompy.html.md#accompy.rhythm_to_audio)(chords, \*[, skeleton, ...])       | Convert chords to audio using a rhythmic skeleton for restrike timing.                                                                 |
| [`resolve_skeleton`](_autosummary/accompy.html.md#accompy.resolve_skeleton)(skeleton)                         | Resolve a skeleton specification to a tuple of durations.                                                                              |
| [`apply_skeleton`](_autosummary/accompy.html.md#accompy.apply_skeleton)(cs, skeleton)                       | Apply a rhythmic skeleton to a chord sequence.                                                                                         |
| [`register_skeleton`](_autosummary/accompy.html.md#accompy.register_skeleton)(key, pattern, \*[, name, ...])   | Register a custom rhythmic skeleton.                                                                                                   |
| [`list_skeletons`](_autosummary/accompy.html.md#accompy.list_skeletons)(\*[, beats_per_measure, style])     | List available skeleton keys, optionally filtered.                                                                                     |
| [`parse_ireal_html`](_autosummary/accompy.html.md#accompy.parse_ireal_html)(html_path)                        | Extract a Score from an iReal Pro HTML export file.                                                                                    |
| [`parse_ireal_url`](_autosummary/accompy.html.md#accompy.parse_ireal_url)(url)                               | Parse an iReal Pro URL (`irealb://` or `irealbook://`) into a Score.                                                                   |
| [`transpose_score`](_autosummary/accompy.html.md#accompy.transpose_score)(score, target_key)                 | Transpose a [`Score`](_autosummary/accompy.html.md#accompy.Score) to a new key.                                                       |
| [`transpose_chord`](_autosummary/accompy.html.md#accompy.transpose_chord)(chord, semitones, \*[, use_flat])  | Transpose a chord symbol by *semitones*.                                                                                               |
| [`transpose_note`](_autosummary/accompy.html.md#accompy.transpose_note)(name, semitones, \*[, use_flat])    | Transpose a single note name by *semitones*.                                                                                           |
| [`generate_wav`](_autosummary/accompy.html.md#accompy.generate_wav)(score, output_path, \*[, ...])        | Generate a WAV file from a Score using a pluggable engine.                                                                             |
| [`generate_mma_wav`](_autosummary/accompy.html.md#accompy.generate_mma_wav)(score, output_path, \*[, ...])    | Alias for [`mma_score_to_wav()`](_autosummary/accompy.html.md#accompy.mma_score_to_wav).                                                         |
| [`mma_score_to_wav`](_autosummary/accompy.html.md#accompy.mma_score_to_wav)(score, output_path, \*[, ...])    | Render a Score to WAV using MMA (Musical MIDI Accompaniment).                                                                          |
| [`make_converter_engine`](_autosummary/accompy.html.md#accompy.make_converter_engine)(\*[, resolver, ...])         | Create a [`ScoreToWav`](_autosummary/accompy.html.md#accompy.ScoreToWav) engine from accompy's converter pipeline.                         |
| [`generate_variations`](_autosummary/accompy.html.md#accompy.generate_variations)(score, output_dir, \*[, ...])  | Batch-generate WAV files for many key / tempo / groove combinations.                                                                   |
| [`render_chords`](_autosummary/accompy.html.md#accompy.render_chords)(chords, \*[, ...])                   | Render chords to a high-quality audio file, optionally AI-enhanced.                                                                    |
| [`render_chords_batch`](_autosummary/accompy.html.md#accompy.render_chords_batch)(configs, \*\*shared_kwargs)    | Run [`render_chords()`](_autosummary/accompy.html.md#accompy.render_chords) for each config dict.                                             |
| [`get_patterns`](_autosummary/accompy.html.md#accompy.get_patterns)(style)                                | Get all patterns for a given style.                                                                                                    |
| [`get_pattern_registry`](_autosummary/accompy.html.md#accompy.get_pattern_registry)()                             | Get the global pattern registry, initializing if needed.                                                                               |
| [`register_style`](_autosummary/accompy.html.md#accompy.register_style)(style, drums, bass, comp)           | Register a custom style with the global registry.                                                                                      |
| [`verify_and_setup`](_autosummary/accompy.html.md#accompy.verify_and_setup)([interactive, auto_fix])          | Verify all dependencies and optionally auto-configure.                                                                                 |
| [`setup_soundfont`](_autosummary/accompy.html.md#accompy.setup_soundfont)([force])                           | Download and configure a SoundFont file.                                                                                               |
| [`diagnose_issues`](_autosummary/accompy.html.md#accompy.diagnose_issues)()                                  | Diagnose common setup issues and provide solutions.                                                                                    |
| [`print_diagnostic_report`](_autosummary/accompy.html.md#accompy.print_diagnostic_report)()                          | Print a comprehensive diagnostic report.                                                                                               |
| [`chord_to_notes`](_autosummary/accompy.html.md#accompy.chord_to_notes)(symbol)                             | Convert chord symbol to MIDI notes using the current default resolver.                                                                 |
| [`get_chord_resolver`](_autosummary/accompy.html.md#accompy.get_chord_resolver)()                               | Get the current default chord resolver.                                                                                                |
| [`set_chord_resolver`](_autosummary/accompy.html.md#accompy.set_chord_resolver)(resolver)                       | Set the default chord resolver.                                                                                                        |
| [`tonal_resolver`](_autosummary/accompy.html.md#accompy.tonal_resolver)(symbol, \*[, transpose])            | Resolve chord symbol to MIDI notes using the tonal package (default).                                                                  |
| [`get_app_folder`](_autosummary/accompy.html.md#accompy.get_app_folder)(\*[, folder_kind])                  | Return the app directory for *folder_kind*, creating it if needed.                                                                     |
| [`get_resource`](_autosummary/accompy.html.md#accompy.get_resource)(name)                                 | Return a user resource path, seeding from package data if missing.                                                                     |
| [`get_config`](_autosummary/accompy.html.md#accompy.get_config)(name)                                   | Return a config file path, seeding from package data if missing.                                                                       |
| [`get_artifact_dir`](_autosummary/accompy.html.md#accompy.get_artifact_dir)(kind)                             | Return (and create) an artifact sub-directory for *kind*.                                                                              |
| [`load_resource_text`](_autosummary/accompy.html.md#accompy.load_resource_text)(name)                           | Read a resource file as text.                                                                                                          |
| [`load_resource_lines`](_autosummary/accompy.html.md#accompy.load_resource_lines)(name)                          | Read a resource file as a list of non-empty stripped lines.                                                                            |
| [`load_resource_json`](_autosummary/accompy.html.md#accompy.load_resource_json)(name)                           | Read a resource file as JSON.                                                                                                          |

### Classes

| [`Score`](_autosummary/accompy.html.md#accompy.Score)(measures[, title, composer, key, ...])      | A musical score containing chord events and metadata.                                         |
|----------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------|
| [`ChordEvent`](_autosummary/accompy.html.md#accompy.ChordEvent)(symbol[, beats])                       | A chord at a specific position in the progression.                                            |
| [`AccompanimentConfig`](_autosummary/accompy.html.md#accompy.AccompanimentConfig)([style, tempo, repeats, ...]) | Configuration for accompaniment generation.                                                   |
| [`MidiEvent`](_autosummary/accompy.html.md#accompy.MidiEvent)(time, channel, note, velocity, ...)     | A single MIDI event.                                                                          |
| [`ChordSequence`](_autosummary/accompy.html.md#accompy.ChordSequence)(chords[, title, key, tempo, ...])   | Ordered sequence of (chord_symbol, duration_beats) pairs with metadata.                       |
| [`NoteSequence`](_autosummary/accompy.html.md#accompy.NoteSequence)(notes[, tempo, time_signature])      | Ordered sequence of (midi_notes, duration_beats) with metadata.                               |
| [`MidiData`](_autosummary/accompy.html.md#accompy.MidiData)([bytes_, pretty_midi_obj, tempo, ...])   | Container for MIDI data — either as bytes or as a pretty_midi object.                         |
| [`AudioData`](_autosummary/accompy.html.md#accompy.AudioData)(waveform[, sr])                         | Container for audio data — numpy array + sample rate.                                         |
| [`ConverterRegistry`](_autosummary/accompy.html.md#accompy.ConverterRegistry)()                               | Registry mapping (source_type, target_type) to named converter functions.                     |
| [`ScoreToWav`](_autosummary/accompy.html.md#accompy.ScoreToWav)(\*args, \*\*kwargs)                    | Callable that renders a [`Score`](_autosummary/accompy.html.md#accompy.Score) to a WAV file. |
| [`DrumPattern`](_autosummary/accompy.html.md#accompy.DrumPattern)(name, beats_per_bar, hits)            | A drum pattern for one or more measures.                                                      |
| [`BassPattern`](_autosummary/accompy.html.md#accompy.BassPattern)(name, notes)                          | A bass pattern template.                                                                      |
| [`CompingPattern`](_autosummary/accompy.html.md#accompy.CompingPattern)(name, hits)                        | A piano/guitar comping (accompaniment) pattern.                                               |
| [`DrumHit`](_autosummary/accompy.html.md#accompy.DrumHit)(beat, drum, velocity)                     | A single drum hit in a pattern.                                                               |
| [`NoteEvent`](_autosummary/accompy.html.md#accompy.NoteEvent)(beat, pitch_offset, duration, velocity) | A melodic note event for bass or other instruments.                                           |
| [`ChordResolver`](_autosummary/accompy.html.md#accompy.ChordResolver)(\*args, \*\*kwargs)                 | Convert chord symbols to MIDI note numbers.                                                   |
| [`PatternSource`](_autosummary/accompy.html.md#accompy.PatternSource)(\*args, \*\*kwargs)                 | Provides musical patterns for a given style.                                                  |
| [`SynthesizerBackend`](_autosummary/accompy.html.md#accompy.SynthesizerBackend)(\*args, \*\*kwargs)            | Audio synthesis backend.                                                                      |
| [`RealtimeAccompaniment`](_autosummary/accompy.html.md#accompy.RealtimeAccompaniment)([config, on_event])         | Real-time accompaniment player (foundation for future work).                                  |

### *class* accompy.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)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

Configuration 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`](https://docs.python.org/3/library/typing.html#typing.Literal)[`'swing'`, `'bossa'`, `'rock'`, `'ballad'`, `'funk'`, `'latin'`, `'waltz'`, `'blues'`]

#### tempo

Beats per minute

* **Type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int)

#### repeats

Number of times to play through the form

* **Type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int)

#### instruments

Which instruments to include

* **Type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`bool`](https://docs.python.org/3/builtins/functions.html#bool)]

#### volumes

Relative volume for each instrument (0.0-1.0)

* **Type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`float`](https://docs.python.org/3/builtins/functions.html#float)]

#### soundfont

Path to SoundFont file for synthesis

* **Type:**
  [`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)]

#### sample_rate

Audio sample rate

* **Type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int)

#### output_format

Output file format

* **Type:**
  [`Literal`](https://docs.python.org/3/library/typing.html#typing.Literal)[`'wav'`, `'mp3'`, `'flac'`, `'midi'`]

#### chord_resolver

Optional custom chord resolution function

* **Type:**
  [`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`Any`](https://docs.python.org/3/library/typing.html#typing.Any)]

#### pattern_source

Optional custom pattern provider

* **Type:**
  [`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`Any`](https://docs.python.org/3/library/typing.html#typing.Any)]

#### synthesis_backend

Optional custom synthesis backend

* **Type:**
  [`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`Any`](https://docs.python.org/3/library/typing.html#typing.Any)]

#### with_overrides(\*\*kwargs)

Create a new config with specified overrides.

This enables immutable updates to configuration.

### Example

```pycon
>>> config = AccompanimentConfig(tempo=120)
>>> fast_config = config.with_overrides(tempo=180)
>>> config.tempo, fast_config.tempo
(120, 180)
```

* **Return type:**
  [`AccompanimentConfig`](_autosummary/accompy.base.html.md#accompy.base.AccompanimentConfig)

### *class* accompy.AudioData(waveform, sr=44100)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

Container for audio data — numpy array + sample rate.

```pycon
>>> import numpy as np
>>> ad = AudioData(waveform=np.zeros(44100), sr=44100)
>>> ad.duration_seconds
1.0
```

#### to_wav_bytes()

Convert to WAV file bytes.

* **Return type:**
  [`bytes`](https://docs.python.org/3/builtins/stdtypes.html#bytes)

#### write(path)

Write audio to a WAV file. Returns the path.

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### *class* accompy.BassPattern(name, notes)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

A bass pattern template.

Uses pitch_offset in NoteEvent to specify intervals from the chord root.
The actual pitches are determined when the pattern is applied to specific chords.

### *class* accompy.ChordEvent(symbol, beats=4)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

A chord at a specific position in the progression.

### Example

```pycon
>>> event = ChordEvent("Dm7", beats=4)
>>> event.symbol
'D-7'
```

### *class* accompy.ChordResolver(\*args, \*\*kwargs)

Bases: [`Protocol`](https://docs.python.org/3/library/typing.html#typing.Protocol)

Convert chord symbols to MIDI note numbers.

Example implementation:

```pycon
>>> def my_resolver(symbol: str) -> list[int]:
...     # Return MIDI notes for chord
...     return [60, 64, 67]  # C major
```

### *class* accompy.ChordSequence(chords, title='', key='C', tempo=120, time_signature=(4, 4), sections=list())

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

Ordered sequence of (chord_symbol, duration_beats) pairs with metadata.

This is the canonical internal representation of a chord progression.

```pycon
>>> cs = ChordSequence([("Dm7", 4.0), ("G7", 4.0), ("Cmaj7", 8.0)])
>>> len(cs)
3
>>> cs[0]
('Dm7', 4.0)
>>> cs.total_beats
16.0
```

#### *property* durations *: [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[float](https://docs.python.org/3/builtins/functions.html#float)]*

Just the durations, without symbols.

#### section_chords(label)

The chords of the first section called `label` (case-insensitive), or `[]`.

```pycon
>>> cs = ChordSequence([("C", 4.0), ("G", 4.0)], sections=[("Verse", 0, 1), ("Chorus", 1, 2)])
>>> cs.section_chords("chorus")
[('G', 4.0)]
```

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`float`](https://docs.python.org/3/builtins/functions.html#float)]]

#### sections *: [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), [int](https://docs.python.org/3/builtins/functions.html#int), [int](https://docs.python.org/3/builtins/functions.html#int)]]*

`(label, start, stop)` where
`chords[start:stop]` are the section’s chords (see [`section_chords()`](_autosummary/accompy.html.md#accompy.ChordSequence.section_chords)).

* **Type:**
  Song structure, when the source has it

#### *property* symbols *: [list](https://docs.python.org/3/builtins/stdtypes.html#list)[[str](https://docs.python.org/3/builtins/stdtypes.html#str)]*

Just the chord symbols, without durations.

#### to_score()

Convert to an accompy Score for pattern-based accompaniment.

### Example

```pycon
>>> cs = ChordSequence([("Dm7", 4.0), ("G7", 4.0)])
>>> score = cs.to_score()
>>> len(score)
2
```

### *class* accompy.CompingPattern(name, hits)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

A piano/guitar comping (accompaniment) pattern.

#### name

Pattern identifier

* **Type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

#### hits

Sequence of (beat, duration, velocity) tuples

* **Type:**
  [`Sequence`](https://docs.python.org/3/library/typing.html#typing.Sequence)[[`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`float`](https://docs.python.org/3/builtins/functions.html#float), [`float`](https://docs.python.org/3/builtins/functions.html#float), [`int`](https://docs.python.org/3/builtins/functions.html#int)]]

### *class* accompy.ConverterRegistry

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

Registry mapping (source_type, target_type) to named converter functions.

Supports multiple converters for the same type pair, distinguished by name.
The first registered converter becomes the default.

```pycon
>>> reg = ConverterRegistry()
>>> reg.register(str, int, int, name='builtin')
>>> reg[str, int]('42')
42
>>> reg.list_converters(str, int)
['builtin']
```

#### get(source_type, target_type, name=None)

Get a specific named converter, or the default if name is None.

* **Return type:**
  [`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)

#### list_converters(source_type, target_type)

List available converter names for a type pair.

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

#### list_pairs()

List all registered (source, target) type name pairs.

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]]

#### register(source_type, target_type, func, , name='', is_default=False)

Register a converter function.

* **Parameters:**
  * **source_type** ([`type`](https://docs.python.org/3/builtins/functions.html#type)) – The input type
  * **target_type** ([`type`](https://docs.python.org/3/builtins/functions.html#type)) – The output type
  * **func** ([`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)) – The converter function (source -> target)
  * **name** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Name for this converter (defaults to func._\_name_\_)
  * **is_default** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – If True, make this the default converter for this pair
* **Return type:**
  [`None`](https://docs.python.org/3/builtins/constants.html#None)

#### set_default(source_type, target_type, name)

Change the default converter for a type pair.

* **Return type:**
  [`None`](https://docs.python.org/3/builtins/constants.html#None)

### *class* accompy.DrumHit(beat, drum, velocity)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

A single drum hit in a pattern.

#### beat

Beat position (0-based within measure)

* **Type:**
  [`float`](https://docs.python.org/3/builtins/functions.html#float)

#### drum

MIDI note number for the drum sound

* **Type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int)

#### velocity

Hit velocity (0-127)

* **Type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int)

### *class* accompy.DrumPattern(name, beats_per_bar, hits)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

A drum pattern for one or more measures.

### Example

```pycon
>>> pattern = DrumPattern("rock", 4, [DrumHit(0, KICK, 100)])
>>> pattern.beats_per_bar
4
```

#### at_tempo(tempo)

Return pattern duration in seconds at a given tempo.

* **Return type:**
  [`float`](https://docs.python.org/3/builtins/functions.html#float)

### *class* accompy.MidiData(bytes_=None, pretty_midi_obj=None, tempo=120, time_signature=(4, 4))

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

Container for MIDI data — either as bytes or as a pretty_midi object.

Wraps MIDI content so converters have a uniform interface regardless
of which MIDI library produced the data.

```pycon
>>> import io
>>> md = MidiData(bytes_=b'MThd...', tempo=120)
>>> md.has_bytes
True
```

#### to_bytes()

Get MIDI as bytes, converting from pretty_midi if needed.

* **Return type:**
  [`bytes`](https://docs.python.org/3/builtins/stdtypes.html#bytes)

#### to_pretty_midi()

Get as pretty_midi.PrettyMIDI, converting from bytes if needed.

#### write(path)

Write MIDI to a file. Returns the path.

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### *class* accompy.MidiEvent(time, channel, note, velocity, duration)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

A single MIDI event.

Used for event-based MIDI generation that enables both batch file creation
and future real-time streaming.

#### time

Event time in beats

* **Type:**
  [`float`](https://docs.python.org/3/builtins/functions.html#float)

#### channel

MIDI channel (0-15)

* **Type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int)

#### note

MIDI note number (0-127)

* **Type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int)

#### velocity

Note velocity (0-127)

* **Type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int)

#### duration

Note duration in beats

* **Type:**
  [`float`](https://docs.python.org/3/builtins/functions.html#float)

### *class* accompy.NoteEvent(beat, pitch_offset, duration, velocity)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

A melodic note event for bass or other instruments.

#### beat

Beat position within measure

* **Type:**
  [`float`](https://docs.python.org/3/builtins/functions.html#float)

#### pitch_offset

Offset from chord root in semitones (0=root, 7=5th, etc.)

* **Type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int)

#### duration

Note duration in beats

* **Type:**
  [`float`](https://docs.python.org/3/builtins/functions.html#float)

#### velocity

Note velocity (0-127)

* **Type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int)

### *class* accompy.NoteSequence(notes, tempo=120, time_signature=(4, 4))

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

Ordered sequence of (midi_notes, duration_beats) with metadata.

Represents resolved chords — chord symbols have been converted to
concrete MIDI note numbers.

```pycon
>>> ns = NoteSequence([([60, 64, 67], 4.0), ([62, 65, 69], 4.0)])
>>> ns[0]
([60, 64, 67], 4.0)
```

### *class* accompy.PatternSource(\*args, \*\*kwargs)

Bases: [`Protocol`](https://docs.python.org/3/library/typing.html#typing.Protocol)

Provides musical patterns for a given style.

### Example

```pycon
>>> class MyPatternSource:
...     def get_patterns(self, style: str) -> dict:
...         return {'drums': [...], 'bass': [...], 'comp': [...]}
...     def available_styles(self) -> list[str]:
...         return ['swing', 'bossa']
```

#### available_styles()

List all available style names.

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]
* **Returns:**
  List of style names

#### get_patterns(style)

Get patterns for a style.

* **Parameters:**
  **style** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Style name (e.g., “swing”, “bossa”, “rock”)
* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)]
* **Returns:**
  Dict with ‘drums’, ‘bass’, ‘comp’ keys containing pattern lists

### *class* accompy.RealtimeAccompaniment(config=None, , on_event=None)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

Real-time accompaniment player (foundation for future work).

This class separates event scheduling from synthesis, enabling integration
with real-time audio systems. Current implementation generates events;
future versions will integrate with hum/pyo for actual audio synthesis.

Example (current usage):

```pycon
>>> from accompy import AccompanimentConfig
>>> config = AccompanimentConfig(tempo=120, style='swing')
>>> player = RealtimeAccompaniment(config)
>>> player.set_chords([('Dm7', 4), ('G7', 4), ('Cmaj7', 8)])
>>> events_iter = player.events()  # Get event iterator
>>> # Future: for event in events_iter: synth.play(event.note, event.velocity)
```

Future usage (with hum integration):

```pycon
>>> from hum.pyo_util import Synth
>>> def on_event(event: MidiEvent):
...     # Send MIDI event to synth in real-time
...     synth.send_note(event.note, event.velocity, event.duration)
>>> player = RealtimeAccompaniment(config, on_event=on_event)
>>> player.play()
```

#### events()

Generate events for current chord progression.

* **Yields:**
  [`MidiEvent`](_autosummary/accompy.base.html.md#accompy.base.MidiEvent) – MidiEvent objects in chronological order
* **Return type:**
  [*Iterator*](https://docs.python.org/3/library/typing.html#typing.Iterator)[[*MidiEvent*](_autosummary/accompy.base.html.md#accompy.base.MidiEvent)]

### Example

```pycon
>>> player = RealtimeAccompaniment()
>>> player.set_chords([('C', 4)])
>>> events = list(player.events())
>>> len(events) > 0
True
```

#### play()

Play the accompaniment (future implementation).

This will integrate with a real-time synthesis backend (hum/pyo)
to actually play audio. Current implementation is a placeholder.

* **Raises:**
  [**NotImplementedError**](https://docs.python.org/3/builtins/exceptions.html#NotImplementedError) – Real-time playback not yet implemented
* **Return type:**
  [`None`](https://docs.python.org/3/builtins/constants.html#None)

#### set_chords(chords)

Update the chord progression.

* **Parameters:**
  **chords** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any)) – Chord progression in any supported format
  (string, Score, list of tuples, etc.)
* **Return type:**
  [`None`](https://docs.python.org/3/builtins/constants.html#None)

### Example

```pycon
>>> player = RealtimeAccompaniment()
>>> player.set_chords("| Dm7 | G7 | Cmaj7 |")
>>> player._score is not None
True
```

#### stop()

Stop playback (future implementation).

* **Raises:**
  [**NotImplementedError**](https://docs.python.org/3/builtins/exceptions.html#NotImplementedError) – Real-time playback not yet implemented
* **Return type:**
  [`None`](https://docs.python.org/3/builtins/constants.html#None)

### *class* accompy.Score(measures, title='Untitled', composer='', key='C', time_signature=(4, 4))

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

A 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

```pycon
>>> score = Score.from_string("| C | Am | F | G |", time_signature=(4, 4))
>>> list(score.measures)
[['C'], ['A-'], ['F'], ['G']]
```

#### *classmethod* from_ireal_url(url)

Parse an iReal Pro URL into a Score.

Example::
: url = “irealb://Autumn%20Leaves=…”
  score = Score.from_ireal_url(url)

* **Return type:**
  [`Score`](_autosummary/accompy.base.html.md#accompy.base.Score)

#### *classmethod* from_string(chord_string, , title='Untitled', key='C', time_signature=(4, 4))

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

```pycon
>>> Score.from_string("| Dm7 | G7 | C^7 | % |").measures  # % means repeat
[['D-7'], ['G7'], ['C^7'], ['C^7']]
```

* **Return type:**
  [`Score`](_autosummary/accompy.base.html.md#accompy.base.Score)

#### to_chord_sequence(, tempo=120)

Convert Score to a ChordSequence (from the converter pipeline).

Each chord gets a duration proportional to its share of the bar.

### Example

```pycon
>>> score = Score.from_string("| Dm7 | G7 | C^7 |")
>>> cs = score.to_chord_sequence(tempo=160)
>>> len(cs)
3
```

### *class* accompy.ScoreToWav(\*args, \*\*kwargs)

Bases: [`Protocol`](https://docs.python.org/3/library/typing.html#typing.Protocol)

Callable that renders a [`Score`](_autosummary/accompy.html.md#accompy.Score) to a WAV file.

Any function matching this signature can be used as a `score_to_wav`
engine in [`generate_wav()`](_autosummary/accompy.html.md#accompy.generate_wav) and [`generate_variations()`](_autosummary/accompy.html.md#accompy.generate_variations).

### *class* accompy.SynthesizerBackend(\*args, \*\*kwargs)

Bases: [`Protocol`](https://docs.python.org/3/library/typing.html#typing.Protocol)

Audio synthesis backend.

Simpler protocol than AudioRenderer, focused just on synthesis.
Used by the synthesis module.

#### *classmethod* is_available()

Check if this backend’s dependencies are installed.

* **Return type:**
  [`bool`](https://docs.python.org/3/builtins/functions.html#bool)
* **Returns:**
  True if the backend can be used

#### render_to_bytes(midi_path, , sample_rate=44100)

Render a MIDI file to PCM bytes (for streaming).

* **Parameters:**
  * **midi_path** ([`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)) – Path to MIDI file
  * **sample_rate** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Audio sample rate
* **Return type:**
  [`bytes`](https://docs.python.org/3/builtins/stdtypes.html#bytes)
* **Returns:**
  Raw PCM audio bytes

#### render_to_file(midi_path, output_path, , sample_rate=44100)

Render a MIDI file to audio.

* **Parameters:**
  * **midi_path** ([`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)) – Path to MIDI file
  * **output_path** ([`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)) – Where to save audio
  * **sample_rate** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Audio sample rate
* **Return type:**
  [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)
* **Returns:**
  Path to the created audio file

### accompy.apply_skeleton(cs, skeleton)

Apply a rhythmic skeleton to a chord sequence.

The skeleton defines strike positions within each *measure*. Each strike
plays whatever chord is active at that beat position. If a strike spans a
chord boundary within a measure, it is split so the chord change is
respected.

* **Parameters:**
  * **cs** – A ChordSequence (from `accompy.converters`).
  * **skeleton** ([`Union`](https://docs.python.org/3/library/typing.html#typing.Union)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple), [`Sequence`](https://docs.python.org/3/library/typing.html#typing.Sequence)]) – Skeleton key, name, style, or duration tuple.
* **Return type:**
  ChordSequence
* **Returns:**
  A new ChordSequence with chords expanded according to the skeleton.

### Example

```pycon
>>> from accompy.converters import ChordSequence
>>> cs = ChordSequence([("Dm7", 2.0), ("G7", 2.0)])
>>> result = apply_skeleton(cs, "tresillo")
>>> [(s, d) for s, d in result]
[('Dm7', 1.5), ('Dm7', 0.5), ('G7', 1.0), ('G7', 1.0)]
```

### accompy.bass_pitch(root, chord_notes, pitch_offset)

The bass note a pattern’s `pitch_offset` plays over a chord.

The chord’s root is moved to C2-B2, then the offset is resolved against the chord
([`resolve_pitch_offset()`](_autosummary/accompy.html.md#accompy.resolve_pitch_offset)), so a pattern’s “3rd” follows the chord’s quality.

```pycon
>>> bass_pitch(57, [57, 60, 64], 4), bass_pitch(48, [48, 52, 55], 4)
(48, 40)
```

* **Return type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int)

### accompy.check_dependencies()

Check which dependencies are available.

* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`bool`](https://docs.python.org/3/builtins/functions.html#bool)]
* **Returns:**
  Dict mapping dependency name to availability status

### Example

```pycon
>>> deps = check_dependencies()
>>> 'midiutil' in deps
True
```

### accompy.chord_events(chord_notes, , style='swing', start_beat=0, duration=4, beats_per_bar=4, instruments=None, volumes=None, pattern_source=None)

The drum, bass and piano events `style` plays over one chord.

This is one step of `generate_midi_events()`, which calls it for every chord of
a score: `chord_notes` are the chord’s MIDI notes, root first (what a chord
resolver returns), `start_beat` where the chord starts and `duration` how many
beats it lasts. It reads no tempo and keeps no state between chords.

```pycon
>>> [(e.time, e.channel, e.note) for e in chord_events([48, 52, 55], style="rock",
...     duration=1)]
[(0, 9, 36), (0, 9, 42), (0.5, 9, 42), (0, 0, 36), (0, 1, 60), (0, 1, 64),
 (0, 1, 67)]
```

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`MidiEvent`](_autosummary/accompy.base.html.md#accompy.base.MidiEvent)]

### accompy.chord_to_notes(symbol)

Convert chord symbol to MIDI notes using the current default resolver.

This is the main entry point for chord resolution in accompy.

* **Parameters:**
  **symbol** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Chord symbol (e.g., “Dm7”, “G7”)
* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`int`](https://docs.python.org/3/builtins/functions.html#int)]
* **Returns:**
  List of MIDI note numbers

### Example

```pycon
>>> notes = chord_to_notes("C")
>>> len(notes) > 0
True
```

### accompy.chords_to_audio(chords, , resolver=None, midi_gen=None, audio_renderer=None, soundfont=None, tempo=120, sr=44100, output_path=None)

Convert chord string to audio.

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

* **Parameters:**
  * **chords** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`ChordSequence`](_autosummary/accompy.converters.html.md#accompy.converters.ChordSequence)) – Chord string or ChordSequence
  * **resolver** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – Chord resolver (‘pychord’, ‘music21’, ‘mingus’, ‘tonal’)
  * **midi_gen** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – MIDI generator (‘pretty_midi’, ‘midiutil’, ‘mido’)
  * **audio_renderer** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – Audio renderer (‘pretty_midi’, ‘fluidsynth’, ‘tonal’)
  * **soundfont** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – Path to SoundFont file
  * **tempo** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – BPM
  * **sr** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Sample rate
  * **output_path** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – Optional path to write WAV file
* **Return type:**
  [`AudioData`](_autosummary/accompy.converters.html.md#accompy.converters.AudioData)
* **Returns:**
  AudioData with waveform and sample rate

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

### accompy.chords_to_midi(chords, , resolver=None, midi_gen=None, tempo=120, output_path=None)

Convert chord string to MIDI data.

* **Parameters:**
  * **chords** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`ChordSequence`](_autosummary/accompy.converters.html.md#accompy.converters.ChordSequence)) – Chord string or ChordSequence
  * **resolver** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – Resolver name (‘pychord’, ‘music21’, ‘mingus’, ‘tonal’)
  * **midi_gen** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – MIDI generator name (‘pretty_midi’, ‘midiutil’, ‘mido’)
  * **tempo** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – BPM
  * **output_path** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – Optional path to write MIDI file
* **Return type:**
  [`MidiData`](_autosummary/accompy.converters.html.md#accompy.converters.MidiData)
* **Returns:**
  MidiData object

```pycon
>>> md = chords_to_midi("| C | Am | F | G |")
>>> md.to_bytes()[:4]
b'MThd'
```

### accompy.chords_to_notes(chords, , resolver=None, tempo=120)

Convert chord string or ChordSequence to resolved MIDI notes.

* **Parameters:**
  * **chords** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`ChordSequence`](_autosummary/accompy.converters.html.md#accompy.converters.ChordSequence)) – Chord string or ChordSequence
  * **resolver** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – Resolver name (‘pychord’, ‘music21’, ‘mingus’, ‘tonal’)
  * **tempo** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – BPM (used if chords is a string)
* **Return type:**
  [`NoteSequence`](_autosummary/accompy.converters.html.md#accompy.converters.NoteSequence)
* **Returns:**
  NoteSequence with MIDI note numbers

```pycon
>>> ns = chords_to_notes("| C | Am |")
>>> len(ns)
2
>>> all(0 <= n <= 127 for notes, _ in ns for n in notes)
True
```

### accompy.chords_to_sequence(chords, , parser=None, tempo=120, title='', key='C', time_signature=(4, 4))

Parse a chord string into a ChordSequence.

* **Parameters:**
  * **chords** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Chord string in any supported format
  * **parser** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – Parser name (‘auto_detect’, ‘plain_text’, ‘chordpro’, ‘musicgen_chord’)
  * **tempo** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – BPM (default 120)
  * **title** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Song title
  * **key** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Key signature
  * **time_signature** ([`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`int`](https://docs.python.org/3/builtins/functions.html#int), [`int`](https://docs.python.org/3/builtins/functions.html#int)]) – Time signature tuple
* **Return type:**
  [`ChordSequence`](_autosummary/accompy.converters.html.md#accompy.converters.ChordSequence)
* **Returns:**
  ChordSequence with parsed chords

```pycon
>>> cs = chords_to_sequence("| Dm7 | G7 | Cmaj7 |", tempo=140)
>>> cs.symbols
['Dm7', 'G7', 'Cmaj7']
>>> cs.tempo
140
```

### accompy.comp_voicing(chord_notes)

The notes the piano plays for a chord: its first four notes moved into C4-B4.

A chord with no notes is voiced as a C major triad.

```pycon
>>> comp_voicing([50, 53, 57, 60, 64]), comp_voicing([])
([62, 65, 69, 60], [60, 64, 67])
```

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`int`](https://docs.python.org/3/builtins/functions.html#int)]

### accompy.convert(source, target_type, , via=None)

Convert source to target_type using the registered converter.

* **Parameters:**
  * **source** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any)) – The source data
  * **target_type** ([`type`](https://docs.python.org/3/builtins/functions.html#type)) – The desired output type
  * **via** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Optional converter name (uses default if None)
* **Return type:**
  [`Any`](https://docs.python.org/3/library/typing.html#typing.Any)
* **Returns:**
  Converted data of target_type

Example:

```default
>>> # After converters are registered:
>>> # audio = convert(chord_seq, AudioData)
```

### accompy.diagnose_issues()

Diagnose common setup issues and provide solutions.

* **Return type:**
  [`List`](https://docs.python.org/3/library/typing.html#typing.List)[[`Tuple`](https://docs.python.org/3/library/typing.html#typing.Tuple)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]]
* **Returns:**
  List of (issue, description, solution) tuples

Example:

```default
from accompy.setup_utils import diagnose_issues
for issue, desc, solution in diagnose_issues():
    print(f"{issue}: {desc}")
    print(f"Solution: {solution}")
```

### accompy.ensure_score(chords, , title='Untitled', key='C', time_signature=(4, 4))

Coerce common chord-progression formats into a `Score`.

Supported inputs:

- `Score`: returned as-is
- `str`: chord string (e.g. `"| C | Am | F | G |"`) OR iReal URL (`irealbook://...`)
- `Iterable[tuple[str, int|float]]`: list of `(chord, beats)` like in `accompany`
- `Iterable[str]`: chord symbols, one per bar
- `list[list[str]]`: already-parsed measures

### Notes

- `Score.measures` in `accompy` does 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

```pycon
>>> 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:**
  [`Score`](_autosummary/accompy.base.html.md#accompy.base.Score)

### accompy.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)

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`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Path to an iReal HTML file, or a chord text file
  * **output_path** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Where to write audio. If None, uses filepath with .wav extension
  * **n_repeats** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Number of times to repeat the progression (default 1)
  * **transpose** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Semitones to transpose (positive=up, negative=down)
  * **resolver** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Chord resolver backend
  * **midi_gen** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – MIDI generator backend
  * **audio_renderer** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Audio renderer backend
  * **soundfont** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Path to SoundFont file
  * **tempo** ([`int`](https://docs.python.org/3/builtins/functions.html#int) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Override BPM (None = use file’s tempo or 120)
  * **sr** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Sample rate
* **Return type:**
  [`AudioData`](_autosummary/accompy.converters.html.md#accompy.converters.AudioData)
* **Returns:**
  AudioData

Example:

```default
>>> 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.file_to_midi(filepath, , output_path=None, n_repeats=1, transpose=0, resolver=None, midi_gen=None, tempo=None)

Convert an iReal Pro HTML/URL file to MIDI.

Same as file_to_audio but outputs MIDI instead.

* **Parameters:**
  * **filepath** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Path to an iReal HTML file, or a chord text file
  * **output_path** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Where to write MIDI. If None, uses filepath with .mid extension
  * **n_repeats** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Number of times to repeat the progression
  * **transpose** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Semitones to transpose
  * **resolver** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Chord resolver backend
  * **midi_gen** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – MIDI generator backend
  * **tempo** ([`int`](https://docs.python.org/3/builtins/functions.html#int) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Override BPM
* **Return type:**
  [`MidiData`](_autosummary/accompy.converters.html.md#accompy.converters.MidiData)
* **Returns:**
  MidiData

### accompy.generate_accompaniment(chords, , style='swing', tempo=120, repeats=1, output_path=None, output_format=None, config=None, use_mma=True, backend=None, autoplay=False)

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`](https://docs.python.org/3/library/typing.html#typing.Any)) – Chord progression (string, Score, list of tuples, iReal URL)
  * **style** ([`Literal`](https://docs.python.org/3/library/typing.html#typing.Literal)[`'swing'`, `'bossa'`, `'rock'`, `'ballad'`, `'funk'`, `'latin'`, `'waltz'`, `'blues'`]) – Musical style (swing, bossa, rock, ballad, funk, latin, waltz, blues)
  * **tempo** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Tempo in BPM
  * **repeats** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Number of times to repeat the progression
  * **output_path** ([`Union`](https://docs.python.org/3/library/typing.html#typing.Union)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path), [`None`](https://docs.python.org/3/builtins/constants.html#None)]) – Where to save the file (None = temp file)
  * **output_format** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`Literal`](https://docs.python.org/3/library/typing.html#typing.Literal)[`'wav'`, `'mp3'`, `'flac'`, `'midi'`, `'mid'`]]) – Output format (wav, mp3, flac, midi)
  * **config** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`AccompanimentConfig`](_autosummary/accompy.base.html.md#accompy.base.AccompanimentConfig)]) – Full configuration object (overrides other params if provided)
  * **use_mma** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – If True and MMA available, use MMA backend
  * **backend** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`Literal`](https://docs.python.org/3/library/typing.html#typing.Literal)[`'auto'`, `'mma'`, `'builtin'`]]) – Explicitly select backend (‘auto’, ‘mma’, ‘builtin’)
  * **autoplay** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – If True, automatically play the generated audio
* **Return type:**
  [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)
* **Returns:**
  Path to the generated audio/MIDI file

### Example

```pycon
>>> 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”.

### accompy.generate_events(chords, , style='swing', repeats=1, time_signature=None, instruments=None, volumes=None, pattern_source=None, chord_resolver=None)

The note events the builtin backend plays for `chords`, without writing a file.

`chords` is anything [`accompy.ensure_score()`](_autosummary/accompy.html.md#accompy.ensure_score) accepts (a chord string, an iReal
URL, measures, chord symbols, `(chord, beats)` pairs, a Score);
`time_signature` applies to the forms that do not carry one (default: the style’s,
see `style_time_signature()`: 3/4 for `waltz`, else 4/4). Times and durations
are in beats: the events do not depend on tempo. `repeats` defaults to 1, as in
[`accompy.generate_accompaniment()`](_autosummary/accompy.html.md#accompy.generate_accompaniment).

```pycon
>>> events = generate_events("| C | G |", style="bossa")
>>> events[0]
MidiEvent(time=0, channel=9, note=37, velocity=56, duration=0.25)
>>> max(e.time for e in events) < 8
True
```

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`MidiEvent`](_autosummary/accompy.base.html.md#accompy.base.MidiEvent)]

### accompy.generate_mma_wav(score, output_path, , groove='Swing', tempo=120, repeats=1)

Render a Score to WAV using MMA (Musical MIDI Accompaniment).

Accepts any valid MMA groove name (e.g. `"Bebop"`, `"GypsyJazz"`).
Run `mma -Dg` to list available grooves.

* **Parameters:**
  * **score** ([`Score`](_autosummary/accompy.base.html.md#accompy.base.Score)) – A [`Score`](_autosummary/accompy.html.md#accompy.Score) with chord measures.
  * **output_path** ([`Union`](https://docs.python.org/3/library/typing.html#typing.Union)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)]) – Destination WAV file path.
  * **groove** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – MMA groove name (case-sensitive).
  * **tempo** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Tempo in BPM.
  * **repeats** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Number of times to repeat the progression.
* **Return type:**
  [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)
* **Returns:**
  Path to the generated WAV file.
* **Raises:**
  [**RuntimeError**](https://docs.python.org/3/builtins/exceptions.html#RuntimeError) – If MMA is not installed or the groove is invalid.

### accompy.generate_variations(score, output_dir, , keys=('C',), tempos=(120,), grooves=('Swing',), repeats=1, filename_template='{title}_{key}_{tempo}bpm_{groove}.wav', score_to_wav=None)

Batch-generate WAV files for many key / tempo / groove combinations.

Produces one WAV for each `(key, tempo, groove)` triple (cycled from the
shortest sequences).  Useful for creating practice backing-track
collections.

* **Parameters:**
  * **score** ([`Score`](_autosummary/accompy.base.html.md#accompy.base.Score)) – Base [`Score`](_autosummary/accompy.html.md#accompy.Score) (will be transposed per key).
  * **output_dir** ([`Union`](https://docs.python.org/3/library/typing.html#typing.Union)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)]) – Directory for output files.
  * **keys** ([`Sequence`](https://docs.python.org/3/library/typing.html#typing.Sequence)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – Keys to transpose to.
  * **tempos** ([`Sequence`](https://docs.python.org/3/library/typing.html#typing.Sequence)[[`int`](https://docs.python.org/3/builtins/functions.html#int)]) – Tempos in BPM to cycle through.
  * **grooves** ([`Sequence`](https://docs.python.org/3/library/typing.html#typing.Sequence)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – Groove / style names to cycle through.
  * **repeats** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Number of repeats per file.
  * **filename_template** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Template for filenames. Placeholders:
    `{title}`, `{key}`, `{tempo}`, `{groove}`.
  * **score_to_wav** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`ScoreToWav`](_autosummary/accompy.tools.html.md#accompy.tools.ScoreToWav)]) – Engine callable.  Defaults to [`mma_score_to_wav()`](_autosummary/accompy.html.md#accompy.mma_score_to_wav).
* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)]
* **Returns:**
  List of Paths to successfully generated files.

Example:

```default
>>> from accompy import Score, generate_variations
>>> score = Score.from_string("| C6 | Do | C6/E | Fo |", key="C")
>>> generate_variations(
...     score, "/tmp/variations",
...     keys=["C", "G", "F"],
...     tempos=[100, 120],
...     grooves=["Swing", "BossaNova"],
... )

>>> # With a custom engine:
>>> from accompy.tools import make_converter_engine
>>> engine = make_converter_engine(audio_renderer="fluidsynth")
>>> generate_variations(
...     score, "/tmp/variations",
...     keys=["C", "G"],
...     tempos=[100, 120],
...     grooves=["Swing"],
...     score_to_wav=engine,
... )
```

### accompy.generate_wav(score, output_path, , groove='Swing', tempo=120, repeats=1, score_to_wav=None)

Generate a WAV file from a Score using a pluggable engine.

By default uses MMA (Musical MIDI Accompaniment).  Pass a custom
`score_to_wav` callable to use a different backend — for instance one
built with [`make_converter_engine()`](_autosummary/accompy.html.md#accompy.make_converter_engine).

* **Parameters:**
  * **score** ([`Score`](_autosummary/accompy.base.html.md#accompy.base.Score)) – A [`Score`](_autosummary/accompy.html.md#accompy.Score) with chord measures.
  * **output_path** ([`Union`](https://docs.python.org/3/library/typing.html#typing.Union)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)]) – Destination WAV file path.
  * **groove** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Groove / style name (interpretation depends on the engine).
  * **tempo** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Tempo in BPM.
  * **repeats** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Number of times to repeat the progression.
  * **score_to_wav** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`ScoreToWav`](_autosummary/accompy.tools.html.md#accompy.tools.ScoreToWav)]) – Engine callable.  Defaults to [`mma_score_to_wav()`](_autosummary/accompy.html.md#accompy.mma_score_to_wav).
* **Return type:**
  [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)
* **Returns:**
  Path to the generated WAV file.

Example:

```default
>>> from accompy import Score, generate_wav
>>> score = Score.from_string("| Dm7 | G7 | C^7 |")
>>> generate_wav(score, "/tmp/test.wav", groove="BossaNova", tempo=140)
PosixPath('/tmp/test.wav')

>>> # With a custom engine:
>>> from accompy.tools import make_converter_engine
>>> engine = make_converter_engine(audio_renderer="fluidsynth")
>>> generate_wav(score, "/tmp/test.wav", score_to_wav=engine, tempo=140)
```

### accompy.get_app_folder(, folder_kind='data')

Return the app directory for *folder_kind*, creating it if needed.

* **Return type:**
  [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)

### accompy.get_artifact_dir(kind)

Return (and create) an artifact sub-directory for *kind*.

* **Return type:**
  [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)

### accompy.get_chord_resolver()

Get the current default chord resolver.

* **Return type:**
  [`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)[[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)], [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`int`](https://docs.python.org/3/builtins/functions.html#int)]]
* **Returns:**
  The active chord resolution function

### Example

```pycon
>>> resolver = get_chord_resolver()
>>> notes = resolver("C")
>>> len(notes) > 0
True
```

### accompy.get_config(name)

Return a config file path, seeding from package data if missing.

* **Return type:**
  [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)

### accompy.get_pattern_registry()

Get the global pattern registry, initializing if needed.

* **Return type:**
  [`PatternRegistry`](_autosummary/accompy.patterns.html.md#accompy.patterns.PatternRegistry)
* **Returns:**
  The global PatternRegistry instance

### Example

```pycon
>>> registry = get_pattern_registry()
>>> 'swing' in registry
True
```

### accompy.get_patterns(style)

Get all patterns for a given style.

* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)
* **Returns:**
  Dict with ‘drums’, ‘bass’, ‘comp’ keys containing pattern lists

### Example

```pycon
>>> patterns = get_patterns("bossa")
>>> drums = patterns["drums"][0]
>>> drums.name
'bossa'
```

### accompy.get_resource(name)

Return a user resource path, seeding from package data if missing.

* **Return type:**
  [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)

### accompy.list_available_converters()

List all available converters organized by pipeline stage.

* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]]
* **Returns:**
  Dict mapping stage names to lists of converter names.

```pycon
>>> info = list_available_converters()
>>> 'parsers' in info
True
>>> 'resolvers' in info
True
```

### accompy.list_skeletons(, beats_per_measure=None, style=None)

List available skeleton keys, optionally filtered.

* **Parameters:**
  * **beats_per_measure** ([`float`](https://docs.python.org/3/builtins/functions.html#float) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Filter to skeletons matching this measure length.
  * **style** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Filter to skeletons associated with this style.
* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]
* **Returns:**
  List of skeleton key strings.

### Examples

```pycon
>>> "tresillo" in list_skeletons()
True
>>> all(RHYTHMIC_SKELETONS[k]["beats_per_measure"] == 3
...     for k in list_skeletons(beats_per_measure=3))
True
```

### accompy.load_resource_json(name)

Read a resource file as JSON.

### accompy.load_resource_lines(name)

Read a resource file as a list of non-empty stripped lines.

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

### accompy.load_resource_text(name)

Read a resource file as text.

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### accompy.make_converter_engine(, resolver=None, midi_gen=None, audio_renderer=None, soundfont=None, sr=44100)

Create a [`ScoreToWav`](_autosummary/accompy.html.md#accompy.ScoreToWav) engine from accompy’s converter pipeline.

This wraps the `ChordSequence → NoteSequence → MidiData → AudioData`
converter chain into the same interface that [`generate_wav()`](_autosummary/accompy.html.md#accompy.generate_wav) expects,
so you can swap it in place of the default MMA engine.

* **Parameters:**
  * **resolver** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – Chord resolver name (e.g. `"pychord"`, `"tonal"`).
  * **midi_gen** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – MIDI generator name (e.g. `"pretty_midi"`, `"midiutil"`).
  * **audio_renderer** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – Audio renderer name (e.g. `"fluidsynth"`, `"pretty_midi"`).
  * **soundfont** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – Path to a SoundFont file (for FluidSynth-based renderers).
  * **sr** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Sample rate.
* **Return type:**
  [`ScoreToWav`](_autosummary/accompy.tools.html.md#accompy.tools.ScoreToWav)
* **Returns:**
  A callable matching the [`ScoreToWav`](_autosummary/accompy.html.md#accompy.ScoreToWav) protocol.

Example:

```default
>>> engine = make_converter_engine(audio_renderer="fluidsynth")
>>> generate_wav(score, "/tmp/out.wav", score_to_wav=engine, tempo=120)
```

### accompy.midi_to_audio(midi_data, , audio_renderer=None, soundfont=None, sr=44100, output_path=None)

Convert MidiData to audio.

* **Parameters:**
  * **midi_data** ([`MidiData`](_autosummary/accompy.converters.html.md#accompy.converters.MidiData)) – MidiData object
  * **audio_renderer** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – Audio renderer name
  * **soundfont** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – Path to SoundFont file
  * **sr** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Sample rate
  * **output_path** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – Optional path to write WAV file
* **Return type:**
  [`AudioData`](_autosummary/accompy.converters.html.md#accompy.converters.AudioData)
* **Returns:**
  AudioData

```pycon
>>> audio = midi_to_audio(some_midi_data)
```

### accompy.mma_score_to_wav(score, output_path, , groove='Swing', tempo=120, repeats=1)

Render a Score to WAV using MMA (Musical MIDI Accompaniment).

Accepts any valid MMA groove name (e.g. `"Bebop"`, `"GypsyJazz"`).
Run `mma -Dg` to list available grooves.

* **Parameters:**
  * **score** ([`Score`](_autosummary/accompy.base.html.md#accompy.base.Score)) – A [`Score`](_autosummary/accompy.html.md#accompy.Score) with chord measures.
  * **output_path** ([`Union`](https://docs.python.org/3/library/typing.html#typing.Union)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)]) – Destination WAV file path.
  * **groove** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – MMA groove name (case-sensitive).
  * **tempo** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Tempo in BPM.
  * **repeats** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Number of times to repeat the progression.
* **Return type:**
  [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)
* **Returns:**
  Path to the generated WAV file.
* **Raises:**
  [**RuntimeError**](https://docs.python.org/3/builtins/exceptions.html#RuntimeError) – If MMA is not installed or the groove is invalid.

### accompy.parse_ireal_html(html_path)

Extract a Score from an iReal Pro HTML export file.

iReal Pro can export songs as HTML files containing an `irealb://` link.
This function reads the file, extracts that link, and parses it into a
[`Score`](_autosummary/accompy.html.md#accompy.Score).

* **Parameters:**
  **html_path** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Path to the HTML file exported from iReal Pro.
* **Return type:**
  Score
* **Returns:**
  A Score with measures, title, key, and time signature.
* **Raises:**
  * [**FileNotFoundError**](https://docs.python.org/3/builtins/exceptions.html#FileNotFoundError) – If *html_path* does not exist.
  * [**ValueError**](https://docs.python.org/3/builtins/exceptions.html#ValueError) – If no iReal URL is found in the HTML.

Example:

```default
>>> score = parse_ireal_html("/path/to/song.html")
>>> score.title
'Autumn Leaves'
```

### accompy.parse_ireal_url(url)

Parse an iReal Pro URL (`irealb://` or `irealbook://`) into a Score.

Decoding is [`accompy.ireal.decode_ireal_url()`](_autosummary/accompy.ireal.html.md#accompy.ireal.decode_ireal_url); the Score is the first tune of
the URL that has chords, each bar the list of its chords as written (iReal chord
notation). Raises `ValueError` when no tune has chords.

```pycon
>>> score = parse_ireal_url("irealbook://Blues=Me=Swing=F=n=[T34F7 |Bb7 Bo7 |C7 Z")
>>> score.measures, score.time_signature
([['F7'], ['Bb7', 'Bo7'], ['C7']], (3, 4))
```

### accompy.pitch_classes(notes)

Return unique pitch classes (0-11) as a tuple.

* **Return type:**
  [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`int`](https://docs.python.org/3/builtins/functions.html#int), [`...`](https://docs.python.org/3/builtins/constants.html#Ellipsis)]

### accompy.play_audio(audio_path)

Play an audio file using the system’s default audio player.

* **Parameters:**
  **audio_path** ([`Union`](https://docs.python.org/3/library/typing.html#typing.Union)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)]) – Path to the audio file
* **Return type:**
  [`bool`](https://docs.python.org/3/builtins/functions.html#bool)
* **Returns:**
  True if playback started successfully, False otherwise

### Example

```pycon
>>> from accompy import play_audio
>>> play_audio("/path/to/audio.wav")
```

### accompy.print_diagnostic_report()

Print a comprehensive diagnostic report.

### accompy.print_setup_instructions()

Print installation instructions for missing dependencies.

### accompy.register_skeleton(key, pattern, , name='', beats_per_measure=None, styles=None)

Register a custom rhythmic skeleton.

* **Parameters:**
  * **key** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Unique string key for the skeleton.
  * **pattern** ([`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)) – Tuple of beat durations.
  * **name** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Human-readable name (defaults to key).
  * **beats_per_measure** ([`float`](https://docs.python.org/3/builtins/functions.html#float) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Measure length in beats (defaults to sum of pattern).
  * **styles** ([`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)] | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – List of associated style strings.
* **Return type:**
  [`None`](https://docs.python.org/3/builtins/constants.html#None)

### Example

```pycon
>>> register_skeleton("my_groove", (1, 0.5, 0.5, 2), name="My Groove")
>>> resolve_skeleton("my_groove")
(1, 0.5, 0.5, 2)
```

### accompy.register_style(style, drums, bass, comp)

Register a custom style with the global registry.

* **Parameters:**
  * **style** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Style name
  * **drums** ([`list`](https://docs.python.org/3/builtins/stdtypes.html#list)) – List of DrumPattern objects
  * **bass** ([`list`](https://docs.python.org/3/builtins/stdtypes.html#list)) – List of BassPattern objects
  * **comp** ([`list`](https://docs.python.org/3/builtins/stdtypes.html#list)) – List of CompingPattern objects
* **Return type:**
  [`None`](https://docs.python.org/3/builtins/constants.html#None)

### Example

```pycon
>>> registry = get_pattern_registry()
>>> register_style('my_funk', [my_drum_pattern], [my_bass_pattern], [])
```

### accompy.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)

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

* **Parameters:**
  * **chords** – Chord input — string (`"| Dm7 | G7 | C^7 |"`), iReal URL,
    [`ChordSequence`](_autosummary/accompy.converters.html.md#accompy.converters.ChordSequence), [`Score`](_autosummary/accompy.base.html.md#accompy.base.Score),
    or list of `(chord, beats)` tuples.
  * **rhythmic_skeleton** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`float`](https://docs.python.org/3/builtins/functions.html#float), [`...`](https://docs.python.org/3/builtins/constants.html#Ellipsis)]) – Restrike pattern within each measure.
  * **bpm** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Tempo in beats per minute.
  * **transpose** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Semitones to transpose (positive=up, negative=down).
  * **n_loops** ([`int`](https://docs.python.org/3/builtins/functions.html#int) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Explicit number of loops. Mutually exclusive with *max_seconds*.
  * **max_seconds** ([`float`](https://docs.python.org/3/builtins/functions.html#float) | [`None`](https://docs.python.org/3/builtins/constants.html#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`](https://docs.python.org/3/library/typing.html#typing.Union)[[`bool`](https://docs.python.org/3/builtins/functions.html#bool), [`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable), [`None`](https://docs.python.org/3/builtins/constants.html#None)]) – `True` for default Suno enhancement, `False`/`None`
    to skip, or a callable `(audio_path, prompt, **kw) → bytes`.
  * **suno_mode** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – `"cover"` (default, re-generates in style) or `"extend"`.
  * **prompt_template** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Template with `{genre}` and `{instruments}` placeholders.
  * **genre** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Genre/style tags for the AI prompt.
  * **instruments** ([`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)] | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Instrument list for the AI prompt. Defaults to
    `["piano", "bass", "drums"]`.
  * **audio_weight** ([`float`](https://docs.python.org/3/builtins/functions.html#float)) – How much the source audio influences AI output (0–1).
  * **style_weight** ([`float`](https://docs.python.org/3/builtins/functions.html#float)) – How much the style prompt influences AI output (0–1).
  * **weirdness** ([`float`](https://docs.python.org/3/builtins/functions.html#float)) – Creative deviation for cover mode (0–1).
  * **model** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Suno model version (e.g. `"V4_5"`).
  * **instrumental** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – If True, generate without vocals.
  * **wait_for_completion** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – If True, poll until AI generation is ready.
  * **poll_interval** ([`float`](https://docs.python.org/3/builtins/functions.html#float)) – Seconds between AI status checks.
  * **timeout** ([`float`](https://docs.python.org/3/builtins/functions.html#float)) – Max seconds to wait for AI completion.
  * **chords_to_midi_audio** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)]) – Override for the MIDI audio rendering step.
    Callable: `(ChordSequence, **kw) → AudioData`.
  * **audio_to_enhanced_audio** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)]) – Override for the AI enhancement step.
    Callable: `(audio_path, prompt, **kw) → bytes`.
  * **midi_store** ([`MutableMapping`](https://docs.python.org/3/library/collections.abc.html#collections.abc.MutableMapping) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Optional store for MIDI files. `None` = don’t persist MIDI.
  * **midi_audio_store** ([`MutableMapping`](https://docs.python.org/3/library/collections.abc.html#collections.abc.MutableMapping) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Store for rendered MIDI audio. `None` = default
    file store under `~/.local/share/accompy/artifacts/midi_audio/`.
  * **enhanced_audio_store** ([`MutableMapping`](https://docs.python.org/3/library/collections.abc.html#collections.abc.MutableMapping) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Store for AI-enhanced audio. `None` = default
    file store under `~/.local/share/accompy/artifacts/enhanced_audio/`.
  * **resolver** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Chord resolver backend name.
  * **midi_gen** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – MIDI generator backend name.
  * **audio_renderer** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Audio renderer backend name.
  * **soundfont** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Path to a SoundFont file.
  * **sr** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Sample rate for MIDI audio rendering.
* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)
* **Returns:**
  Filesystem path to the final audio file.

### accompy.render_chords_batch(configs, \*\*shared_kwargs)

Run [`render_chords()`](_autosummary/accompy.html.md#accompy.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`](https://docs.python.org/3/library/typing.html#typing.Iterable)[[`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)]) – Iterable of dicts, each containing keyword arguments for
    [`render_chords()`](_autosummary/accompy.html.md#accompy.render_chords).
  * **\*\*shared_kwargs** – Default arguments applied to every config.
* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]
* **Returns:**
  List of filesystem paths to the final audio files.

Example:

```default
>>> 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)
```

### accompy.resolve_pitch_offset(, root_pc, chord_pcs, target_offset)

Resolve a pitch offset against a chord.

The patterns use semitone offsets (0=root, 7=5th, etc.). When an offset
represents a chord tone which varies by quality (e.g. 3rd), we prefer a
matching chord tone from `chord_pcs`.

### Examples

For a minor chord, a pattern might request offset 4 (“3rd”); this
function will choose 3 if the chord contains a minor 3rd.

* **Return type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int)

### accompy.resolve_skeleton(skeleton)

Resolve a skeleton specification to a tuple of durations.

Accepts:

> - A tuple or list of numbers (pass-through)
> - A skeleton key (e.g., `"tresillo"`, `"whole_note"`)
> - A skeleton name, case-insensitive (e.g., `"Tresillo"`)
> - A style string (e.g., `"reggae"`) — returns the first match
* **Return type:**
  [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)
* **Returns:**
  Tuple of beat durations summing to the measure length.
* **Raises:**
  [**KeyError**](https://docs.python.org/3/builtins/exceptions.html#KeyError) – If the skeleton cannot be resolved.

### Examples

```pycon
>>> resolve_skeleton("whole_note")
(4,)
>>> resolve_skeleton("tresillo")
(1.5, 1.5, 1)
>>> resolve_skeleton((2, 2))
(2, 2)
>>> resolve_skeleton("Dotted half + quarter")
(3, 1)
```

### accompy.rhythm_to_audio(chords, , skeleton='whole_note', resolver=None, midi_gen=None, audio_renderer=None, soundfont=None, tempo=120, sr=44100, output_path=None)

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

Same as [`rhythm_to_midi()`](_autosummary/accompy.html.md#accompy.rhythm_to_midi) but renders all the way to audio.

* **Parameters:**
  * **chords** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`ChordSequence`](_autosummary/accompy.converters.html.md#accompy.converters.ChordSequence)) – Chord string or ChordSequence.
  * **skeleton** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`float`](https://docs.python.org/3/builtins/functions.html#float), [`...`](https://docs.python.org/3/builtins/constants.html#Ellipsis)]) – Skeleton key, name, style, or duration tuple.
  * **resolver** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Chord resolver name.
  * **midi_gen** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – MIDI generator name.
  * **audio_renderer** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Audio renderer name.
  * **soundfont** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Path to SoundFont file.
  * **tempo** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – BPM.
  * **sr** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Sample rate.
  * **output_path** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Optional path to write WAV file.
* **Return type:**
  [`AudioData`](_autosummary/accompy.converters.html.md#accompy.converters.AudioData)
* **Returns:**
  AudioData with waveform and sample rate.

### Example

```pycon
>>> audio = rhythm_to_audio("| C | Am |", skeleton="half_notes")
```

### accompy.rhythm_to_midi(chords, , skeleton='whole_note', resolver=None, midi_gen=None, tempo=120, output_path=None)

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`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`ChordSequence`](_autosummary/accompy.converters.html.md#accompy.converters.ChordSequence)) – Chord string (e.g., `"| Dm7 | G7 | Cmaj7 |"`) or ChordSequence.
  * **skeleton** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`float`](https://docs.python.org/3/builtins/functions.html#float), [`...`](https://docs.python.org/3/builtins/constants.html#Ellipsis)]) – Skeleton key, name, style, or duration tuple.
    Defaults to `"whole_note"` (one strike per measure).
  * **resolver** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Chord resolver name (e.g., `"pychord"`, `"tonal"`).
  * **midi_gen** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – MIDI generator name (e.g., `"pretty_midi"`, `"midiutil"`).
  * **tempo** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – BPM (used if chords is a string).
  * **output_path** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Optional path to write MIDI file.
* **Return type:**
  [`MidiData`](_autosummary/accompy.converters.html.md#accompy.converters.MidiData)
* **Returns:**
  MidiData object.

### Example

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

### accompy.select_patterns(patterns, beats_per_bar)

The `(drum, bass, comp)` patterns the renderer plays from a style’s pattern lists.

The drum pattern is the first one whose `beats_per_bar` matches (else the first);
bass and comping take the first of their list. A missing one is `None`.

```pycon
>>> from accompy.patterns import get_patterns
>>> [p.name for p in select_patterns(get_patterns("swing"), 4)]
['swing_basic', 'walking', 'swing_comp']
```

* **Return type:**
  [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)

### accompy.set_chord_resolver(resolver)

Set the default chord resolver.

This enables global customization of chord-to-notes resolution.

* **Parameters:**
  **resolver** ([`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)[[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)], [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`int`](https://docs.python.org/3/builtins/functions.html#int)]]) – A function that takes a chord symbol (str) and returns MIDI notes (list[int])
* **Return type:**
  [`None`](https://docs.python.org/3/builtins/constants.html#None)

### Example

```pycon
>>> def my_resolver(symbol: str) -> list[int]:
...     # Custom chord voicing logic
...     return [60, 64, 67]  # C major triad
>>> previous = get_chord_resolver()
>>> set_chord_resolver(my_resolver)
>>> chord_to_notes("Dm7")
[60, 64, 67]
>>> set_chord_resolver(previous)  # put the default back: the setting is process-global
```

### accompy.setup_soundfont(force=False)

Download and configure a SoundFont file.

* **Parameters:**
  **force** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – If True, download even if a SoundFont already exists
* **Return type:**
  [`bool`](https://docs.python.org/3/builtins/functions.html#bool)
* **Returns:**
  True if successful, False otherwise

Example:

```default
from accompy.setup_utils import setup_soundfont
if setup_soundfont():
    print("SoundFont configured successfully!")
```

### accompy.song_to_chord_sequence(song, , bars_per_line=None, beats_per_chord=None, beats_per_bar=4, tempo=120)

Convert a songleaf-shaped `song` to a [`ChordSequence`](_autosummary/accompy.converters.html.md#accompy.converters.ChordSequence).

* **Parameters:**
  * **song** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any)) – Anything with `text`, `annotations` and `meta` as songleaf’s `Song`.
  * **bars_per_line** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`float`](https://docs.python.org/3/builtins/functions.html#float)]) – Bars each chord-carrying line lasts, shared by its chords.
  * **beats_per_chord** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`float`](https://docs.python.org/3/builtins/functions.html#float)]) – Beats every chord lasts. Exclusive with `bars_per_line`.
  * **beats_per_bar** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Beats in a bar (the time signature’s numerator).
  * **tempo** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Tempo in BPM (the song’s `meta["tempo"]` wins when it is a number).
* **Return type:**
  [`ChordSequence`](_autosummary/accompy.converters.html.md#accompy.converters.ChordSequence)
* **Returns:**
  A ChordSequence whose `sections` follow the song’s `section` annotations
  (ranges over the chords), with the song’s title and key.
* **Raises:**
  [**ValueError**](https://docs.python.org/3/builtins/exceptions.html#ValueError) – if both `bars_per_line` and `beats_per_chord` are given, or
      either is not positive.

### accompy.tonal_resolver(symbol, , transpose=-12)

Resolve chord symbol to MIDI notes using the tonal package (default).

The tonal package is lightweight and designed for music theory operations.
It anchors chord roots around C4=60. We apply a default -12 semitone transpose
to voice chords closer to C3=48 for better bass/piano range.

* **Parameters:**
  * **symbol** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Chord symbol (e.g., “Dm7”, “G7”, “Cmaj7”)
  * **transpose** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Semitone offset to apply (default: -12)
* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`int`](https://docs.python.org/3/builtins/functions.html#int)]
* **Returns:**
  List of MIDI note numbers

### Example

```pycon
>>> notes = tonal_resolver("Cmaj7")
>>> len(notes) > 0
True
```

#### NOTE
Requires: pip install tonal
See: [https://github.com/thorwhalen/tonal](https://github.com/thorwhalen/tonal)

### accompy.transpose_chord(chord, semitones, , use_flat=None)

Transpose a chord symbol by *semitones*.

Handles slash chords (e.g. `"C6/E"`).

* **Parameters:**
  * **chord** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Chord symbol like `"Am7"`, `"C6/E"`, `"G#o"`.
  * **semitones** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Number of semitones.
  * **use_flat** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`bool`](https://docs.python.org/3/builtins/functions.html#bool)]) – Force flat/sharp spelling (see [`transpose_note()`](_autosummary/accompy.html.md#accompy.transpose_note)).
* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### Example

```pycon
>>> transpose_chord("Am7", 2)
'Bm7'
>>> transpose_chord("C6/E", 5)
'F6/A'
>>> transpose_chord("G#o", -2, use_flat=True)
'Gbo'
```

### accompy.transpose_note(name, semitones, , use_flat=None)

Transpose a single note name by *semitones*.

* **Parameters:**
  * **name** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Note name like `"C"`, `"Eb"`, `"F#"`.
  * **semitones** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Number of semitones (positive = up, negative = down).
  * **use_flat** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`bool`](https://docs.python.org/3/builtins/functions.html#bool)]) – Force flat (True) or sharp (False) spelling.
    `None` (default) uses flats for downward transposition.
* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### Example

```pycon
>>> transpose_note("C", 5)
'F'
>>> transpose_note("A", -2)
'G'
>>> transpose_note("C", 1, use_flat=True)
'Db'
```

### accompy.transpose_score(score, target_key)

Transpose a [`Score`](_autosummary/accompy.html.md#accompy.Score) to a new key.

The spelling (sharp vs flat) is chosen automatically based on the
*target_key*.

* **Parameters:**
  * **score** – A [`Score`](_autosummary/accompy.html.md#accompy.Score) instance.
  * **target_key** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Target key, e.g. `"Eb"`, `"G"`, `"F#"`.
* **Return type:**
  Score
* **Returns:**
  A new Score in the target key with an updated title.

### Example

```pycon
>>> from accompy import Score
>>> s = Score.from_string("| C | Am | F | G |", key="C")
>>> t = transpose_score(s, "G")
>>> [m[0] for m in t.measures]
['G', 'E-', 'C', 'D']
```

### accompy.verify_and_setup(interactive=True, auto_fix=False)

Verify all dependencies and optionally auto-configure.

* **Parameters:**
  * **interactive** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – If True, prompt user for permission before making changes
  * **auto_fix** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – If True and interactive=False, automatically fix issues without prompting
* **Return type:**
  [`Dict`](https://docs.python.org/3/library/typing.html#typing.Dict)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`bool`](https://docs.python.org/3/builtins/functions.html#bool)]
* **Returns:**
  Dict mapping dependency name to whether it’s available

### Example

```pycon
>>> from accompy.setup_utils import verify_and_setup
>>> status = verify_and_setup(interactive=False)
>>> if all(status.values()):
...     print("Ready to use!")
```

### Modules

| [`audio_renderers`](_autosummary/accompy.audio_renderers.html.md#module-accompy.audio_renderers)       | Audio renderers — convert MidiData to AudioData.                                |
|-------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------|
| [`base`](_autosummary/accompy.base.html.md#module-accompy.base)                             | Core domain models for accompy.                                                 |
| [`chord_parsers`](_autosummary/accompy.chord_parsers.html.md#module-accompy.chord_parsers)           | Chord sheet parsers — convert various text formats to ChordSequence.            |
| [`chord_resolution`](_autosummary/accompy.chord_resolution.html.md#module-accompy.chord_resolution)     | Chord symbol to MIDI notes resolution.                                          |
| [`chord_resolvers`](_autosummary/accompy.chord_resolvers.html.md#module-accompy.chord_resolvers)       | Chord resolvers — convert chord symbols to MIDI note numbers.                   |
| [`converters`](_autosummary/accompy.converters.html.md#module-accompy.converters)                 | Core types for the chord-to-audio pipeline.                                     |
| [`data_access`](_autosummary/accompy.data_access.html.md#module-accompy.data_access)               | Per-user data directory management for accompy.                                 |
| [`ireal`](_autosummary/accompy.ireal.html.md#module-accompy.ireal)                           | Decode iReal Pro URLs (`irealb://` and `irealbook://`) into tunes and bars.     |
| [`main`](_autosummary/accompy.main.html.md#module-accompy.main)                             | Main accompaniment generation module.                                           |
| [`midi_generators`](_autosummary/accompy.midi_generators.html.md#module-accompy.midi_generators)       | MIDI generators — convert NoteSequence to MidiData.                             |
| [`patterns`](_autosummary/accompy.patterns.html.md#module-accompy.patterns)                     | Pattern registry and access for accompany patterns.                             |
| [`pipeline`](_autosummary/accompy.pipeline.html.md#module-accompy.pipeline)                     | High-level pipeline API — one-call chord-to-audio conversion.                   |
| [`protocols`](_autosummary/accompy.protocols.html.md#module-accompy.protocols)                   | Protocols defining extensibility contracts for accompy.                         |
| [`realtime`](_autosummary/accompy.realtime.html.md#module-accompy.realtime)                     | Real-time accompaniment support (foundation).                                   |
| [`renderers`](_autosummary/accompy.renderers.html.md#module-accompy.renderers)                   | MIDI and MMA rendering backends for accompy.                                    |
| [`rendering`](_autosummary/accompy.rendering.html.md#module-accompy.rendering)                   | High-quality chord rendering pipeline — from chord charts to AI-enhanced audio. |
| [`rhythmic_skeletons`](_autosummary/accompy.rhythmic_skeletons.html.md#module-accompy.rhythmic_skeletons) | Rhythmic skeletons — duration-only measure patterns for simple accompaniment.   |
| [`setup_utils`](_autosummary/accompy.setup_utils.html.md#module-accompy.setup_utils)               | Setup and configuration utilities for accompy.                                  |
| [`songs`](_autosummary/accompy.songs.html.md#module-accompy.songs)                           | Songs as backing-track input: a `songleaf` Song becomes a ChordSequence.        |
| [`synthesis`](_autosummary/accompy.synthesis.html.md#module-accompy.synthesis)                   | Audio synthesis backends for accompy.                                           |
| [`tools`](_autosummary/accompy.tools.html.md#module-accompy.tools)                           | Tools for generating accompaniment audio from Score objects.                    |
| [`util`](_autosummary/accompy.util.html.md#module-accompy.util)                             | Utility functions for chord parsing and normalization.                          |
| [`wips`](_autosummary/accompy.wips.html.md#module-accompy.wips)                             | Backward-compatibility shim — wips modules have moved to accompy top level.     |


# _autosummary/accompy.ireal.html.md

# accompy.ireal

Decode iReal Pro URLs (`irealb://` and `irealbook://`) into tunes and bars.

accompy owns this decoding; the TypeScript twin (`ts/src/ireal.ts`) is its exact
counterpart. The unscrambling and the chord-string cleanup started as a copy of the parts
of pyRealParser ([https://github.com/drs251/pyRealParser](https://github.com/drs251/pyRealParser), MIT licence, notice below) that
accompy used. Changes from it:

- `T12` is 12/8; every other time-signature code `T<a><b>` is a/b;
- the chart is read bar by bar in one linear pass: every `{...}` repeat is written out
  with its own endings (`}N2`, `}` then `[N2`, three endings; a `}` closing the
  last ending replays nothing), a `}` with no `{` repeats from the last `[`, the
  previous `}` or the top, a `{` inside an open repeat restarts it (iReal has no
  nesting), and the `}` stays a barline;
- a D.C./D.S. al Coda replays from the segno `S` (or the top) to the first `Q`, as
  whole bars, then plays the coda;
- `r` (repeat the previous two bars) makes two bars and keeps the bar after it;
- `p` (the previous chord again) and `W` (an invisible root) with no chord before
  them are dropped; `x` or `r` with nothing to repeat is dropped;
- backslashes in chord text are literal text;
- song fields are read by position, so an empty field (an empty composer) shifts nothing;
- each bar is a list of its chords (pyRealParser glued them into one string per bar), and
  end, segno and coda marks are left out of the chords;
- the `l` (large print) mark is removed without eating the `l` of `alt`;
- `Z` (final double bar) is a barline.

Regex digit and word classes follow Python’s Unicode tables; the twin’s JavaScript ones can
be a version newer (characters added in Unicode 15.1/16 differ; iReal uses none of them).

The URL layout. `irealb://` holds songs joined by `===`, then an optional playlist
name; a song is ten `=`-separated fields, `title=composer=(unused)=style=key=transpose=
music=comp_style=bpm=repeats`, whose music starts with [`SCRAMBLE_PREFIX`](_autosummary/accompy.ireal.html.md#accompy.ireal.SCRAMBLE_PREFIX) and is
scrambled. Empty fields can make `===` inside a song, so songs are found by their music
field, not by splitting on `===`. `irealbook://` (the older format) holds six-field
songs, `title=composer=style=key=n=music`, with the music in plain text.

```pycon
>>> [t.measures for t in decode_ireal_url("irealbook://Blues=Me=Swing=F=n=[T34F7 |Bb7 p|r| |C7 Z")]
[[['F7'], ['Bb7', 'Bb7'], ['F7'], ['Bb7', 'Bb7'], ['C7']]]
```

### Module Attributes

| [`SCRAMBLE_PREFIX`](_autosummary/accompy.ireal.html.md#accompy.ireal.SCRAMBLE_PREFIX)           | The start of a scrambled (`irealb://`) music field.                           |
|----------------------------------------------------------------------------|-------------------------------------------------------------------------------|
| [`TIME_SIGNATURE_EXCEPTIONS`](_autosummary/accompy.ireal.html.md#accompy.ireal.TIME_SIGNATURE_EXCEPTIONS) | Time-signature codes that are not `T<numerator><denominator>`.                |
| [`PLAIN_SONG_FIELDS`](_autosummary/accompy.ireal.html.md#accompy.ireal.PLAIN_SONG_FIELDS)         | Number of fields in an `irealbook://` song, and the index of its music field. |
| [`PLAIN_MUSIC_INDEX`](_autosummary/accompy.ireal.html.md#accompy.ireal.PLAIN_MUSIC_INDEX)         | Number of fields in an `irealbook://` song, and the index of its music field. |

### Functions

| [`cleanup_chord_string`](_autosummary/accompy.ireal.html.md#accompy.ireal.cleanup_chord_string)(chord_string)   | Unify bar lines (`Z`, the final double bar, is one too) and repeat signs; drop spacers and empty bars.                                                                   |
|---------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [`decode_ireal_url`](_autosummary/accompy.ireal.html.md#accompy.ireal.decode_ireal_url)(url)                | The tunes of an iReal URL (a playlist has several), skipping those that do not decode.                                                                                   |
| [`flatten_measures`](_autosummary/accompy.ireal.html.md#accompy.ireal.flatten_measures)(chord_string)       | The bars of an (unscrambled) chord string, each a list of its chords, with repeats, endings, codas and signs written out (a `p` repeats the previous chord on its beat). |
| [`time_signature`](_autosummary/accompy.ireal.html.md#accompy.ireal.time_signature)(chord_string)         | The first time signature (`T44`, `T34`, `T12` = 12/8, ...), else 4/4.                                                                                                    |
| [`unscramble`](_autosummary/accompy.ireal.html.md#accompy.ireal.unscramble)(scrambled)                | Undo iReal's scrambling of a music field (after [`SCRAMBLE_PREFIX`](_autosummary/accompy.ireal.html.md#accompy.ireal.SCRAMBLE_PREFIX)).                                                       |

### Classes

| [`IrealTune`](_autosummary/accompy.ireal.html.md#accompy.ireal.IrealTune)([title, composer, style, key, ...])   | One song of an iReal URL: its metadata, cleaned chord string and flattened bars.   |
|--------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------|

### *class* accompy.ireal.IrealTune(title='', composer='', style='', key='', transpose='', comp_style='', bpm='', repeats='', chord_string='', time_signature=(4, 4), measures=list())

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

One song of an iReal URL: its metadata, cleaned chord string and flattened bars.

`measures` holds one list of chords per bar (e.g. `['D-7', 'G7']`), with
repeats, endings, codas and repeat signs written out.

#### chord_specs(, beats_per_bar=None)

`(chord, beats)` pairs: each bar shared evenly by its chords. Bars last
`beats_per_bar` beats, by default the time signature’s numerator.

```pycon
>>> IrealTune(measures=[["C"], ["D-7", "G7"]], time_signature=(3, 4)).chord_specs()
[('C', 3.0), ('D-7', 1.5), ('G7', 1.5)]
```

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`float`](https://docs.python.org/3/builtins/functions.html#float)]]

#### *property* tempo *: [int](https://docs.python.org/3/builtins/functions.html#int) | [None](https://docs.python.org/3/builtins/constants.html#None)*

The tempo in BPM, or None when unset (empty, not a number, or not above 0).

### accompy.ireal.PLAIN_MUSIC_INDEX *= 5*

Number of fields in an `irealbook://` song, and the index of its music field.

### accompy.ireal.PLAIN_SONG_FIELDS *= 6*

Number of fields in an `irealbook://` song, and the index of its music field.

### accompy.ireal.SCRAMBLE_PREFIX *= '1r34LbKcu7'*

The start of a scrambled (`irealb://`) music field.

### accompy.ireal.TIME_SIGNATURE_EXCEPTIONS *= {(1, 2): (12, 8)}*

Time-signature codes that are not `T<numerator><denominator>`.

### accompy.ireal.cleanup_chord_string(chord_string)

Unify bar lines (`Z`, the final double bar, is one too) and repeat signs; drop
spacers and empty bars.

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### accompy.ireal.decode_ireal_url(url)

The tunes of an iReal URL (a playlist has several), skipping those that do not decode.

The URL ends at its first raw `"` (as when cut out of an HTML `href`; a `%22`
is a quote inside a title or comment) and is then percent-decoded; the `irealb://` / `irealbook://` scheme is optional. Music fields that
start with [`SCRAMBLE_PREFIX`](_autosummary/accompy.ireal.html.md#accompy.ireal.SCRAMBLE_PREFIX) are read as `irealb` songs; a URL with none is
read as `irealbook` six-field songs.

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`IrealTune`](_autosummary/accompy.ireal.html.md#accompy.ireal.IrealTune)]

### accompy.ireal.flatten_measures(chord_string)

The bars of an (unscrambled) chord string, each a list of its chords, with repeats,
endings, codas and signs written out (a `p` repeats the previous chord on its beat).

```pycon
>>> flatten_measures("{C^7 p|A-7 D7 |N1D-7,G7 }N2G-7 C7 F7 |F^7 Z")
[['C^7', 'C^7'], ['A-7', 'D7'], ['D-7', 'G7'], ['C^7', 'C^7'], ['A-7', 'D7'], ['G-7', 'C7', 'F7'], ['F^7']]
```

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]]

### accompy.ireal.time_signature(chord_string)

The first time signature (`T44`, `T34`, `T12` = 12/8, …), else 4/4.

* **Return type:**
  [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`int`](https://docs.python.org/3/builtins/functions.html#int), [`int`](https://docs.python.org/3/builtins/functions.html#int)]

### accompy.ireal.unscramble(scrambled)

Undo iReal’s scrambling of a music field (after [`SCRAMBLE_PREFIX`](_autosummary/accompy.ireal.html.md#accompy.ireal.SCRAMBLE_PREFIX)).

Every full 50-character block that is not the last (or followed by fewer than 2
characters) has characters 0-4 and 10-23 swapped with their mirror (49 - i). The
operation is its own inverse.

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)


# _autosummary/accompy.main.html.md

# accompy.main

Main accompaniment generation module.

Integrates all components (patterns, chord resolution, MIDI rendering,
synthesis) to provide the main accompy API.

### Functions

| [`check_dependencies`](_autosummary/accompy.main.html.md#accompy.main.check_dependencies)()                             | Check which dependencies are available.                        |
|---------------------------------------------------------------------------------------------------|----------------------------------------------------------------|
| [`generate_accompaniment`](_autosummary/accompy.main.html.md#accompy.main.generate_accompaniment)(chords, \*[, style, ...]) | Generate an accompaniment audio file from a chord progression. |
| [`play_audio`](_autosummary/accompy.main.html.md#accompy.main.play_audio)(audio_path)                           | Play an audio file using the system's default audio player.    |
| [`print_setup_instructions`](_autosummary/accompy.main.html.md#accompy.main.print_setup_instructions)()                       | Print installation instructions for missing dependencies.      |

### accompy.main.check_dependencies()

Check which dependencies are available.

* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`bool`](https://docs.python.org/3/builtins/functions.html#bool)]
* **Returns:**
  Dict mapping dependency name to availability status

### Example

```pycon
>>> 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)

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`](https://docs.python.org/3/library/typing.html#typing.Any)) – Chord progression (string, Score, list of tuples, iReal URL)
  * **style** ([`Literal`](https://docs.python.org/3/library/typing.html#typing.Literal)[`'swing'`, `'bossa'`, `'rock'`, `'ballad'`, `'funk'`, `'latin'`, `'waltz'`, `'blues'`]) – Musical style (swing, bossa, rock, ballad, funk, latin, waltz, blues)
  * **tempo** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Tempo in BPM
  * **repeats** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Number of times to repeat the progression
  * **output_path** ([`Union`](https://docs.python.org/3/library/typing.html#typing.Union)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path), [`None`](https://docs.python.org/3/builtins/constants.html#None)]) – Where to save the file (None = temp file)
  * **output_format** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`Literal`](https://docs.python.org/3/library/typing.html#typing.Literal)[`'wav'`, `'mp3'`, `'flac'`, `'midi'`, `'mid'`]]) – Output format (wav, mp3, flac, midi)
  * **config** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`AccompanimentConfig`](_autosummary/accompy.base.html.md#accompy.base.AccompanimentConfig)]) – Full configuration object (overrides other params if provided)
  * **use_mma** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – If True and MMA available, use MMA backend
  * **backend** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`Literal`](https://docs.python.org/3/library/typing.html#typing.Literal)[`'auto'`, `'mma'`, `'builtin'`]]) – Explicitly select backend (‘auto’, ‘mma’, ‘builtin’)
  * **autoplay** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – If True, automatically play the generated audio
* **Return type:**
  [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)
* **Returns:**
  Path to the generated audio/MIDI file

### Example

```pycon
>>> 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”.

### accompy.main.play_audio(audio_path)

Play an audio file using the system’s default audio player.

* **Parameters:**
  **audio_path** ([`Union`](https://docs.python.org/3/library/typing.html#typing.Union)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)]) – Path to the audio file
* **Return type:**
  [`bool`](https://docs.python.org/3/builtins/functions.html#bool)
* **Returns:**
  True if playback started successfully, False otherwise

### Example

```pycon
>>> from accompy import play_audio
>>> play_audio("/path/to/audio.wav")
```

### accompy.main.print_setup_instructions()

Print installation instructions for missing dependencies.


# _autosummary/accompy.midi_generators.html.md

# accompy.midi_generators

MIDI generators — convert NoteSequence to MidiData.

Registered converters: NoteSequence -> MidiData

Multiple backends:

- pretty_midi: most Pythonic API, good for programmatic construction
- midiutil: accompy’s existing dependency, simpler
- mido: lowest-level, message-based

Also provides ChordSequence -> MidiData shortcut converters that
combine chord resolution + MIDI generation in one step.

### Functions

| [`chordseq_to_midi_builtin_accompaniment`](_autosummary/accompy.midi_generators.html.md#accompy.midi_generators.chordseq_to_midi_builtin_accompaniment)(cs, \*)   | Convert ChordSequence to multi-track MIDI using accompy's pattern engine.   |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------|
| [`chordseq_to_midi_mma`](_autosummary/accompy.midi_generators.html.md#accompy.midi_generators.chordseq_to_midi_mma)(cs, \*[, style, repeats])   | Convert ChordSequence to MIDI using MMA (Musical MIDI Accompaniment).       |
| [`noteseq_to_midi_midiutil`](_autosummary/accompy.midi_generators.html.md#accompy.midi_generators.noteseq_to_midi_midiutil)(ns)                     | Convert NoteSequence to MidiData using midiutil (MIDIFile).                 |
| [`noteseq_to_midi_mido`](_autosummary/accompy.midi_generators.html.md#accompy.midi_generators.noteseq_to_midi_mido)(ns)                         | Convert NoteSequence to MidiData using mido.                                |
| [`noteseq_to_midi_pretty_midi`](_autosummary/accompy.midi_generators.html.md#accompy.midi_generators.noteseq_to_midi_pretty_midi)(ns, \*[, ...])       | Convert NoteSequence to MidiData using pretty_midi.                         |

### accompy.midi_generators.chordseq_to_midi_builtin_accompaniment(cs, , style='swing', repeats=1)

Convert ChordSequence to multi-track MIDI using accompy’s pattern engine.

This bridges the converter pipeline to the existing pattern-based
accompaniment engine (drums, bass, piano).

```pycon
>>> cs = ChordSequence([("Dm7", 4.0), ("G7", 4.0), ("Cmaj7", 4.0)])
>>> md = chordseq_to_midi_builtin_accompaniment(cs, style="swing")
>>> md.has_bytes
True
```

* **Return type:**
  [`MidiData`](_autosummary/accompy.converters.html.md#accompy.converters.MidiData)

### accompy.midi_generators.chordseq_to_midi_mma(cs, , style='swing', repeats=1)

Convert ChordSequence to MIDI using MMA (Musical MIDI Accompaniment).

MMA generates sophisticated multi-instrument accompaniment patterns
from chord symbols, similar to Band-in-a-Box.

Requires: `mma` CLI on PATH.
See [https://www.mellowood.ca/mma/](https://www.mellowood.ca/mma/) for installation.

```pycon
>>> cs = ChordSequence([("Dm7", 4.0), ("G7", 4.0), ("Cmaj7", 4.0)])
>>> md = chordseq_to_midi_mma(cs, style="swing")
```

* **Return type:**
  [`MidiData`](_autosummary/accompy.converters.html.md#accompy.converters.MidiData)

### accompy.midi_generators.noteseq_to_midi_midiutil(ns)

Convert NoteSequence to MidiData using midiutil (MIDIFile).

```pycon
>>> ns = NoteSequence([([60, 64, 67], 4.0)], tempo=120)
>>> md = noteseq_to_midi_midiutil(ns)
>>> md.has_bytes
True
```

* **Return type:**
  [`MidiData`](_autosummary/accompy.converters.html.md#accompy.converters.MidiData)

### accompy.midi_generators.noteseq_to_midi_mido(ns)

Convert NoteSequence to MidiData using mido.

```pycon
>>> ns = NoteSequence([([60, 64, 67], 4.0)], tempo=120)
>>> md = noteseq_to_midi_mido(ns)
>>> md.has_bytes
True
```

* **Return type:**
  [`MidiData`](_autosummary/accompy.converters.html.md#accompy.converters.MidiData)

### accompy.midi_generators.noteseq_to_midi_pretty_midi(ns, , program=0, instrument_name='Piano')

Convert NoteSequence to MidiData using pretty_midi.

Renders each chord as a block of simultaneous notes.

```pycon
>>> ns = NoteSequence([([60, 64, 67], 4.0)], tempo=120)
>>> md = noteseq_to_midi_pretty_midi(ns)
>>> md.has_pretty_midi
True
```

* **Return type:**
  [`MidiData`](_autosummary/accompy.converters.html.md#accompy.converters.MidiData)


# _autosummary/accompy.patterns.builtin.html.md

# accompy.patterns.builtin

Built-in pattern definitions for all supported styles.

Contains SWING, BOSSA, ROCK, BALLAD, FUNK, LATIN, WALTZ, and BLUES patterns.


# _autosummary/accompy.patterns.dataclasses.html.md

# accompy.patterns.dataclasses

Pattern data structures for accompaniment generation.

Contains the core pattern dataclasses: DrumHit, NoteEvent, DrumPattern,
BassPattern, and CompingPattern.

### Classes

| [`BassPattern`](_autosummary/accompy.patterns.dataclasses.html.md#accompy.patterns.dataclasses.BassPattern)(name, notes)                          | A bass pattern template.                            |
|----------------------------------------------------------------------------------------------------|-----------------------------------------------------|
| [`CompingPattern`](_autosummary/accompy.patterns.dataclasses.html.md#accompy.patterns.dataclasses.CompingPattern)(name, hits)                        | A piano/guitar comping (accompaniment) pattern.     |
| [`DrumHit`](_autosummary/accompy.patterns.dataclasses.html.md#accompy.patterns.dataclasses.DrumHit)(beat, drum, velocity)                     | A single drum hit in a pattern.                     |
| [`DrumPattern`](_autosummary/accompy.patterns.dataclasses.html.md#accompy.patterns.dataclasses.DrumPattern)(name, beats_per_bar, hits)            | A drum pattern for one or more measures.            |
| [`NoteEvent`](_autosummary/accompy.patterns.dataclasses.html.md#accompy.patterns.dataclasses.NoteEvent)(beat, pitch_offset, duration, velocity) | A melodic note event for bass or other instruments. |

### *class* accompy.patterns.dataclasses.BassPattern(name, notes)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

A bass pattern template.

Uses pitch_offset in NoteEvent to specify intervals from the chord root.
The actual pitches are determined when the pattern is applied to specific chords.

### *class* accompy.patterns.dataclasses.CompingPattern(name, hits)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

A piano/guitar comping (accompaniment) pattern.

#### name

Pattern identifier

* **Type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

#### hits

Sequence of (beat, duration, velocity) tuples

* **Type:**
  [`Sequence`](https://docs.python.org/3/library/typing.html#typing.Sequence)[[`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`float`](https://docs.python.org/3/builtins/functions.html#float), [`float`](https://docs.python.org/3/builtins/functions.html#float), [`int`](https://docs.python.org/3/builtins/functions.html#int)]]

### *class* accompy.patterns.dataclasses.DrumHit(beat, drum, velocity)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

A single drum hit in a pattern.

#### beat

Beat position (0-based within measure)

* **Type:**
  [`float`](https://docs.python.org/3/builtins/functions.html#float)

#### drum

MIDI note number for the drum sound

* **Type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int)

#### velocity

Hit velocity (0-127)

* **Type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int)

### *class* accompy.patterns.dataclasses.DrumPattern(name, beats_per_bar, hits)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

A drum pattern for one or more measures.

### Example

```pycon
>>> pattern = DrumPattern("rock", 4, [DrumHit(0, KICK, 100)])
>>> pattern.beats_per_bar
4
```

#### at_tempo(tempo)

Return pattern duration in seconds at a given tempo.

* **Return type:**
  [`float`](https://docs.python.org/3/builtins/functions.html#float)

### *class* accompy.patterns.dataclasses.NoteEvent(beat, pitch_offset, duration, velocity)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

A melodic note event for bass or other instruments.

#### beat

Beat position within measure

* **Type:**
  [`float`](https://docs.python.org/3/builtins/functions.html#float)

#### pitch_offset

Offset from chord root in semitones (0=root, 7=5th, etc.)

* **Type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int)

#### duration

Note duration in beats

* **Type:**
  [`float`](https://docs.python.org/3/builtins/functions.html#float)

#### velocity

Note velocity (0-127)

* **Type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int)


# _autosummary/accompy.patterns.html.md

# accompy.patterns

Pattern registry and access for accompany patterns.

This module provides access to musical patterns (drums, bass, comping) for
different styles. Includes a MutableMapping-based PatternRegistry for
runtime pattern registration.

### Functions

| [`get_pattern_registry`](_autosummary/accompy.patterns.html.md#accompy.patterns.get_pattern_registry)()                   | Get the global pattern registry, initializing if needed.   |
|-------------------------------------------------------------------------------------------|------------------------------------------------------------|
| [`get_patterns`](_autosummary/accompy.patterns.html.md#accompy.patterns.get_patterns)(style)                      | Get all patterns for a given style.                        |
| [`register_style`](_autosummary/accompy.patterns.html.md#accompy.patterns.register_style)(style, drums, bass, comp) | Register a custom style with the global registry.          |

### Classes

| [`DrumPattern`](_autosummary/accompy.patterns.html.md#accompy.patterns.DrumPattern)(name, beats_per_bar, hits)            | A drum pattern for one or more measures.            |
|----------------------------------------------------------------------------------------------------|-----------------------------------------------------|
| [`BassPattern`](_autosummary/accompy.patterns.html.md#accompy.patterns.BassPattern)(name, notes)                          | A bass pattern template.                            |
| [`CompingPattern`](_autosummary/accompy.patterns.html.md#accompy.patterns.CompingPattern)(name, hits)                        | A piano/guitar comping (accompaniment) pattern.     |
| [`DrumHit`](_autosummary/accompy.patterns.html.md#accompy.patterns.DrumHit)(beat, drum, velocity)                     | A single drum hit in a pattern.                     |
| [`NoteEvent`](_autosummary/accompy.patterns.html.md#accompy.patterns.NoteEvent)(beat, pitch_offset, duration, velocity) | A melodic note event for bass or other instruments. |
| [`PatternRegistry`](_autosummary/accompy.patterns.html.md#accompy.patterns.PatternRegistry)()                                 | Registry of accompaniment patterns by style.        |

### *class* accompy.patterns.BassPattern(name, notes)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

A bass pattern template.

Uses pitch_offset in NoteEvent to specify intervals from the chord root.
The actual pitches are determined when the pattern is applied to specific chords.

### *class* accompy.patterns.CompingPattern(name, hits)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

A piano/guitar comping (accompaniment) pattern.

#### name

Pattern identifier

* **Type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

#### hits

Sequence of (beat, duration, velocity) tuples

* **Type:**
  [`Sequence`](https://docs.python.org/3/library/typing.html#typing.Sequence)[[`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`float`](https://docs.python.org/3/builtins/functions.html#float), [`float`](https://docs.python.org/3/builtins/functions.html#float), [`int`](https://docs.python.org/3/builtins/functions.html#int)]]

### *class* accompy.patterns.DrumHit(beat, drum, velocity)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

A single drum hit in a pattern.

#### beat

Beat position (0-based within measure)

* **Type:**
  [`float`](https://docs.python.org/3/builtins/functions.html#float)

#### drum

MIDI note number for the drum sound

* **Type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int)

#### velocity

Hit velocity (0-127)

* **Type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int)

### *class* accompy.patterns.DrumPattern(name, beats_per_bar, hits)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

A drum pattern for one or more measures.

### Example

```pycon
>>> pattern = DrumPattern("rock", 4, [DrumHit(0, KICK, 100)])
>>> pattern.beats_per_bar
4
```

#### at_tempo(tempo)

Return pattern duration in seconds at a given tempo.

* **Return type:**
  [`float`](https://docs.python.org/3/builtins/functions.html#float)

### *class* accompy.patterns.NoteEvent(beat, pitch_offset, duration, velocity)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

A melodic note event for bass or other instruments.

#### beat

Beat position within measure

* **Type:**
  [`float`](https://docs.python.org/3/builtins/functions.html#float)

#### pitch_offset

Offset from chord root in semitones (0=root, 7=5th, etc.)

* **Type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int)

#### duration

Note duration in beats

* **Type:**
  [`float`](https://docs.python.org/3/builtins/functions.html#float)

#### velocity

Note velocity (0-127)

* **Type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int)

### *class* accompy.patterns.PatternRegistry

Bases: [`MutableMapping`](https://docs.python.org/3/library/collections.abc.html#collections.abc.MutableMapping)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)]

Registry of accompaniment patterns by style.

Implements MutableMapping for intuitive access:

```default
registry['bossa']  # Get patterns
registry['my_style'] = {...}  # Register custom
del registry['my_style']  # Remove
```

### Example

```pycon
>>> registry = PatternRegistry()
>>> registry.register_builtin_patterns()
>>> 'swing' in registry
True
>>> registry['swing']['drums'][0].name
'swing_basic'
```

#### available_styles()

Get list of all available style names.

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]

#### get_patterns(style)

Get patterns for a style (PatternSource protocol method).

* **Parameters:**
  **style** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Style name
* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)
* **Returns:**
  Dict with ‘drums’, ‘bass’, ‘comp’ keys

#### register_builtin_patterns()

Load all built-in patterns.

* **Return type:**
  [`None`](https://docs.python.org/3/builtins/constants.html#None)

### accompy.patterns.get_pattern_registry()

Get the global pattern registry, initializing if needed.

* **Return type:**
  [`PatternRegistry`](_autosummary/accompy.patterns.html.md#accompy.patterns.PatternRegistry)
* **Returns:**
  The global PatternRegistry instance

### Example

```pycon
>>> registry = get_pattern_registry()
>>> 'swing' in registry
True
```

### accompy.patterns.get_patterns(style)

Get all patterns for a given style.

* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)
* **Returns:**
  Dict with ‘drums’, ‘bass’, ‘comp’ keys containing pattern lists

### Example

```pycon
>>> patterns = get_patterns("bossa")
>>> drums = patterns["drums"][0]
>>> drums.name
'bossa'
```

### accompy.patterns.register_style(style, drums, bass, comp)

Register a custom style with the global registry.

* **Parameters:**
  * **style** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Style name
  * **drums** ([`list`](https://docs.python.org/3/builtins/stdtypes.html#list)) – List of DrumPattern objects
  * **bass** ([`list`](https://docs.python.org/3/builtins/stdtypes.html#list)) – List of BassPattern objects
  * **comp** ([`list`](https://docs.python.org/3/builtins/stdtypes.html#list)) – List of CompingPattern objects
* **Return type:**
  [`None`](https://docs.python.org/3/builtins/constants.html#None)

### Example

```pycon
>>> registry = get_pattern_registry()
>>> register_style('my_funk', [my_drum_pattern], [my_bass_pattern], [])
```

### Modules

| [`builtin`](_autosummary/accompy.patterns.builtin.html.md#module-accompy.patterns.builtin)         | Built-in pattern definitions for all supported styles.   |
|--------------------------------------------------------------------------------------------------|----------------------------------------------------------|
| [`dataclasses`](_autosummary/accompy.patterns.dataclasses.html.md#module-accompy.patterns.dataclasses) | Pattern data structures for accompaniment generation.    |


# _autosummary/accompy.pipeline.html.md

# 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:

```default
>>> 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`](_autosummary/accompy.pipeline.html.md#accompy.pipeline.chords_to_audio)(chords, \*[, resolver, ...])    | Convert chord string to audio.                                         |
|--------------------------------------------------------------------------------------------------|------------------------------------------------------------------------|
| [`chords_to_midi`](_autosummary/accompy.pipeline.html.md#accompy.pipeline.chords_to_midi)(chords, \*[, resolver, ...])     | Convert chord string to MIDI data.                                     |
| [`chords_to_notes`](_autosummary/accompy.pipeline.html.md#accompy.pipeline.chords_to_notes)(chords, \*[, resolver, tempo])  | Convert chord string or ChordSequence to resolved MIDI notes.          |
| [`chords_to_sequence`](_autosummary/accompy.pipeline.html.md#accompy.pipeline.chords_to_sequence)(chords, \*[, parser, ...])   | Parse a chord string into a ChordSequence.                             |
| [`file_to_audio`](_autosummary/accompy.pipeline.html.md#accompy.pipeline.file_to_audio)(filepath, \*[, output_path, ...]) | Convert an iReal Pro HTML/URL file to audio.                           |
| [`file_to_midi`](_autosummary/accompy.pipeline.html.md#accompy.pipeline.file_to_midi)(filepath, \*[, output_path, ...])  | Convert an iReal Pro HTML/URL file to MIDI.                            |
| [`list_available_converters`](_autosummary/accompy.pipeline.html.md#accompy.pipeline.list_available_converters)()                     | List all available converters organized by pipeline stage.             |
| [`midi_to_audio`](_autosummary/accompy.pipeline.html.md#accompy.pipeline.midi_to_audio)(midi_data, \*[, ...])             | Convert MidiData to audio.                                             |
| [`rhythm_to_audio`](_autosummary/accompy.pipeline.html.md#accompy.pipeline.rhythm_to_audio)(chords, \*[, skeleton, ...])    | Convert chords to audio using a rhythmic skeleton for restrike timing. |
| [`rhythm_to_midi`](_autosummary/accompy.pipeline.html.md#accompy.pipeline.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)

Convert chord string to audio.

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

* **Parameters:**
  * **chords** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`ChordSequence`](_autosummary/accompy.converters.html.md#accompy.converters.ChordSequence)) – Chord string or ChordSequence
  * **resolver** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – Chord resolver (‘pychord’, ‘music21’, ‘mingus’, ‘tonal’)
  * **midi_gen** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – MIDI generator (‘pretty_midi’, ‘midiutil’, ‘mido’)
  * **audio_renderer** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – Audio renderer (‘pretty_midi’, ‘fluidsynth’, ‘tonal’)
  * **soundfont** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – Path to SoundFont file
  * **tempo** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – BPM
  * **sr** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Sample rate
  * **output_path** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – Optional path to write WAV file
* **Return type:**
  [`AudioData`](_autosummary/accompy.converters.html.md#accompy.converters.AudioData)
* **Returns:**
  AudioData with waveform and sample rate

```pycon
>>> 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)

Convert chord string to MIDI data.

* **Parameters:**
  * **chords** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`ChordSequence`](_autosummary/accompy.converters.html.md#accompy.converters.ChordSequence)) – Chord string or ChordSequence
  * **resolver** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – Resolver name (‘pychord’, ‘music21’, ‘mingus’, ‘tonal’)
  * **midi_gen** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – MIDI generator name (‘pretty_midi’, ‘midiutil’, ‘mido’)
  * **tempo** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – BPM
  * **output_path** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – Optional path to write MIDI file
* **Return type:**
  [`MidiData`](_autosummary/accompy.converters.html.md#accompy.converters.MidiData)
* **Returns:**
  MidiData object

```pycon
>>> md = chords_to_midi("| C | Am | F | G |")
>>> md.to_bytes()[:4]
b'MThd'
```

### accompy.pipeline.chords_to_notes(chords, , resolver=None, tempo=120)

Convert chord string or ChordSequence to resolved MIDI notes.

* **Parameters:**
  * **chords** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`ChordSequence`](_autosummary/accompy.converters.html.md#accompy.converters.ChordSequence)) – Chord string or ChordSequence
  * **resolver** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – Resolver name (‘pychord’, ‘music21’, ‘mingus’, ‘tonal’)
  * **tempo** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – BPM (used if chords is a string)
* **Return type:**
  [`NoteSequence`](_autosummary/accompy.converters.html.md#accompy.converters.NoteSequence)
* **Returns:**
  NoteSequence with MIDI note numbers

```pycon
>>> 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))

Parse a chord string into a ChordSequence.

* **Parameters:**
  * **chords** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Chord string in any supported format
  * **parser** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – Parser name (‘auto_detect’, ‘plain_text’, ‘chordpro’, ‘musicgen_chord’)
  * **tempo** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – BPM (default 120)
  * **title** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Song title
  * **key** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Key signature
  * **time_signature** ([`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`int`](https://docs.python.org/3/builtins/functions.html#int), [`int`](https://docs.python.org/3/builtins/functions.html#int)]) – Time signature tuple
* **Return type:**
  [`ChordSequence`](_autosummary/accompy.converters.html.md#accompy.converters.ChordSequence)
* **Returns:**
  ChordSequence with parsed chords

```pycon
>>> 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)

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`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Path to an iReal HTML file, or a chord text file
  * **output_path** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Where to write audio. If None, uses filepath with .wav extension
  * **n_repeats** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Number of times to repeat the progression (default 1)
  * **transpose** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Semitones to transpose (positive=up, negative=down)
  * **resolver** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Chord resolver backend
  * **midi_gen** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – MIDI generator backend
  * **audio_renderer** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Audio renderer backend
  * **soundfont** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Path to SoundFont file
  * **tempo** ([`int`](https://docs.python.org/3/builtins/functions.html#int) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Override BPM (None = use file’s tempo or 120)
  * **sr** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Sample rate
* **Return type:**
  [`AudioData`](_autosummary/accompy.converters.html.md#accompy.converters.AudioData)
* **Returns:**
  AudioData

Example:

```default
>>> 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)

Convert an iReal Pro HTML/URL file to MIDI.

Same as file_to_audio but outputs MIDI instead.

* **Parameters:**
  * **filepath** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Path to an iReal HTML file, or a chord text file
  * **output_path** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Where to write MIDI. If None, uses filepath with .mid extension
  * **n_repeats** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Number of times to repeat the progression
  * **transpose** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Semitones to transpose
  * **resolver** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Chord resolver backend
  * **midi_gen** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – MIDI generator backend
  * **tempo** ([`int`](https://docs.python.org/3/builtins/functions.html#int) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Override BPM
* **Return type:**
  [`MidiData`](_autosummary/accompy.converters.html.md#accompy.converters.MidiData)
* **Returns:**
  MidiData

### accompy.pipeline.list_available_converters()

List all available converters organized by pipeline stage.

* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]]
* **Returns:**
  Dict mapping stage names to lists of converter names.

```pycon
>>> 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)

Convert MidiData to audio.

* **Parameters:**
  * **midi_data** ([`MidiData`](_autosummary/accompy.converters.html.md#accompy.converters.MidiData)) – MidiData object
  * **audio_renderer** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – Audio renderer name
  * **soundfont** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – Path to SoundFont file
  * **sr** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Sample rate
  * **output_path** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – Optional path to write WAV file
* **Return type:**
  [`AudioData`](_autosummary/accompy.converters.html.md#accompy.converters.AudioData)
* **Returns:**
  AudioData

```pycon
>>> 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)

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

Same as [`rhythm_to_midi()`](_autosummary/accompy.pipeline.html.md#accompy.pipeline.rhythm_to_midi) but renders all the way to audio.

* **Parameters:**
  * **chords** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`ChordSequence`](_autosummary/accompy.converters.html.md#accompy.converters.ChordSequence)) – Chord string or ChordSequence.
  * **skeleton** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`float`](https://docs.python.org/3/builtins/functions.html#float), [`...`](https://docs.python.org/3/builtins/constants.html#Ellipsis)]) – Skeleton key, name, style, or duration tuple.
  * **resolver** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Chord resolver name.
  * **midi_gen** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – MIDI generator name.
  * **audio_renderer** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Audio renderer name.
  * **soundfont** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Path to SoundFont file.
  * **tempo** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – BPM.
  * **sr** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Sample rate.
  * **output_path** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Optional path to write WAV file.
* **Return type:**
  [`AudioData`](_autosummary/accompy.converters.html.md#accompy.converters.AudioData)
* **Returns:**
  AudioData with waveform and sample rate.

### Example

```pycon
>>> 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)

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`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`ChordSequence`](_autosummary/accompy.converters.html.md#accompy.converters.ChordSequence)) – Chord string (e.g., `"| Dm7 | G7 | Cmaj7 |"`) or ChordSequence.
  * **skeleton** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`float`](https://docs.python.org/3/builtins/functions.html#float), [`...`](https://docs.python.org/3/builtins/constants.html#Ellipsis)]) – Skeleton key, name, style, or duration tuple.
    Defaults to `"whole_note"` (one strike per measure).
  * **resolver** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Chord resolver name (e.g., `"pychord"`, `"tonal"`).
  * **midi_gen** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – MIDI generator name (e.g., `"pretty_midi"`, `"midiutil"`).
  * **tempo** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – BPM (used if chords is a string).
  * **output_path** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Optional path to write MIDI file.
* **Return type:**
  [`MidiData`](_autosummary/accompy.converters.html.md#accompy.converters.MidiData)
* **Returns:**
  MidiData object.

### Example

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


# _autosummary/accompy.protocols.html.md

# accompy.protocols

Protocols defining extensibility contracts for accompy.

These protocols (structural interfaces) enable dependency injection and
allow users to provide custom implementations of core components.

Key protocols:

- ChordResolver: Convert chord symbols to MIDI notes
- PatternSource: Provide patterns for styles
- MidiEventGenerator: Generate MIDI events from scores
- AudioRenderer: Render MIDI to audio

See PEP 544 for more on Protocol types.

### Classes

| [`AudioRenderer`](_autosummary/accompy.protocols.html.md#accompy.protocols.AudioRenderer)(\*args, \*\*kwargs)      | Renders MIDI events to audio.                  |
|-----------------------------------------------------------------------------------------|------------------------------------------------|
| [`ChordResolver`](_autosummary/accompy.protocols.html.md#accompy.protocols.ChordResolver)(\*args, \*\*kwargs)      | Convert chord symbols to MIDI note numbers.    |
| [`MidiEventGenerator`](_autosummary/accompy.protocols.html.md#accompy.protocols.MidiEventGenerator)(\*args, \*\*kwargs) | Generates MIDI events from score and patterns. |
| [`PatternSource`](_autosummary/accompy.protocols.html.md#accompy.protocols.PatternSource)(\*args, \*\*kwargs)      | Provides musical patterns for a given style.   |
| [`SynthesizerBackend`](_autosummary/accompy.protocols.html.md#accompy.protocols.SynthesizerBackend)(\*args, \*\*kwargs) | Audio synthesis backend.                       |

### *class* accompy.protocols.AudioRenderer(\*args, \*\*kwargs)

Bases: [`Protocol`](https://docs.python.org/3/library/typing.html#typing.Protocol)

Renders MIDI events to audio.

This protocol abstracts audio synthesis, enabling:

- Different synthesis backends (FluidSynth, Pyo, etc.)
- Real-time vs. batch rendering
- Alternative output formats

#### render(events, config)

Render MIDI events to PCM audio data.

* **Parameters:**
  * **events** ([`Iterator`](https://docs.python.org/3/library/typing.html#typing.Iterator)[[`MidiEvent`](_autosummary/accompy.base.html.md#accompy.base.MidiEvent)]) – Iterator of MIDI events
  * **config** ([`AccompanimentConfig`](_autosummary/accompy.base.html.md#accompy.base.AccompanimentConfig)) – Rendering configuration (tempo, sample rate, etc.)
* **Return type:**
  [`bytes`](https://docs.python.org/3/builtins/stdtypes.html#bytes)
* **Returns:**
  Raw PCM audio bytes

#### render_to_file(events, config, output_path)

Render MIDI events directly to an audio file.

* **Parameters:**
  * **events** ([`Iterator`](https://docs.python.org/3/library/typing.html#typing.Iterator)[[`MidiEvent`](_autosummary/accompy.base.html.md#accompy.base.MidiEvent)]) – Iterator of MIDI events
  * **config** ([`AccompanimentConfig`](_autosummary/accompy.base.html.md#accompy.base.AccompanimentConfig)) – Rendering configuration
  * **output_path** ([`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)) – Where to save the audio file
* **Return type:**
  [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)
* **Returns:**
  Path to the created file

### *class* accompy.protocols.ChordResolver(\*args, \*\*kwargs)

Bases: [`Protocol`](https://docs.python.org/3/library/typing.html#typing.Protocol)

Convert chord symbols to MIDI note numbers.

Example implementation:

```pycon
>>> def my_resolver(symbol: str) -> list[int]:
...     # Return MIDI notes for chord
...     return [60, 64, 67]  # C major
```

### *class* accompy.protocols.MidiEventGenerator(\*args, \*\*kwargs)

Bases: [`Protocol`](https://docs.python.org/3/library/typing.html#typing.Protocol)

Generates MIDI events from score and patterns.

This protocol enables alternative MIDI generation strategies
(e.g., more sophisticated voicings, real-time adaptation).

#### generate(score, config, , chord_resolver, pattern_source)

Generate MIDI events from a score.

* **Parameters:**
  * **score** ([`Score`](_autosummary/accompy.base.html.md#accompy.base.Score)) – Musical score with chord progression
  * **config** ([`AccompanimentConfig`](_autosummary/accompy.base.html.md#accompy.base.AccompanimentConfig)) – Accompaniment configuration
  * **chord_resolver** ([`ChordResolver`](_autosummary/accompy.protocols.html.md#accompy.protocols.ChordResolver)) – Function to resolve chords to notes
  * **pattern_source** ([`PatternSource`](_autosummary/accompy.protocols.html.md#accompy.protocols.PatternSource)) – Source of musical patterns
* **Yields:**
  [`MidiEvent`](_autosummary/accompy.base.html.md#accompy.base.MidiEvent) – MidiEvent objects in time order
* **Return type:**
  *Iterator*[[*MidiEvent*](_autosummary/accompy.html.md#accompy.MidiEvent)]

### *class* accompy.protocols.PatternSource(\*args, \*\*kwargs)

Bases: [`Protocol`](https://docs.python.org/3/library/typing.html#typing.Protocol)

Provides musical patterns for a given style.

### Example

```pycon
>>> class MyPatternSource:
...     def get_patterns(self, style: str) -> dict:
...         return {'drums': [...], 'bass': [...], 'comp': [...]}
...     def available_styles(self) -> list[str]:
...         return ['swing', 'bossa']
```

#### available_styles()

List all available style names.

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]
* **Returns:**
  List of style names

#### get_patterns(style)

Get patterns for a style.

* **Parameters:**
  **style** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Style name (e.g., “swing”, “bossa”, “rock”)
* **Return type:**
  [`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)]
* **Returns:**
  Dict with ‘drums’, ‘bass’, ‘comp’ keys containing pattern lists

### *class* accompy.protocols.SynthesizerBackend(\*args, \*\*kwargs)

Bases: [`Protocol`](https://docs.python.org/3/library/typing.html#typing.Protocol)

Audio synthesis backend.

Simpler protocol than AudioRenderer, focused just on synthesis.
Used by the synthesis module.

#### *classmethod* is_available()

Check if this backend’s dependencies are installed.

* **Return type:**
  [`bool`](https://docs.python.org/3/builtins/functions.html#bool)
* **Returns:**
  True if the backend can be used

#### render_to_bytes(midi_path, , sample_rate=44100)

Render a MIDI file to PCM bytes (for streaming).

* **Parameters:**
  * **midi_path** ([`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)) – Path to MIDI file
  * **sample_rate** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Audio sample rate
* **Return type:**
  [`bytes`](https://docs.python.org/3/builtins/stdtypes.html#bytes)
* **Returns:**
  Raw PCM audio bytes

#### render_to_file(midi_path, output_path, , sample_rate=44100)

Render a MIDI file to audio.

* **Parameters:**
  * **midi_path** ([`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)) – Path to MIDI file
  * **output_path** ([`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)) – Where to save audio
  * **sample_rate** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Audio sample rate
* **Return type:**
  [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)
* **Returns:**
  Path to the created audio file


# _autosummary/accompy.realtime.html.md

# accompy.realtime

Real-time accompaniment support (foundation).

This module provides the foundation for real-time accompaniment playback,
separating event scheduling from synthesis. This enables integration with
real-time audio systems like hum/pyo in the future.

#### NOTE
This is scaffolding for future work. Current implementation focuses on
event generation infrastructure. Real-time audio synthesis integration
with hum/pyo is planned for a future release.

### Classes

| [`RealtimeAccompaniment`](_autosummary/accompy.realtime.html.md#accompy.realtime.RealtimeAccompaniment)([config, on_event])   | Real-time accompaniment player (foundation for future work).   |
|----------------------------------------------------------------------------------------------|----------------------------------------------------------------|

### *class* accompy.realtime.RealtimeAccompaniment(config=None, , on_event=None)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

Real-time accompaniment player (foundation for future work).

This class separates event scheduling from synthesis, enabling integration
with real-time audio systems. Current implementation generates events;
future versions will integrate with hum/pyo for actual audio synthesis.

Example (current usage):

```pycon
>>> from accompy import AccompanimentConfig
>>> config = AccompanimentConfig(tempo=120, style='swing')
>>> player = RealtimeAccompaniment(config)
>>> player.set_chords([('Dm7', 4), ('G7', 4), ('Cmaj7', 8)])
>>> events_iter = player.events()  # Get event iterator
>>> # Future: for event in events_iter: synth.play(event.note, event.velocity)
```

Future usage (with hum integration):

```pycon
>>> from hum.pyo_util import Synth
>>> def on_event(event: MidiEvent):
...     # Send MIDI event to synth in real-time
...     synth.send_note(event.note, event.velocity, event.duration)
>>> player = RealtimeAccompaniment(config, on_event=on_event)
>>> player.play()
```

#### events()

Generate events for current chord progression.

* **Yields:**
  [`MidiEvent`](_autosummary/accompy.base.html.md#accompy.base.MidiEvent) – MidiEvent objects in chronological order
* **Return type:**
  [*Iterator*](https://docs.python.org/3/library/typing.html#typing.Iterator)[[*MidiEvent*](_autosummary/accompy.base.html.md#accompy.base.MidiEvent)]

### Example

```pycon
>>> player = RealtimeAccompaniment()
>>> player.set_chords([('C', 4)])
>>> events = list(player.events())
>>> len(events) > 0
True
```

#### play()

Play the accompaniment (future implementation).

This will integrate with a real-time synthesis backend (hum/pyo)
to actually play audio. Current implementation is a placeholder.

* **Raises:**
  [**NotImplementedError**](https://docs.python.org/3/builtins/exceptions.html#NotImplementedError) – Real-time playback not yet implemented
* **Return type:**
  [`None`](https://docs.python.org/3/builtins/constants.html#None)

#### set_chords(chords)

Update the chord progression.

* **Parameters:**
  **chords** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any)) – Chord progression in any supported format
  (string, Score, list of tuples, etc.)
* **Return type:**
  [`None`](https://docs.python.org/3/builtins/constants.html#None)

### Example

```pycon
>>> player = RealtimeAccompaniment()
>>> player.set_chords("| Dm7 | G7 | Cmaj7 |")
>>> player._score is not None
True
```

#### stop()

Stop playback (future implementation).

* **Raises:**
  [**NotImplementedError**](https://docs.python.org/3/builtins/exceptions.html#NotImplementedError) – Real-time playback not yet implemented
* **Return type:**
  [`None`](https://docs.python.org/3/builtins/constants.html#None)


# _autosummary/accompy.renderers.html.md

# accompy.renderers

MIDI and MMA rendering backends for accompy.

This module provides different backends for generating MIDI from scores:

- midi: Built-in MIDI generation using midiutil
- mma: MMA (Musical MIDI Accompaniment) backend for more realistic grooves

### Functions

| [`chord_events`](_autosummary/accompy.renderers.html.md#accompy.renderers.chord_events)(chord_notes, \*[, style, ...])        | The drum, bass and piano events `style` plays over one chord.                      |
|-----------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------|
| [`bass_pitch`](_autosummary/accompy.renderers.html.md#accompy.renderers.bass_pitch)(root, chord_notes, pitch_offset)        | The bass note a pattern's `pitch_offset` plays over a chord.                       |
| [`comp_voicing`](_autosummary/accompy.renderers.html.md#accompy.renderers.comp_voicing)(chord_notes)                          | The notes the piano plays for a chord: its first four notes moved into C4-B4.      |
| [`pitch_classes`](_autosummary/accompy.renderers.html.md#accompy.renderers.pitch_classes)(notes)                               | Return unique pitch classes (0-11) as a tuple.                                     |
| [`resolve_pitch_offset`](_autosummary/accompy.renderers.html.md#accompy.renderers.resolve_pitch_offset)(\*, root_pc, chord_pcs, ...)  | Resolve a pitch offset against a chord.                                            |
| [`generate_events`](_autosummary/accompy.renderers.html.md#accompy.renderers.generate_events)(chords, \*[, style, repeats, ...]) | The note events the builtin backend plays for `chords`, without writing a file.    |
| [`select_patterns`](_autosummary/accompy.renderers.html.md#accompy.renderers.select_patterns)(patterns, beats_per_bar)           | The `(drum, bass, comp)` patterns the renderer plays from a style's pattern lists. |
| [`generate_midi_events`](_autosummary/accompy.renderers.html.md#accompy.renderers.generate_midi_events)(score, config, \*, ...)       | Generate MIDI events from score.                                                   |
| [`events_to_midi_file`](_autosummary/accompy.renderers.html.md#accompy.renderers.events_to_midi_file)(events, path, tempo[, ...])    | Write MIDI events to a MIDI file.                                                  |

### accompy.renderers.bass_pitch(root, chord_notes, pitch_offset)

The bass note a pattern’s `pitch_offset` plays over a chord.

The chord’s root is moved to C2-B2, then the offset is resolved against the chord
([`resolve_pitch_offset()`](_autosummary/accompy.renderers.html.md#accompy.renderers.resolve_pitch_offset)), so a pattern’s “3rd” follows the chord’s quality.

```pycon
>>> bass_pitch(57, [57, 60, 64], 4), bass_pitch(48, [48, 52, 55], 4)
(48, 40)
```

* **Return type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int)

### accompy.renderers.chord_events(chord_notes, , style='swing', start_beat=0, duration=4, beats_per_bar=4, instruments=None, volumes=None, pattern_source=None)

The drum, bass and piano events `style` plays over one chord.

This is one step of [`generate_midi_events()`](_autosummary/accompy.renderers.html.md#accompy.renderers.generate_midi_events), which calls it for every chord of
a score: `chord_notes` are the chord’s MIDI notes, root first (what a chord
resolver returns), `start_beat` where the chord starts and `duration` how many
beats it lasts. It reads no tempo and keeps no state between chords.

```pycon
>>> [(e.time, e.channel, e.note) for e in chord_events([48, 52, 55], style="rock",
...     duration=1)]
[(0, 9, 36), (0, 9, 42), (0.5, 9, 42), (0, 0, 36), (0, 1, 60), (0, 1, 64),
 (0, 1, 67)]
```

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`MidiEvent`](_autosummary/accompy.base.html.md#accompy.base.MidiEvent)]

### accompy.renderers.comp_voicing(chord_notes)

The notes the piano plays for a chord: its first four notes moved into C4-B4.

A chord with no notes is voiced as a C major triad.

```pycon
>>> comp_voicing([50, 53, 57, 60, 64]), comp_voicing([])
([62, 65, 69, 60], [60, 64, 67])
```

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`int`](https://docs.python.org/3/builtins/functions.html#int)]

### accompy.renderers.events_to_midi_file(events, path, tempo, time_signature=(4, 4))

Write MIDI events to a MIDI file.

* **Parameters:**
  * **events** ([`Sequence`](https://docs.python.org/3/library/typing.html#typing.Sequence)[[`MidiEvent`](_autosummary/accompy.base.html.md#accompy.base.MidiEvent)]) – Sequence of MIDI events (must be subscriptable, not just iterable)
  * **path** ([`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)) – Output file path
  * **tempo** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Tempo in BPM
  * **time_signature** ([`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`int`](https://docs.python.org/3/builtins/functions.html#int), [`int`](https://docs.python.org/3/builtins/functions.html#int)]) – Time signature (numerator, denominator)
* **Return type:**
  [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)
* **Returns:**
  Path to the created MIDI file

#### NOTE
Requires midiutil: pip install midiutil

### accompy.renderers.generate_events(chords, , style='swing', repeats=1, time_signature=None, instruments=None, volumes=None, pattern_source=None, chord_resolver=None)

The note events the builtin backend plays for `chords`, without writing a file.

`chords` is anything [`accompy.ensure_score()`](_autosummary/accompy.html.md#accompy.ensure_score) accepts (a chord string, an iReal
URL, measures, chord symbols, `(chord, beats)` pairs, a Score);
`time_signature` applies to the forms that do not carry one (default: the style’s,
see `style_time_signature()`: 3/4 for `waltz`, else 4/4). Times and durations
are in beats: the events do not depend on tempo. `repeats` defaults to 1, as in
[`accompy.generate_accompaniment()`](_autosummary/accompy.html.md#accompy.generate_accompaniment).

```pycon
>>> events = generate_events("| C | G |", style="bossa")
>>> events[0]
MidiEvent(time=0, channel=9, note=37, velocity=56, duration=0.25)
>>> max(e.time for e in events) < 8
True
```

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`MidiEvent`](_autosummary/accompy.base.html.md#accompy.base.MidiEvent)]

### accompy.renderers.generate_midi_events(score, config, , pattern_source, chord_resolver)

Generate MIDI events from score.

Yields events in time order. Does NOT write files.
This enables real-time streaming or batch file creation.

* **Parameters:**
  * **score** ([`Score`](_autosummary/accompy.base.html.md#accompy.base.Score)) – Musical score with chord progression
  * **config** ([`AccompanimentConfig`](_autosummary/accompy.base.html.md#accompy.base.AccompanimentConfig)) – Accompaniment configuration
  * **pattern_source** – Source providing patterns (must have get_patterns method)
  * **chord_resolver** – Function to convert chord symbols to MIDI notes
* **Yields:**
  [`MidiEvent`](_autosummary/accompy.base.html.md#accompy.base.MidiEvent) – MidiEvent objects in chronological order
* **Return type:**
  [*Iterator*](https://docs.python.org/3/library/typing.html#typing.Iterator)[[*MidiEvent*](_autosummary/accompy.base.html.md#accompy.base.MidiEvent)]

### Example

```pycon
>>> from accompy.base import Score, AccompanimentConfig
>>> from accompy.patterns import get_patterns
>>> from accompy.chord_resolution import chord_to_notes
>>> score = Score.from_string("| C | Am | F | G |")
>>> config = AccompanimentConfig()
>>> events = generate_midi_events(score, config,
...     pattern_source=type('PS', (), {'get_patterns': get_patterns})(),
...     chord_resolver=chord_to_notes)
>>> first_event = next(events)
```

### accompy.renderers.pitch_classes(notes)

Return unique pitch classes (0-11) as a tuple.

* **Return type:**
  [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`int`](https://docs.python.org/3/builtins/functions.html#int), [`...`](https://docs.python.org/3/builtins/constants.html#Ellipsis)]

### accompy.renderers.resolve_pitch_offset(, root_pc, chord_pcs, target_offset)

Resolve a pitch offset against a chord.

The patterns use semitone offsets (0=root, 7=5th, etc.). When an offset
represents a chord tone which varies by quality (e.g. 3rd), we prefer a
matching chord tone from `chord_pcs`.

### Examples

For a minor chord, a pattern might request offset 4 (“3rd”); this
function will choose 3 if the chord contains a minor 3rd.

* **Return type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int)

### accompy.renderers.select_patterns(patterns, beats_per_bar)

The `(drum, bass, comp)` patterns the renderer plays from a style’s pattern lists.

The drum pattern is the first one whose `beats_per_bar` matches (else the first);
bass and comping take the first of their list. A missing one is `None`.

```pycon
>>> from accompy.patterns import get_patterns
>>> [p.name for p in select_patterns(get_patterns("swing"), 4)]
['swing_basic', 'walking', 'swing_comp']
```

* **Return type:**
  [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)

### Modules

| [`midi`](_autosummary/accompy.renderers.midi.html.md#module-accompy.renderers.midi)   | MIDI event generation (stateless, iterator-based).   |
|---------------------------------------------------------------------------------------|------------------------------------------------------|


# _autosummary/accompy.renderers.midi.html.md

# accompy.renderers.midi

MIDI event generation (stateless, iterator-based).

This module provides event-based MIDI generation that separates event creation
from file writing, enabling both batch file creation and future real-time streaming.

Key functions:

- generate_midi_events: Pure function that yields MIDI events
- events_to_midi_file: Side-effect function that writes events to a file

### Module Attributes

| [`NO_CHORD_SYMBOLS`](_autosummary/accompy.renderers.midi.html.md#accompy.renderers.midi.NO_CHORD_SYMBOLS)     | the renderer leaves their beats silent.                                                                                                                   |
|-----------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------|
| [`FALLBACK_CHORD_NOTES`](_autosummary/accompy.renderers.midi.html.md#accompy.renderers.midi.FALLBACK_CHORD_NOTES) | a major triad on C3, moved to the symbol's root when it has a readable one (see [`fallback_chord_notes()`](_autosummary/accompy.renderers.midi.html.md#accompy.renderers.midi.fallback_chord_notes)). |

### Functions

| [`bar_chord_spans`](_autosummary/accompy.renderers.midi.html.md#accompy.renderers.midi.bar_chord_spans)(beats_per_bar, n_chords)           | `(offset, duration)` in beats of each of `n_chords` chords sharing one bar.         |
|-----------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------|
| [`bass_pitch`](_autosummary/accompy.renderers.midi.html.md#accompy.renderers.midi.bass_pitch)(root, chord_notes, pitch_offset)        | The bass note a pattern's `pitch_offset` plays over a chord.                        |
| [`chord_events`](_autosummary/accompy.renderers.midi.html.md#accompy.renderers.midi.chord_events)(chord_notes, \*[, style, ...])        | The drum, bass and piano events `style` plays over one chord.                       |
| [`comp_voicing`](_autosummary/accompy.renderers.midi.html.md#accompy.renderers.midi.comp_voicing)(chord_notes)                          | The notes the piano plays for a chord: its first four notes moved into C4-B4.       |
| [`events_to_midi_file`](_autosummary/accompy.renderers.midi.html.md#accompy.renderers.midi.events_to_midi_file)(events, path, tempo[, ...])    | Write MIDI events to a MIDI file.                                                   |
| [`fallback_chord_notes`](_autosummary/accompy.renderers.midi.html.md#accompy.renderers.midi.fallback_chord_notes)(symbol)                       | What the renderer plays for a symbol its resolver cannot read: a triad on its root. |
| [`generate_builtin_midi`](_autosummary/accompy.renderers.midi.html.md#accompy.renderers.midi.generate_builtin_midi)(score, config, \*, ...)      | Generate a MIDI file using the built-in renderer.                                   |
| [`generate_events`](_autosummary/accompy.renderers.midi.html.md#accompy.renderers.midi.generate_events)(chords, \*[, style, repeats, ...]) | The note events the builtin backend plays for `chords`, without writing a file.     |
| [`generate_midi_events`](_autosummary/accompy.renderers.midi.html.md#accompy.renderers.midi.generate_midi_events)(score, config, \*, ...)       | Generate MIDI events from score.                                                    |
| [`pitch_classes`](_autosummary/accompy.renderers.midi.html.md#accompy.renderers.midi.pitch_classes)(notes)                               | Return unique pitch classes (0-11) as a tuple.                                      |
| [`resolve_pitch_offset`](_autosummary/accompy.renderers.midi.html.md#accompy.renderers.midi.resolve_pitch_offset)(\*, root_pc, chord_pcs, ...)  | Resolve a pitch offset against a chord.                                             |
| [`select_patterns`](_autosummary/accompy.renderers.midi.html.md#accompy.renderers.midi.select_patterns)(patterns, beats_per_bar)           | The `(drum, bass, comp)` patterns the renderer plays from a style's pattern lists.  |
| [`style_time_signature`](_autosummary/accompy.renderers.midi.html.md#accompy.renderers.midi.style_time_signature)(pattern_source, style)        | The meter a style implies: its first drum pattern's beats per bar over 4, else 4/4. |

### accompy.renderers.midi.FALLBACK_CHORD_NOTES *= (48, 52, 55)*

a major triad on C3,
moved to the symbol’s root when it has a readable one (see [`fallback_chord_notes()`](_autosummary/accompy.renderers.midi.html.md#accompy.renderers.midi.fallback_chord_notes)).

* **Type:**
  The notes used when the chord resolver cannot read a symbol

### accompy.renderers.midi.NO_CHORD_SYMBOLS *= ('', 'n', 'N.C.', 'NC')*

the renderer leaves their beats silent.

* **Type:**
  Chord symbols that mean “no chord here”

### accompy.renderers.midi.bar_chord_spans(beats_per_bar, n_chords)

`(offset, duration)` in beats of each of `n_chords` chords sharing one bar.

The bar is always filled: with fewer chords than beats, the beats are split evenly and
the remainder goes to the first chords (3 chords in 4/4 get 2, 1 and 1 beats); with more
chords than beats, each gets `beats_per_bar / n_chords` beats.

```pycon
>>> bar_chord_spans(4, 2)
[(0, 2), (2, 2)]
>>> bar_chord_spans(4, 3)
[(0, 2), (2, 1), (3, 1)]
>>> bar_chord_spans(4, 5)[1]
(0.8, 0.8)
>>> bar_chord_spans(4, 0)
[]
```

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`float`](https://docs.python.org/3/builtins/functions.html#float), [`float`](https://docs.python.org/3/builtins/functions.html#float)]]

### accompy.renderers.midi.bass_pitch(root, chord_notes, pitch_offset)

The bass note a pattern’s `pitch_offset` plays over a chord.

The chord’s root is moved to C2-B2, then the offset is resolved against the chord
([`resolve_pitch_offset()`](_autosummary/accompy.renderers.midi.html.md#accompy.renderers.midi.resolve_pitch_offset)), so a pattern’s “3rd” follows the chord’s quality.

```pycon
>>> bass_pitch(57, [57, 60, 64], 4), bass_pitch(48, [48, 52, 55], 4)
(48, 40)
```

* **Return type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int)

### accompy.renderers.midi.chord_events(chord_notes, , style='swing', start_beat=0, duration=4, beats_per_bar=4, instruments=None, volumes=None, pattern_source=None)

The drum, bass and piano events `style` plays over one chord.

This is one step of [`generate_midi_events()`](_autosummary/accompy.renderers.midi.html.md#accompy.renderers.midi.generate_midi_events), which calls it for every chord of
a score: `chord_notes` are the chord’s MIDI notes, root first (what a chord
resolver returns), `start_beat` where the chord starts and `duration` how many
beats it lasts. It reads no tempo and keeps no state between chords.

```pycon
>>> [(e.time, e.channel, e.note) for e in chord_events([48, 52, 55], style="rock",
...     duration=1)]
[(0, 9, 36), (0, 9, 42), (0.5, 9, 42), (0, 0, 36), (0, 1, 60), (0, 1, 64),
 (0, 1, 67)]
```

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`MidiEvent`](_autosummary/accompy.base.html.md#accompy.base.MidiEvent)]

### accompy.renderers.midi.comp_voicing(chord_notes)

The notes the piano plays for a chord: its first four notes moved into C4-B4.

A chord with no notes is voiced as a C major triad.

```pycon
>>> comp_voicing([50, 53, 57, 60, 64]), comp_voicing([])
([62, 65, 69, 60], [60, 64, 67])
```

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`int`](https://docs.python.org/3/builtins/functions.html#int)]

### accompy.renderers.midi.events_to_midi_file(events, path, tempo, time_signature=(4, 4))

Write MIDI events to a MIDI file.

* **Parameters:**
  * **events** ([`Sequence`](https://docs.python.org/3/library/typing.html#typing.Sequence)[[`MidiEvent`](_autosummary/accompy.base.html.md#accompy.base.MidiEvent)]) – Sequence of MIDI events (must be subscriptable, not just iterable)
  * **path** ([`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)) – Output file path
  * **tempo** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Tempo in BPM
  * **time_signature** ([`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`int`](https://docs.python.org/3/builtins/functions.html#int), [`int`](https://docs.python.org/3/builtins/functions.html#int)]) – Time signature (numerator, denominator)
* **Return type:**
  [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)
* **Returns:**
  Path to the created MIDI file

#### NOTE
Requires midiutil: pip install midiutil

### accompy.renderers.midi.fallback_chord_notes(symbol)

What the renderer plays for a symbol its resolver cannot read: a triad on its root.

The root is the leading note name, in either case and with `#`/`b` or `♯`/`♭`
(`C`, `F#`, `B♭`, `eb`); without one, the triad is on C. The triad is major
unless the symbol says minor (`-`, `m`, `min`, not `maj`): `E#m` plays F minor.

```pycon
>>> fallback_chord_notes("G#13(b9)"), fallback_chord_notes("?")
([56, 60, 63], [48, 52, 55])
>>> fallback_chord_notes("E#-7"), fallback_chord_notes("E#maj7")
([53, 56, 60], [53, 57, 60])
```

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`int`](https://docs.python.org/3/builtins/functions.html#int)]

### accompy.renderers.midi.generate_builtin_midi(score, config, , pattern_source, chord_resolver)

Generate a MIDI file using the built-in renderer.

This is a convenience function that combines event generation and file writing.

* **Parameters:**
  * **score** ([`Score`](_autosummary/accompy.base.html.md#accompy.base.Score)) – Musical score
  * **config** ([`AccompanimentConfig`](_autosummary/accompy.base.html.md#accompy.base.AccompanimentConfig)) – Configuration
  * **pattern_source** – Pattern provider
  * **chord_resolver** – Chord resolution function
* **Return type:**
  [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)
* **Returns:**
  Path to the generated MIDI file

### accompy.renderers.midi.generate_events(chords, , style='swing', repeats=1, time_signature=None, instruments=None, volumes=None, pattern_source=None, chord_resolver=None)

The note events the builtin backend plays for `chords`, without writing a file.

`chords` is anything [`accompy.ensure_score()`](_autosummary/accompy.html.md#accompy.ensure_score) accepts (a chord string, an iReal
URL, measures, chord symbols, `(chord, beats)` pairs, a Score);
`time_signature` applies to the forms that do not carry one (default: the style’s,
see [`style_time_signature()`](_autosummary/accompy.renderers.midi.html.md#accompy.renderers.midi.style_time_signature): 3/4 for `waltz`, else 4/4). Times and durations
are in beats: the events do not depend on tempo. `repeats` defaults to 1, as in
[`accompy.generate_accompaniment()`](_autosummary/accompy.html.md#accompy.generate_accompaniment).

```pycon
>>> events = generate_events("| C | G |", style="bossa")
>>> events[0]
MidiEvent(time=0, channel=9, note=37, velocity=56, duration=0.25)
>>> max(e.time for e in events) < 8
True
```

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`MidiEvent`](_autosummary/accompy.base.html.md#accompy.base.MidiEvent)]

### accompy.renderers.midi.generate_midi_events(score, config, , pattern_source, chord_resolver)

Generate MIDI events from score.

Yields events in time order. Does NOT write files.
This enables real-time streaming or batch file creation.

* **Parameters:**
  * **score** ([`Score`](_autosummary/accompy.base.html.md#accompy.base.Score)) – Musical score with chord progression
  * **config** ([`AccompanimentConfig`](_autosummary/accompy.base.html.md#accompy.base.AccompanimentConfig)) – Accompaniment configuration
  * **pattern_source** – Source providing patterns (must have get_patterns method)
  * **chord_resolver** – Function to convert chord symbols to MIDI notes
* **Yields:**
  [`MidiEvent`](_autosummary/accompy.base.html.md#accompy.base.MidiEvent) – MidiEvent objects in chronological order
* **Return type:**
  [*Iterator*](https://docs.python.org/3/library/typing.html#typing.Iterator)[[*MidiEvent*](_autosummary/accompy.base.html.md#accompy.base.MidiEvent)]

### Example

```pycon
>>> from accompy.base import Score, AccompanimentConfig
>>> from accompy.patterns import get_patterns
>>> from accompy.chord_resolution import chord_to_notes
>>> score = Score.from_string("| C | Am | F | G |")
>>> config = AccompanimentConfig()
>>> events = generate_midi_events(score, config,
...     pattern_source=type('PS', (), {'get_patterns': get_patterns})(),
...     chord_resolver=chord_to_notes)
>>> first_event = next(events)
```

### accompy.renderers.midi.pitch_classes(notes)

Return unique pitch classes (0-11) as a tuple.

* **Return type:**
  [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`int`](https://docs.python.org/3/builtins/functions.html#int), [`...`](https://docs.python.org/3/builtins/constants.html#Ellipsis)]

### accompy.renderers.midi.resolve_pitch_offset(, root_pc, chord_pcs, target_offset)

Resolve a pitch offset against a chord.

The patterns use semitone offsets (0=root, 7=5th, etc.). When an offset
represents a chord tone which varies by quality (e.g. 3rd), we prefer a
matching chord tone from `chord_pcs`.

### Examples

For a minor chord, a pattern might request offset 4 (“3rd”); this
function will choose 3 if the chord contains a minor 3rd.

* **Return type:**
  [`int`](https://docs.python.org/3/builtins/functions.html#int)

### accompy.renderers.midi.select_patterns(patterns, beats_per_bar)

The `(drum, bass, comp)` patterns the renderer plays from a style’s pattern lists.

The drum pattern is the first one whose `beats_per_bar` matches (else the first);
bass and comping take the first of their list. A missing one is `None`.

```pycon
>>> from accompy.patterns import get_patterns
>>> [p.name for p in select_patterns(get_patterns("swing"), 4)]
['swing_basic', 'walking', 'swing_comp']
```

* **Return type:**
  [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)

### accompy.renderers.midi.style_time_signature(pattern_source, style)

The meter a style implies: its first drum pattern’s beats per bar over 4, else 4/4.

```pycon
>>> from accompy.patterns import get_pattern_registry
>>> style_time_signature(get_pattern_registry(), "waltz")
(3, 4)
>>> style_time_signature(get_pattern_registry(), "swing")
(4, 4)
```

* **Return type:**
  [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`int`](https://docs.python.org/3/builtins/functions.html#int), [`int`](https://docs.python.org/3/builtins/functions.html#int)]


# _autosummary/accompy.rendering.html.md

# 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:

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

Quick start:

```default
>>> 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):

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

Batch rendering:

```default
>>> 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`](_autosummary/accompy.rendering.html.md#accompy.rendering.render_chords)(chords, \*[, ...])                | Render chords to a high-quality audio file, optionally AI-enhanced.                        |
|--------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------|
| [`render_chords_batch`](_autosummary/accompy.rendering.html.md#accompy.rendering.render_chords_batch)(configs, \*\*shared_kwargs) | Run [`render_chords()`](_autosummary/accompy.rendering.html.md#accompy.rendering.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)

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

* **Parameters:**
  * **chords** – Chord input — string (`"| Dm7 | G7 | C^7 |"`), iReal URL,
    [`ChordSequence`](_autosummary/accompy.converters.html.md#accompy.converters.ChordSequence), [`Score`](_autosummary/accompy.base.html.md#accompy.base.Score),
    or list of `(chord, beats)` tuples.
  * **rhythmic_skeleton** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`float`](https://docs.python.org/3/builtins/functions.html#float), [`...`](https://docs.python.org/3/builtins/constants.html#Ellipsis)]) – Restrike pattern within each measure.
  * **bpm** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Tempo in beats per minute.
  * **transpose** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Semitones to transpose (positive=up, negative=down).
  * **n_loops** ([`int`](https://docs.python.org/3/builtins/functions.html#int) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Explicit number of loops. Mutually exclusive with *max_seconds*.
  * **max_seconds** ([`float`](https://docs.python.org/3/builtins/functions.html#float) | [`None`](https://docs.python.org/3/builtins/constants.html#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`](https://docs.python.org/3/library/typing.html#typing.Union)[[`bool`](https://docs.python.org/3/builtins/functions.html#bool), [`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable), [`None`](https://docs.python.org/3/builtins/constants.html#None)]) – `True` for default Suno enhancement, `False`/`None`
    to skip, or a callable `(audio_path, prompt, **kw) → bytes`.
  * **suno_mode** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – `"cover"` (default, re-generates in style) or `"extend"`.
  * **prompt_template** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Template with `{genre}` and `{instruments}` placeholders.
  * **genre** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Genre/style tags for the AI prompt.
  * **instruments** ([`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)] | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Instrument list for the AI prompt. Defaults to
    `["piano", "bass", "drums"]`.
  * **audio_weight** ([`float`](https://docs.python.org/3/builtins/functions.html#float)) – How much the source audio influences AI output (0–1).
  * **style_weight** ([`float`](https://docs.python.org/3/builtins/functions.html#float)) – How much the style prompt influences AI output (0–1).
  * **weirdness** ([`float`](https://docs.python.org/3/builtins/functions.html#float)) – Creative deviation for cover mode (0–1).
  * **model** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Suno model version (e.g. `"V4_5"`).
  * **instrumental** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – If True, generate without vocals.
  * **wait_for_completion** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – If True, poll until AI generation is ready.
  * **poll_interval** ([`float`](https://docs.python.org/3/builtins/functions.html#float)) – Seconds between AI status checks.
  * **timeout** ([`float`](https://docs.python.org/3/builtins/functions.html#float)) – Max seconds to wait for AI completion.
  * **chords_to_midi_audio** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)]) – Override for the MIDI audio rendering step.
    Callable: `(ChordSequence, **kw) → AudioData`.
  * **audio_to_enhanced_audio** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`Callable`](https://docs.python.org/3/library/typing.html#typing.Callable)]) – Override for the AI enhancement step.
    Callable: `(audio_path, prompt, **kw) → bytes`.
  * **midi_store** ([`MutableMapping`](https://docs.python.org/3/library/collections.abc.html#collections.abc.MutableMapping) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Optional store for MIDI files. `None` = don’t persist MIDI.
  * **midi_audio_store** ([`MutableMapping`](https://docs.python.org/3/library/collections.abc.html#collections.abc.MutableMapping) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Store for rendered MIDI audio. `None` = default
    file store under `~/.local/share/accompy/artifacts/midi_audio/`.
  * **enhanced_audio_store** ([`MutableMapping`](https://docs.python.org/3/library/collections.abc.html#collections.abc.MutableMapping) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Store for AI-enhanced audio. `None` = default
    file store under `~/.local/share/accompy/artifacts/enhanced_audio/`.
  * **resolver** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Chord resolver backend name.
  * **midi_gen** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – MIDI generator backend name.
  * **audio_renderer** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Audio renderer backend name.
  * **soundfont** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Path to a SoundFont file.
  * **sr** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Sample rate for MIDI audio rendering.
* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)
* **Returns:**
  Filesystem path to the final audio file.

### accompy.rendering.render_chords_batch(configs, \*\*shared_kwargs)

Run [`render_chords()`](_autosummary/accompy.rendering.html.md#accompy.rendering.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`](https://docs.python.org/3/library/typing.html#typing.Iterable)[[`dict`](https://docs.python.org/3/builtins/stdtypes.html#dict)]) – Iterable of dicts, each containing keyword arguments for
    [`render_chords()`](_autosummary/accompy.rendering.html.md#accompy.rendering.render_chords).
  * **\*\*shared_kwargs** – Default arguments applied to every config.
* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]
* **Returns:**
  List of filesystem paths to the final audio files.

Example:

```default
>>> 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)
```


# _autosummary/accompy.rhythmic_skeletons.html.md

# accompy.rhythmic_skeletons

Rhythmic skeletons — duration-only measure patterns for simple accompaniment.

A rhythmic skeleton is a tuple of durations (in beats) that sum to the time
signature, describing when you strike within a measure and for how long each
strike sustains, with no regard for what you play. No pitches, no voicings, no
velocities, no instrument assignments.

The purpose of separating this layer out is to provide a gravitational center
for more sophisticated generation. A human accompanist doesn’t mechanically
repeat a fixed pattern — they vary, anticipate, syncopate, and breathe around
a characteristic rhythmic feel. By defining that feel as a minimal skeleton, we
give downstream processes a clear, lightweight seed to elaborate from.

Example:

```default
>>> from accompy.rhythmic_skeletons import resolve_skeleton, apply_skeleton
>>> resolve_skeleton("tresillo")
(1.5, 1.5, 1)
>>> resolve_skeleton((2, 2))
(2, 2)

>>> from accompy.converters import ChordSequence
>>> cs = ChordSequence([("Dm7", 4.0), ("G7", 4.0)])
>>> expanded = apply_skeleton(cs, "tresillo")
>>> [(sym, dur) for sym, dur in expanded]
[('Dm7', 1.5), ('Dm7', 1.5), ('Dm7', 1.0), ('G7', 1.5), ('G7', 1.5), ('G7', 1.0)]
```

### Functions

| [`apply_skeleton`](_autosummary/accompy.rhythmic_skeletons.html.md#accompy.rhythmic_skeletons.apply_skeleton)(cs, skeleton)                     | Apply a rhythmic skeleton to a chord sequence.            |
|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------|
| [`list_skeletons`](_autosummary/accompy.rhythmic_skeletons.html.md#accompy.rhythmic_skeletons.list_skeletons)(\*[, beats_per_measure, style])   | List available skeleton keys, optionally filtered.        |
| [`register_skeleton`](_autosummary/accompy.rhythmic_skeletons.html.md#accompy.rhythmic_skeletons.register_skeleton)(key, pattern, \*[, name, ...]) | Register a custom rhythmic skeleton.                      |
| [`resolve_skeleton`](_autosummary/accompy.rhythmic_skeletons.html.md#accompy.rhythmic_skeletons.resolve_skeleton)(skeleton)                       | Resolve a skeleton specification to a tuple of durations. |

### accompy.rhythmic_skeletons.apply_skeleton(cs, skeleton)

Apply a rhythmic skeleton to a chord sequence.

The skeleton defines strike positions within each *measure*. Each strike
plays whatever chord is active at that beat position. If a strike spans a
chord boundary within a measure, it is split so the chord change is
respected.

* **Parameters:**
  * **cs** – A ChordSequence (from `accompy.converters`).
  * **skeleton** ([`Union`](https://docs.python.org/3/library/typing.html#typing.Union)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple), [`Sequence`](https://docs.python.org/3/library/typing.html#typing.Sequence)]) – Skeleton key, name, style, or duration tuple.
* **Return type:**
  ChordSequence
* **Returns:**
  A new ChordSequence with chords expanded according to the skeleton.

### Example

```pycon
>>> from accompy.converters import ChordSequence
>>> cs = ChordSequence([("Dm7", 2.0), ("G7", 2.0)])
>>> result = apply_skeleton(cs, "tresillo")
>>> [(s, d) for s, d in result]
[('Dm7', 1.5), ('Dm7', 0.5), ('G7', 1.0), ('G7', 1.0)]
```

### accompy.rhythmic_skeletons.list_skeletons(, beats_per_measure=None, style=None)

List available skeleton keys, optionally filtered.

* **Parameters:**
  * **beats_per_measure** ([`float`](https://docs.python.org/3/builtins/functions.html#float) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Filter to skeletons matching this measure length.
  * **style** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Filter to skeletons associated with this style.
* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]
* **Returns:**
  List of skeleton key strings.

### Examples

```pycon
>>> "tresillo" in list_skeletons()
True
>>> all(RHYTHMIC_SKELETONS[k]["beats_per_measure"] == 3
...     for k in list_skeletons(beats_per_measure=3))
True
```

### accompy.rhythmic_skeletons.register_skeleton(key, pattern, , name='', beats_per_measure=None, styles=None)

Register a custom rhythmic skeleton.

* **Parameters:**
  * **key** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Unique string key for the skeleton.
  * **pattern** ([`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)) – Tuple of beat durations.
  * **name** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Human-readable name (defaults to key).
  * **beats_per_measure** ([`float`](https://docs.python.org/3/builtins/functions.html#float) | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – Measure length in beats (defaults to sum of pattern).
  * **styles** ([`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)] | [`None`](https://docs.python.org/3/builtins/constants.html#None)) – List of associated style strings.
* **Return type:**
  [`None`](https://docs.python.org/3/builtins/constants.html#None)

### Example

```pycon
>>> register_skeleton("my_groove", (1, 0.5, 0.5, 2), name="My Groove")
>>> resolve_skeleton("my_groove")
(1, 0.5, 0.5, 2)
```

### accompy.rhythmic_skeletons.resolve_skeleton(skeleton)

Resolve a skeleton specification to a tuple of durations.

Accepts:

> - A tuple or list of numbers (pass-through)
> - A skeleton key (e.g., `"tresillo"`, `"whole_note"`)
> - A skeleton name, case-insensitive (e.g., `"Tresillo"`)
> - A style string (e.g., `"reggae"`) — returns the first match
* **Return type:**
  [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)
* **Returns:**
  Tuple of beat durations summing to the measure length.
* **Raises:**
  [**KeyError**](https://docs.python.org/3/builtins/exceptions.html#KeyError) – If the skeleton cannot be resolved.

### Examples

```pycon
>>> resolve_skeleton("whole_note")
(4,)
>>> resolve_skeleton("tresillo")
(1.5, 1.5, 1)
>>> resolve_skeleton((2, 2))
(2, 2)
>>> resolve_skeleton("Dotted half + quarter")
(3, 1)
```


# _autosummary/accompy.setup_utils.html.md

# accompy.setup_utils

Setup and configuration utilities for accompy.

This module provides automatic setup, verification, and troubleshooting
tools to help users get accompy configured correctly.

### Functions

| [`diagnose_issues`](_autosummary/accompy.setup_utils.html.md#accompy.setup_utils.diagnose_issues)()                         | Diagnose common setup issues and provide solutions.    |
|--------------------------------------------------------------------------------------------|--------------------------------------------------------|
| [`print_diagnostic_report`](_autosummary/accompy.setup_utils.html.md#accompy.setup_utils.print_diagnostic_report)()                 | Print a comprehensive diagnostic report.               |
| [`setup_soundfont`](_autosummary/accompy.setup_utils.html.md#accompy.setup_utils.setup_soundfont)([force])                  | Download and configure a SoundFont file.               |
| [`verify_and_setup`](_autosummary/accompy.setup_utils.html.md#accompy.setup_utils.verify_and_setup)([interactive, auto_fix]) | Verify all dependencies and optionally auto-configure. |

### accompy.setup_utils.diagnose_issues()

Diagnose common setup issues and provide solutions.

* **Return type:**
  [`List`](https://docs.python.org/3/library/typing.html#typing.List)[[`Tuple`](https://docs.python.org/3/library/typing.html#typing.Tuple)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]]
* **Returns:**
  List of (issue, description, solution) tuples

Example:

```default
from accompy.setup_utils import diagnose_issues
for issue, desc, solution in diagnose_issues():
    print(f"{issue}: {desc}")
    print(f"Solution: {solution}")
```

### accompy.setup_utils.print_diagnostic_report()

Print a comprehensive diagnostic report.

### accompy.setup_utils.setup_soundfont(force=False)

Download and configure a SoundFont file.

* **Parameters:**
  **force** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – If True, download even if a SoundFont already exists
* **Return type:**
  [`bool`](https://docs.python.org/3/builtins/functions.html#bool)
* **Returns:**
  True if successful, False otherwise

Example:

```default
from accompy.setup_utils import setup_soundfont
if setup_soundfont():
    print("SoundFont configured successfully!")
```

### accompy.setup_utils.verify_and_setup(interactive=True, auto_fix=False)

Verify all dependencies and optionally auto-configure.

* **Parameters:**
  * **interactive** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – If True, prompt user for permission before making changes
  * **auto_fix** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool)) – If True and interactive=False, automatically fix issues without prompting
* **Return type:**
  [`Dict`](https://docs.python.org/3/library/typing.html#typing.Dict)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`bool`](https://docs.python.org/3/builtins/functions.html#bool)]
* **Returns:**
  Dict mapping dependency name to whether it’s available

### Example

```pycon
>>> from accompy.setup_utils import verify_and_setup
>>> status = verify_and_setup(interactive=False)
>>> if all(status.values()):
...     print("Ready to use!")
```


# _autosummary/accompy.songs.html.md

# accompy.songs

Songs as backing-track input: a `songleaf` Song becomes a ChordSequence.

`songleaf` keeps a song as lyrics plus standoff chord annotations anchored on
syllables; it has no durations. [`song_to_chord_sequence()`](_autosummary/accompy.songs.html.md#accompy.songs.song_to_chord_sequence) supplies them with
two simple, explicit heuristics:

- `beats_per_chord=N`: every chord lasts `N` beats;
- `bars_per_line=N`: every chord-carrying line lasts `N` bars, shared equally by
  the chords on it (so a two-chord line at `bars_per_line=1` gives each chord half a
  bar);
- neither (the default): every chord lasts one bar.

The converter reads a Song by shape (`text`, `annotations` of `kind`/`start`/
`body`, `meta`), so `songleaf` is not a dependency of `accompy`.

```pycon
>>> from types import SimpleNamespace as NS
>>> song = NS(
...     text="Hello there\nGoodbye now",
...     annotations=[
...         NS(kind="section", start=0, end=23, body={"label": "Verse"}),
...         NS(kind="chord", start=0, end=0, body={"symbol": "C"}),
...         NS(kind="chord", start=6, end=6, body={"symbol": "G"}),
...         NS(kind="chord", start=12, end=12, body={"symbol": "Am"}),
...     ],
...     meta={"title": "Hi", "key": "C"},
... )
>>> cs = song_to_chord_sequence(song, bars_per_line=1)
>>> cs.chords
[('C', 2.0), ('G', 2.0), ('Am', 4.0)]
>>> cs.sections
[('Verse', 0, 3)]
```

### Functions

| [`song_to_chord_sequence`](_autosummary/accompy.songs.html.md#accompy.songs.song_to_chord_sequence)(song, \*[, ...])   | Convert a songleaf-shaped `song` to a [`ChordSequence`](_autosummary/accompy.converters.html.md#accompy.converters.ChordSequence).   |
|--------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------|

### accompy.songs.song_to_chord_sequence(song, , bars_per_line=None, beats_per_chord=None, beats_per_bar=4, tempo=120)

Convert a songleaf-shaped `song` to a [`ChordSequence`](_autosummary/accompy.converters.html.md#accompy.converters.ChordSequence).

* **Parameters:**
  * **song** ([`Any`](https://docs.python.org/3/library/typing.html#typing.Any)) – Anything with `text`, `annotations` and `meta` as songleaf’s `Song`.
  * **bars_per_line** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`float`](https://docs.python.org/3/builtins/functions.html#float)]) – Bars each chord-carrying line lasts, shared by its chords.
  * **beats_per_chord** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`float`](https://docs.python.org/3/builtins/functions.html#float)]) – Beats every chord lasts. Exclusive with `bars_per_line`.
  * **beats_per_bar** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Beats in a bar (the time signature’s numerator).
  * **tempo** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Tempo in BPM (the song’s `meta["tempo"]` wins when it is a number).
* **Return type:**
  [`ChordSequence`](_autosummary/accompy.converters.html.md#accompy.converters.ChordSequence)
* **Returns:**
  A ChordSequence whose `sections` follow the song’s `section` annotations
  (ranges over the chords), with the song’s title and key.
* **Raises:**
  [**ValueError**](https://docs.python.org/3/builtins/exceptions.html#ValueError) – if both `bars_per_line` and `beats_per_chord` are given, or
      either is not positive.


# _autosummary/accompy.synthesis.fluidsynth.html.md

# accompy.synthesis.fluidsynth

FluidSynth synthesis backend.

Uses FluidSynth with SoundFonts to render MIDI to high-quality audio.
FluidSynth is the default and most widely-supported backend for accompy.

### Functions

| [`convert_audio`](_autosummary/accompy.synthesis.fluidsynth.html.md#accompy.synthesis.fluidsynth.convert_audio)(input_path, output_path)   | Convert audio between formats using ffmpeg or pydub.   |
|-------------------------------------------------------------------------------------------|--------------------------------------------------------|
| [`find_default_soundfont`](_autosummary/accompy.synthesis.fluidsynth.html.md#accompy.synthesis.fluidsynth.find_default_soundfont)()                 | Find the default SoundFont file in standard locations. |

### Classes

| [`FluidSynthBackend`](_autosummary/accompy.synthesis.fluidsynth.html.md#accompy.synthesis.fluidsynth.FluidSynthBackend)([soundfont_path])   | FluidSynth-based synthesis.   |
|----------------------------------------------------------------------------------------|-------------------------------|

### *class* accompy.synthesis.fluidsynth.FluidSynthBackend(soundfont_path=None)

Bases: [`SynthesizerBackend`](_autosummary/accompy.synthesis.html.md#accompy.synthesis.SynthesizerBackend)

FluidSynth-based synthesis.

Uses SoundFont files (.sf2) to render MIDI with realistic instrument sounds.
Supports both Python wrapper (midi2audio) and command-line FluidSynth.

### Example

```pycon
>>> backend = FluidSynthBackend()
>>> backend.render_to_file(midi_path, output_path)
```

#### *classmethod* is_available()

Check if FluidSynth is available.

* **Return type:**
  [`bool`](https://docs.python.org/3/builtins/functions.html#bool)

#### render_to_file(midi_path, output_path, , sample_rate=44100)

Render MIDI file to audio using FluidSynth.

Tries Python wrapper (midi2audio) first, then falls back to command-line FluidSynth.

* **Parameters:**
  * **midi_path** ([`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)) – Input MIDI file
  * **output_path** ([`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)) – Output audio file (.wav, .mp3, .flac)
  * **sample_rate** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Sample rate in Hz
* **Return type:**
  [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)
* **Returns:**
  Path to created audio file

### accompy.synthesis.fluidsynth.convert_audio(input_path, output_path)

Convert audio between formats using ffmpeg or pydub.

* **Parameters:**
  * **input_path** ([`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)) – Input audio file
  * **output_path** ([`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)) – Output audio file
* **Raises:**
  [**RuntimeError**](https://docs.python.org/3/builtins/exceptions.html#RuntimeError) – If neither ffmpeg nor pydub is available
* **Return type:**
  [`None`](https://docs.python.org/3/builtins/constants.html#None)

### accompy.synthesis.fluidsynth.find_default_soundfont()

Find the default SoundFont file in standard locations.

* **Return type:**
  [`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)]
* **Returns:**
  Path to SoundFont file, or None if not found


# _autosummary/accompy.synthesis.html.md

# accompy.synthesis

Audio synthesis backends for accompy.

Provides abstraction over different synthesis engines:

- FluidSynth: Default, uses SoundFonts for realistic instrument sounds
- Pyo: Real-time synthesis (future integration with hum package)

The synthesis backends are used to convert MIDI files to audio.

### Functions

| [`get_default_backend`](_autosummary/accompy.synthesis.html.md#accompy.synthesis.get_default_backend)()   | Get the best available synthesis backend.   |
|--------------------------------------------------------------------------|---------------------------------------------|

### Classes

| [`SynthesizerBackend`](_autosummary/accompy.synthesis.html.md#accompy.synthesis.SynthesizerBackend)()   | Abstract base for audio synthesis backends.   |
|-------------------------------------------------------------------------|-----------------------------------------------|

### *class* accompy.synthesis.SynthesizerBackend

Bases: [`ABC`](https://docs.python.org/3/library/abc.html#abc.ABC)

Abstract base for audio synthesis backends.

Subclasses implement specific synthesis engines (FluidSynth, Pyo, etc.).

#### *abstractmethod classmethod* is_available()

Check if this backend’s dependencies are installed.

* **Return type:**
  [`bool`](https://docs.python.org/3/builtins/functions.html#bool)
* **Returns:**
  True if the backend can be used

#### render_to_bytes(midi_path, , sample_rate=44100)

Render a MIDI file to PCM bytes (for streaming).

* **Parameters:**
  * **midi_path** ([`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)) – Path to MIDI file
  * **sample_rate** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Audio sample rate
* **Return type:**
  [`bytes`](https://docs.python.org/3/builtins/stdtypes.html#bytes)
* **Returns:**
  Raw PCM audio bytes

#### NOTE
Default implementation not provided - subclasses should override
for streaming support.

#### *abstractmethod* render_to_file(midi_path, output_path, , sample_rate=44100)

Render a MIDI file to an audio file.

* **Parameters:**
  * **midi_path** ([`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)) – Path to input MIDI file
  * **output_path** ([`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)) – Path for output audio file
  * **sample_rate** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Audio sample rate in Hz
* **Return type:**
  [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)
* **Returns:**
  Path to the created audio file

### accompy.synthesis.get_default_backend()

Get the best available synthesis backend.

* **Return type:**
  [`SynthesizerBackend`](_autosummary/accompy.synthesis.html.md#accompy.synthesis.SynthesizerBackend)
* **Returns:**
  An instance of an available SynthesizerBackend
* **Raises:**
  [**RuntimeError**](https://docs.python.org/3/builtins/exceptions.html#RuntimeError) – If no synthesis backend is available

### Modules

| [`fluidsynth`](_autosummary/accompy.synthesis.fluidsynth.html.md#module-accompy.synthesis.fluidsynth)   | FluidSynth synthesis backend.   |
|---------------------------------------------------------------------------------------------------|---------------------------------|


# _autosummary/accompy.tools.html.md

# accompy.tools

Tools for generating accompaniment audio from Score objects.

Provides a pluggable `score_to_wav` engine architecture.  The default engine
uses MMA (Musical MIDI Accompaniment), but any callable with the
[`ScoreToWav`](_autosummary/accompy.tools.html.md#accompy.tools.ScoreToWav) signature can be swapped in — including engines built from
accompy’s own converter pipeline.

Quick start:

```default
>>> from accompy import Score, generate_wav
>>> score = Score.from_string("| Dm7 | G7 | C^7 |")
>>> generate_wav(score, "/tmp/test.wav", groove="BossaNova", tempo=140)
```

Using an alternative engine:

```default
>>> from accompy.tools import make_converter_engine, generate_wav
>>> engine = make_converter_engine(resolver="pychord", midi_gen="pretty_midi",
...                                 audio_renderer="fluidsynth")
>>> generate_wav(score, "/tmp/test.wav", score_to_wav=engine, tempo=140)
```

### Module Attributes

| [`generate_mma_wav`](_autosummary/accompy.tools.html.md#accompy.tools.generate_mma_wav)(score, output_path, \*[, ...])   | Alias for [`mma_score_to_wav()`](_autosummary/accompy.tools.html.md#accompy.tools.mma_score_to_wav).   |
|----------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------|

### Functions

| [`generate_mma_wav`](_autosummary/accompy.tools.html.md#accompy.tools.generate_mma_wav)(score, output_path, \*[, ...])   | Alias for [`mma_score_to_wav()`](_autosummary/accompy.tools.html.md#accompy.tools.mma_score_to_wav).                                 |
|----------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------|
| [`generate_variations`](_autosummary/accompy.tools.html.md#accompy.tools.generate_variations)(score, output_dir, \*[, ...]) | Batch-generate WAV files for many key / tempo / groove combinations.                                           |
| [`generate_wav`](_autosummary/accompy.tools.html.md#accompy.tools.generate_wav)(score, output_path, \*[, ...])       | Generate a WAV file from a Score using a pluggable engine.                                                     |
| [`make_converter_engine`](_autosummary/accompy.tools.html.md#accompy.tools.make_converter_engine)(\*[, resolver, ...])        | Create a [`ScoreToWav`](_autosummary/accompy.tools.html.md#accompy.tools.ScoreToWav) engine from accompy's converter pipeline. |
| [`mma_score_to_wav`](_autosummary/accompy.tools.html.md#accompy.tools.mma_score_to_wav)(score, output_path, \*[, ...])   | Render a Score to WAV using MMA (Musical MIDI Accompaniment).                                                  |

### Classes

| [`ScoreToWav`](_autosummary/accompy.tools.html.md#accompy.tools.ScoreToWav)(\*args, \*\*kwargs)   | Callable that renders a `Score` to a WAV file.   |
|-----------------------------------------------------------------------------------|--------------------------------------------------|

### *class* accompy.tools.ScoreToWav(\*args, \*\*kwargs)

Bases: [`Protocol`](https://docs.python.org/3/library/typing.html#typing.Protocol)

Callable that renders a `Score` to a WAV file.

Any function matching this signature can be used as a `score_to_wav`
engine in [`generate_wav()`](_autosummary/accompy.tools.html.md#accompy.tools.generate_wav) and [`generate_variations()`](_autosummary/accompy.tools.html.md#accompy.tools.generate_variations).

### accompy.tools.generate_mma_wav(score, output_path, , groove='Swing', tempo=120, repeats=1)

Alias for [`mma_score_to_wav()`](_autosummary/accompy.tools.html.md#accompy.tools.mma_score_to_wav).  Kept for backward compatibility.

* **Return type:**
  [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)

### accompy.tools.generate_variations(score, output_dir, , keys=('C',), tempos=(120,), grooves=('Swing',), repeats=1, filename_template='{title}_{key}_{tempo}bpm_{groove}.wav', score_to_wav=None)

Batch-generate WAV files for many key / tempo / groove combinations.

Produces one WAV for each `(key, tempo, groove)` triple (cycled from the
shortest sequences).  Useful for creating practice backing-track
collections.

* **Parameters:**
  * **score** ([`Score`](_autosummary/accompy.base.html.md#accompy.base.Score)) – Base `Score` (will be transposed per key).
  * **output_dir** ([`Union`](https://docs.python.org/3/library/typing.html#typing.Union)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)]) – Directory for output files.
  * **keys** ([`Sequence`](https://docs.python.org/3/library/typing.html#typing.Sequence)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – Keys to transpose to.
  * **tempos** ([`Sequence`](https://docs.python.org/3/library/typing.html#typing.Sequence)[[`int`](https://docs.python.org/3/builtins/functions.html#int)]) – Tempos in BPM to cycle through.
  * **grooves** ([`Sequence`](https://docs.python.org/3/library/typing.html#typing.Sequence)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – Groove / style names to cycle through.
  * **repeats** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Number of repeats per file.
  * **filename_template** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Template for filenames. Placeholders:
    `{title}`, `{key}`, `{tempo}`, `{groove}`.
  * **score_to_wav** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`ScoreToWav`](_autosummary/accompy.tools.html.md#accompy.tools.ScoreToWav)]) – Engine callable.  Defaults to [`mma_score_to_wav()`](_autosummary/accompy.tools.html.md#accompy.tools.mma_score_to_wav).
* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)]
* **Returns:**
  List of Paths to successfully generated files.

Example:

```default
>>> from accompy import Score, generate_variations
>>> score = Score.from_string("| C6 | Do | C6/E | Fo |", key="C")
>>> generate_variations(
...     score, "/tmp/variations",
...     keys=["C", "G", "F"],
...     tempos=[100, 120],
...     grooves=["Swing", "BossaNova"],
... )

>>> # With a custom engine:
>>> from accompy.tools import make_converter_engine
>>> engine = make_converter_engine(audio_renderer="fluidsynth")
>>> generate_variations(
...     score, "/tmp/variations",
...     keys=["C", "G"],
...     tempos=[100, 120],
...     grooves=["Swing"],
...     score_to_wav=engine,
... )
```

### accompy.tools.generate_wav(score, output_path, , groove='Swing', tempo=120, repeats=1, score_to_wav=None)

Generate a WAV file from a Score using a pluggable engine.

By default uses MMA (Musical MIDI Accompaniment).  Pass a custom
`score_to_wav` callable to use a different backend — for instance one
built with [`make_converter_engine()`](_autosummary/accompy.tools.html.md#accompy.tools.make_converter_engine).

* **Parameters:**
  * **score** ([`Score`](_autosummary/accompy.base.html.md#accompy.base.Score)) – A `Score` with chord measures.
  * **output_path** ([`Union`](https://docs.python.org/3/library/typing.html#typing.Union)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)]) – Destination WAV file path.
  * **groove** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Groove / style name (interpretation depends on the engine).
  * **tempo** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Tempo in BPM.
  * **repeats** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Number of times to repeat the progression.
  * **score_to_wav** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`ScoreToWav`](_autosummary/accompy.tools.html.md#accompy.tools.ScoreToWav)]) – Engine callable.  Defaults to [`mma_score_to_wav()`](_autosummary/accompy.tools.html.md#accompy.tools.mma_score_to_wav).
* **Return type:**
  [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)
* **Returns:**
  Path to the generated WAV file.

Example:

```default
>>> from accompy import Score, generate_wav
>>> score = Score.from_string("| Dm7 | G7 | C^7 |")
>>> generate_wav(score, "/tmp/test.wav", groove="BossaNova", tempo=140)
PosixPath('/tmp/test.wav')

>>> # With a custom engine:
>>> from accompy.tools import make_converter_engine
>>> engine = make_converter_engine(audio_renderer="fluidsynth")
>>> generate_wav(score, "/tmp/test.wav", score_to_wav=engine, tempo=140)
```

### accompy.tools.make_converter_engine(, resolver=None, midi_gen=None, audio_renderer=None, soundfont=None, sr=44100)

Create a [`ScoreToWav`](_autosummary/accompy.tools.html.md#accompy.tools.ScoreToWav) engine from accompy’s converter pipeline.

This wraps the `ChordSequence → NoteSequence → MidiData → AudioData`
converter chain into the same interface that [`generate_wav()`](_autosummary/accompy.tools.html.md#accompy.tools.generate_wav) expects,
so you can swap it in place of the default MMA engine.

* **Parameters:**
  * **resolver** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – Chord resolver name (e.g. `"pychord"`, `"tonal"`).
  * **midi_gen** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – MIDI generator name (e.g. `"pretty_midi"`, `"midiutil"`).
  * **audio_renderer** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – Audio renderer name (e.g. `"fluidsynth"`, `"pretty_midi"`).
  * **soundfont** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]) – Path to a SoundFont file (for FluidSynth-based renderers).
  * **sr** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Sample rate.
* **Return type:**
  [`ScoreToWav`](_autosummary/accompy.tools.html.md#accompy.tools.ScoreToWav)
* **Returns:**
  A callable matching the [`ScoreToWav`](_autosummary/accompy.tools.html.md#accompy.tools.ScoreToWav) protocol.

Example:

```default
>>> engine = make_converter_engine(audio_renderer="fluidsynth")
>>> generate_wav(score, "/tmp/out.wav", score_to_wav=engine, tempo=120)
```

### accompy.tools.mma_score_to_wav(score, output_path, , groove='Swing', tempo=120, repeats=1)

Render a Score to WAV using MMA (Musical MIDI Accompaniment).

Accepts any valid MMA groove name (e.g. `"Bebop"`, `"GypsyJazz"`).
Run `mma -Dg` to list available grooves.

* **Parameters:**
  * **score** ([`Score`](_autosummary/accompy.base.html.md#accompy.base.Score)) – A `Score` with chord measures.
  * **output_path** ([`Union`](https://docs.python.org/3/library/typing.html#typing.Union)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str), [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)]) – Destination WAV file path.
  * **groove** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – MMA groove name (case-sensitive).
  * **tempo** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Tempo in BPM.
  * **repeats** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Number of times to repeat the progression.
* **Return type:**
  [`Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path)
* **Returns:**
  Path to the generated WAV file.
* **Raises:**
  [**RuntimeError**](https://docs.python.org/3/builtins/exceptions.html#RuntimeError) – If MMA is not installed or the groove is invalid.


# _autosummary/accompy.util.html.md

# accompy.util

Utility functions for chord parsing and normalization.

Contains helpers for chord symbol normalization, chord string parsing,
and iReal URL parsing.

### Module Attributes

| [`CHORD_SYMBOL_REPLACEMENTS`](_autosummary/accompy.util.html.md#accompy.util.CHORD_SYMBOL_REPLACEMENTS)   | each `old` becomes `new` at the end of the symbol or of a part before a slash (longest `old` wins).                               |
|------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|
| [`UNNORMALIZED_SYMBOLS`](_autosummary/accompy.util.html.md#accompy.util.UNNORMALIZED_SYMBOLS)        | Symbols [`normalize_chord_symbol()`](_autosummary/accompy.util.html.md#accompy.util.normalize_chord_symbol) returns unchanged (no chord, or a repeat sign). |

### Functions

| [`normalize_chord_symbol`](_autosummary/accompy.util.html.md#accompy.util.normalize_chord_symbol)(symbol)                    | Normalize chord symbols to a standard format.                        |
|----------------------------------------------------------------------------------------------------|----------------------------------------------------------------------|
| [`parse_chord_string`](_autosummary/accompy.util.html.md#accompy.util.parse_chord_string)(chord_string)                  | Parse a chord string into measures, each containing chord symbols.   |
| [`parse_ireal_html`](_autosummary/accompy.util.html.md#accompy.util.parse_ireal_html)(html_path)                       | Extract a Score from an iReal Pro HTML export file.                  |
| [`parse_ireal_url`](_autosummary/accompy.util.html.md#accompy.util.parse_ireal_url)(url)                              | Parse an iReal Pro URL (`irealb://` or `irealbook://`) into a Score. |
| [`parse_time_sig`](_autosummary/accompy.util.html.md#accompy.util.parse_time_sig)(ts_str)                            | Parse time signature string like '4/4' into tuple.                   |
| [`score_from_chord_specs`](_autosummary/accompy.util.html.md#accompy.util.score_from_chord_specs)(chords, \*[, title, ...])  | Create a `Score` from `(chord, beats)` pairs.                        |
| [`transpose_chord`](_autosummary/accompy.util.html.md#accompy.util.transpose_chord)(chord, semitones, \*[, use_flat]) | Transpose a chord symbol by *semitones*.                             |
| [`transpose_note`](_autosummary/accompy.util.html.md#accompy.util.transpose_note)(name, semitones, \*[, use_flat])   | Transpose a single note name by *semitones*.                         |
| [`transpose_score`](_autosummary/accompy.util.html.md#accompy.util.transpose_score)(score, target_key)                | Transpose a `Score` to a new key.                                    |

### accompy.util.CHORD_SYMBOL_REPLACEMENTS *= (('maj7', '^7'), ('Maj7', '^7'), ('M7', '^7'), ('maj9', '^9'), ('Maj9', '^9'), ('M9', '^9'), ('maj', '^'), ('Maj', '^'), ('min7', '-7'), ('mi7', '-7'), ('mi9', '-9'), ('min', '-'), ('mi', '-'), ('m7', '-7'), ('m9', '-9'), ('m', '-'), ('dim7', 'o7'), ('dim', 'o'), ('°7', 'o7'), ('°', 'o'), ('m7b5', 'h7'), ('ø7', 'h7'), ('ø', 'h'), ('sus2', 'sus2'), ('add9', 'add9'), ('add2', 'add2'))*

each `old` becomes
`new` at the end of the symbol or of a part before a slash (longest `old` wins).

* **Type:**
  The suffix rewrites [`normalize_chord_symbol()`](_autosummary/accompy.util.html.md#accompy.util.normalize_chord_symbol) applies

### accompy.util.UNNORMALIZED_SYMBOLS *= ('', 'n', 'N.C.', 'NC', '%', 'x')*

Symbols [`normalize_chord_symbol()`](_autosummary/accompy.util.html.md#accompy.util.normalize_chord_symbol) returns unchanged (no chord, or a repeat sign).

### accompy.util.normalize_chord_symbol(symbol)

Normalize chord symbols to a standard format.

Handles conversions like:

- Cm -> C-
- Cmaj7 -> C^7
- Cdim, C° -> Co
- CM7, CMaj7 -> C^7; Cmi7 -> C-7
- Cm7b5 -> Ch7 (half-diminished)

Each `/`-separated part of the symbol has its longest matching suffix from
[`CHORD_SYMBOL_REPLACEMENTS`](_autosummary/accompy.util.html.md#accompy.util.CHORD_SYMBOL_REPLACEMENTS) rewritten, once (so `dim` is never read as a
word ending in `m`).

### Example

```pycon
>>> normalize_chord_symbol("Cmaj7")
'C^7'
>>> normalize_chord_symbol("Dm7b5")
'Dh7'
>>> normalize_chord_symbol("Cdim7"), normalize_chord_symbol("Bbm7/F")
('Co7', 'Bb-7/F')
```

* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### accompy.util.parse_chord_string(chord_string)

Parse a chord string into measures, each containing chord symbols.

### Example

```pycon
>>> parse_chord_string("| C | Am | F | G |")
[['C'], ['A-'], ['F'], ['G']]
>>> parse_chord_string("| C Am | F G |")
[['C', 'A-'], ['F', 'G']]
```

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)]]

### accompy.util.parse_ireal_html(html_path)

Extract a Score from an iReal Pro HTML export file.

iReal Pro can export songs as HTML files containing an `irealb://` link.
This function reads the file, extracts that link, and parses it into a
`Score`.

* **Parameters:**
  **html_path** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Path to the HTML file exported from iReal Pro.
* **Return type:**
  Score
* **Returns:**
  A Score with measures, title, key, and time signature.
* **Raises:**
  * [**FileNotFoundError**](https://docs.python.org/3/builtins/exceptions.html#FileNotFoundError) – If *html_path* does not exist.
  * [**ValueError**](https://docs.python.org/3/builtins/exceptions.html#ValueError) – If no iReal URL is found in the HTML.

Example:

```default
>>> score = parse_ireal_html("/path/to/song.html")
>>> score.title
'Autumn Leaves'
```

### accompy.util.parse_ireal_url(url)

Parse an iReal Pro URL (`irealb://` or `irealbook://`) into a Score.

Decoding is [`accompy.ireal.decode_ireal_url()`](_autosummary/accompy.ireal.html.md#accompy.ireal.decode_ireal_url); the Score is the first tune of
the URL that has chords, each bar the list of its chords as written (iReal chord
notation). Raises `ValueError` when no tune has chords.

```pycon
>>> score = parse_ireal_url("irealbook://Blues=Me=Swing=F=n=[T34F7 |Bb7 Bo7 |C7 Z")
>>> score.measures, score.time_signature
([['F7'], ['Bb7', 'Bo7'], ['C7']], (3, 4))
```

### accompy.util.parse_time_sig(ts_str)

Parse time signature string like ‘4/4’ into tuple.

### Example

```pycon
>>> parse_time_sig("3/4")
(3, 4)
>>> parse_time_sig("6/8")
(6, 8)
>>> parse_time_sig(None)
(4, 4)
```

* **Return type:**
  [`tuple`](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[`int`](https://docs.python.org/3/builtins/functions.html#int), [`int`](https://docs.python.org/3/builtins/functions.html#int)]

### accompy.util.score_from_chord_specs(chords, , title='Untitled', key='C', time_signature=(4, 4))

Create a `Score` from `(chord, beats)` pairs.

Durations that are multiples of the bar length map cleanly to repeated bars.
Other durations are approximated by grouping chords into bars.

### accompy.util.transpose_chord(chord, semitones, , use_flat=None)

Transpose a chord symbol by *semitones*.

Handles slash chords (e.g. `"C6/E"`).

* **Parameters:**
  * **chord** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Chord symbol like `"Am7"`, `"C6/E"`, `"G#o"`.
  * **semitones** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Number of semitones.
  * **use_flat** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`bool`](https://docs.python.org/3/builtins/functions.html#bool)]) – Force flat/sharp spelling (see [`transpose_note()`](_autosummary/accompy.util.html.md#accompy.util.transpose_note)).
* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### Example

```pycon
>>> transpose_chord("Am7", 2)
'Bm7'
>>> transpose_chord("C6/E", 5)
'F6/A'
>>> transpose_chord("G#o", -2, use_flat=True)
'Gbo'
```

### accompy.util.transpose_note(name, semitones, , use_flat=None)

Transpose a single note name by *semitones*.

* **Parameters:**
  * **name** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Note name like `"C"`, `"Eb"`, `"F#"`.
  * **semitones** ([`int`](https://docs.python.org/3/builtins/functions.html#int)) – Number of semitones (positive = up, negative = down).
  * **use_flat** ([`Optional`](https://docs.python.org/3/library/typing.html#typing.Optional)[[`bool`](https://docs.python.org/3/builtins/functions.html#bool)]) – Force flat (True) or sharp (False) spelling.
    `None` (default) uses flats for downward transposition.
* **Return type:**
  [`str`](https://docs.python.org/3/builtins/stdtypes.html#str)

### Example

```pycon
>>> transpose_note("C", 5)
'F'
>>> transpose_note("A", -2)
'G'
>>> transpose_note("C", 1, use_flat=True)
'Db'
```

### accompy.util.transpose_score(score, target_key)

Transpose a `Score` to a new key.

The spelling (sharp vs flat) is chosen automatically based on the
*target_key*.

* **Parameters:**
  * **score** – A `Score` instance.
  * **target_key** ([`str`](https://docs.python.org/3/builtins/stdtypes.html#str)) – Target key, e.g. `"Eb"`, `"G"`, `"F#"`.
* **Return type:**
  Score
* **Returns:**
  A new Score in the target key with an updated title.

### Example

```pycon
>>> from accompy import Score
>>> s = Score.from_string("| C | Am | F | G |", key="C")
>>> t = transpose_score(s, "G")
>>> [m[0] for m in t.measures]
['G', 'E-', 'C', 'D']
```


# _autosummary/accompy.wips.audio_renderers.html.md

# accompy.wips.audio_renderers

Backward-compat shim. Use `accompy.audio_renderers` instead.


# _autosummary/accompy.wips.chord_parsers.html.md

# accompy.wips.chord_parsers

Backward-compat shim. Use `accompy.chord_parsers` instead.


# _autosummary/accompy.wips.chord_resolvers.html.md

# accompy.wips.chord_resolvers

Backward-compat shim. Use `accompy.chord_resolvers` instead.


# _autosummary/accompy.wips.html.md

# accompy.wips

Backward-compatibility shim — wips modules have moved to accompy top level.

Import from `accompy.converters`, `accompy.chord_parsers`, etc. instead.

### Modules

| [`audio_renderers`](_autosummary/accompy.wips.audio_renderers.html.md#module-accompy.wips.audio_renderers)   | Backward-compat shim.   |
|--------------------------------------------------------------------------------------------------------|-------------------------|
| [`chord_parsers`](_autosummary/accompy.wips.chord_parsers.html.md#module-accompy.wips.chord_parsers)       | Backward-compat shim.   |
| [`chord_resolvers`](_autosummary/accompy.wips.chord_resolvers.html.md#module-accompy.wips.chord_resolvers)   | Backward-compat shim.   |
| [`midi_generators`](_autosummary/accompy.wips.midi_generators.html.md#module-accompy.wips.midi_generators)   | Backward-compat shim.   |
| [`pipeline`](_autosummary/accompy.wips.pipeline.html.md#module-accompy.wips.pipeline)                 | Backward-compat shim.   |
| [`types`](_autosummary/accompy.wips.types.html.md#module-accompy.wips.types)                       | Backward-compat shim.   |


# _autosummary/accompy.wips.midi_generators.html.md

# accompy.wips.midi_generators

Backward-compat shim. Use `accompy.midi_generators` instead.


# _autosummary/accompy.wips.pipeline.html.md

# accompy.wips.pipeline

Backward-compat shim. Use `accompy.pipeline` instead.


# _autosummary/accompy.wips.types.html.md

# accompy.wips.types

Backward-compat shim. Use `accompy.converters` instead.


# about-this-build.html.md

<!-- generated by epythet -->

# About this build

This documentation was built on **2026-11-23 07:59 UTC** from commit <a href="https://github.com/thorwhalen/accompy/commit/5d5840aaa46f5f983685e70d9e8bcba05f5d1288"><code>5d5840a</code></a> on branch <code>main</code>, for **accompy 0.3.23** (from <code>pyproject.toml</code>).

#### NOTE
Nothing suggests a mismatch: the tree was clean at the commit above, and the documented version is the one on PyPI.

## Source

|                     |                                                                                                                                                           |
|---------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------|
| Commit              | <a href="https://github.com/thorwhalen/accompy/commit/5d5840aaa46f5f983685e70d9e8bcba05f5d1288"><code>5d5840aaa46f5f983685e70d9e8bcba05f5d1288</code></a> |
| Branch              | <code>main</code>                                                                                                                                         |
| Tags at this commit | none                                                                                                                                                      |
| Working tree        | clean                                                                                                                                                     |
| Remote              | <code>https://github.com/thorwhalen/accompy</code>                                                                                                        |

## Continuous integration

|              |                                                                                            |
|--------------|--------------------------------------------------------------------------------------------|
| Repository   | <code>thorwhalen/accompy</code>                                                            |
| Run          | <a href="https://github.com/thorwhalen/accompy/actions/runs/45134824739">45134824739</a>   |
| Ref          | <code>refs/heads/main</code>                                                               |
| Event commit | <code>5d5840aaa46f5f983685e70d9e8bcba05f5d1288</code> (in the history of the built commit) |

## Tools

|          |         |
|----------|---------|
| epythet  | 0.2.24  |
| Sphinx   | 9.1.1   |
| docutils | 0.22.4  |
| Python   | 3.12.16 |

## Configuration as resolved

|               |                                                                   |
|---------------|-------------------------------------------------------------------|
| theme         | <code>auto</code> (Sphinx theme <code>pydata_sphinx_theme</code>) |
| accent        | <code>#893466</code>                                              |
| api_generator | <code>autosummary</code>                                          |
| ignore        | <code>tests/</code>, <code>scrap/</code>, <code>examples/</code>  |
| agent_outputs | <code>true</code>                                                 |
| aggregates    | <code>md</code>                                                   |
| ai_artifacts  | <code>true</code>                                                 |

## Package on PyPI

Latest release: <a href="https://pypi.org/project/accompy/0.3.23/">0.3.23</a>, the same as the documented version.

## Reproduce

```bash
git clone https://github.com/thorwhalen/accompy && cd accompy
git checkout 5d5840aaa46f5f983685e70d9e8bcba05f5d1288
pip install "epythet==0.2.24"
epythet quickstart . --ignore tests/ scrap/ examples/
```

The same data, for machines: <a href="build_info.json"><code>build_info.json</code></a> (schema version 1).


# ai-agents.html.md

<!-- generated by epythet -->

# For AI agents

`accompy` ships artifacts for coding agents alongside its code. This page lists
them, says where each lives in the repository, and points at the
machine-readable copies of this documentation.

## Skills

Skills are folders holding a `SKILL.md` (the [Agent Skills](https://agentskills.io) format): a description that tells an agent when to use it and a body with the procedure. Install one into your agent with `gh skill` (any host: `--agent claude-code`, `copilot`, `cursor`, `codex`, `gemini`), or use the copy bundled in the wheel.

### `accompy-patterns`

Use when creating, modifying, or debugging musical patterns (drum, bass, comping, rhythmic skeletons) in the accompy pattern system. Triggers on DrumPattern, BassPattern, CompingPattern, PatternRegistry, rhythmic_skeletons, resolve_skeleton, apply_skeleton, rhythm_to_midi, or when working with accompy/patterns/ or accompy/rhythmic_skeletons.py.

```bash
gh skill install thorwhalen/accompy accompy-patterns --agent claude-code
```

Source: [`skills/accompy-patterns`](https://github.com/thorwhalen/accompy/tree/HEAD/skills/accompy-patterns).

### `user-data-folder`

Use when setting up per-user persistent data directories for a Python package — configuration files, bundled resources (seed-on-missing pattern), and runtime artifact folders. Triggers on XDG directories, app data folder, user config, seed data, importlib.resources, or when externalizing module-level constants to user-editable files.

```bash
gh skill install thorwhalen/accompy user-data-folder --agent claude-code
```

Source: [`skills/user-data-folder`](https://github.com/thorwhalen/accompy/tree/HEAD/skills/user-data-folder).

## Instruction files

Files agents read before working in this repository.

- [`CLAUDE.md`](https://github.com/thorwhalen/accompy/tree/HEAD/CLAUDE.md): read by Claude Code

## Machine-readable documentation

This site publishes the same documentation in forms that fit an agent’s context window:

- [`llms.txt`](https://thorwhalen.github.io/accompy/llms.txt): an index of every page with a one-line description ([llms.txt](https://llmstxt.org) format)
- [`accompy.md`](https://thorwhalen.github.io/accompy/accompy.md): the whole documentation as one Markdown file
- `<page>.html.md`: a rendered Markdown twin of every page, advertised from each page’s `<head>` with `<link rel="alternate" type="text/markdown">`
- [`objects.inv`](https://thorwhalen.github.io/accompy/objects.inv): the Sphinx inventory: a symbol-to-URL index (`sphobjinv convert plain objects.inv -`)


# api.html.md

# API reference

| [`accompy`](_autosummary/accompy.html.md#module-accompy)   | accompy - Generate accompaniment audio from chord charts.   |
|---------------------------------------------------------------------------|-------------------------------------------------------------|


