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))
Drum-only audio loaded!
# Drum-only transcription — no `full_song` flag needed.
# Outputs are saved to the specified output_dir.
drum_only_result = ds.transcribe(
    audio_path=drum_only_path,
    output_dir="transcription",
)

print("Drum-only transcription complete. File generated:", drum_only_result)
...Loading & analysing audio...
(HOP_LENGTH: 128)
(Wait Frames Applied: 17)
(len_onset_times:158)
   -> Tempo: 64.6 BPM | Onsets: 158
   -> Classifier: standard polyphonic engine
   -> Classified 158 events
...Building score: transcription/test_transcription.pdf
--- Building Score for: transcription/test_transcription.pdf [Time Sig: 4/4] ---
Saving to: transcription/test_transcription.json
Generating PDF: transcription/test_transcription.pdf (Sig: 4/4, 64 BPM)
PDF successfully saved to: transcription/test_transcription.pdf
SUCCESS: MIDI file generated at -> transcription/test_transcription.mid
--- Done ---
Drum-only transcription complete. File generated: transcription/test_transcription.pdf

Output (Drum Only)

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