Module

Audio.SoundFont

#AudioBuffer

data AudioBuffer :: Type

The SoundFont API which we will expose the Audio Buffer for a single note

#Instrument

type Instrument = Tuple InstrumentName SoundFont

an instrument name attached to its SoundFont

#InstrumentChannels

type InstrumentChannels = Map InstrumentName Int

the mapping of instrument names to MIDI channels

#MidiNote

type MidiNote = { channel :: Int, duration :: Number, gain :: Number, id :: Int, timeOffset :: Number }

A Midi Note

#SoundFont

type SoundFont = Map Int AudioBuffer

the instrument soundfont a mapping between MIDI pitch and the note's AudioBuffer

#canPlayOgg

canPlayOgg :: Effect Boolean

can the browser play ogg format ?

#isWebAudioEnabled

isWebAudioEnabled :: Effect Boolean

is the browser web-audio enabled ?

#setNoteRing

setNoteRing :: Number -> Effect Unit

setting for how long the note 'rings' after it's alloted time in order to support features such as a more legato feel This should be a number between 0 (no ring) and 1 (double the original note duration)

#logLoadResource

#loadInstrument

loadInstrument :: Maybe String -> InstrumentName -> Aff Instrument

load a single instrument SoundFont The options are to load the soundfont from: Benjamin Gleitzman's server (default) A directory from the local server if this is supplied

#loadInstruments

loadInstruments :: Maybe String -> Array InstrumentName -> Aff (Array Instrument)

load a bunch of instrument SoundFonts (in parallel) again with options to load either locally or remotely from Benjamin Gleitzman's server

#loadRemoteSoundFonts

loadRemoteSoundFonts :: Array InstrumentName -> Aff (Array Instrument)

load a bunch of soundfonts from the Gleitzmann server

#loadPianoSoundFont

loadPianoSoundFont :: String -> Aff Instrument

load the piano soundfont from a relative directory on the local server

#playNote

playNote :: Array Instrument -> MidiNote -> Effect Number

play a single note through its soundfont buffer. if the note cannot be played because it: uses an invalid instrument has a note index that can't be resolved then treat the note as a Rest, with its stated duration

#playNotes

playNotes :: Array Instrument -> Array MidiNote -> Effect Number

play a bunch of notes asynchronously return the duration of the phrase (i.e. the time offset plus duration of the last note in the phrase)

#instrumentChannels

instrumentChannels :: Array Instrument -> InstrumentChannels

create a map of instrument name to channel from an Instrument Array

Modules