Play with sound: compose notes in JSON and play it
Project description
musicJSON
Author: David WANG
- This runs like a midi player: user writes notes in JSON file and listen it.
- Adjust the sound with your knowledge in synthesis
Although there is musicXML files, which are more professional, musicXML is too complicated for human to read.
Installation:
pip install musicjson
Usage:
(1) First, you need to create a JSON file with the following format, and save it in the same folder of your program. Assumed its name is 'music.json'
Or, you can go to get a ready JSON file in my homepage:
https://github.com/DavidWang2AI/musicjson/tree/main/data
- Remarks:
a) tempo: relative speed
b) band: how many parts, to be played simultaneously
c) data: the notes: key name followed by length. To make it readable by human, please try to keep each division in a line.
In the following sample, there are 2 parts to be played at the same time.So the total length in time for each of them is equal. The key names placed in the same square bracket are chord, ie to be played at the same time. "O" is the rest.
{
"tempo": 2.1,
"band": 2,
"data": [
[
["A4",0.333],["C5",0.333],["E5",0.334],["A5",0.333],["C6",0.333],["E6",0.334],["D6",0.333],["C6",0.333],["B5",0.334],
["A5",0.333],["C6",0.333],["E6",0.334],["A6",0.333],["C7",0.333],["E7",0.334],["D7",0.333],["C7",0.333],["B6",0.334],
["a6",0.333],["A6",0.333],["g6",0.334],["G6",0.333],["f6",0.333],["F6",0.334],["E6",0.333],["d6",0.333],["D6",0.334],
["c6",0.333],["C6",0.333],["B5",0.334],["a5",0.333],["A5",0.333],["g5",0.334],["G5",0.333],["f5",0.333],["F5",0.334],
["E5",0.5],["d5",0.5],["E5",0.5],["B4",0.5],["D5",0.5],["C5",0.5]
],
[
[["E4","C4","A3"],1],["O",1],[["E4","C4","A3"],1],
[["E4","C4","A3"],1],["O",1],[["E4","C4","A3"],1],
[["E4","C4","A3"],1],["O",2],
["O",2],["O",1],
["O",2],["O",1]
]
]
}
(2) Run the following script to play the notes you composed in JSON file ("music.json for this example"):
from musicjson.band import *
b=Band()
b.play('music.json')
If you want to save the music into a wav file:
from musicjson.band import *
b=Band()
b.play('music.json', save=True, savefile='music.wav')
About the Author
I am currently in Grade 11 (as of 1st half of 2022). I have great interests in AI trading and real world simulation with C++, Java and Python.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file musicjson-0.0.2.tar.gz
.
File metadata
- Download URL: musicjson-0.0.2.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce29fbd367affa8311d6dfb1618d9b180c724ee9325f3be17dbf71ba2397cc80 |
|
MD5 | 57deddb30ef4d77115fd2e2f60483946 |
|
BLAKE2b-256 | 82eaf722bc2946846d9fde018220668d765db475f1dd05e3e6b1330397f0cc98 |
File details
Details for the file musicjson-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: musicjson-0.0.2-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7672f2d2b35dc464d6f2651810fedadfd084e66d1f2b59bfa6f2c127c403aadb |
|
MD5 | 96d746cce22b791d0de396f76e93dc38 |
|
BLAKE2b-256 | c46860bcc539cf976a1ac07e748faf8996d7a0fa463184d83854f3f64aad5d34 |