A Python library for generative music
By Hay Kranen
bbgen is a Python library that allows you to make generative music. It is designed for non-realtime use: you shouldn't be using this library for a performance.
bbgen is a wrapper around a couple of other libraries that perform most of the heavy lifting, this includes pydub for composing / editing audio files, pedalboard for effects, dawdreamer for rendering midi and isobar for generating the music.
bbgen is most definitely a work in progress, and it desperately needs documentation which i haven't written yet. But you can look in the test
folder for a couple of examples.
I have ran bbgen on macOS 14.6.1 on an Apple M1 processor, and it also works on Linux (Ubuntu 22.04 LTS). I haven't tested on Windows yet.
Render a MIDI file using a sampler like this:
from bbgen.dreampler import Dreampler
from mido import MidiFile, Message
from pydub import AudioSegment
midi = MidiFile("satie.mid")
clarinet = AudioSegment.from_wav("clarinet.wav")
Dreampler(clarinet).render_midi(midi).export("satie-dreampler.mp3")
You probably need to install Fluidsynth and i guess ffmpeg as well.
I've tested bbgen on Python 3.10. It might run on newer versions as well but i haven't tested that yet.
This is should work:
- Clone this repo
git clone https://github.com/hay/bbgen.git
- Make a virtual environment and install the
requirements.txt
python -m venv env
source env/bin/activate
pip install -r requirements.txt
- Try running the
samplers.py
example intest
to showcase the three different samples available in bbgen:
cd test
python samplers.py
- Documentation
- Speed up the samplers (esp.
Dreampler
andDreamstrument
are very slow)
MIT © Hay Kranen