termtab-0.1.0.0: TUI guitar tablature and score editor
Safe HaskellNone
LanguageGHC2021

Termtab.Audio.FluidSynth

Description

The FluidSynth backend for AudioEngine: owns a settings/synth/audio-driver triple from Termtab.Audio.FluidSynth.Raw and exposes it as domain-typed operations (noteOn, noteOff, programChange take Types newtypes, not raw CInts). Termtab.Audio dispatches to this module whenever BackendFluidSynth is selected.

Synopsis

Documentation

data FluidSynthEngine Source #

An initialized FluidSynth instance: settings, synth, and audio driver handles that must all be torn down together (see shutdownFluidSynth) in the reverse of their creation order.

initFluidSynth :: AudioConfig -> IO FluidSynthEngine Source #

Bring up a FluidSynth instance: create settings, force the platform-appropriate audioDriverName, create the synth, load the SoundFont from acSoundFontPath, then start the audio driver. Each step that can fail tears down everything created so far before throwing the corresponding FluidSynthError, so callers never get a half-initialized FluidSynthEngine.

shutdownFluidSynth :: FluidSynthEngine -> IO () Source #

Tear down a FluidSynthEngine in the reverse of initFluidSynth's creation order: audio driver, then synth, then settings.

withFluidSynth :: AudioConfig -> (FluidSynthEngine -> IO a) -> IO a Source #

Initialize a FluidSynthEngine, run an action with it, and shut it down afterwards even on exception (via bracket).

noteOn :: FluidSynthEngine -> MidiChannel -> Pitch -> Velocity -> IO () Source #

Start a note sounding on the given channel/pitch/velocity.

noteOff :: FluidSynthEngine -> MidiChannel -> Pitch -> IO () Source #

Stop the note previously started with noteOn at the same channel/pitch.

programChange :: FluidSynthEngine -> MidiChannel -> MidiProgram -> IO () Source #

Switch the given channel to the given General MIDI program (instrument patch) from the loaded SoundFont.