The Table Engine
sound.h
Go to the documentation of this file.
1 
10 #pragma once
11 
12 #include <string>
13 #include <iostream>
14 #include <SDL2/SDL.h>
15 #include <SDL2/SDL_mixer.h>
16 
25 struct Sound {
26  Mix_Chunk* m_sound;
27 
36  Sound(std::string path);
37 
45  void play(int loops);
46 
52  void stop();
53 
59  void pause();
60 
66  void resume();
67 
75  void setVolume(int volume);
76 
83  ~Sound();
84 };
Encapsulates sound management functionality using SDL_mixer.
Definition: sound.h:25
void stop()
Stops all sound on the channel used by this sound.
~Sound()
Destructor that frees the loaded sound.
void play(int loops)
Plays the loaded sound.
void resume()
Resumes all paused sound on the channel used by this sound.
void pause()
Pauses all sound on the channel used by this sound.
void setVolume(int volume)
Sets the volume for the channel used by this sound.
Sound(std::string path)
Constructor that initializes the SDL_mixer and loads sound from a specified path.
Mix_Chunk * m_sound
Pointer to the sound data loaded from a file.
Definition: sound.h:26