mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:53:51 +00:00
Added sound test (remember to git submodule update)
This commit is contained in:
parent
0d4f2ab3ef
commit
cf4185faef
4 changed files with 66 additions and 1 deletions
|
@ -200,3 +200,5 @@ option(BUILD_ESMTOOL "build ESM inspector" ON)
|
||||||
if (BUILD_ESMTOOL)
|
if (BUILD_ESMTOOL)
|
||||||
add_subdirectory( apps/esmtool )
|
add_subdirectory( apps/esmtool )
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
add_subdirectory( apps/soundtest )
|
||||||
|
|
11
apps/soundtest/CMakeLists.txt
Normal file
11
apps/soundtest/CMakeLists.txt
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
project(SoundTest)
|
||||||
|
|
||||||
|
# local files
|
||||||
|
|
||||||
|
# Main executable
|
||||||
|
add_executable(sound_test main.cpp ${OENGINE_SOUND})
|
||||||
|
|
||||||
|
target_link_libraries(sound_test
|
||||||
|
${OPENAL_LIBRARY}
|
||||||
|
${AUDIERE_LIBRARY}
|
||||||
|
)
|
52
apps/soundtest/main.cpp
Normal file
52
apps/soundtest/main.cpp
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <mangle/stream/servers/file_stream.hpp>
|
||||||
|
#include <mangle/sound/filters/openal_audiere.hpp>
|
||||||
|
#include <mangle/sound/sources/stream_source.hpp>
|
||||||
|
#include <mangle/stream/filters/buffer_stream.hpp>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace Mangle::Stream;
|
||||||
|
using namespace Mangle::Sound;
|
||||||
|
|
||||||
|
AudiereLoader loader;
|
||||||
|
OpenAL_Factory openal;
|
||||||
|
|
||||||
|
void play(const char* name)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
cout << "Opening " << name << " via Audiere\n";
|
||||||
|
SampleSourcePtr samples = loader.load(name);
|
||||||
|
cout << "Loading entire file into memory\n";
|
||||||
|
StreamPtr buf(new BufferStream(samples));
|
||||||
|
|
||||||
|
// Recreate the stream as a sample source (we're only doing it
|
||||||
|
// this complicated to test each step individually)
|
||||||
|
int a,b,c;
|
||||||
|
samples->getInfo(&a,&b,&c);
|
||||||
|
samples.reset(new Stream2Samples(buf, a,b,c));
|
||||||
|
|
||||||
|
cout << "Creating OpenAL sound from data\n";
|
||||||
|
SoundPtr snd = openal.loadRaw(samples);
|
||||||
|
cout << "Playing (abort with Ctrl-C)\n";
|
||||||
|
snd->play();
|
||||||
|
|
||||||
|
while(snd->isPlaying())
|
||||||
|
usleep(10000);
|
||||||
|
cout << "Done playing\n";
|
||||||
|
}
|
||||||
|
catch(exception &e)
|
||||||
|
{
|
||||||
|
cout << " ERROR: " << e.what() << "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
if(argc==1)
|
||||||
|
cout << "Specify sound file (wav, mp3, ogg) on command line.\n";
|
||||||
|
for(int i=1; i<argc; i++)
|
||||||
|
play(argv[i]);
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -1 +1 @@
|
||||||
Subproject commit 86a811c736810ef156fd2788be74951c5416ca03
|
Subproject commit f95ea1677cc5c52790e1342aa6d3d6bba950b8be
|
Loading…
Reference in a new issue