persona-3-dual
A DS demake of Persona 3
Loading...
Searching...
No Matches
AudioManager Class Reference

#include <AudioManager.hpp>

Inheritance diagram for AudioManager:
Collaboration diagram for AudioManager:

Public Member Functions

void init () override
void process () override
void shutdown () override
void registerAudio (std::string path, ae::q20_12_t loopStartTime, ae::q20_12_t loopEndTime)
 Sets up the audio track to be played.
void playAudio ()
 Play the currently registered audio, if paused.
void pauseAudio ()
 Pause the currently registered audio, if playing.
void stopAudio ()
 Deregister the currently registered audio.
void registerSFX (SFX sfx)
 Register the SFX to be played.
void playSFX (SFX sfx, int volume, int panning)
 Play the specified registered SFX.
void stopSFX ()
 Stop all currently playing SFXs.
ae::q20_12_t getDuration ()
 Get the total duration of the audio.
ae::q20_12_t getTime ()
 Get the current time of the audio.

Private Member Functions

 AudioManager ()=default
int getFrame ()
 Get the current audio frame.
void seekFrame (int frame)
 Move to the specified audio frame.
void setLoop (ae::q20_12_t startTime, ae::q20_12_t endTime)
 Set the audio looping points.
void loop ()
 Looping logic.
void rewind ()
 Move to the start of the audio track.
uint32_t decodeFrame ()
 Decode the current audio frame.
uint32_t decode (short *sample_data, int num_samples)
 Decode the given audio sample based on the current frame.
mm_word processStream (mm_word length, mm_addr dest, mm_stream_formats format)
 Processes the next audio data to play.

Static Private Member Functions

static mm_word audioCallback (mm_word length, mm_addr dest, mm_stream_formats format)
 Callback for maxmod audio streaming, acting as a wrapper for processStream.

Private Attributes

qoaplay_desc * qp = nullptr
bool isLoopingEnabled = false
bool isAudioRegistered = false
int startFrame = 0
int endFrame = 0

Friends

class Singleton< AudioManager >

Detailed Description

Definition at line 13 of file AudioManager.hpp.

Constructor & Destructor Documentation

◆ AudioManager()

AudioManager::AudioManager ( )
privatedefault
Here is the caller graph for this function:

Member Function Documentation

◆ audioCallback()

mm_word AudioManager::audioCallback ( mm_word length,
mm_addr dest,
mm_stream_formats format )
staticprivate

Callback for maxmod audio streaming, acting as a wrapper for processStream.

Parameters
lengththe audio word length
destthe audio destination address
formatthe audio stream format
Returns
mm_word the audio data to play

Definition at line 202 of file AudioManager.cpp.

Here is the caller graph for this function:

◆ decode()

uint32_t AudioManager::decode ( short * sample_data,
int num_samples )
private

Decode the given audio sample based on the current frame.

Parameters
sample_datathe sample data
num_samplesthe number of samples
Returns
uint32_t the frame length

Definition at line 164 of file AudioManager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ decodeFrame()

uint32_t AudioManager::decodeFrame ( )
private

Decode the current audio frame.

Returns
uint32_t the number of samples

Definition at line 148 of file AudioManager.cpp.

Here is the caller graph for this function:

◆ getDuration()

ae::q20_12_t AudioManager::getDuration ( )

Get the total duration of the audio.

Returns
ae::q20_12_t the duration in seconds

Definition at line 42 of file AudioManager.cpp.

Here is the call graph for this function:

◆ getFrame()

int AudioManager::getFrame ( )
private

Get the current audio frame.

Returns
int the audio frame

Definition at line 61 of file AudioManager.cpp.

Here is the caller graph for this function:

◆ getTime()

ae::q20_12_t AudioManager::getTime ( )

Get the current time of the audio.

Returns
ae::q20_12_t the time in seconds

Definition at line 52 of file AudioManager.cpp.

