HephAudio v3.0.6
A cross-platform C++ library for recording, playing, and processing audio on Windows, Android, Linux, iOS, and macOS.
Loading...
Searching...
No Matches
HephAudio::Native::WinAudio Class Referencefinal

uses WASAPI. More...

#include <WinAudio.h>

Inheritance diagram for HephAudio::Native::WinAudio:
HephAudio::Native::WinAudioBase HephAudio::Native::NativeAudio

Public Member Functions

 WinAudio ()
 
 WinAudio (const WinAudio &)=delete
 
WinAudiooperator= (const WinAudio &)=delete
 
 ~WinAudio ()
 
void SetMasterVolume (double volume) override
 
double GetMasterVolume () const override
 
void InitializeRender (AudioDevice *device, AudioFormatInfo format) override
 
void StopRendering () override
 
void InitializeCapture (AudioDevice *device, AudioFormatInfo format) override
 
void StopCapturing () override
 
void GetNativeParams (NativeAudioParams &nativeParams) const override
 
void SetNativeParams (const NativeAudioParams &nativeParams) override
 
void SetDisplayName (const std::string &displayName)
 
void SetIconPath (const std::filesystem::path &iconPath)
 
void InitializeRender ()
 
void InitializeRender (AudioChannelLayout channelLayout, uint32_t sampleRate)
 
void InitializeRender (AudioFormatInfo format)
 
void InitializeCapture ()
 
void InitializeCapture (AudioChannelLayout channelLayout, uint32_t sampleRate)
 
void InitializeCapture (AudioFormatInfo format)
 
- Public Member Functions inherited from HephAudio::Native::WinAudioBase
 WinAudioBase ()
 
 WinAudioBase (const WinAudioBase &)=delete
 
WinAudioBaseoperator= (const WinAudioBase &)=delete
 
virtual ~WinAudioBase ()=default
 
- Public Member Functions inherited from HephAudio::Native::NativeAudio
 NativeAudio ()
 
 NativeAudio (const NativeAudio &)=delete
 
NativeAudiooperator= (const NativeAudio &)=delete
 
virtual ~NativeAudio ()=default
 
std::shared_ptr< IAudioDecoderGetAudioDecoder () const
 
void SetAudioDecoder (std::shared_ptr< IAudioDecoder > pNewDecoder)
 
std::shared_ptr< IAudioEncoderGetAudioEncoder () const
 
void SetAudioEncoder (std::shared_ptr< IAudioEncoder > pNewEncoder)
 
AudioObjectPlay (const std::filesystem::path &filePath)
 
AudioObjectPlay (const std::filesystem::path &filePath, uint32_t playCount)
 
AudioObjectPlay (const std::filesystem::path &filePath, uint32_t playCount, bool isPaused)
 
AudioObjectLoad (const std::filesystem::path &filePath)
 
AudioObjectLoad (const std::filesystem::path &filePath, uint32_t playCount)
 
AudioObjectLoad (const std::filesystem::path &filePath, uint32_t playCount, bool isPaused)
 
AudioObjectCreateAudioObject (const std::string &name, size_t bufferFrameCount, AudioChannelLayout channelLayout, uint16_t sampleRate)
 
bool DestroyAudioObject (AudioObject *pAudioObject)
 
bool DestroyAudioObject (const Heph::Guid &audioObjectId)
 
bool AudioObjectExists (AudioObject *pAudioObject) const
 
bool AudioObjectExists (const Heph::Guid &audioObjectId) const
 
AudioObjectGetAudioObject (size_t index)
 
AudioObjectGetAudioObject (const Heph::Guid &audioObjectId)
 
AudioObjectGetAudioObject (const std::string &audioObjectName)
 
size_t GetAudioObjectCount () const
 
void ResumeCapture ()
 
void PauseCapture ()
 
bool IsCapturePaused () const
 
uint32_t GetDeviceEnumerationPeriod () const
 
void SetDeviceEnumerationPeriod (uint32_t deviceEnumerationPeriod_ms)
 
const AudioFormatInfoGetRenderFormat () const
 
const AudioFormatInfoGetCaptureFormat () const
 
void InitializeRender ()
 
void InitializeRender (AudioChannelLayout channelLayout, uint32_t sampleRate)
 
void InitializeRender (AudioFormatInfo format)
 
void InitializeCapture ()
 
void InitializeCapture (AudioChannelLayout channelLayout, uint32_t sampleRate)
 
void InitializeCapture (AudioFormatInfo format)
 
AudioDevice GetAudioDeviceById (const std::string &deviceId) const
 
AudioDevice GetRenderDevice () const
 
AudioDevice GetCaptureDevice () const
 
AudioDevice GetDefaultAudioDevice (AudioDeviceType deviceType) const
 
std::vector< AudioDeviceGetAudioDevices (AudioDeviceType deviceType) const
 

Additional Inherited Members

- Public Attributes inherited from HephAudio::Native::NativeAudio
Heph::Event OnAudioDeviceAdded
 
Heph::Event OnAudioDeviceRemoved
 
Heph::Event OnCapture
 
- Protected Member Functions inherited from HephAudio::Native::WinAudioBase
void InitializeCOM () const
 
- Protected Member Functions inherited from HephAudio::Native::NativeAudio
void JoinRenderThread ()
 
void JoinCaptureThread ()
 
void JoinDeviceThread ()
 
EncodedAudioBuffer Mix (uint32_t frameCount)
 
size_t GetAOCountToMix () const
 
virtual double GetFinalAOVolume (AudioObject *pAudioObject) const
 
