package bogue

  1. Overview
  2. Docs

Basic audio mixer for sound effects.

This simple audio mixer makes it possible to play quick sounds, for instance when clicking on buttons, or for game sounds effects.

Only WAV files are supported. For playing MP3 music, and for more options, it is advisable to use the SDL_Mixer library.

Remark: This module is essentially independent of the rest of Bogue, so its source can, with very few modifications, be used for any SDL application.

Remark: Under Windows, using WLS2, it was reported that sound works if wslg is installed.

Dependency graph
type t
type sound = (int, Stdlib.Bigarray.int16_signed_elt) Tsdl.Sdl.bigarray
type repeat =
  1. | Repeat of int
  2. | Forever
val test : unit -> unit
val init : unit -> string option

Initialize SDL audio.

  • returns

    the name of the audio driver, or None if no audio is available.

val create_mixer : ?tracks:int -> ?freq:int -> string option -> t

create devname creates the mixer an opens the sound device. If devname is None, a dummy mixer is returned, which will produce no sound. Only s16le format is supported by the callback at this time. The mixer is initially paused, you need to unpause it before playing anything.

val load_chunk : t -> string -> sound

Load a WAV file.

val play_chunk : ?track:int -> ?effects:(sound -> unit) list -> ?volume:float -> ?repeat:repeat -> t -> sound -> int option

Play chunk on the desired track number. If track is not specified, find an available track. By default repeat = Repeat 1.

  • returns

    chosen track number, or None

val change_volume : float -> sound -> unit

Multiply sound intensity by a float factor

val pause : t -> unit
val unpause : t -> unit
val close : t -> unit