Wolf3D
sample.hpp
Go to the documentation of this file.
1 
12 #pragma once
13 #include <SDL2/SDL_mixer.h>
14 
15 #include <memory>
16 #include <string>
17 
18 class Sample {
19  public:
20  //
28  Sample(const std::string &path, int volume, bool stack = false);
29 
34  void play();
35 
41  void play(int times);
42 
48  void set_volume(int volume);
49 
50  private:
51  // The chunk for storing the sound effect in
52  std::unique_ptr<Mix_Chunk, void (*)(Mix_Chunk *)> chunk;
53  // The channel being used for playing back the audio, used to prevent stacking
54  int playing_channel = -1;
55  // If stacking is allowed
56  bool stack = false;
57 };
Definition: sample.hpp:18
void play()
Play the Sample on a free mixer channel.
Definition: sample.cpp:15
void set_volume(int volume)
Set the volume of the Sample.
Definition: sample.cpp:35
Sample(const std::string &path, int volume, bool stack=false)
Construct the Sample object.
Definition: sample.cpp:3