Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
commit-message:
prefix: ci
- package-ecosystem: uv
directory: /
schedule:
interval: weekly
commit-message:
prefix: chore(deps)
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: CI

on:
push:
branches: [main]
pull_request:

permissions:
contents: read

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Install FluidSynth, GM soundfont and ffmpeg for the preview tests
run: sudo apt-get update && sudo apt-get install -y fluidsynth fluid-soundfont-gm ffmpeg
- uses: astral-sh/setup-uv@v10.3.2
with:
enable-cache: true
- run: uv sync --locked
- run: uv run ruff check .
- run: uv run ruff format --check .
- run: uv run mypy
- run: uv run pytest -rs
18 changes: 18 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: release-please

on:
push:
branches: [main]

permissions:
contents: write
pull-requests: write

jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: googleapis/release-please-action@v5
with:
config-file: release-please-config.json
manifest-file: .release-please-manifest.json
24 changes: 24 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-toml
- id: check-json
- id: check-added-large-files
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.17.2
hooks:
- id: ruff-check
args: [--fix]
- id: ruff-format
- repo: local
hooks:
- id: mypy
name: mypy
entry: uv run mypy
language: system
types: [python]
pass_filenames: false
3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "0.1.0"
}
31 changes: 31 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# drumsmith

CLI that compiles a YAML song description into General MIDI drums, then renders audio with a sampled kit. Python 3.12, `uv`, `src/` layout.

## Commands

```sh
uv sync
uv run ruff check . && uv run ruff format --check . && uv run mypy && uv run pytest
uv run drumsmith demo -o out/
uv run drumsmith preview -o out/ # needs fluidsynth + a GM soundfont
```

## Layout

- `src/drumsmith/gm.py`: GM percussion note numbers, PPQ, drum channel.
- `src/drumsmith/midi.py`: `NoteEvent` and the type 0 MIDI writer.
- `src/drumsmith/demo.py`: hard-coded groove used until the parser exists.
- `src/drumsmith/renderers/`: the `Renderer` protocol, `MissingDependencyError`, and backends (FluidSynth so far).
- `src/drumsmith/audio.py`: stdlib WAV utilities.
- `docs/roadmap.md`: milestones. `docs/decisions.md`: engineering choices and tool findings.

## Rules

- Work one milestone at a time (see `docs/roadmap.md`). Stop after each, run the checks and report briefly before continuing. Tick it off in the roadmap.
- MIDI output must be deterministic: the same input gives byte-identical files.
- Never commit samples, soundfonts, kits or rendered audio (see `.gitignore`). List every supported kit's licence in `LICENSES.md`.
- A missing external tool raises `MissingDependencyError` with Debian/Ubuntu, Homebrew and Arch install hints; the CLI exits 2 without writing anything.
- Before using an external tool, read its `--help` or man page and record the flags and findings in `docs/decisions.md`. Log any new engineering choice there too.
- mypy runs in strict mode; keep everything annotated.
- Commit messages use Conventional Commits; release-please drives versioning, so don't hand-edit the version or `CHANGELOG.md`.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 Joe Heffer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,26 @@

A command-line tool that turns a short text description of a song into a humanised drum backing track to practise bass along to. A YAML song file compiles to General MIDI, which is then rendered to audio with a sampled drum kit.

**Work in progress.** Milestone 1: the MIDI writer and a FluidSynth preview of a hard-coded groove.
**Work in progress.** Milestone 1 of the [roadmap](docs/roadmap.md) is done: the MIDI writer and a FluidSynth preview of a hard-coded groove.

```sh
uv sync
uv run drumsmith demo -o out/ # write out/demo.mid
uv run drumsmith preview -o out/ # also render out/demo.wav with FluidSynth
uv run pytest
```

## Development

```sh
uv sync
uv run pre-commit install # run ruff and mypy on every commit
uv run ruff check . && uv run ruff format --check . && uv run mypy && uv run pytest
```

The preview tests need `fluidsynth`, a General MIDI soundfont and `ffmpeg`; they are skipped when these are missing. Engineering choices are logged in [docs/decisions.md](docs/decisions.md).

