Transcribe a Drum Track#

This is the core DrumScript pipeline: give it an audio file and it generates PDF sheet music.

ds.transcribe() runs the full end-to-end pipeline:

  1. Load & normalise the audio (peak normalisation to [-1, 1]).

  2. Detect tempo using spectral onset envelope analysis.

  3. Detect onsets — the exact timestamps where drum hits occur.

  4. Classify each hit using DrumScript’s deterministic, physics-based engine (fundamental frequency, spectral centroid, decay time, and energy ratios).

  5. Build & export a PDF score with dual-voice notation (cymbals stems-up, drums stems-down).

Drum-only audio vs. full songs#

By default, ds.transcribe() expects an isolated drum stem — i.e. audio that contains drums only, with no bass, vocals, or other instruments.

  • For an isolated drum stem, call ds.transcribe(path) directly. (This is the default.)

  • For a full polyphonic mix, pass full_song=True and DrumScript will isolate the drums first via Demucs, then transcribe.

Both cases are demonstrated below.

(Note: We are using copyright-free synthetic tracks for these demonstrations.)


1. Transcribing an isolated drum stem (default)#

Use this path when your input is already drum-only — for example, a stem exported from a DAW, or a drum recording captured in isolation.

No special flags are needed: just call ds.transcribe(path).

from IPython.display import Audio, display

import drumscript as ds

# Load drum-only audio
drum_only_path = "audio/test.wav"
drum_only_audio = ds.load_audio(drum_only_path)
print("Drum-only audio loaded!")
display(Audio(drum_only_path))

> ds.transcribe() automatically outputs .pdf, .xml and .json as standard#

# Drum-only transcription — no `full_song` flag needed.
# Outputs are saved to the specified output_dir.
output_files = ds.transcribe(
    audio_path=drum_only_path,
    output_dir="transcription",
)

# transcribe() returns a dict with the paths to all three outputs (v0.2.0+)
print("Drum-only transcription complete!")
print(f"  PDF sheet music:  {output_files['pdf_path']}")
print(f"  MIDI (for DAWs):  {output_files['midi_path']}")
print(f"  JSON (raw data):  {output_files['json_path']}")

… or just choose one output (ie pdf):#

# Drum-only transcription — no `full_song` flag needed.
# Outputs are saved to the specified output_dir.
output_files = ds.transcribe(
    audio_path=drum_only_path,
    output_dir="transcription",
)

print("Drum-only transcription complete. PDF generated:", output_files["pdf_path"])

Please note: If no output_dir is specified when running ds.transcribe() the default save location is the outputs/ directory.

The screenshots below show the PDF score generated from the full-song example above.

Page 1

Page 1