Labyrinth
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
audio.hpp
1 //////////////////////////////
2 //
3 // File: lxs/audio/audio.hpp
4 // Author: Maciej Kaminski
5 // E-mail: maciej.a.kaminski@gmail.com
6 // Website: maciejkaminski.pl
7 //
8 // File creation date: Nov 2 2012
9 // This file is part of Project Labyrinth
10 // This file is going to be released under terms of GNU GPL in near future
11 //
12 //////////////////////////////
13 
14 #ifndef __LXS_AUD_
15 #define __LXS_AUD_
16 #include <string>
17 #include "helper/openal.hpp"
18 #include "lxs/audio/oggdatasource.hpp"
19 
20 namespace LxS
21 {
22  //!@brief this is namespace for audio processing, including decoding and playing soundtrack
23  namespace Audio
24  {
25  class BGM;
26  //! global object for managing sound system. While it's not implemented as a singleton, it by design should be
27  class Audio
28  {
29  BGM * p_BGM;
30  BGM * p_BGM_tmp; // temporary BGM object for soundtrack transistions
31  BGM * UISFX; // sfx for UI
32  BGM * SFX1; // SFX for game
33  float volume;
34  ALCdevice* device;
35  ALCcontext* context;
36  bool initialized;
37  //void BGMPlay();// separate thread;
38  float BGM_vol_multiplier;
39  public:
40  Audio ();
41  ~Audio();
42  //! is soundsystem initialized?
43  bool IsInitialized() { return initialized;}
44  //! initialize sound system
45  void Initialize();
46  //! start playing sounds
47  void Play();
48  //! global volume multiplier for sound system
49  float GetGlobalVolume();
50  //! how loud?
51  void SetGlobalVolume(float volume);
52  //! uninitialize sound system
53  void UnloadResources();
54  //! select bgm playlist
55  //! \param playlist_name - filename of BGM file to start new playlist with
56  //! \param transition - fade out/in if true; rapid soundtrack switch if false
57  void SetPlaylist(std::string playlist_name,
58  bool transition);
59 
60  //! append track to current BGM
61  void AddToPlaylist(std::string file_name);
62  //! volume multiplier for background music;
63  void SetBGMVolumeMultiplier(float m);
64  //! return track that is currently being played
65  std::string & GetNowPlaying();
66 
67  //! play sound effect
68  void PlaySFX(std::string file_name);
69  //! play UI soundeffect
70  void PlayUISFX(std::string file_name);
71 
72  //! is soundtrack being played
73  bool IsPlaying();
74  };
75 
76  }
77 
78 }
79 
80 #endif