mirror of
https://github.com/borgesdan/xn65
synced 2024-12-29 21:54:47 +01:00
Implementações em SoundEffects
This commit is contained in:
parent
a51a5ef1af
commit
6a48d6d664
@ -1,6 +1,7 @@
|
|||||||
#include "platform-dx/init.hpp"
|
#include "platform-dx/init.hpp"
|
||||||
#include "csharp/type.hpp"
|
#include "csharp/type.hpp"
|
||||||
#include "graphics/readers/texture2D.hpp"
|
#include "graphics/readers/texture2D.hpp"
|
||||||
|
#include "audio/readers/soundeffect.hpp"
|
||||||
#include "content/typereadermanager.hpp"
|
#include "content/typereadermanager.hpp"
|
||||||
#include "content/defaultreaders.hpp"
|
#include "content/defaultreaders.hpp"
|
||||||
#include "platform-dx/implementations.hpp"
|
#include "platform-dx/implementations.hpp"
|
||||||
@ -47,6 +48,7 @@ namespace xna {
|
|||||||
insertRegisteredReader<Vector3Reader>("Vector3Reader");
|
insertRegisteredReader<Vector3Reader>("Vector3Reader");
|
||||||
insertRegisteredReader<Vector4Reader>("Vector4Reader");
|
insertRegisteredReader<Vector4Reader>("Vector4Reader");
|
||||||
insertRegisteredReader<Texture2DReader>("Texture2DReader");
|
insertRegisteredReader<Texture2DReader>("Texture2DReader");
|
||||||
|
insertRegisteredReader<SoundEffect>("SoundEffectReader");
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlatformInit::InitActivadors()
|
void PlatformInit::InitActivadors()
|
||||||
@ -74,5 +76,6 @@ namespace xna {
|
|||||||
insertActivadorReader<Vector3Reader>();
|
insertActivadorReader<Vector3Reader>();
|
||||||
insertActivadorReader<Vector4Reader>();
|
insertActivadorReader<Vector4Reader>();
|
||||||
insertActivadorReader<Texture2DReader>();
|
insertActivadorReader<Texture2DReader>();
|
||||||
|
insertActivadorReader<SoundEffect>();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -11,6 +11,9 @@ namespace xna {
|
|||||||
impl = nullptr;
|
impl = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SoundEffect::SoundEffect() {
|
||||||
|
}
|
||||||
|
|
||||||
SoundEffect::SoundEffect(String const& fileName) {
|
SoundEffect::SoundEffect(String const& fileName) {
|
||||||
if (!AudioEngine::impl || !AudioEngine::impl->_dxAudioEngine)
|
if (!AudioEngine::impl || !AudioEngine::impl->_dxAudioEngine)
|
||||||
return;
|
return;
|
||||||
@ -19,8 +22,37 @@ namespace xna {
|
|||||||
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(
|
||||||
impl = nullptr;
|
std::vector<Byte> format,
|
||||||
|
std::vector<Byte> data,
|
||||||
|
Int loopStart,
|
||||||
|
Int loopLength,
|
||||||
|
TimeSpan const& duration) {
|
||||||
|
if (!AudioEngine::impl || !AudioEngine::impl->_dxAudioEngine)
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto wavData = unew<Byte[]>(data.size());
|
||||||
|
for (size_t i = 0; i < data.size(); ++i)
|
||||||
|
wavData[i] = data[i];
|
||||||
|
|
||||||
|
auto wavFormat = reinterpret_cast<WAVEFORMATEX*>(format.data());
|
||||||
|
auto startAudio = wavData.get() + sizeof(WAVEFORMATEX);
|
||||||
|
/*auto se = new DxSoundEffect(
|
||||||
|
AudioEngine::impl->_dxAudioEngine.get(),
|
||||||
|
wavData,
|
||||||
|
wavFormat,
|
||||||
|
startAudio,
|
||||||
|
data.size(),
|
||||||
|
loopStart,
|
||||||
|
loopLength);*/
|
||||||
|
impl->_dxSoundEffect = unew<DxSoundEffect>(
|
||||||
|
AudioEngine::impl->_dxAudioEngine.get(),
|
||||||
|
wavData,
|
||||||
|
wavFormat,
|
||||||
|
startAudio,
|
||||||
|
data.size(),
|
||||||
|
loopStart,
|
||||||
|
loopLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundEffect::Play() {
|
void SoundEffect::Play() {
|
||||||
|
@ -12,7 +12,13 @@ namespace xna {
|
|||||||
SoundEffectReader() : ContentTypeReaderT(typeof<SoundEffect>()) {}
|
SoundEffectReader() : ContentTypeReaderT(typeof<SoundEffect>()) {}
|
||||||
|
|
||||||
PSoundEffect Read(ContentReader& input, PSoundEffect& existingInstance) override {
|
PSoundEffect Read(ContentReader& input, PSoundEffect& existingInstance) override {
|
||||||
return nullptr;
|
const auto count1 = input.ReadInt32();
|
||||||
|
auto format = input.ReadBytes(count1);
|
||||||
|
auto count2 = input.ReadInt32();
|
||||||
|
auto data = input.ReadBytes(count2);
|
||||||
|
auto loopStart = input.ReadInt32();
|
||||||
|
auto loopLength = input.ReadInt32();
|
||||||
|
auto num = input.ReadInt32();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,12 @@ namespace xna {
|
|||||||
public:
|
public:
|
||||||
SoundEffect();
|
SoundEffect();
|
||||||
SoundEffect(String const& fileName);
|
SoundEffect(String const& fileName);
|
||||||
~SoundEffect();
|
SoundEffect(
|
||||||
|
std::vector<Byte> format,
|
||||||
|
std::vector<Byte> data,
|
||||||
|
Int loopStart,
|
||||||
|
Int loopLength,
|
||||||
|
TimeSpan const& duration);
|
||||||
void Play();
|
void Play();
|
||||||
void Play(float volume, float pitch, float pan);
|
void Play(float volume, float pitch, float pan);
|
||||||
uptr<SoundEffectInstance> CreateInstance();
|
uptr<SoundEffectInstance> CreateInstance();
|
||||||
|
@ -27,6 +27,8 @@ namespace xna {
|
|||||||
void LoadContent() override {
|
void LoadContent() override {
|
||||||
spriteBatch = New<SpriteBatch>(*graphicsDevice);
|
spriteBatch = New<SpriteBatch>(*graphicsDevice);
|
||||||
|
|
||||||
|
auto effect = Content()->Load<PSoundEffect>("ExitReached");
|
||||||
|
|
||||||
Game::LoadContent();
|
Game::LoadContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user