- Static Protected Member Functions inherited from HephAudio::Native::WinAudioBase
static AudioFormatInfo WFX2AFI (const WAVEFORMATEXTENSIBLE &wfx)
 
static WAVEFORMATEXTENSIBLE AFI2WFX (const AudioFormatInfo &afi)
 
static std::string GetComErrorMessage (HRESULT hr)
 
- Protected Attributes inherited from HephAudio::Native::NativeAudio
std::shared_ptr< IAudioDecoderpAudioDecoder
 
std::shared_ptr< IAudioEncoderpAudioEncoder
 
std::vector< AudioObjectaudioObjects
 
std::vector< AudioDeviceaudioDevices
 
std::thread::id mainThreadId
 
std::thread renderThread
 
std::thread captureThread
 
std::thread deviceThread
 
std::string renderDeviceId
 
std::string captureDeviceId
 
AudioFormatInfo renderFormat
 
AudioFormatInfo captureFormat
 
bool disposing
 
bool isRenderInitialized
 
bool isCaptureInitialized
 
bool isCapturePaused
 
uint32_t deviceEnumerationPeriod_ms
 
std::mutex audioDevicesMutex
 
std::recursive_mutex audioObjectsMutex
 
- Static Protected Attributes inherited from HephAudio::Native::NativeAudio
static constexpr bool DEVICE_ENUMERATION_FAIL = false
 
static constexpr bool DEVICE_ENUMERATION_SUCCESS = true
 

Detailed Description

uses WASAPI.

Constructor & Destructor Documentation

◆ WinAudio()

HephAudio::Native::WinAudio::WinAudio ( )

creates a new instance and initializes it with default values.

◆ ~WinAudio()

HephAudio::Native::WinAudio::~WinAudio ( )

releases the resources and destroys the instance.

Member Function Documentation

◆ SetMasterVolume()

void HephAudio::Native::WinAudio::SetMasterVolume ( double volume)
overridevirtual

sets the master volume.

Parameters
volumenew master volume.
Important
values above 1 may cause distortion.

Implements HephAudio::Native::NativeAudio.

◆ GetMasterVolume()

double HephAudio::Native::WinAudio::GetMasterVolume ( ) const
overridevirtual

gets the master volume.

Implements HephAudio::Native::NativeAudio.

◆ InitializeRender() [1/4]

void HephAudio::Native::WinAudio::InitializeRender ( AudioDevice * device,
AudioFormatInfo format )
overridevirtual

initializes rendering with the provided device and the provided format.

Parameters
devicepointer to the audio render device.
formatrender format.

Implements HephAudio::Native::NativeAudio.

◆ StopRendering()

void HephAudio::Native::WinAudio::StopRendering ( )
overridevirtual

stops rendering and releases the resources allocated for it.

Implements HephAudio::Native::NativeAudio.

◆ InitializeCapture() [1/4]

void HephAudio::Native::WinAudio::InitializeCapture ( AudioDevice * device,
AudioFormatInfo format )
overridevirtual

initializes capturing with the provided device and the provided format.

Parameters
devicepointer to the audio capture device.
formatcapture format.

Implements HephAudio::Native::NativeAudio.

◆ StopCapturing()

void HephAudio::Native::WinAudio::StopCapturing ( )
overridevirtual

stops capturing and releases the resources allocated for it.

Implements HephAudio::Native::NativeAudio.

◆ GetNativeParams()

void HephAudio::Native::WinAudio::GetNativeParams ( NativeAudioParams & nativeParams) const
overridevirtual

gets the native API specific parameters.

Implements HephAudio::Native::NativeAudio.

◆ SetNativeParams()

void HephAudio::Native::WinAudio::SetNativeParams ( const NativeAudioParams & nativeParams)
overridevirtual

sets the native API specific parameters.

Implements HephAudio::Native::NativeAudio.

◆ SetDisplayName()

void HephAudio::Native::WinAudio::SetDisplayName ( const std::string & displayName)

sets the display name in the volume mixer.

◆ SetIconPath()

void HephAudio::Native::WinAudio::SetIconPath ( const std::filesystem::path & iconPath)

sets the icon displayed in the volume mixer.

◆ InitializeRender() [2/4]

void HephAudio::Native::NativeAudio::InitializeRender ( )

initializes rendering with the default device and default format.

◆ InitializeRender() [3/4]

void HephAudio::Native::NativeAudio::InitializeRender ( AudioChannelLayout channelLayout,
uint32_t sampleRate )

initializes rendering with the default device and the provided format.

Parameters
channelLayoutchannel layout of the render format.
sampleRatesample rate of the render format.

◆ InitializeRender() [4/4]

void HephAudio::Native::NativeAudio::InitializeRender ( AudioFormatInfo format)

initializes rendering with the default device and the provided format.

Parameters
formatrender format.

◆ InitializeCapture() [2/4]

void HephAudio::Native::NativeAudio::InitializeCapture ( )

initializes capturing with the default device and default format.

◆ InitializeCapture() [3/4]

void HephAudio::Native::NativeAudio::InitializeCapture ( AudioChannelLayout channelLayout,
uint32_t sampleRate )

initializes capturing with the default device and the provided format.

Parameters
channelLayoutchannel layout of the capture format.
sampleRatesample rate of the capture format.

◆ InitializeCapture() [4/4]

void HephAudio::Native::NativeAudio::InitializeCapture ( AudioFormatInfo format)

initializes capturing with the default device and the provided format.

Parameters
formatcapture format.