Skip to content

This is an IPython extension module that adds support for integrated audio files from Abjad MIDI output.

Notifications You must be signed in to change notification settings

LoyolaChicagoDigitalHumanities/abjad-ipy-midi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Abjad-MIDI IPython Extension

This is an IPython module that renders Abjad expressions as HTML5 <audio> tags inside Notebooks. Rendering relies on Fluidsynth and a SoundFont, which you can find here or you can source your own. A particularly good list of soundfonts is provided on the MuseScore pages. It works by replacing the top-level play() method in Abjad.

The module can be loaded into your own notebooks using the example code below:

from abjad import *
%load_ext abjad_midi.ext.ipython
loadSoundFont('path/to/soundfont.sf2', 'gm')

pitch_numbers = 4 * [0, 2, 4, 9, 7]
duration = Duration(1, 8)
notes = scoretools.make_notes(pitch_numbers, duration)
staff = Staff(notes)
play(staff)

This project was inspired by the wonderful work of Tiago Antao, which was recently integrated into the Abjad project.

Prerequisites

This project requires installations of IPython, Abjad, Fluidsynth and FFmpeg. You can follow the instructions on Jazz Patterns repository for a proper install of Abjad in a virtual environment. Fluidsynth is easily available in most packages managers, or directly from their Sourceforge project page, just make sure that the binary is within your PATH.

You will also need to find a SoundFont file, which is a collection of samples that Fluidsynth uses to render MIDI data as audio. There are many free and commercial ones available, or you can even make your own. One of the best open source SoundFonts available is the FluidR3 project; the General MIDI (GM) font contains many instruments including pianos, guitars, and drums. SoundFonts do not require installation, so you can keep your SoundFonts in the same folder as your IPython notebooks or collect them in your Python virtual environment.

A brief note about Fluidsynth. On OS X, especially if using HomeBrew, you need to ensure libsndfile support is compiled in. Otherwise, no output formats are supported (except raw).

brew install --with-libsndfile fluidsynth
brew insatll ffmpeg

MacPorts

port install fluidsynth
port install ffmpeg

Installation

This project uses setuptools, so installation is as easy as:

git clone https://github.com/ctsdh-luc-edu/abjad-ipy-midi
cd abjad-ipy-midi
python setup.py install

We're at an early stage in our overall project, so we don't provide a standard Python package for direct installation via pip. For the most part, our effort is following some moving targets (including Abjad), which we build from repository instead of using pip.

We strongly encourage working in a Python virtualenv, which is greatly helpful for setting up experimental software without cluttering your global site packages (site-packages) folder.

About

This is an IPython extension module that adds support for integrated audio files from Abjad MIDI output.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages