iMackshun

AudioManager.h

Jan 8th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.70 KB | None | 0 0
  1. #ifndef AUDIOMANAGER_H
  2. #define AUDIOMANAGER_H
  3.  
  4. /**DESCRIPTION: The platform-dependent class used to manage audio playback.**/
  5.  
  6. /**C INCLUDES**/
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <string.h>
  10. #include <math.h>
  11.  
  12. /**C++ INCLUDES**/
  13. #include <vector>
  14.  
  15. /**PLATFORM INCLUDES**/
  16. #include <3ds.h>
  17.  
  18. /**ENGINE INCLUDES**/
  19. #include "AudioInstance.h"
  20.  
  21. /*DEFINITIONS*/
  22. #define SAMPLE_RATE 44100
  23. #define FRAMES_PER_BUFFER 1024
  24. #define NUM_CHANNELS 1
  25. #define SAMPLES_PER_BUFFER (FRAMES_PER_BUFFER * NUM_CHANNELS)
  26.  
  27. class AudioManager{
  28. public:
  29.     //Constructor
  30.     AudioManager();
  31.     //Destructor
  32.     ~AudioManager();
  33.     //Functions
  34.     //Initializes the platform's audio library.
  35.     void Init();
  36.     //Updates the AudioManager. Used to get rid of audio that has completed playback.
  37.     void Update();
  38.     //Adds an AudioInstance to the queue of sounds to be mixed.
  39.     static void PlayAudio(AudioInstance* audioObject);
  40.     //Pauses a specific AudioInstance’s playback.
  41.     static void PauseAudio(AudioInstance* audioObject);
  42.     //Stops an AudioInstance’s, removing it from the queue.
  43.     static void StopAudio(AudioInstance* audioObject);
  44.     //Used to determine whether the audio is currently playing.
  45.     static bool isAudioPlaying(AudioInstance* audioObject);
  46.     //Clears all of the currently playing audio.
  47.     static void Clear();
  48.     //Shuts down the platform's audio library and releases memory.
  49.     void Destroy();
  50.     //Members
  51.     //Dual buffers for the consistent playback of audio.
  52.     ndspWaveBuf waveBuf[2];
  53.     //Used for flipping between the buffers.
  54.     bool activeBuffer = false;
  55.     //Allocated memory that stores the result of mixing the currently queued audio. To be memcpy’d to the output device.
  56.     short* audioData = NULL;
  57. };
  58.  
  59. #endif
Advertisement
Add Comment
Please, Sign In to add comment