| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Termtab.Audio
Description
Backend-agnostic handle for sound playback.
AudioEngine hides which synthesis backend is actually in use behind a
single opaque type; today the only implemented backend is FluidSynth
(see Termtab.Audio.FluidSynth). The engine* functions here are
direct, synchronous calls meant for simple one-off sounds (e.g. an
editor "preview this note" action); driving full-song playback with
correct timing instead goes through Termtab.Audio.Playback and
Termtab.Audio.PlaybackThread, which queue AudioCommands (re-exported
from Termtab.Audio.Types) rather than calling these directly.
Synopsis
- data AudioEngine
- startAudioEngine :: BackendType -> AudioConfig -> IO AudioEngine
- stopAudioEngine :: AudioEngine -> IO ()
- withAudioEngine :: BackendType -> AudioConfig -> (AudioEngine -> IO a) -> IO a
- engineNoteOn :: AudioEngine -> MidiChannel -> Pitch -> Velocity -> IO ()
- engineNoteOff :: AudioEngine -> MidiChannel -> Pitch -> IO ()
- engineProgramChange :: AudioEngine -> MidiChannel -> MidiProgram -> IO ()
- module Termtab.Audio.Types
Documentation
data AudioEngine Source #
An initialized backend, ready to receive note events. Opaque to
callers outside this module — dispatch on which backend is active
happens only in the engine* functions below via BackendHandle.
startAudioEngine :: BackendType -> AudioConfig -> IO AudioEngine Source #
Initialize the requested backend. BackendPortMidi is not yet backed
by an engine implementation and calling it errors immediately —
callers should only pass BackendFluidSynth until that lands.
stopAudioEngine :: AudioEngine -> IO () Source #
Release the resources held by an AudioEngine. Prefer withAudioEngine
over calling this directly so shutdown still happens on exception.
withAudioEngine :: BackendType -> AudioConfig -> (AudioEngine -> IO a) -> IO a Source #
Start a backend, run an action with it, and shut it down afterwards
even if the action throws (via bracket).
engineNoteOn :: AudioEngine -> MidiChannel -> Pitch -> Velocity -> IO () Source #
Send a note-on directly to the audio backend (synchronous).
engineNoteOff :: AudioEngine -> MidiChannel -> Pitch -> IO () Source #
Send a note-off directly to the audio backend (synchronous).
engineProgramChange :: AudioEngine -> MidiChannel -> MidiProgram -> IO () Source #
Send a program change directly to the audio backend (synchronous).
module Termtab.Audio.Types