Package

purescript-soundfonts

Repository
newlandsvalley/purescript-soundfonts
License
MIT
Uploaded by
newlandsvalley
Published on
2018-02-16

Latest release Build Status

This library allows you to play music directly in the browser using a variety of instruments. These are provided, courtesy of Benjamin Gleitzman's package of pre-rendered sound fonts. You can either load them remotely from the Gleitzman GitHub account or else host then locally on your own server. They load as dictionaries of AudioBuffers - one for each note on each selected instrument. Once loaded. you can play individual notes or groups of notes on your instruments of choice.

Also included is conversion to a Melody type which is suitable for use in a soundfont player widget.

The conversion of a Gleitzman note name (e.g. Ab4) to a MIDI pitch uses middle C = C4.

Acknowledgements

The design in very heavily influenced by danigb's JavaScript soundfont project: soundfont-player and in fact initial versions of this library simply wrapped his. However, this version minimises the amount of native JavaScript which is still necessary in order to wrap Web-Audio functions. These are used in the following places:

  • When building an AudioBuffer for each note in an instrument SoundFont.
  • When playing a note that uses an AudioBuffer.
  • In functions canPlayOgg and isWebAudioEnabled.

Installation

bower install purescript-soundfonts

Module documentation

Module documentation is published on Pursuit.