reference

This documentation is automatically generated from the openFrameworks source code using doxygen and refers to the most recent release, version 0.12.0.

#include <ofMediaFoundationSoundPlayer.h>

Inheritance diagram for ofMediaFoundationSoundPlayer:
ofBaseSoundPlayer of::MFSourceReaderNotifyCallback

Classes

struct  MyComDeleterFunctor
 
struct  MyVoiceDeleterFunctor
 
class  SourceReaderCallback
 
struct  StreamingVoiceContext
 

Public Member Functions

 ofMediaFoundationSoundPlayer ()
 
 ~ofMediaFoundationSoundPlayer ()
 
bool load (const of::filesystem::path &fileName, bool stream=false) override
 
void unload () override
 
void play () override
 
void stop () override
 
void setVolume (float vol) override
 
void setPan (float apan) override
 
void setSpeed (float spd) override
 
void setPaused (bool bP) override
 
void setLoop (bool bLp) override
 
void setMultiPlay (bool bMp) override
 
void setPosition (float pct) override
 
void setPositionMS (int ms) override
 
float getPosition () const override
 
int getPositionMS () const override
 
bool isPlaying () const override
 
float getSpeed () const override
 
float getPan () const override
 
bool isLoaded () const override
 
float getVolume () const override
 
float getDurationSeconds ()
 
uint32_t getDurationMS ()
 
- Public Member Functions inherited from ofBaseSoundPlayer
 ofBaseSoundPlayer ()
 
virtual ~ofBaseSoundPlayer ()
 

Static Public Member Functions

static void SetMasterVolume (float apct)
 

Protected Types

using UniqueVoice = std::unique_ptr< IXAudio2SourceVoice, MyVoiceDeleterFunctor >
 

Protected Member Functions

void OnSourceReaderEvent (HRESULT hrStatus, DWORD dwStreamIndex, DWORD dwStreamFlags, LONGLONG llTimestamp, IMFSample *pSample) override
 
void update (ofEventArgs &args)
 
void addUpdateListener ()
 
void removeUpdateListener ()
 
void _clearExtraVoices ()
 
void _setPan (IXAudio2SourceVoice *avoice, float apan)
 
bool _readToBuffer (IMFSourceReader *areader)
 

Static Protected Member Functions

static bool sInitXAudio2 ()
 
static bool sCloseXAudio2 ()
 
static bool sInitAudioSystems ()
 
static void sCloseAudioSystems ()
 

Protected Attributes

bool mBAddedUpdateEvent = false
 
bool mBStreaming = false
 
unsigned short mNumChannels = 0
 
unsigned long mSampleRate = 44000
 
std::vector< BYTE > mBuffer
 
WAVEFORMATEX mWaveFormatEx
 
Microsoft::WRL::ComPtr< IMFSourceReader > mSrcReader
 
UniqueVoice mVoice
 
std::list< std::pair< unsigned int, IXAudio2SourceVoice * > > mExtraVoices
 
bool mBLoaded = false
 
bool mBIsPlaying = false
 
float mVolume = 1.0f
 
float mPan = 0.0f
 
float mSpeed = 1.0f
 
float mPosPct = 0.0f
 
bool mBMultiPlay = false
 
bool mBLoop = false
 
bool mBCanSeek = false
 
double mDurationSeconds = 0
 
uint32_t mDurationMS = 0
 
unsigned char mBytesPerSample = 2
 
uint64_t mTotalNumFrames = 0
 
size_t mBufferIndex = 0
 
uint64_t mNumSamplesAlreadyPlayed = 0
 
uint64_t mNumSamplesStored = 0
 
unsigned int MAX_BUFFER_COUNT = 3
 
std::vector< std::vector< BYTE > > mStreamBuffers
 
int currentStreamBuffer = 0
 
std::shared_ptr< StreamingVoiceContextmVoiceContext
 
bool mBEndOfStream = false
 
CRITICAL_SECTION m_critSec
 
std::shared_ptr< SourceReaderCallbackmSrcReaderCallback
 
std::mutex mSrcReaderMutex
 
bool mBRequestNewReaderSample = false
 

Static Protected Attributes

static int sNumInstances = 0
 
static Microsoft::WRL::ComPtr< IXAudio2 > sXAudio2 = nullptr
 
static std::shared_ptr< IXAudio2MasteringVoice > sXAudioMasteringVoice
 

Member Typedef Documentation

◆ UniqueVoice

using ofMediaFoundationSoundPlayer::UniqueVoice = std::unique_ptr< IXAudio2SourceVoice, MyVoiceDeleterFunctor >
protected

Constructor & Destructor Documentation

◆ ofMediaFoundationSoundPlayer()

ofMediaFoundationSoundPlayer::ofMediaFoundationSoundPlayer ( )

◆ ~ofMediaFoundationSoundPlayer()

