ASW Lib
A.D.S. Games SDL Wrapper Library. A library targeted at Allegro4 users who want to switch to SDL3 and use modern c++.
Loading...
Searching...
No Matches
sound.cpp
Go to the documentation of this file.
2
3#include <SDL3_mixer/SDL_mixer.h>
4
5void asw::sound::play(const asw::Sample& sample,
6 int volume,
7 unsigned char pan,
8 int loop) {
9 const int channel = Mix_GroupAvailable(0);
10 Mix_VolumeChunk(sample.get(), volume);
11 Mix_SetPanning(channel, pan, 255 - pan);
12 Mix_PlayChannel(-1, sample.get(), loop);
13}
14
15void asw::sound::playMusic(const asw::Music& sample, int volume) {
16 Mix_VolumeMusic(volume);
17 Mix_PlayMusic(sample.get(), -1);
18}
19
21 Mix_HaltMusic();
22}
void play(const asw::Sample &sample, int volume=255, unsigned char pan=128, int loop=0)
Play a sample.
Definition sound.cpp:5
void stopMusic()
Stop the currently playing music.
Definition sound.cpp:20
void playMusic(const asw::Music &sample, int volume=255)
Play a music sample.
Definition sound.cpp:15
std::shared_ptr< Mix_Chunk > Sample
Alias for a shared pointer to an Mix_Chunk.
Definition types.h:26
std::shared_ptr< Mix_Music > Music
Alias for a shared pointer to an Mix_Music.
Definition types.h:29
Sound module for the ASW library.