Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

8bit-music-lib (English)

This is a Python library for playing 8-bit style chiptune music.

日本語READMEはこちら

  • Compatible with Jupyter Notebook, so it can also run on Google Colaboratory.
  • Recommended for those who want to quickly try playing 8-bit music.
  • In the future, support for importing and exporting MML and MIDI files is planned.

Note
Waveforms are quantized to 8-bit resolution, but for compatibility with playback libraries,
the output format is 16-bit PCM array.


File Structure

8bit-music-lib
├── music8bit
│   ├── __init__.py
│   ├── mixer.py
│   ├── notes.py
│   ├── part.py
│   ├── utils.py
│   └── wave.py
├── .gitignore
├── CHANGELOG.md
├── LICENSE
├── README.md
├── README_ja.md
└── setup.py

Installation

It is recommended to install with a playback library.

Recommended: via sounddevice (Windows/macOS/Linux)

pip install 8bit-music-lib[sounddevice]

Alternative: via simpleaudio (requires C++ build tools on Windows)

pip install 8bit-music-lib[simpleaudio]

Jupyter Notebook / Google Colaboratory

Useful for playing audio and displaying waveforms directly in the notebook.
On Colab, add ! at the beginning of the command:

pip install 8bit-music-lib[jupyter]

Minimal installation

pip install 8bit-music-lib

Only waveform generation is available; audio playback is not supported.


Importing

Simple import:

from music8bit import *

To avoid conflicts with other modules:

import music8bit as m8

Example (Simple Demo: Twinkle Twinkle Little Star)

import music8bit as m8

# Define notes
notes = [
    (['C5'],1), (['C5'],1), (['G5'],1), (['G5'],1),
    (['A5'],1), (['A5'],1), (['G5'],2),
    (['F5'],1), (['F5'],1), (['E5'],1), (['E5'],1),
    (['D5'],1), (['D5'],1), (['C5'],2)
]

# Define a part
part1 = m8.Part(
    melody=notes,
    volume=0.5,
    generator=m8.SquareWave(),
    first_bpm=120
)

# Create a song
song = m8.SongMixer([part1])

# Play
song.play()

Detailed usage, complex examples, and explanations of each class are summarized in the Wiki.


Afterword

This library was created out of the developer's personal desire to play music on Google Colab,
and turned into a library that anyone can use.

Honestly, the usability and completeness are limited.
For creating proper music, using MML or a DAW is much easier.
If you can run Pygame, convenient external libraries like Musicpy are also available in Python.

To those who still enjoy using this library, I hope you have a good 8-bit life.

Metadata

Release files for 8bit-music-lib 0.2.2

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

Source distribution (sdist)

Source distribution for 8bit-music-lib 0.2.2
File Size Uploaded Provenance Actions
8bit_music_lib-0.2.2.tar.gz 9.9 kB Without provenance Details for 8bit_music_lib-0.2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for 8bit-music-lib 0.2.2
File Interpreter ABI Platform Actions
8bit_music_lib-0.2.2-py3-none-any.whl Python 3 none any Details for 8bit_music_lib-0.2.2-py3-none-any.whl

Total release size: 21.0 kB

Release files / 8bit_music_lib-0.2.2.tar.gz

Download URL 8bit_music_lib-0.2.2.tar.gz
Size 9.9 kB
Tags Source
SHA-256 checksum
How to use checksums
69e5d2a0afb43527deab539a61e55a286e162f75023ccf6eb1e097238de8d93b
BLAKE2b-256 checksum
How to use checksums
b45e156407a6c6b1a01a577c8dc7d7abaee00efca59fddf7ad1b2df59d651529
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release files / 8bit_music_lib-0.2.2-py3-none-any.whl

Download URL 8bit_music_lib-0.2.2-py3-none-any.whl
Size 11.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a08683004c9e2678dcc2014da09a45dddffbc50de4432a01a7e1228743420e64
BLAKE2b-256 checksum
How to use checksums
0b82fd6a59cc23a2241ca0f6297635ddf619b40139574efdd40d457cb0b2ef50
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Security for 8bit-music-lib 0.2.2

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