Leviathan  0.8.0.0
Leviathan game engine
SoundDevice.h
Go to the documentation of this file.
1 // Leviathan Game Engine
2 // Copyright (c) 2012-2018 Henri Hyyryläinen
3 #pragma once
4 #include "Define.h"
5 // ------------------------------------ //
6 #include "AudioSource.h"
7 #include "ProceduralSound.h"
8 
9 #include "Common/Types.h"
10 
11 namespace cAudio {
12 
13 class IAudioManager;
14 class IListener;
15 } // namespace cAudio
16 
17 namespace Leviathan {
18 
20 class SoundDevice {
21 public:
24 
27  DLLEXPORT bool Init(bool simulatesound = false, bool noconsolelog = false);
28  DLLEXPORT void Release();
29 
30  DLLEXPORT void Tick(int PassedMs);
31 
38  // DLLEXPORT bool PlaySoundEffect(const std::string& file);
39 
40  DLLEXPORT void SetSoundListenerPosition(const Float3& pos, const Float4& orientation);
41 
43  DLLEXPORT void SetGlobalVolume(float vol);
44 
45 
46  // ------------------------------------ //
47  // Audio playing functions
48 
50  DLLEXPORT void Play2DSoundEffect(const std::string& filename);
51 
59  const std::string& filename, bool looping, bool startpaused);
60 
61 
65  ProceduralSoundData::pointer data, const char* soundname);
66 
67 
71 
72  // ------------------------------------ //
73  DLLEXPORT inline cAudio::IAudioManager* GetAudioManager()
74  {
75  return AudioManager;
76  }
77 
80  DLLEXPORT static std::vector<std::string> GetAudioDevices(
81  size_t* indexofdefault = nullptr);
82 
83 private:
84  cAudio::IAudioManager* AudioManager = nullptr;
85  cAudio::IListener* ListeningPosition = nullptr;
86 
88  std::string AudioLogPath;
89 
91  std::vector<AudioSource::pointer> HandledAudioSources;
92 };
93 
94 } // namespace Leviathan
DLLEXPORT bool Init(bool simulatesound=false, bool noconsolelog=false)
Definition: SoundDevice.cpp:26
DLLEXPORT void Tick(int PassedMs)
DLLEXPORT void SetGlobalVolume(float vol)
Manages loading the audio library and provides some helpers.
Definition: SoundDevice.h:20
DLLEXPORT cAudio::IAudioManager * GetAudioManager()
Definition: SoundDevice.h:73
DLLEXPORT AudioSource::pointer Play2DSound(const std::string &filename, bool looping, bool startpaused)
Plays a 2d sound with options.
DLLEXPORT void BabysitAudio(AudioSource::pointer audio)
This class holds the audio source until it has finished playing and then releases the reference...
static DLLEXPORT std::vector< std::string > GetAudioDevices(size_t *indexofdefault=nullptr)
Returns a list of audio playback devices.
DLLEXPORT AudioSource::pointer CreateProceduralSound(ProceduralSoundData::pointer data, const char *soundname)
Opens an audio source from a procedural data stream.
DLLEXPORT void Play2DSoundEffect(const std::string &filename)
Plays a 2d sound without possibility of interrupting.
DLLEXPORT void SetSoundListenerPosition(const Float3 &pos, const Float4 &orientation)
Loads the file and plays the sound.
DLLEXPORT ~SoundDevice()
Definition: SoundDevice.cpp:21
boost::intrusive_ptr< JSProxyable > pointer
Definition: JSProxyable.h:15
#define DLLEXPORT
Definition: Include.h:115
DLLEXPORT void Release()
Definition: SoundDevice.cpp:99
The access mask controls which registered functions and classes a script sees.
Definition: GameModule.h:12