ofMediaFoundationSoundPlayer::~ofMediaFoundationSoundPlayer ( )

Member Function Documentation

◆ _clearExtraVoices()

void ofMediaFoundationSoundPlayer::_clearExtraVoices ( )
protected

◆ _readToBuffer()

bool ofMediaFoundationSoundPlayer::_readToBuffer ( IMFSourceReader *  areader)
protected

◆ _setPan()

void ofMediaFoundationSoundPlayer::_setPan ( IXAudio2SourceVoice *  avoice,
float  apan 
)
protected

◆ addUpdateListener()

void ofMediaFoundationSoundPlayer::addUpdateListener ( )
protected

◆ getDurationMS()

uint32_t ofMediaFoundationSoundPlayer::getDurationMS ( )
inline

◆ getDurationSeconds()

float ofMediaFoundationSoundPlayer::getDurationSeconds ( )
inline

◆ getPan()

float ofMediaFoundationSoundPlayer::getPan ( ) const
overridevirtual

Implements ofBaseSoundPlayer.

◆ getPosition()

float ofMediaFoundationSoundPlayer::getPosition ( ) const
overridevirtual

Implements ofBaseSoundPlayer.

◆ getPositionMS()

int ofMediaFoundationSoundPlayer::getPositionMS ( ) const
overridevirtual

Implements ofBaseSoundPlayer.

◆ getSpeed()

float ofMediaFoundationSoundPlayer::getSpeed ( ) const
overridevirtual

Implements ofBaseSoundPlayer.

◆ getVolume()

float ofMediaFoundationSoundPlayer::getVolume ( ) const
overridevirtual

Implements ofBaseSoundPlayer.

◆ isLoaded()

bool ofMediaFoundationSoundPlayer::isLoaded ( ) const
overridevirtual

Implements ofBaseSoundPlayer.

◆ isPlaying()

bool ofMediaFoundationSoundPlayer::isPlaying ( ) const
overridevirtual

Implements ofBaseSoundPlayer.

◆ load()

bool ofMediaFoundationSoundPlayer::load ( const of::filesystem::path &  fileName,
bool  stream = false 
)
overridevirtual

Implements ofBaseSoundPlayer.

◆ OnSourceReaderEvent()

void ofMediaFoundationSoundPlayer::OnSourceReaderEvent ( HRESULT  hrStatus,
DWORD  dwStreamIndex,
DWORD  dwStreamFlags,
LONGLONG  llTimestamp,
IMFSample *  pSample 
)
overrideprotectedvirtual

◆ play()

void ofMediaFoundationSoundPlayer::play ( )
overridevirtual

Implements ofBaseSoundPlayer.

◆ removeUpdateListener()

void ofMediaFoundationSoundPlayer::removeUpdateListener ( )
protected

◆ sCloseAudioSystems()

void ofMediaFoundationSoundPlayer::sCloseAudioSystems ( )
staticprotected

◆ sCloseXAudio2()

bool ofMediaFoundationSoundPlayer::sCloseXAudio2 ( )
staticprotected

◆ setLoop()

void ofMediaFoundationSoundPlayer::setLoop ( bool  bLp)
overridevirtual

Implements ofBaseSoundPlayer.

◆ SetMasterVolume()

void ofMediaFoundationSoundPlayer::SetMasterVolume ( float  apct)
static

◆ setMultiPlay()

void ofMediaFoundationSoundPlayer::setMultiPlay ( bool  bMp)
overridevirtual

Implements ofBaseSoundPlayer.

◆ setPan()

void ofMediaFoundationSoundPlayer::setPan ( float  apan)
overridevirtual

Implements ofBaseSoundPlayer.

◆ setPaused()

void ofMediaFoundationSoundPlayer::setPaused ( bool  bP)
overridevirtual

Implements ofBaseSoundPlayer.

◆ setPosition()

void ofMediaFoundationSoundPlayer::setPosition ( float  pct)
overridevirtual

Implements ofBaseSoundPlayer.

◆ setPositionMS()

void ofMediaFoundationSoundPlayer::setPositionMS ( int  ms)
overridevirtual

Implements ofBaseSoundPlayer.

◆ setSpeed()

void ofMediaFoundationSoundPlayer::setSpeed ( float  spd)
overridevirtual

Implements ofBaseSoundPlayer.

◆ setVolume()

void ofMediaFoundationSoundPlayer::setVolume ( float  vol)
overridevirtual

Implements ofBaseSoundPlayer.

◆ sInitAudioSystems()

bool ofMediaFoundationSoundPlayer::sInitAudioSystems ( )
staticprotected

◆ sInitXAudio2()

bool ofMediaFoundationSoundPlayer::sInitXAudio2 ( )
staticprotected

◆ stop()

void ofMediaFoundationSoundPlayer::stop ( )
overridevirtual

Implements ofBaseSoundPlayer.

◆ unload()

void ofMediaFoundationSoundPlayer::unload ( )
overridevirtual

