mirror of
https://github.com/borgesdan/xn65
synced 2024-12-29 21:54:47 +01:00
Corrige AudiEngine
This commit is contained in:
parent
11c3b6aa4a
commit
a51a5ef1af
@ -1,15 +1,10 @@
|
|||||||
#include "platform-dx/implementations.hpp"
|
#include "platform-dx/implementations.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
AudioEngine::AudioEngine()
|
void AudioEngine::Initialize() {
|
||||||
{
|
|
||||||
impl = unew<PlatformImplementation>();
|
impl = unew<PlatformImplementation>();
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioEngine::~AudioEngine() {
|
|
||||||
impl = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AudioEngine::Reset() {
|
bool AudioEngine::Reset() {
|
||||||
if (!impl || !impl->_dxAudioEngine)
|
if (!impl || !impl->_dxAudioEngine)
|
||||||
return false;
|
return false;
|
||||||
|
@ -78,25 +78,11 @@ namespace xna {
|
|||||||
return StartGameLoop();
|
return StartGameLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::Initialize() {
|
void Game::Initialize() {
|
||||||
//#if (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
|
|
||||||
Microsoft::WRL::Wrappers::RoInitializeWrapper initialize(RO_INIT_MULTITHREADED);
|
|
||||||
if (FAILED(initialize))
|
|
||||||
{
|
|
||||||
MessageBox(nullptr, "Ocorreu um erro ao chamar Microsoft::WRL::Wrappers::RoInitializeWrapper.", "XN65", MB_OK);
|
|
||||||
}
|
|
||||||
//#else
|
|
||||||
HRESULT hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED);
|
|
||||||
if (FAILED(hr))
|
|
||||||
{
|
|
||||||
MessageBox(nullptr, "Ocorreu um erro ao chamar CoInitializeEx.", "XN65", MB_OK);
|
|
||||||
}
|
|
||||||
//#endif
|
|
||||||
Keyboard::Initialize();
|
Keyboard::Initialize();
|
||||||
Mouse::Initialize();
|
Mouse::Initialize();
|
||||||
GamePad::Initialize();
|
GamePad::Initialize();
|
||||||
|
AudioEngine::Initialize();
|
||||||
_audioEngine = New<AudioEngine>();
|
|
||||||
|
|
||||||
LoadContent();
|
LoadContent();
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,19 @@
|
|||||||
#include "platform-dx/implementations.hpp"
|
#include "platform-dx/implementations.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
void Platform::Init() {
|
void Platform::Init() {
|
||||||
|
Microsoft::WRL::Wrappers::RoInitializeWrapper initialize(RO_INIT_MULTITHREADED);
|
||||||
|
if (FAILED(initialize))
|
||||||
|
{
|
||||||
|
MessageBox(nullptr, "Ocorreu um erro ao chamar Microsoft::WRL::Wrappers::RoInitializeWrapper.", "XN65", MB_OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED);
|
||||||
|
if (FAILED(hr))
|
||||||
|
{
|
||||||
|
MessageBox(nullptr, "Ocorreu um erro ao chamar CoInitializeEx.", "XN65", MB_OK);
|
||||||
|
}
|
||||||
|
|
||||||
PlatformInit::Init();
|
PlatformInit::Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,12 +11,12 @@ namespace xna {
|
|||||||
impl = nullptr;
|
impl = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
SoundEffect::SoundEffect(AudioEngine& audioEngine, String const& fileName) {
|
SoundEffect::SoundEffect(String const& fileName) {
|
||||||
if (!audioEngine.impl->_dxAudioEngine)
|
if (!AudioEngine::impl || !AudioEngine::impl->_dxAudioEngine)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const auto file = XnaHToWString(fileName);
|
const auto file = XnaHToWString(fileName);
|
||||||
impl->_dxSoundEffect = unew<DxSoundEffect>(audioEngine.impl->_dxAudioEngine.get(), file.c_str());
|
impl->_dxSoundEffect = unew<DxSoundEffect>(AudioEngine::impl->_dxAudioEngine.get(), file.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
SoundEffect::~SoundEffect() {
|
SoundEffect::~SoundEffect() {
|
||||||
|
@ -5,21 +5,26 @@
|
|||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
class AudioEngine {
|
class AudioEngine {
|
||||||
public:
|
public:
|
||||||
AudioEngine();
|
static bool Reset();
|
||||||
~AudioEngine();
|
static bool Resume();
|
||||||
bool Reset();
|
static bool Suspend();
|
||||||
bool Resume();
|
static bool Update();
|
||||||
bool Suspend();
|
static void DefaultSampleRate(int value);
|
||||||
bool Update();
|
static void MasterVolume(float value);
|
||||||
void DefaultSampleRate(int value);
|
static void MasteringLimit(int limit, int loudness);
|
||||||
void MasterVolume(float value);
|
static void Reverb(AudioReverb value);
|
||||||
void MasteringLimit(int limit, int loudness);
|
|
||||||
void Reverb(AudioReverb value);
|
static void Initialize();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct PlatformImplementation;
|
struct PlatformImplementation;
|
||||||
uptr<PlatformImplementation> impl = nullptr;
|
inline static uptr<PlatformImplementation> impl = nullptr;
|
||||||
|
|
||||||
|
private:
|
||||||
|
AudioEngine();
|
||||||
|
AudioEngine(AudioEngine&);
|
||||||
|
AudioEngine(AudioEngine&&);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
20
inc/audio/readers/soundeffect.hpp
Normal file
20
inc/audio/readers/soundeffect.hpp
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#ifndef XNA_AUDIO_READERS_SOUNDEFFECT_HPP
|
||||||
|
#define XNA_AUDIO_READERS_SOUNDEFFECT_HPP
|
||||||
|
|
||||||
|
#include "content/manager.hpp"
|
||||||
|
#include "content/reader.hpp"
|
||||||
|
#include "csharp/type.hpp"
|
||||||
|
#include "audio/soundeffect.hpp"
|
||||||
|
|
||||||
|
namespace xna {
|
||||||
|
class SoundEffectReader : public ContentTypeReaderT<PSoundEffect> {
|
||||||
|
public:
|
||||||
|
SoundEffectReader() : ContentTypeReaderT(typeof<SoundEffect>()) {}
|
||||||
|
|
||||||
|
PSoundEffect Read(ContentReader& input, PSoundEffect& existingInstance) override {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -25,7 +25,8 @@ namespace xna {
|
|||||||
|
|
||||||
class SoundEffect {
|
class SoundEffect {
|
||||||
public:
|
public:
|
||||||
SoundEffect(AudioEngine& audioEngine, String const& fileName);
|
SoundEffect();
|
||||||
|
SoundEffect(String const& fileName);
|
||||||
~SoundEffect();
|
~SoundEffect();
|
||||||
void Play();
|
void Play();
|
||||||
void Play(float volume, float pitch, float pan);
|
void Play(float volume, float pitch, float pan);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user