MMAV is a Multimedia Component and Plugin for Ogre.
Features:
1. Play wav and ogg file
2. 3D sound
3. Audio grouping
http://chucklesoft.blogspot.com/
MMAV Audio Component for Ogre
-
- OGRE Retired Team Member
- Posts: 972
- Joined: Mon Jun 02, 2008 6:52 pm
- Location: Berlin
- x 65
Re: MMAV Audio Component for Ogre
Maybe you could show some code examples? 

-
- Gnoblar
- Posts: 5
- Joined: Wed Nov 07, 2012 3:16 pm
Re: MMAV Audio Component for Ogre
Code usage:
Sample1:
Sample 3:
Sample1:
Code: Select all
#include "Ogre.h"
#include "MMAV.h"
#include "conio.h"
int main(int argc, char* argv[])
{
Ogre::String pluginsPath;
#ifndef OGRE_STATIC_LIB
#if OGRE_DEBUG_MODE
pluginsPath = "plugins_d.cfg";
#else
pluginsPath = "plugins.cfg";
#endif
#endif
Ogre::Root* mOgreRoot = new Ogre::Root(pluginsPath,"ogre.cfg","Ogre.log");
MMAV::AVSystem* mAVSystem = new MMAV::AVSystem(pluginsPath);
//
Ogre::ConfigFile cf;
#if OGRE_DEBUG_MODE
cf.load("resources_d.cfg");
#else
cf.load("resources.cfg");
#endif
Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
Ogre::String sec, type, arch;
while(seci.hasMoreElements())
{
sec = seci.peekNextKey();
Ogre::ConfigFile::SettingsMultiMap* settings = seci.getNext();
Ogre::ConfigFile::SettingsMultiMap::iterator i;
for(i = settings->begin(); i != settings->end(); i++)
{
type = i->first;
arch = i->second;
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(arch, type, sec);
}
}
//
mAVSystem->initialize();
MMAV::AudioGroup* mAudioGroup = mAVSystem->createAudioGroup();//for example sound effect or background music
//mAudioGroup->setVolumeScaler(100);//volume scale will apply only to this audio group
MMAV::AudioEmitter* mAudioEmitter = mAudioGroup->createAudioEmitter("chirp.ogg");//you can play ogg or wav. I put wav file in Sample 2
mAudioEmitter->play(true);
std::cout<<"press any key to stop"<<std::endl;
while(1)
{
if(kbhit())
break;
}
delete mAVSystem;
delete mOgreRoot;
return 0;
}
Code: Select all
#include "Ogre.h"
#include "MMAV.h"
#include "ExampleApplication.h"
//------------------------------------------------
//------------------------------------------------
class Sample3FrameListener : public ExampleFrameListener
{
public:
Sample3FrameListener(RenderWindow* win, Camera* cam) : ExampleFrameListener( win, cam )
{
mMoveSpeed = 15.0;
}
bool frameRenderingQueued( const FrameEvent& evt )
{
if( ExampleFrameListener::frameRenderingQueued( evt ) == false )
return false;
MMAV::AVSystem* avs = MMAV::AVSystem::getSingletonPtr();
if(avs)
{
avs->update(evt.timeSinceLastFrame);
avs->getAudioDevice()->setListenerPosition(mCamera->getPosition());
avs->getAudioDevice()->setListenerOrientation(mCamera->getOrientation());
//std::cout<<mCamera->getPosition()<<std::endl;
}
if( mKeyboard->isKeyDown( OIS::KC_LSHIFT ) ||
mKeyboard->isKeyDown( OIS::KC_RSHIFT ))
{
mMoveSpeed = 50;
}
else
{
mMoveSpeed = 15;
}
return true;
}
};
//------------------------------------------------
//------------------------------------------------
class Sample3Application : public ExampleApplication
{
public:
Sample3Application()
{
}
~Sample3Application()
{
delete mAVSystem;
}
protected:
SceneNode * mCameraNode;
MMAV::AVSystem* mAVSystem;
MMAV::AudioGroup* mAudioGroup;
virtual void setupResources(void)
{
ExampleApplication::setupResources();
//
String pluginsPath;
// only use plugins.cfg if not static
#ifndef OGRE_STATIC_LIB
#if OGRE_DEBUG_MODE
pluginsPath = mResourcePath + "plugins_d.cfg";
#else
pluginsPath = mResourcePath + "plugins.cfg";
#endif
#endif
mAVSystem = new MMAV::AVSystem(pluginsPath);
mAVSystem->initialize();
//
mAudioGroup = mAVSystem->createAudioGroup();
//
}
virtual void createFrameListener(void)
{
mFrameListener= new Sample3FrameListener(mWindow, mCamera);
mRoot->addFrameListener(mFrameListener);
}
virtual void createCamera(void)
{
// Create the camera
mCamera = mSceneMgr->createCamera("PlayerCam");
// Position it at 500 in Z direction
mCamera->setPosition(Vector3(0,0,35));
// Look back along -Z
mCamera->lookAt(Vector3(0,0,-300));
mCamera->setNearClipDistance(0.1);
mCamera->setFarClipDistance(10000);
}
void createScene(void)
{
//mSceneMgr->setSkyBox(true, "Examples/CloudyNoonSkyBox", 500 );
Ogre::Entity* ent = mSceneMgr->createEntity("Sphere.mesh");
Ogre::SceneNode* sn = mSceneMgr->getRootSceneNode()->createChildSceneNode();
sn->attachObject(ent);
MMAV::AudioEmitter* mAudioEmitter = mAudioGroup->createAudioEmitter("chirp.wav");
mAudioEmitter->setPosition(sn->getPosition());
mAudioEmitter->setOrientation(sn->getOrientation());
mAudioEmitter->setMaxDistance(100);
mAudioEmitter->play(true);
std::cout<<"press w,s,a,d to move camera, press l-shift to increase camera speed"<<std::endl;
}
};
//------------------------------------------------
//------------------------------------------------
int main(int argc, char* argv[])
{
Sample3Application app;
try
{
app.go();
}
catch( Ogre::Exception& e )
{
std::cerr<<"An exception has occurred: "<<e.getFullDescription().c_str()<<std::endl;
}
}