Skip to main content

Library to programmatically play piano

Project description

PyPiano

PyPiano is a python library to programmatically play piano. It is an easy-to-use abstraction layer on top of the python-mingus package providing a simple user interface to play mingus music containers, such as Notes, NoteContainers, Bars and Tracks. It bundles a default sound fonts file to enable playing and recording audio out of the box. By default, 8 different pianos are available. It allows playing Piano via audio output or recording music to wav files.

Installation

For PyPiano to work you need Fluidsynth to be installed. Please check the Fluidsynth website on how to install Fluidsynth on your system. You can install PyPiano using pip:

pip install git+https://github.com/FelixGSE/pypiano.git

Usage

from pypiano import Piano
from mingus.containers import Note

p = Piano()

# Play a simple C-4 via audio
p.play("C-4")

# Play a mingus Note
note = Note("C-4")
p.play(note)

# Record a Note to a wav file
p.play(note, recording_file="my_first_recording.wav", record_seconds=2)

# Use a different instrument
p.load_instrument("Honky-tonk Piano")
p.play(note)

The same code works with more complex mingus containers like, NoteContainers, Bars and Tracks

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Please make sure to update tests as appropriate.

Note that the sound fonts are checked in as Git large file. If you have git-lfs installed the bundled sound font files in pypiano/sound_fonts/FluidR3_GM.sf2 should be cloned automatically. If not, you should install git-lfs and fetch them after.

Know issues

The default sound fonts were taken from the fluid-soundfont debian package (check /scripts/get_default_sf_file.py for details). The file contains 194 instruments of which only 8 are used within this project, thus making the package unnecessarily large. All 186 unused instruments should be removed from the shipped sound fonts to reduce package size. It is an open task to find out how to safely remove unused instruments.

License

  • PyPiano is distributed under MIT license - Check corresponding license file
  • Default sound fonts are distributed under MIT license - Check corresponding license file

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pypiano-0.1.0-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file pypiano-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pypiano-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for pypiano-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8f1645cb4efcc906636ff21cdaf0b11a36e8f7b06b50ba5d0aee1b3474947264
MD5 38952fb48267600c0edebead8a668fa2
BLAKE2b-256 8d2debfa3202eaaf394f1072ad83bd793c6089c123da3aa57a725dce4f5f7fe6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page