Mountain  1.0.0
Simple C++ 2D Game Framework
audio.hpp
1 #pragma once
2 
3 #include <functional>
4 
5 #include "Mountain/core.hpp"
6 #include "Mountain/audio/audio_buffer.hpp"
7 #include "Mountain/audio/audio_device.hpp"
9 
10 // OpenAL type forward declaration
11 
12 // ReSharper disable once CppEnforceTypeAliasCodeStyle
13 // ReSharper disable once CppInconsistentNaming
14 typedef char ALCchar;
15 // ReSharper disable once CppEnforceTypeAliasCodeStyle
16 // ReSharper disable once CppInconsistentNaming
17 typedef int ALCsizei;
18 // ReSharper disable once CppEnforceTypeAliasCodeStyle
19 // ReSharper disable once CppInconsistentNaming
20 typedef int ALCenum;
21 
22 namespace Mountain
23 {
24  class Audio
25  {
26  STATIC_CLASS(Audio)
27 
28  public:
29  MOUNTAIN_API static bool_t Initialize();
30 
31  MOUNTAIN_API static void Shutdown();
32 
33  MOUNTAIN_API static void Update();
34 
36  [[nodiscard]]
37  MOUNTAIN_API static AudioContext* GetContext();
38 
39  MOUNTAIN_API static void RegisterBuffer(AudioBuffer* buffer);
40 
41  MOUNTAIN_API static void UnregisterBuffer(AudioBuffer* buffer);
42 
43  MOUNTAIN_API static void UpdateContext();
44 
45  MOUNTAIN_API static const AudioDevice* GetCurrentDevice();
46 
47  MOUNTAIN_API static void SetCurrentDevice(AudioDevice* newCurrentDevice);
48 
49  MOUNTAIN_API static float_t GetDistanceFactor();
50 
51  MOUNTAIN_API static void SetDistanceFactor(float_t newDistanceFactor);
52 
53  private:
54  MOUNTAIN_API static inline AudioDevice* m_CurrentDevice = nullptr;
55  MOUNTAIN_API static inline AudioContext* m_CurrentContext = nullptr;
56 
57  MOUNTAIN_API static inline List<AudioBuffer*> m_Buffers;
58 
59  MOUNTAIN_API static inline float_t m_DistanceFactor = 0.2f;
60 
61  MOUNTAIN_API static inline bool_t m_DefaultDeviceChanged = false;
62 
63  static void EventCallback(ALCenum eventType, ALCenum deviceType, ALCdevice* device, ALCsizei length, const ALCchar* message, void* userParam);
64 
68  static void IterateAlStringList(const char_t* list, const std::function<void(const char_t*)>& lambda);
69  };
70 }
Defines the Mountain::List class.
static MOUNTAIN_API AudioContext * GetContext()
Returns the current device&#39;s context.
A dynamic array implementation. Wrapper around the std::vector class.
Definition: list.hpp:24
Contains all declarations of the Mountain Framework.
Definition: audio.hpp:22