47 lines
1.3 KiB
C++
47 lines
1.3 KiB
C++
#ifndef MINIAUDIOENGINE_H
|
|
#define MINIAUDIOENGINE_H
|
|
|
|
#define MINIAUDIO_IMPLEMENTATION
|
|
#include "miniaudio.h"
|
|
#include "defines.h" //MAX_LAYERS
|
|
#include <stdio.h> // for printf
|
|
|
|
class MiniAudioEngine
|
|
{
|
|
friend class AudioWidget;
|
|
|
|
public:
|
|
MiniAudioEngine();
|
|
void stopEngine();
|
|
bool startEngine(int id);
|
|
static void audioDataCallback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount);
|
|
|
|
protected:
|
|
ma_result loadMedia(int layer, char *media );
|
|
void volChanged(int layer, float vol);
|
|
void panChanged(int layer, float pan);
|
|
void pitchChanged(int layer, float pitch);
|
|
void playbackChanged(int layer, Status status);
|
|
float getDuration(int layer);
|
|
float getCursor(int layer);
|
|
void setCursor(int layer, int cursor);
|
|
ma_result printFormatInfo(int layer);
|
|
|
|
private:
|
|
ma_resource_manager_config resourceManagerConfig;
|
|
ma_resource_manager resourceManager;
|
|
ma_device_info* pPlaybackDeviceInfos;
|
|
ma_uint32 playbackDeviceCount;
|
|
ma_uint32 iChosenDevice;
|
|
ma_engine engine;
|
|
ma_device device;
|
|
ma_context context;
|
|
ma_sound m_currentSound[MAX_LAYERS];
|
|
ma_bool8 m_mediaLoaded[MAX_LAYERS];
|
|
|
|
ma_result getAllAudioDevices();
|
|
ma_result startDevice(int id);
|
|
ma_result startContext();
|
|
};
|
|
|
|
#endif // MINIAUDIOENGINE_H
|