HephAudio v3.1.0
A cross-platform C++ library for recording, playing, and processing audio on Windows, Android, Linux, iOS, and macOS.
Loading...
Searching...
No Matches
Audio.h
Go to the documentation of this file.
1#pragma once
2#include "HephAudioShared.h"
6#include <memory>
7
10namespace HephAudio
11{
17 {
18 Default,
19
20#if defined(_WIN32)
21 WASAPI,
22 DirectSound,
23 MMEAPI,
24#endif
25
26#if defined(__APPLE__)
27 CoreAudio,
28#endif
29
30#if defined(__ANDROID__)
31#if __ANDROID_API__ >= HEPHAUDIO_ANDROID_AAUDIO_MIN_API_LEVEL
32 AAudio,
33#endif
34 OpenSLES,
35#endif
36
37#if defined(__linux__) && !defined(__ANDROID__)
38 ALSA,
39#endif
40 };
41
46 class HEPH_API Audio final
47 {
48 private:
49 std::shared_ptr<Native::NativeAudio> pNativeAudio;
50
51 public:
54
57
60
61 public:
64
71
76 std::shared_ptr<Native::NativeAudio> GetNativeAudio() const;
77
79 std::shared_ptr<IAudioDecoder> GetAudioDecoder() const;
80
82 void SetAudioDecoder(std::shared_ptr<IAudioDecoder> pNewDecoder);
83
85 std::shared_ptr<IAudioEncoder> GetAudioEncoder() const;
86
88 void SetAudioEncoder(std::shared_ptr<IAudioEncoder> pNewEncoder);
89
91 AudioObject* Play(const std::filesystem::path& filePath);
92
94 AudioObject* Play(const std::filesystem::path& filePath, uint32_t playCount);
95
97 AudioObject* Load(const std::filesystem::path& filePath);
98
100 AudioObject* Load(const std::filesystem::path& filePath, uint32_t playCount);
101
103 AudioObject* CreateAudioObject(const std::string& name, size_t bufferFrameCount, AudioChannelLayout channelLayout, uint32_t sampleRate);
104
106 bool DestroyAudioObject(AudioObject* pAudioObject);
107
109 bool DestroyAudioObject(const Heph::Guid& audioObjectId);
110
112 bool AudioObjectExists(AudioObject* pAudioObject) const;
113
115 bool AudioObjectExists(const Heph::Guid& audioObjectId) const;
116
118 AudioObject* GetAudioObject(size_t index) const;
119
121 AudioObject* GetAudioObject(const Heph::Guid& audioObjectId);
122
124 AudioObject* GetAudioObject(const std::string& audioObjectName) const;
125
127 size_t GetAudioObjectCount() const;
128
131
134
136 bool IsCapturePaused() const;
137
140
142 void SetDeviceEnumerationPeriod(uint32_t deviceEnumerationPeriod_ms);
143
145 void SetMasterVolume(double volume);
146
148 double GetMasterVolume() const;
149
152
155
158
160 void InitializeRender(const AudioChannelLayout& channelLayout, uint32_t sampleRate);
161
164
166 void InitializeRender(AudioDevice* device, const AudioChannelLayout& channelLayout, uint32_t sampleRate);
167
170
173
176
178 void InitializeCapture(const AudioChannelLayout& channelLayout, uint32_t sampleRate);
179
182
184 void InitializeCapture(AudioDevice* device, const AudioChannelLayout& channelLayout, uint32_t sampleRate);
185
188
191
194
197
199 AudioDevice GetAudioDeviceById(const std::string& deviceId) const;
200
203
206
209
211 std::vector<AudioDevice> GetAudioDevices(AudioDeviceType deviceType) const;
212
213 private:
214 static std::shared_ptr<Native::NativeAudio> CreateNativeAudio(AudioAPI api);
215 };
216}
AudioDeviceType
Definition AudioDevice.h:11
AudioAPI
available native audio APIs.
Definition Audio.h:17
#define HEPH_API
Definition HephShared.h:124
manages the native audio classes.
Definition Audio.h:47
AudioDevice GetDefaultAudioDevice(AudioDeviceType deviceType) const
const AudioFormatInfo & GetCaptureFormat() const
void SetNativeParams(const Native::NativeAudioParams &nativeParams)
bool DestroyAudioObject(AudioObject *pAudioObject)
void InitializeRender(AudioDevice *device, const AudioChannelLayout &channelLayout, uint32_t sampleRate)
void SetAudioEncoder(std::shared_ptr< IAudioEncoder > pNewEncoder)
void InitializeCapture(AudioDevice *device, const AudioChannelLayout &channelLayout, uint32_t sampleRate)
bool IsCapturePaused() const
void InitializeRender()
std::shared_ptr< IAudioEncoder > GetAudioEncoder() const
AudioObject * Load(const std::filesystem::path &filePath, uint32_t playCount)
AudioObject * GetAudioObject(const Heph::Guid &audioObjectId)
AudioObject * Play(const std::filesystem::path &filePath)
void InitializeRender(AudioDevice *device, AudioFormatInfo format)
bool AudioObjectExists(const Heph::Guid &audioObjectId) const
bool DestroyAudioObject(const Heph::Guid &audioObjectId)
std::shared_ptr< IAudioDecoder > GetAudioDecoder() const
void SetAudioDecoder(std::shared_ptr< IAudioDecoder > pNewDecoder)
Heph::Event & OnAudioDeviceAdded
Definition Audio.h:53
AudioObject * Load(const std::filesystem::path &filePath)
size_t GetAudioObjectCount() const
AudioObject * GetAudioObject(const std::string &audioObjectName) const
void InitializeRender(const AudioChannelLayout &channelLayout, uint32_t sampleRate)
Audio(AudioAPI api)
AudioDevice GetAudioDeviceById(const std::string &deviceId) const
void GetNativeParams(Native::NativeAudioParams &nativeParams) const
double GetMasterVolume() const
const AudioFormatInfo & GetRenderFormat() const
void SetMasterVolume(double volume)
std::shared_ptr< Native::NativeAudio > GetNativeAudio() const
void InitializeCapture(AudioDevice *device, AudioFormatInfo format)
void InitializeRender(AudioFormatInfo format)
AudioDevice GetCaptureDevice() const
AudioObject * CreateAudioObject(const std::string &name, size_t bufferFrameCount, AudioChannelLayout channelLayout, uint32_t sampleRate)
AudioDevice GetRenderDevice() const
void InitializeCapture(AudioFormatInfo format)
Heph::Event & OnAudioDeviceRemoved
Definition Audio.h:56
void InitializeCapture(const AudioChannelLayout &channelLayout, uint32_t sampleRate)
uint32_t GetDeviceEnumerationPeriod() const
bool AudioObjectExists(AudioObject *pAudioObject) const
AudioObject * GetAudioObject(size_t index) const
std::vector< AudioDevice > GetAudioDevices(AudioDeviceType deviceType) const
AudioObject * Play(const std::filesystem::path &filePath, uint32_t playCount)
void InitializeCapture()
void SetDeviceEnumerationPeriod(uint32_t deviceEnumerationPeriod_ms)
Heph::Event & OnCapture
Definition Audio.h:59
class for managing callback functions.
Definition Event.h:25
stores information about the channel layout.
Definition AudioChannelLayout.h:337
stores information about an audio device.
Definition AudioDevice.h:60
stores the properties of the audio signals
Definition AudioFormatInfo.h:20
stores information that's necessary to play audio.
Definition AudioObject.h:33
base class for storing the native audio API specific parameters.
Definition NativeAudioParams.h:15
struct for storing globally unique identifiers.
Definition Guid.h:14