Skip to main content

Test Himig on macOS, Linux, and Windows PyPI Python License

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 🎶

Demo preview


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, or R for rest)
    • DURATION: Length in seconds (float or int)
  • Example: ["C4:0.5", "G4:1.0", "R:0.25"]

Built-in Melodies

  • happy_birthday
  • twinkle_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.

Buy Me a Coffee

Metadata

Release files for himig 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for himig 1.0.3
File Size Uploaded Provenance Actions
himig-1.0.3.tar.gz 8.0 kB Without provenance Details for himig-1.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for himig 1.0.3
File Interpreter ABI Platform Actions
himig-1.0.3-py3-none-any.whl Python 3 none any Details for himig-1.0.3-py3-none-any.whl

Total release size: 16.3 kB

Release files / himig-1.0.3.tar.gz

Download URL himig-1.0.3.tar.gz
Size 8.0 kB
Tags Source
SHA-256 checksum
How to use checksums
f06ff4b1cee7edf756f50246e3b29c34ef4202d4b3b8aa20e04f2d9b7102b687
BLAKE2b-256 checksum
How to use checksums
770897879ebdb3dd0058f8bff134cda848251eb72bc2221ffd65ecf053d7bcfb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Release files / himig-1.0.3-py3-none-any.whl

Download URL himig-1.0.3-py3-none-any.whl
Size 8.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c5ae9c09d819ad39cbebfd109107cbce6f9c0bba3e58181d514803032a2ca730
BLAKE2b-256 checksum
How to use checksums
9314496c70cdc75630839820494cdc4aafacc809fc6d710a8005e49651bbe52a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Security for himig 1.0.3

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page