Class AudioAnalyzerPlayer

Inheritance Relationships

Base Type

Class Documentation

class AudioAnalyzerPlayer : public AudioAnalyzerSource

Audio Analyzer Player Source.

This class will be used to load audio from a disk file and interact with it using the most basic player options (play/stop/pause)

Public Functions

AudioAnalyzerPlayer()

Constructor

~AudioAnalyzerPlayer()

Destructor This will unload the loaded audio too

AudioAnalyzerPlayer(AudioAnalyzerPlayer const &x) = delete

Disable copy constructor

Parameters:

x – —

void operator=(AudioAnalyzerPlayer const &x) = delete

Disable copy assignment

Parameters:

x – —

bool initializeAudio(const FString &filePath, uint32 periodSizeInFrames, uint32 periodSizeInMilliseconds, uint32 periods)

Loads the audio wav info and opens the audio player device

Parameters:
  • filePath – Path to the audio file

  • periodSizeInFrames – Device audio buffer size in frames (power of 2), 0 to use default value

  • periodSizeInMilliseconds – Device audio buffer size in milliseconds, 0 to use default value

  • periods – Device audio buffer size multiplier

Returns:

Audio initilization execution result

bool asyncInitializeAudio(const FString &filePath, uint32 periodSizeInFrames, uint32 periodSizeInMilliseconds, uint32 periods)

Loads the audio wav info and opens the audio player device

Parameters:
  • filePath – Path to the audio file

  • periodSizeInFrames – Device audio buffer size in frames (power of 2), 0 to use default value

  • periodSizeInMilliseconds – Device audio buffer size in milliseconds, 0 to use default value

  • periods – Device audio buffer size multiplier

Returns:

Audio initilization scheduled

void unloadAudio()

Closes audio player device

void play(int loops, float startTime)

Starts audio playback

Parameters:
  • loops – Number of loops

  • startTime – Start playback position

void stop()

Stops audio playback

void pause(bool forcePause = true)

Pauses audio playback if the device is in playing state UnPauses audio playback if the device has been paused previously

Parameters:

forcePause – Set the pause to this state

bool isPlaying() const

Returns if the device is currently playing audio

Returns:

Device is playing

bool isPaused() const

Returns if the device is currently paused

Returns:

Device is paused

virtual float getPlaybackProgress(float &bufferPosTime)

Returns the playback progress and buffer postion time

Parameters:

bufferPosTime[out] Buffer position (same as below value)

Returns:

float Progress in seconds

float getPlaybackProgress()

Returns the playback progress

Returns:

float Progress in seconds

void setPlaybackProgress(float time)

Sets the playback progress

Parameters:

time – New playback position in seconds

float getPlaybackVolume()

Returns the playback volume

Returns:

volume in range 0.0-1.0

void setPlaybackVolume(float volume)

Sets the playback volume

Parameters:

volume – New volume in range 0.0-1.0

float getTotalDuration() const

Returns the total audio duration

Returns:

Duration in seconds

void registerOnPlaybackEnd(std::function<void()> callback)

Registers the called function when the audio playback reaches its end

Parameters:

callback – Function callback

void registerOnPlaybackLoopEnd(std::function<void()> callback)

Registers the called function when one loop of the audio playback reaches its end

Parameters:

callback – Function callback

void adjustBufferSize(float bufferSeconds)

Sets the playback buffer size

Parameters:

bufferSeconds – Buffer size in seconds

void setEnableMetadataLoad(bool enableMetadataLoad)

Enables or disables metadata load

Parameters:

enableMetadataLoad – Enable metadata load

void getMetadata(FString &Filename, FString &Extension, FString &MetaType, FString &Title, FString &Artist, FString &Album, FString &Year, FString &Genre)

Get file metadata

Parameters:
  • Filename[out] Filename of the audio file

  • Extension[out] Extension of the audio file

  • MetaType[out] ID3_V1 | ID3_V2.3 | ID3_V2.4

  • Title[out] Title of the song

  • Artist[out] Artist

  • Album[out] Album

  • Year[out] Year

  • Genre[out] Genre

void getMetadataArt(const FString &Prefix, const FString &Folder, int32 &NumberOfPictures)

Extract the AlbumArt pictures into the selected folder. Prefix1.png, Prefix2.png,…

Parameters:
  • Prefix – Prefix used to name the pictures.

  • Folder – Destination folder

  • NumberOfPictures[out] Number of stored pictures

void setDefaultAudioDevice(const FString &audioDeviceName)

Set default player device

Parameters:

audioDeviceName – New default audio device name

void getDefaultAudioDevice(FString &audioDeviceName)

Get default player device

Parameters:

audioDeviceName[out] Default audio device name

const AudioAnalyzerDeviceInfo &cgetAudioDeviceInfo() const

(Const) Returns the audio device info

Returns:

audio device info structure

AudioAnalyzerDeviceInfo &getAudioDeviceInfo()

Returns the audio device info

Returns:

audio device info structure

const int getRemainingLoops() const

Get remaining loops

Returns:

Remaining loops

inline const ma_decoder *getAudioDecoder() const

Get audio decoder

Returns:

ma_decoder

virtual bool hasOnlyHeader() const

Returns if only has been loaded the header data

Returns:

Has onkly header data

inline virtual bool needsBufferOffset() const

Returns if the buffer needs to be offset

Returns:

Needs buffer offset

void registerOnInitAudioEnd(std::function<void(bool)> callback)

Registers the called function when the init audio ends

Parameters:

callback – Function callback

inline bool isAsyncInitRunning() const

Returns if the async initialization thread is running

Returns:

bool Async Initialization is running

Public Members

std::function<void()> onPlaybackEndCallBack

Reference to the onPlaybackEnd function callback

std::function<void()> onPlaybackLoopEndCallBack

Reference to the onPlaybackLoopEnd function callback

Public Static Functions

static void getOutputAudioDeviceNames(TArray<FString> &audioDeviceNames)

Get output audio device names list

Parameters:

audioDeviceNames[out] Player device names list