PyLody
PyLody is a small package designed to create simple melodies.
Usage
To create a melody you can use two methods: you can use notescript notation or add melody elements manually.
The notescript notation
The notescript notation is a little-function programming language that allows you to write a melody using the melody elements: the letter notation of notes, pauses and repeating blocks.
The letter notation of notes and pauses must contains the duration at end of the declaration:
[Note or pause] [Duration (in milliseconds)]
The letter notation of notes must match this regex: \w\d#? [duration] (the duration regex is \d+).
The pause declaration is - [duration].
The repeating block is a part of melody that can repeat any number of times. This is the structure of this block:
[Number of times to repeat] {
...elements to repeat...
}
To create an infinite repeating loop just write an asterisk (*) as the number of times to repeat.
The notescript notation supports commentaries: /The text in the slashes will be ignored/.
Creating a melody
First of all, create a MelodyBuilder object. The constructor of this class takes one optional argument —— a notescript. To play the melody call the play method.
from pylody import MelodyBuilder
mb = MelodyBuilder(notescript)
mb.play()
You can create a melody without the notescript. Just add elements manually:
from pylody.elements import Pause, Note, Block
# The note declaration
mb.add(Note(note="A",
octave=4,
duration=250)) # A4 250
# The pause declaration
mb.add(Pause(duration=250)) # - 250
# The block declaration
block = Block(repeattimes=1)
...
block.add(element)
...
mb.add(block)
Or you can play elements separately:
note.play()
pause.play()
block.play()
Example
from pylody import MelodyBuilder
mb = MelodyBuilder(r"""
\ Example \
* {
2 {
A4 250
B4 250
}
3 {
A4# 250
}
- 500
}
""")
mb.play()
Metadata
Release files for PyLody 1.0.0
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 |
|---|---|---|---|---|
| PyLody-1.0.0.tar.gz | 4.4 kB | Without provenance | Details for PyLody-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| PyLody-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for PyLody-1.0.0-py3-none-any.whl |
Total release size: 9.2 kB
Release files / PyLody-1.0.0.tar.gz
| Download URL | PyLody-1.0.0.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a070ccf20ede9e7189b4fc0d71b869763ec92a88b199cbed3695f0da79c451ea
|
|
BLAKE2b-256 checksum How to use checksums |
0e8521bcb2bd6646004ddd42154c3a08550e5e7364dd0dc2b3b087b808e8d998
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.6
|
Release files / PyLody-1.0.0-py3-none-any.whl
| Download URL | PyLody-1.0.0-py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0c4896b6e4a54bb6c49d54caa4dfdd449057b2f8c3fecc477432dc7e90a2f139
|
|
BLAKE2b-256 checksum How to use checksums |
c281d6e8383070f32038f8b097c8edce52a6e55b506634c0e55c325be065c84b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.6
|
Security for PyLody 1.0.0
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.