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'
###notes: 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 import band
b=Band()
b.play('music.json')
If you want to save the music into a wav file:
from musicjson import band
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.1.tar.gz
.
File metadata
- Download URL: musicjson-0.0.1.tar.gz
- Upload date:
- Size: 4.7 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 | 76cba82c6aab6c87ba5ccfc4050b674a32f1ee7415244f18278001cc7dddb7f8 |
|
MD5 | 7ab911ba6d12ca2ed2814bbc5cb3da1a |
|
BLAKE2b-256 | 3881230214cde1ac1d4a50281ea788fbdcf5198ce33828848f93f7fa0218d154 |
File details
Details for the file musicjson-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: musicjson-0.0.1-py3-none-any.whl
- Upload date:
- Size: 5.2 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 | 349660946472a38362a9c8764f82118d258e82740f69b64d15b9320bb2fa02f8 |
|
MD5 | a8089eeb92d741fa75139cc03f640197 |
|
BLAKE2b-256 | 013a5773c76fb4f9b2eee8a881a923be31bd98b183d30b52cd3f46e4e867dec2 |