Music Harmonization Package
A Reinforcement Learning package to generate musical harmonies, starting from a general sequence of notes in the scale of C major. Outputs musical harmonies, MIDI files, and mp4 videos.
Prerequisites
- ffmpeg must be installed on your system.
Examples
Here are a few example outputs generated by the package. The top line is the melody, given as input. The other notes played are generated. In this case a simple C major scale. The following videos are two different outputs generated by the agent.
https://github.com/user-attachments/assets/e7a52a7e-48b0-4076-8552-e5e392ad850d
https://github.com/user-attachments/assets/9b4d98df-2e92-45ec-9ef5-695c0d947d09
Installation
Install this package via pyPI:
pip install harmonization-env
https://pypi.org/project/harmonization-env/
Basic Usage
Here's a complete example showing the main features:
import torch
from harmonization_env import *
path_to_params = "..."
env = HarmonizationEnv(device = 'cpu')
net = NetM.load_from_checkpoint(path_to_params, device = 'cpu')
# Create a melody sequence
# Notes are represented as MIDI numbers (60 = middle C)
melody = torch.tensor([64, 64, 65, 65,
67, 69, 69, 62,
67, 67, 68, 71,
69, 71, 72, 65,
64, 64, 62, 62,
60, 60, 60, 60,
60], dtype = torch.int32)
melody += 12
# get output
chords, reward = agent.get(
melody = melody,
)
run = chords[0, :]
v = Voicer(melody, run)
voices = v.get()
player = MIDIGenerator(tempo = 80)
# get and play midi output
player.generate(voices, filenames = 'test0.mid')
player.play(filename = 'test0.mid')
# Create visualization video
# Download soundfont from https://member.keymusician.com/Member/FluidR3_GM/index.html
vg = VideoGenerator('test0.mid', soundfont_path='FluidR3_GM.sf2')
vg.get_video(output_filename='output.mp4')
Metadata
Release files for harmonization-env 1.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 |
|---|---|---|---|---|
| harmonization_env-1.0.tar.gz | 24.0 kB | Without provenance | Details for harmonization_env-1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| harmonization_env-1.0-py3-none-any.whl | Python 3 | none | any | Details for harmonization_env-1.0-py3-none-any.whl |
Total release size: 59.0 kB
Release files / harmonization_env-1.0.tar.gz
| Download URL | harmonization_env-1.0.tar.gz |
|---|---|
| Size | 24.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aaf52662d70a5ac81a5edfac0924f1fbbee48ca727060b827eda2f3fc05453a7
|
|
BLAKE2b-256 checksum How to use checksums |
7f69d42526b3f047ceea451de93c6cb14fe9f93574e86e1aec03bda95fa6a973
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.11.0
|
Release files / harmonization_env-1.0-py3-none-any.whl
| Download URL | harmonization_env-1.0-py3-none-any.whl |
|---|---|
| Size | 34.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4100fb7a84636a9cc9798c5adee5806b5e30ab444749761d7bf6cf326c773b4b
|
|
BLAKE2b-256 checksum How to use checksums |
66c676b97c39bb7e6d3b3f5b96d9bff6c430376062e63605d1f2d6c4f7b9f952
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.11.0
|
Security for harmonization-env 1.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.