Moved miniaudio to ma namespace. Added Engine destructor. Added Engine Listener Position.
This commit is contained in:
@@ -6,16 +6,18 @@
|
||||
#include <string>
|
||||
|
||||
namespace ChargeAudio {
|
||||
using namespace Corrade;
|
||||
namespace {
|
||||
namespace _ma {
|
||||
#include "miniaudio/miniaudio.h"
|
||||
}
|
||||
using namespace Corrade;
|
||||
using namespace _ma;
|
||||
class Sound {
|
||||
public:
|
||||
~Sound();
|
||||
void Play();
|
||||
void Pause();
|
||||
void Reset();
|
||||
|
||||
void SetPosition(Magnum::Vector3 position);
|
||||
Magnum::Vector3 GetPosition();
|
||||
void SetVolume(float value);
|
||||
@@ -31,7 +33,11 @@ private:
|
||||
class Engine {
|
||||
public:
|
||||
Engine();
|
||||
~Engine();
|
||||
Containers::Pointer<Sound> CreateSound(std::string filepath);
|
||||
|
||||
void SetPosition(Magnum::Vector3 position);
|
||||
Magnum::Vector3 GetPosition();
|
||||
void SetVolume(float value);
|
||||
float GetVolume();
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
#include "ChargeAudio.hpp"
|
||||
#include <Corrade/Containers/Pointer.h>
|
||||
#include <Corrade/Utility/Debug.h>
|
||||
#include <Magnum/Math/Vector3.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <stdexcept>
|
||||
@@ -17,6 +18,8 @@ Engine::Engine() {
|
||||
}
|
||||
}
|
||||
|
||||
Engine::~Engine() { ma_engine_uninit(&maEngine); }
|
||||
|
||||
Containers::Pointer<Sound> Engine::CreateSound(std::string filepath) {
|
||||
auto sound = Containers::Pointer<Sound>(new Sound());
|
||||
sound->baseEngine = this;
|
||||
@@ -34,5 +37,16 @@ Containers::Pointer<Sound> Engine::CreateSound(std::string filepath) {
|
||||
}
|
||||
|
||||
// Controls
|
||||
void Engine::SetPosition(Magnum::Vector3 position) {
|
||||
ma_engine_listener_set_position(&maEngine, 0, position.x(), position.y(),
|
||||
position.z());
|
||||
}
|
||||
|
||||
Magnum::Vector3 Engine::GetPosition() {
|
||||
ma_vec3f pos = ma_engine_listener_get_position(&maEngine, 0);
|
||||
return Magnum::Vector3(pos.x, pos.y, pos.z);
|
||||
;
|
||||
}
|
||||
|
||||
void Engine::SetVolume(float value) { ma_engine_set_volume(&maEngine, value); }
|
||||
float Engine::GetVolume() { return ma_engine_get_volume(&maEngine); }
|
||||
|
@@ -16,8 +16,7 @@ void Sound::SetPosition(Magnum::Vector3 position) {
|
||||
}
|
||||
Magnum::Vector3 Sound::GetPosition() {
|
||||
ma_vec3f pos = ma_sound_get_position(&maSound);
|
||||
Magnum::Vector3 position(pos.x, pos.y, pos.z);
|
||||
return position;
|
||||
return Magnum::Vector3(pos.x, pos.y, pos.z);
|
||||
}
|
||||
void Sound::SetVolume(float value) { ma_sound_set_volume(&maSound, value); }
|
||||
float Sound::GetVolume() { return ma_sound_get_volume(&maSound); }
|
||||
|
Reference in New Issue
Block a user