◆ init()

void AudioManager::init ( )
override

Definition at line 15 of file AudioManager.cpp.

◆ loop()

void AudioManager::loop ( )
private

Looping logic.

Definition at line 121 of file AudioManager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pauseAudio()

void AudioManager::pauseAudio ( )

Pause the currently registered audio, if playing.

Definition at line 309 of file AudioManager.cpp.

◆ playAudio()

void AudioManager::playAudio ( )

Play the currently registered audio, if paused.

Definition at line 304 of file AudioManager.cpp.

Here is the caller graph for this function:

◆ playSFX()

void AudioManager::playSFX ( SFX sfx,
int volume,
int panning )

Play the specified registered SFX.

Parameters
sfxthe SFX to play
volumethe volume of the SFX. Range is from 0-127
panningthe direction to play the sound effect (left to right). The range is 0-127 (64 plays both left and right equally)

Definition at line 341 of file AudioManager.cpp.

◆ process()

void AudioManager::process ( )
override

Definition at line 29 of file AudioManager.cpp.

◆ processStream()

mm_word AudioManager::processStream ( mm_word length,
mm_addr dest,
mm_stream_formats format )
private

Processes the next audio data to play.

Parameters
lengththe audio word length
destthe audio destination address
formatthe audio stream format
Returns
mm_word the decoded audio data

Definition at line 207 of file AudioManager.cpp.

Here is the call graph for this function:

◆ registerAudio()

void AudioManager::registerAudio ( std::string path,
ae::q20_12_t loopStartTime,
ae::q20_12_t loopEndTime )

Sets up the audio track to be played.

Parameters
paththe file path to the audio track
loopStartTimethe loop start time in seconds
loopEndTimethe loop end time in seconds

Definition at line 225 of file AudioManager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ registerSFX()

void AudioManager::registerSFX ( SFX sfx)

Register the SFX to be played.

Parameters
sfxthe SFX to register

Definition at line 336 of file AudioManager.cpp.

◆ rewind()

void AudioManager::rewind ( )
private

Move to the start of the audio track.

Definition at line 135 of file AudioManager.cpp.

Here is the caller graph for this function:

◆ seekFrame()

void AudioManager::seekFrame ( int frame)
private

Move to the specified audio frame.

Parameters
framethe audio frame to move to

Definition at line 70 of file AudioManager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setLoop()

void AudioManager::setLoop ( ae::q20_12_t startTime,
ae::q20_12_t endTime )
private

Set the audio looping points.

Parameters
startTimethe loop start time in seconds
endTimethe loop end time in seconds

Definition at line 95 of file AudioManager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ shutdown()

void AudioManager::shutdown ( )
override

Definition at line 37 of file AudioManager.cpp.

Here is the call graph for this function:

◆ stopAudio()

void AudioManager::stopAudio ( )

Deregister the currently registered audio.

Definition at line 314 of file AudioManager.cpp.

Here is the caller graph for this function:

◆ stopSFX()

void AudioManager::stopSFX ( )

Stop all currently playing SFXs.

Definition at line 352 of file AudioManager.cpp.

◆ Singleton< AudioManager >

friend class Singleton< AudioManager >
friend

Definition at line 79 of file AudioManager.hpp.

Member Data Documentation

◆ endFrame

int AudioManager::endFrame = 0
private

Definition at line 89 of file AudioManager.hpp.

◆ isAudioRegistered

bool AudioManager::isAudioRegistered = false
private

Definition at line 87 of file AudioManager.hpp.

◆ isLoopingEnabled

bool AudioManager::isLoopingEnabled = false
private

Definition at line 86 of file AudioManager.hpp.

◆ qp

qoaplay_desc* AudioManager::qp = nullptr
private

Definition at line 85 of file AudioManager.hpp.

◆ startFrame

int AudioManager::startFrame = 0
private

Definition at line 88 of file AudioManager.hpp.


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