Implements ofBaseSoundPlayer.

◆ update()

void ofMediaFoundationSoundPlayer::update ( ofEventArgs args)
protected

Member Data Documentation

◆ currentStreamBuffer

int ofMediaFoundationSoundPlayer::currentStreamBuffer = 0
protected

◆ m_critSec

CRITICAL_SECTION ofMediaFoundationSoundPlayer::m_critSec
protected

◆ MAX_BUFFER_COUNT

unsigned int ofMediaFoundationSoundPlayer::MAX_BUFFER_COUNT = 3
protected

◆ mBAddedUpdateEvent

bool ofMediaFoundationSoundPlayer::mBAddedUpdateEvent = false
protected

◆ mBCanSeek

bool ofMediaFoundationSoundPlayer::mBCanSeek = false
protected

◆ mBEndOfStream

bool ofMediaFoundationSoundPlayer::mBEndOfStream = false
protected

◆ mBIsPlaying

bool ofMediaFoundationSoundPlayer::mBIsPlaying = false
protected

◆ mBLoaded

bool ofMediaFoundationSoundPlayer::mBLoaded = false
protected

◆ mBLoop

bool ofMediaFoundationSoundPlayer::mBLoop = false
protected

◆ mBMultiPlay

bool ofMediaFoundationSoundPlayer::mBMultiPlay = false
protected

◆ mBRequestNewReaderSample

bool ofMediaFoundationSoundPlayer::mBRequestNewReaderSample = false
protected

◆ mBStreaming

bool ofMediaFoundationSoundPlayer::mBStreaming = false
protected

◆ mBuffer

std::vector<BYTE> ofMediaFoundationSoundPlayer::mBuffer
protected

◆ mBufferIndex

size_t ofMediaFoundationSoundPlayer::mBufferIndex = 0
protected

◆ mBytesPerSample

unsigned char ofMediaFoundationSoundPlayer::mBytesPerSample = 2
protected

◆ mDurationMS

uint32_t ofMediaFoundationSoundPlayer::mDurationMS = 0
protected

◆ mDurationSeconds

double ofMediaFoundationSoundPlayer::mDurationSeconds = 0
protected

◆ mExtraVoices

std::list< std::pair<unsigned int, IXAudio2SourceVoice*> > ofMediaFoundationSoundPlayer::mExtraVoices
protected

◆ mNumChannels

unsigned short ofMediaFoundationSoundPlayer::mNumChannels = 0
protected

◆ mNumSamplesAlreadyPlayed

uint64_t ofMediaFoundationSoundPlayer::mNumSamplesAlreadyPlayed = 0
protected

◆ mNumSamplesStored

uint64_t ofMediaFoundationSoundPlayer::mNumSamplesStored = 0
protected

◆ mPan

float ofMediaFoundationSoundPlayer::mPan = 0.0f
protected

◆ mPosPct

float ofMediaFoundationSoundPlayer::mPosPct = 0.0f
protected

◆ mSampleRate

unsigned long ofMediaFoundationSoundPlayer::mSampleRate = 44000
protected

◆ mSpeed

float ofMediaFoundationSoundPlayer::mSpeed = 1.0f
protected

◆ mSrcReader

Microsoft::WRL::ComPtr<IMFSourceReader> ofMediaFoundationSoundPlayer::mSrcReader
protected

◆ mSrcReaderCallback

std::shared_ptr<SourceReaderCallback> ofMediaFoundationSoundPlayer::mSrcReaderCallback
protected

◆ mSrcReaderMutex

std::mutex ofMediaFoundationSoundPlayer::mSrcReaderMutex
protected

◆ mStreamBuffers

std::vector< std::vector<BYTE> > ofMediaFoundationSoundPlayer::mStreamBuffers
protected

◆ mTotalNumFrames

uint64_t ofMediaFoundationSoundPlayer::mTotalNumFrames = 0
protected

◆ mVoice

UniqueVoice ofMediaFoundationSoundPlayer::mVoice
protected

◆ mVoiceContext

std::shared_ptr<StreamingVoiceContext> ofMediaFoundationSoundPlayer::mVoiceContext
protected

◆ mVolume

float ofMediaFoundationSoundPlayer::mVolume = 1.0f
protected

◆ mWaveFormatEx

WAVEFORMATEX ofMediaFoundationSoundPlayer::mWaveFormatEx
protected

◆ sNumInstances

int ofMediaFoundationSoundPlayer::sNumInstances = 0
staticprotected

◆ sXAudio2

ComPtr< IXAudio2 > ofMediaFoundationSoundPlayer::sXAudio2 = nullptr
staticprotected

◆ sXAudioMasteringVoice

std::shared_ptr< IXAudio2MasteringVoice > ofMediaFoundationSoundPlayer::sXAudioMasteringVoice
staticprotected

The documentation for this class was generated from the following files: