Skip to main content

Glorified Metronome

Project description

Music Drummer

Glorified Metronome

DESCRIPTION

The methods of this package depend upon music21.

For this package (and music21 too), a duration of 1 is a quarter-note. So, 1/2 would be an eighth-note, etc.

For this package, the (general MIDI) kit is made up of the following instrument types (and defaults):

'kick' (default: 'kick1')
'snare' (default: 'snare1')
'hihat' (default: 'hihat1')
'toms' (default 'tom3')
'cymbals' (default: 'crash1')
'percussion' (default: 'woodblock1')

Each above type includes a music21 Part and a counter (that starts at 0 of course).

The known instruments and their names, MIDI numbers, and types can be seen by printing the return of instrument_map().

The high-hats are special-cased and are named closed, open, and pedal. All are added to the hihat Part, so that they can interact with each other. In a pattern(), besides 0 and 1, the special 2 and 3 bits can be used to indicate that the open and pedal high-hat should be played. This allows the high-hats to interact in that method.

You can change default instruments with the set_instrument() method. This is most useful for the kick and snare types, because there are two variations for each: acoustic and electric.

SYNOPSIS

from music_drummer import Drummer

# Ex 1 - basic 4/4 metronome groove:
d = Drummer()
d.set_bpm(60) # set the beats per minute
d.set_ts() # set the default time signature of 4/4
# add a 16-beat phrase for 64 measures
for _ in range(64):
    d.pattern(
        patterns={
            'kick':  '1000000010000000',
            'snare': '0000100000001000',
            'hihat': '1010101010101010',
        },
    )
d.sync_parts() # make the parts play simultaneously
d.show(format='midi') # or nothing, ='text', etc. see music21 docs

# Ex 2 - 5/8 groove with intro:
d = Drummer()

d.set_instrument('kick', 'kick2') # change to the electric kick
d.set_instrument('snare', 'snare2') # change to the electric snare
# print(d.instrument_map()) # full list of known instruments

d.set_bpm(99) # change the beats per minute from 120
d.set_ts('5/8') # change the time signature from 4/4

d.count_in(2) # count-in on the hi-hats for 2 measures
d.rest('kick', duration=10)
d.rest('snare', duration=10)
d.rest('cymbals', duration=10)
d.rest('toms', duration=10)

# 3 known hi-hat states: closed, open, pedal
d.note('closed', duration=1/2)
d.note('open', duration=1/2)
d.note('pedal', duration=1/2)
d.note('closed', duration=1/2)
d.rest(['snare', 'kick', 'cymbals', 'toms'], duration=2)

# 7 known cymbals:
d.note('crash1')
d.note('crash2')
d.note('china')
d.note('splash')
d.note('ride1')
d.note('ride2')
d.note('ridebell')
d.rest(['kick', 'snare', 'hihat', 'toms'], duration=7)

# 6 known toms:
d.note('tom1', duration=1/3)
d.note('tom2', duration=1/3)
d.note('tom3', duration=1/3)
d.note('tom4', duration=1/3)
d.note('tom5', duration=1/3)
d.note('tom6', duration=1/3)
d.rest(['kick', 'snare', 'hihat', 'cymbals'], duration=2)

# add a eighth-note snare flam to the score
d.note('snare', duration=1/2, flam=1/16)
d.rest(['kick', 'hihat', 'cymbals', 'toms'], duration=1/2)

# add a 5-note snare roll for an eighth-note, increasing in volume
d.roll('snare', duration=1/2, subdivisions=5, crescendo=[100, 127])
d.rest(['kick', 'hihat', 'cymbals', 'toms'], duration=1/2)

# crash and kick!
d.note('kick', duration=1/2)
d.note('crash1', duration=1/2)
d.rest(['snare', 'hihat', 'toms'], duration=1/2)

# add a 4-part, 8-bar, eighth-note phrase to the score
for _ in range(8):
    d.pattern(
        patterns={
            'kick':   '1000000010',
            'snare':  '0000001000',
            'hihat':  '2311111111',
        },
        duration=1/2
    )

d.sync_parts() # make the parts play simultaneously

d.show() # or format='text', format='midi', etc. see music21 docs
# or
d.write() # or filename='groove.mid' for example

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

music_drummer-0.3.0.tar.gz (44.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

music_drummer-0.3.0-py3-none-any.whl (30.2 kB view details)

Uploaded Python 3

File details

Details for the file music_drummer-0.3.0.tar.gz.

File metadata

  • Download URL: music_drummer-0.3.0.tar.gz
  • Upload date:
  • Size: 44.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for music_drummer-0.3.0.tar.gz
Algorithm Hash digest
SHA256 64aa1162e2e2cf4ae49b4fbe6f324006b8b78e8897c4fa89b6267a11354e2569
MD5 9cc7864f3d099b07614fa851907ccb07
BLAKE2b-256 6e5f063878e9d8b5724875aa4f1e436d975374d01a17c8b2f0230c6ad68096bc

See more details on using hashes here.

File details

Details for the file music_drummer-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: music_drummer-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 30.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for music_drummer-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2a640c61925286a35fa2007b0ce4bbeb326ab6e8c8b15cc431057742b415a9cd
MD5 f5bb34f648566b685ff27aef7f1accf9
BLAKE2b-256 30c3255cac4ee5311f7536bbbb34ce88a6ddee980bd539c8dcf30f43145a1368

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page