Skip to content

audio.um

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

audio.um

 Module for audio loading and playback.

struct Sound*

type Sound* = struct {
	looping: bool
	volume: th.fu
	path: str
}

A structure used to create playbacks.

struct Playback*

type Playback* = struct{
	decoder: ^struct{}
	// Indicates if the sound is playing.
	playing: bool
	// If set to true, playback will be paused.
	paused: bool
	// If true, playback will keep on playing again after it ends.
	looping: bool
	// Multiplier of the volume.
	volume: th.fu
	// Sets the current PCM frame. Write only.
	frame: int
}

Playback is a currently played instance of a sound. The properties are set to the value the sound has. sound.play returns a pointer. Be sure to keep it if you want to change the sound while its playing.

fn load*

fn load*(path: str): Sound {

Loads sound at a path.

fn play*

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

Plays the sound.

Clone this wiki locally