Python music synthesis module that lets you compose, play, and save melodies
Project description
Himig
himig is a Python music synthesis module that lets you compose, play, and save melodies.
Features
- Compose melodies using note names and durations
"NOTE:DURATION"format (e.g.,"C4:0.5"). - Play melodies directly on your system audio.
- Save melodies as WAV files.
- Generate in-memory WAV bytes for web apps.
- Sample built-in melodies: Happy Birthday, Twinkle Twinkle, Ode to Joy, Für Elise.
- Lightweight: Only depends on numpy.
Demo
Himig Playground on Streamlit Cloud 🎶
Installation
pip install himig
Or, for development:
git clone https://github.com/j-ncel/himig.git
cd himig
pip install -e .
Usage
Play a Melody
from himig import play
melody = ["C4:0.5", "C4:0.5", "G4:1.0"]
play(melody)
Save a Melody as WAV
from himig import save
melody = ["C4:0.5", "C4:0.5", "G4:1.0"]
save(melody, "happy.wav")
Use Built-in Melodies
from himig import play, happy_birthday, twinkle_twinkle
play(happy_birthday)
play(twinkle_twinkle)
Use in Streamlit
import streamlit as st
from himig import generate_wav_bytes, happy_birthday
wav_bytes = generate_wav_bytes(happy_birthday)
st.audio(wav_bytes, format="audio/wav")
Melody Format
- Each melody is a list of strings:
"NOTE:DURATION"NOTE: Note name (e.g.,C4,F#5,Bb3, orRfor rest)DURATION: Length in seconds (float or int)
- Example:
["C4:0.5", "G4:1.0", "R:0.25"]
Built-in Melodies
happy_birthdaytwinkle_twinkle
You can import them directly:
from himig import happy_birthday, twinkle_twinkle
You can contribute more melodies to the project—contributions are welcome!
Project Structure
himig/
│
├── himig/
│ ├── __init__.py
│ ├── _core.py
│ ├── _audio_player.py
│ ├── constants.py
│ └── melodies.py
├── playground/
│ ├── st-playground.py
│ └── demo.gif
├── tests/
│ └── test_himig.py
├── README.md
├── pyproject.toml
├── requirements.txt
└── LICENSE
Links
License
This project is licensed under the MIT License. See the LICENSE file for details.
Project details
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file himig-1.0.3.tar.gz.
File metadata
- Download URL: himig-1.0.3.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f06ff4b1cee7edf756f50246e3b29c34ef4202d4b3b8aa20e04f2d9b7102b687
|
|
| MD5 |
00d9cfee2ee5d6473ef244214541ae41
|
|
| BLAKE2b-256 |
770897879ebdb3dd0058f8bff134cda848251eb72bc2221ffd65ecf053d7bcfb
|
File details
Details for the file himig-1.0.3-py3-none-any.whl.
File metadata
- Download URL: himig-1.0.3-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5ae9c09d819ad39cbebfd109107cbce6f9c0bba3e58181d514803032a2ca730
|
|
| MD5 |
ba6a1f5af90a724ddf98c28d62fc7762
|
|
| BLAKE2b-256 |
9314496c70cdc75630839820494cdc4aafacc809fc6d710a8005e49651bbe52a
|