Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "audio3d/audio3d.h"
00012
00013 #include <math.h>
00014
00015
00016
00018
00019
00020
00022
00023
00025
00026
00027
00029
00030 int
00031 main
00032 (
00033 IN int argc,
00034 IN const char * argv[]
00035 )
00036 {
00037 int retval = 0;
00038 ASSERT(2 == argc, "usage: audio3d-test <filename>");
00039 const char * soundfile = argv[1];
00040
00041 try {
00042
00043
00044 smart_ptr<audio3d::SoundManager> sndMgr =
00045 audio3d::SoundManager::create(NULL, NULL);
00046 ASSERT(sndMgr, "failed to create sound manager");
00047
00048
00049 audio3d::id_t lid = sndMgr->createListener();
00050 ASSERT(lid, "bad listener id: %d", (int) lid);
00051
00052
00053 float baseVolume = 1.0;
00054 audio3d::id_t sid =
00055 sndMgr->createSound(lid, soundfile, baseVolume);
00056 ASSERT(sid, "null");
00057
00058
00059 useconds_t us = 100 * 1000;
00060 float dt = 1.0e-6 * us;
00061 float t = 0;
00062 while (true) {
00063 usleep(us);
00064
00065 t += dt;
00066 point3d_t pos(3.0 * sin(t), 2.0 * sin(2.0 * t), 5.0 * cos(7.0 * t));
00067
00068 sndMgr->updateSound(sid, pos);
00069
00070 sndMgr->updateSounds();
00071 }
00072
00073 } catch (std::exception& e) {
00074 DPRINTF("Exception: %s", e.what());
00075 retval = 1;
00076 }
00077
00078 return retval;
00079 }
00080