diff --git a/rwengine/include/audio/MADStream.hpp b/rwengine/include/audio/MADStream.hpp index 45a83ab4..8ae61791 100644 --- a/rwengine/include/audio/MADStream.hpp +++ b/rwengine/include/audio/MADStream.hpp @@ -11,6 +11,9 @@ #include #include #include +#include +#include +#include "audio/alCheck.hpp" #include @@ -25,6 +28,10 @@ class MADStream : public sf::SoundStream unsigned int mReadProgress; std::vector mCurrentSamples; + constexpr static size_t numALbuffers = 8; + ALuint buffers[numALbuffers]; + ALuint alSource; + static inline signed int scale(mad_fixed_t sample); static mad_flow ms_header(void* user, mad_header const* header); static mad_flow ms_input(void* user, mad_stream* stream); diff --git a/rwengine/src/audio/MADStream.cpp b/rwengine/src/audio/MADStream.cpp index 0fdf493e..e81cb0d7 100644 --- a/rwengine/src/audio/MADStream.cpp +++ b/rwengine/src/audio/MADStream.cpp @@ -94,7 +94,8 @@ void MADStream::onSeek(sf::Time timeOffset) MADStream::MADStream() : mFdm(nullptr) { - + alCheck(alGenBuffers(numALbuffers, buffers)); + alCheck(alGenSources(1, &alSource)); } MADStream::~MADStream() @@ -136,5 +137,11 @@ bool MADStream::openFromFile(const std::string& loc) this->initialize(2, mMadSampleRate); + alCheck(alSourcef(alSource, AL_PITCH, 1)); + alCheck(alSourcef(alSource, AL_GAIN, 1)); + alCheck(alSource3f(alSource, AL_POSITION, 0, 0, 0)); + alCheck(alSource3f(alSource, AL_VELOCITY, 0, 0, 0)); + alCheck(alSourcei(alSource, AL_LOOPING, AL_FALSE)); + return true; }