Random Rhythms in Python!
Partition a musical duration into rhythmic phrases.
Usage:
- Determine the pool of durations to use in your rhythmic phrase:
128th to 128: .03125 .0625 .125 .25 .5 1 2 4 8 16 32 64 128
# durations = [ 2**x for x in range(-5, 8) ]
Triplets: .167 .333 .667 1.333 2.667
# durations = [ 2**x/3 for x in range(-1, 4) ]
Dotted: .375 .75 1.5 3 6
# durations = [ 2**x+2**x/2 for x in range(-2, 3) ]
Double dotted: .4375 .875 1.75 3.5 7
# durations = [ 2**x+2**x/2+2**x/4 for x in range(-2, 3) ]
where 1 is a quarter-note, 0.5 is an eighth, 2 is a half-note, etc.
- Import the class:
from random_rhythms import Rhythm
- Instantiate a random-rhythm object:
params = { # these are the defaults:
measure_size: 4, # in quarter-notes (or fractions thereof)
durations: [ 1/4, 1/2, 1/3, 1, 3/2, 2 ], # 1 = quarter-note
weights: [ 1, 1, 1, 1, 1, 1 ],
groups: {}, # number of notes, keyed by a duration
smallest: 1/128 # lower threshold for adding to the phrase
}
r = Rhythm(**params)
- Get a motif:
motif = r.motif()
print(motif)
Musical example:
from music21 import *
import random
from random_rhythms import Rhythm
r = Rhythm(measure_size=5 groups={1/3: 3, 1/2: 2})
motifs = [ r.motif() for x in range(4) ]
sc = scale.WholeToneScale('C4')
s = stream.Stream()
s.append(meter.TimeSignature('5/4'))
for m in motifs:
for d in m:
p = random.choice(sc.pitches)
n = note.Note(p)
n.duration = duration.Duration(d)
s.append(n)
s.show() # or 'midi'
Metadata
Release files for random-rhythms 0.1.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| random_rhythms-0.1.11.tar.gz | 41.1 kB | Without provenance | Details for random_rhythms-0.1.11.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| random_rhythms-0.1.11-py3-none-any.whl | Python 3 | none | any | Details for random_rhythms-0.1.11-py3-none-any.whl |
Total release size: 69.1 kB
Release files / random_rhythms-0.1.11.tar.gz
| Download URL | random_rhythms-0.1.11.tar.gz |
|---|---|
| Size | 41.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4e6ccd42d87a1e91359c3ae2f7636de134d10dbd33b461455e697505ad15be9e
|
|
BLAKE2b-256 checksum How to use checksums |
968b17d132b6869f7cf4900ecfec3a391c3e26c2e5590b44587da08845dd5fdc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / random_rhythms-0.1.11-py3-none-any.whl
| Download URL | random_rhythms-0.1.11-py3-none-any.whl |
|---|---|
| Size | 28.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5d929abc8586caf801c1f6a4ba2e754967b615297d1af386f28e37a635ccee54
|
|
BLAKE2b-256 checksum How to use checksums |
b621e51d0d16db010574037fcd349fa5df8c6aa5fd5fea8e1d44d58e32075d3d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Security for random-rhythms 0.1.11
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.