Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef AUDIOMANAGER_H
- #define AUDIOMANAGER_H
- /**DESCRIPTION: The platform-dependent class used to manage audio playback.**/
- /**C INCLUDES**/
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <math.h>
- /**C++ INCLUDES**/
- #include <vector>
- /**PLATFORM INCLUDES**/
- #include <3ds.h>
- /**ENGINE INCLUDES**/
- #include "AudioInstance.h"
- /*DEFINITIONS*/
- #define SAMPLE_RATE 44100
- #define FRAMES_PER_BUFFER 1024
- #define NUM_CHANNELS 1
- #define SAMPLES_PER_BUFFER (FRAMES_PER_BUFFER * NUM_CHANNELS)
- class AudioManager{
- public:
- //Constructor
- AudioManager();
- //Destructor
- ~AudioManager();
- //Functions
- //Initializes the platform's audio library.
- void Init();
- //Updates the AudioManager. Used to get rid of audio that has completed playback.
- void Update();
- //Adds an AudioInstance to the queue of sounds to be mixed.
- static void PlayAudio(AudioInstance* audioObject);
- //Pauses a specific AudioInstance’s playback.
- static void PauseAudio(AudioInstance* audioObject);
- //Stops an AudioInstance’s, removing it from the queue.
- static void StopAudio(AudioInstance* audioObject);
- //Used to determine whether the audio is currently playing.
- static bool isAudioPlaying(AudioInstance* audioObject);
- //Clears all of the currently playing audio.
- static void Clear();
- //Shuts down the platform's audio library and releases memory.
- void Destroy();
- //Members
- //Dual buffers for the consistent playback of audio.
- ndspWaveBuf waveBuf[2];
- //Used for flipping between the buffers.
- bool activeBuffer = false;
- //Allocated memory that stores the result of mixing the currently queued audio. To be memcpy’d to the output device.
- short* audioData = NULL;
- };
- #endif
Advertisement
Add Comment
Please, Sign In to add comment