Fireset
Loading...
Searching...
No Matches
audio.h
1// Copyright (c) 2025-2026 Henrique Rodrigues Santos
2// Licensed under the MIT License
3// Github: https://github.com/saintsHr/Fireset
4
5#pragma once
6
7#include <AL/al.h>
8#include <AL/alc.h>
9#include <stdbool.h>
10
11#include "fireset/vector.h"
12
18
24typedef struct {
27 int bps;
28 long frames;
29 short* samples;
30 ALenum format;
31 ALuint buffer;
32} FsSound;
33
39typedef struct {
40 ALuint handle;
42 bool looping;
43 bool playing;
45
54FsSound fsSoundLoad(const char* filename);
55
63void fsSoundFree(FsSound* sound);
64
74FsSoundSource fsSoundSourceCreate(FsVec2 position, bool looping);
75
85void fsSoundSourcePlay(FsSound* sound, FsSoundSource* source, float volume);
86
95
103void fsSoundSourceFree(FsSoundSource* source);
104
113void fsSoundSourceHandle(int count, FsSoundSource* sources);
114
127
FsSound fsSoundLoad(const char *filename)
Loads a sound from file.
Definition audio.c:12
void fsSoundSourceStop(FsSoundSource *source)
Stops a sound source.
Definition audio.c:143
void fsSoundSourceHandle(int count, FsSoundSource *sources)
Updates multiple sound sources.
Definition audio.c:87
void fsSoundListenerSetPosition(FsVec2 position)
Sets the audio listener position.
Definition audio.c:191
void fsSoundSourceFree(FsSoundSource *source)
Frees a sound source.
Definition audio.c:177
FsSoundSource fsSoundSourceCreate(FsVec2 position, bool looping)
Creates a new sound source.
Definition audio.c:77
void fsSoundSourcePlay(FsSound *sound, FsSoundSource *source, float volume)
Plays a sound on a source.
Definition audio.c:112
void fsSoundFree(FsSound *sound)
Frees a loaded sound.
Definition audio.c:163
Represents a sound source in 2D space.
Definition audio.h:39
FsVec2 position
Definition audio.h:41
ALuint handle
Definition audio.h:40
bool playing
Definition audio.h:43
bool looping
Definition audio.h:42
Represents a loaded sound buffer.
Definition audio.h:24
int channels
Definition audio.h:25
short * samples
Definition audio.h:29
ALuint buffer
Definition audio.h:31
int sampleRate
Definition audio.h:26
long frames
Definition audio.h:28
ALenum format
Definition audio.h:30
int bps
Definition audio.h:27
2D vector.
Definition vector.h:18