Commit messages follow [Conventional Commits](https://www.conventionalcommits.org/) (`feat:`, `fix:`, `docs:`, `chore:` …). [release-please](https://github.com/googleapis/release-please) uses them to open release PRs that bump the version and update `CHANGELOG.md`.

## Licence

The code is released under the [MIT licence](LICENSE). drumsmith ships no samples; the licences of the drum kits it downloads are listed in [LICENSES.md](LICENSES.md).
11 changes: 11 additions & 0 deletions docs/roadmap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Roadmap

Stop after each milestone, run the checks, and report briefly before continuing.

1. [x] Scaffold the project and write a valid General MIDI file from a hard-coded groove. Preview it with FluidSynth.
2. [ ] Parser, event model and tests for the song format, including bad-input cases.
3. [ ] Humaniser, with tests for determinism, velocity ranges and timing caps.
4. [ ] sfizz backend, kit config, `fetch_kit.py`, `test-kit`, and the AVL kit working end to end.
5. [ ] Sections, fills, count-in, tempo scaling, loop and stems.
6. [ ] DrumGizmo backend and a second kit.
7. [ ] README with a quick-start, the song format reference, and `docs/decisions.md`.
29 changes: 28 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,31 @@ version = "0.1.0"
description = "Compile a short text description of a song into a humanised drum backing track."
readme = "README.md"
requires-python = ">=3.12,<3.13"
license = "MIT"
license-files = ["LICENSE"]
authors = [{ name = "Joe Heffer" }]
classifiers = [
"Environment :: Console",
"Programming Language :: Python :: 3.12",
"Topic :: Multimedia :: Sound/Audio :: MIDI",
"Typing :: Typed",
]
dependencies = ["mido>=1.3"]

[project.urls]
Repository = "https://github.com/Joe-Heffer/drumsmith"
Issues = "https://github.com/Joe-Heffer/drumsmith/issues"

[project.scripts]
drumsmith = "drumsmith.cli:main"

[dependency-groups]
dev = ["pytest>=8", "ruff>=0.6"]
dev = [
"mypy>=2.4.0",
"pre-commit>=4.7.0",
"pytest>=8",
"ruff>=0.6",
]

[build-system]
requires = ["hatchling"]
Expand All @@ -25,3 +43,12 @@ select = ["E", "F", "W", "I", "B", "UP", "SIM"]

[tool.pytest.ini_options]
testpaths = ["tests"]

[tool.mypy]
python_version = "3.12"
strict = true
files = ["src", "tests"]

[[tool.mypy.overrides]]
module = ["mido", "mido.*"]
ignore_missing_imports = true
18 changes: 18 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
"bootstrap-sha": "4288c7e8d56557d387ac855e0c36252ef2eb7cd8",
"packages": {
".": {
"release-type": "python",
"package-name": "drumsmith",
"include-component-in-tag": false,
"extra-files": [
{
"type": "toml",
"path": "uv.lock",
"jsonpath": "$.package[?(@.name.value=='drumsmith')].version"
}
]
}
}
}
4 changes: 3 additions & 1 deletion src/drumsmith/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""drumsmith: turn a short text description of a song into a drum backing track."""

__version__ = "0.1.0"
from importlib.metadata import version

__version__ = version("drumsmith")
4 changes: 3 additions & 1 deletion src/drumsmith/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import argparse
import sys
from collections.abc import Callable
from pathlib import Path

from drumsmith import __version__, demo
Expand Down Expand Up @@ -61,7 +62,8 @@ def build_parser() -> argparse.ArgumentParser:

def main(argv: list[str] | None = None) -> int:
args = build_parser().parse_args(argv)
return args.func(args)
func: Callable[[argparse.Namespace], int] = args.func
return func(args)


if __name__ == "__main__":
Expand Down
15 changes: 13 additions & 2 deletions src/drumsmith/midi.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,19 @@ def build_midi(
return mid


def write_midi(path: Path, *args, **kwargs) -> Path:
def write_midi(
path: Path,
events: list[NoteEvent],
*,
bpm: float,
time_signature: tuple[int, int],
total_ticks: int,
title: str = "drumsmith",
) -> Path:
"""Build a MIDI file (see :func:`build_midi`) and save it to ``path``."""
path.parent.mkdir(parents=True, exist_ok=True)
build_midi(*args, **kwargs).save(path)
mid = build_midi(
events, bpm=bpm, time_signature=time_signature, total_ticks=total_ticks, title=title
)
mid.save(path)
return path
Empty file added src/drumsmith/py.typed
Empty file.
4 changes: 3 additions & 1 deletion tests/test_preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,7 @@ def test_not_silent_and_below_full_scale(demo_wav: Path) -> None:
text=True,
check=True,
)
max_db = float(re.search(r"max_volume: (-?[\d.]+|-inf) dB", result.stderr).group(1))
match = re.search(r"max_volume: (-?[\d.]+|-inf) dB", result.stderr)
assert match is not None, result.stderr
max_db = float(match.group(1))
assert -60.0 < max_db < 0.0
Loading
Loading