Nimbin[12]?SDL & Graphics / mapcreator / src/audio/audio.hpp

mapcreator git · master

SDL3 2.5D game and engine using assets, with map editor

sdl3 c++ game engine map-editor cmake · first commit 2025-10-31 · last commit 2026-09-07 (1 month ago) · synced 3 days ago · upstream: git.ide3.de/hsnr/sdl-spieleentwicklung/map_creator

C++ 99.3%
git clone https://git.christianimmanuel.de/sdl-graphics/mapcreator.gitwget https://git.christianimmanuel.de/sdl-graphics/mapcreator/archive/mapcreator.tar.gz
src/audio/audio.hpp 692 B · 34 lines raw
#pragma once

#include <SDL3_mixer/SDL_mixer.h>

#define AUDIO_MAX_SOUNDS 64
#define AUDIO_ID_LEN     64

struct AudioSound {
    char id[AUDIO_ID_LEN];
    MIX_Audio* audio;
    MIX_Track* track;
};

class Audio {
public:
    Audio();

    bool RegisterSound(const char* id, const char* filename);
    bool Play(const char* id, SDL_PropertiesID options = 0);
    bool Stop(const char* id, SDL_PropertiesID options = 0);
    bool is_Playing(const char* id);
    void Quit();

private:
    MIX_Mixer* mixer;
    AudioSound sounds[AUDIO_MAX_SOUNDS];
    int sound_count;

    AudioSound* Find(const char* id);

    Audio(const Audio&) = delete;
    Audio& operator=(const Audio&) = delete;
};