Skip to content

audio.um

Marek Maskarinec edited this page Oct 15, 2022 · 8 revisions

audio.um

 Module for audio loading and playback.

struct Sound*

type Sound* = struct { _: ^struct{} }

Represents an instance of a playable sound. It is an opaque structure.

fn load*

fn load*(path: str): Sound {

Loads a sounds at path, if there is an error, the underlying pointer will be NULL.

fn copy*

fn (s: ^Sound) copy*(): Sound {

Copies the sound. This will create another sound which can be configured and played independently from the original sound.

fn isPlaying*

fn (s: ^Sound) isPlaying*(): bool {

Returns true if the sound is still playing.

fn play*

fn (s: ^Sound) play*() {

Plays the sound.

fn start*

fn (s: ^Sound) start*(): ^Sound {

The start function allows you to play a single sound multiple times. It will create a copy and return a pointer to it, so you can controll it while it is playing. The returned pointer can be discarded.

fn stop*

fn (s: ^Sound) stop*() {

Stops the sound, but keeps the progress. If you want to start from the begginning, use audio.Sound.seekToFrame(0).

fn setVol*

fn (s: ^Sound) setVol*(vol: real32) {

Sets the volume as a multiplier of the base volume.

fn setPan*

fn (s: ^Sound) setPan*(pan: real32) {

Sets the pan of the sound.

fn setPitch*

fn (s: ^Sound) setPitch*(pitch: real32) {

Sets the pitch of the sound.

fn setLooping*

fn (s: ^Sound) setLooping*(looping: bool) {

Sets whether the sound will loop upon finishing.

fn seekToFrame*

fn (s: ^Sound) seekToFrame*(frame: uint) {

Seeks to a specified PCM frame.

fn frameCount*

fn (s: ^Sound) frameCount*(): uint {

Returns length of the sound in PCM frames.

fn setup*

fn setup*() {

INTERNAL

fn cycle*

fn cycle*() {

INTERNAL

Clone this wiki locally