Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

vrj::SoundManagerSonix Class Reference

Enables VR Juggler to reconfigure the sonix sound interface. More...

#include <SoundManagerSonix.h>

Inheritance diagram for vrj::SoundManagerSonix:

Inheritance graph
[legend]
Collaboration diagram for vrj::SoundManagerSonix:

Collaboration graph
[legend]
List of all members.

Public Methods

virtual bool configAdd (jccl::ConfigElementPtr element)
 Adds the element to the configuration. More...

virtual bool configRemove (jccl::ConfigElementPtr element)
 Removes the element from the current configuration. More...

virtual bool configCanHandle (jccl::ConfigElementPtr element)
 Can the handler handle the given element? More...

virtual void update ()
 Enables a frame to be drawn. More...

virtual void sync ()
 Blocks until the end of the frame. More...


Detailed Description

Enables VR Juggler to reconfigure the sonix sound interface.

Definition at line 44 of file SoundManagerSonix.h.


Member Function Documentation

bool vrj::SoundManagerSonix::configAdd jccl::ConfigElementPtr    element [virtual]
 

Adds the element to the configuration.

Precondition:
configCanHandle(element) == true

Reimplemented from vrj::SoundManager.

Definition at line 48 of file SoundManagerSonix.cpp.

References configCanHandle.

00049    {
00050       vprDEBUG(vprDBG_ALL, vprDBG_CONFIG_LVL)
00051          << "======================================\n" << vprDEBUG_FLUSH;
00052       vprDEBUG(vprDBG_ALL, vprDBG_CONFIG_LVL)
00053          << "SoundManagerSonix is being configured...\n" << vprDEBUG_FLUSH;
00054 
00055       if (!configCanHandle( element ))
00056       {
00057          std::cerr << "ERROR: Wrong element type in SoundManagerSonix\n"
00058                    << std::flush;
00059          return false;
00060       }
00061 
00062       std::string manager_name = element->getName();
00063       vprDEBUG(vprDBG_ALL, vprDBG_CONFIG_LVL) << "My Name: " << manager_name
00064                                               << "\n" << vprDEBUG_FLUSH;
00065       std::string api_to_use = element->getProperty<std::string>( "api" );
00066       vprDEBUG(vprDBG_ALL, vprDBG_CONFIG_LVL) << "Use API: " << api_to_use
00067                                               << "\n" << vprDEBUG_FLUSH;
00068       float listener_position[3];
00069       listener_position[0] = (float)element->getProperty<float>( "listener_position", 0 );
00070       listener_position[1] = (float)element->getProperty<float>( "listener_position", 1 );
00071       listener_position[2] = (float)element->getProperty<float>( "listener_position", 2 );
00072       vprDEBUG(vprDBG_ALL, vprDBG_CONFIG_LVL)
00073          << "Listener Position: " << listener_position[0] << ","
00074          << listener_position[1] << "," << listener_position[2] << "\n" << vprDEBUG_FLUSH;
00075       std::string file_search_path = element->getProperty<std::string>( "file_search_path" );
00076       vprDEBUG(vprDBG_ALL, vprDBG_CONFIG_LVL)
00077          << "Search path: " << file_search_path << "\n" << vprDEBUG_FLUSH;
00078 
00079       // configure sonix
00080       sonix::instance()->changeAPI( api_to_use );
00081       gmtl::Matrix44f mat;
00082       gmtl::setTrans( mat, gmtl::Vec3f( listener_position[0], listener_position[1], listener_position[2] ) );
00083       sonix::instance()->setListenerPosition( mat );
00084 
00085       // read the list of sounds
00086       int size = element->getNum( "sound" );
00087       vprDEBUG(vprDBG_ALL, vprDBG_CONFIG_LVL) << "Configuring " << size
00088                                               << " sounds.\n" << vprDEBUG_FLUSH;
00089       for (int x = 0; x < size; ++x)
00090       {
00091          jccl::ConfigElementPtr sound_element =
00092             element->getProperty<jccl::ConfigElementPtr>("sound", x);
00093          std::string alias = sound_element->getName();
00094          std::string filename = sound_element->getProperty<std::string>("filename");
00095          filename = vpr::replaceEnvVars( filename );
00096          bool ambient = sound_element->getProperty<bool>("ambient");
00097          bool retriggerable = sound_element->getProperty<bool>("retriggerable");
00098          int loop = sound_element->getProperty<int>("loop");
00099          float cutoff = sound_element->getProperty<float>("cutoff");
00100          float volume = sound_element->getProperty<float>("volume");
00101          float pitchbend = sound_element->getProperty<float>("pitch_bend");
00102          float position[3];
00103          position[0] = sound_element->getProperty<float>("position", 0);
00104          position[1] = sound_element->getProperty<float>("position", 1);
00105          position[2] = sound_element->getProperty<float>("position", 2);
00106 
00107          // configure the sound...
00108          snx::SoundInfo si;
00109          si.datasource = snx::SoundInfo::FILESYSTEM;
00110          si.filename = filename;
00111          si.cutoff = cutoff;
00112          si.volume = volume;
00113          si.pitchbend = pitchbend;
00114          si.repeat = loop;
00115          si.ambient = ambient;
00116          si.retriggerable = retriggerable;
00117          si.position[0] = position[0];
00118          si.position[1] = position[1];
00119          si.position[2] = position[2];
00120          vprDEBUG(vprDBG_ALL, vprDBG_CONFIG_LVL)
00121             << "- Configuring " << alias << " (" << filename << ")\n"
00122             << vprDEBUG_FLUSH;
00123          vprDEBUG(vprDBG_ALL, vprDBG_STATE_LVL)
00124             << "  + pos(" << position[0] << "," << position[1] << ","
00125             << position[2] << ")," << "loop(" << loop << "),\n"
00126             << vprDEBUG_FLUSH;
00127          vprDEBUG(vprDBG_ALL, vprDBG_STATE_LVL)
00128             << "  + amb(" << ambient << ")," << "ct(" << cutoff << "),"
00129             << "vl(" << volume << "),\n" << vprDEBUG_FLUSH;
00130          vprDEBUG(vprDBG_ALL, vprDBG_STATE_LVL)
00131             << "  + freq(" << pitchbend << ")," << "retrig(" << retriggerable
00132             << ")\n" << vprDEBUG_FLUSH;
00133 
00134          sonix::instance()->configure( alias, si );
00135       }
00136       vprDEBUG(vprDBG_ALL, vprDBG_CONFIG_LVL)
00137          << "======================================\n" << vprDEBUG_FLUSH;
00138 
00139       return true;
00140    }

bool vrj::SoundManagerSonix::configRemove jccl::ConfigElementPtr    element [virtual]
 

Removes the element from the current configuration.

Precondition:
configCanHandle(element) == true

Reimplemented from vrj::SoundManager.

Definition at line 146 of file SoundManagerSonix.cpp.

00147    {
00148       // remove any specified sounds...
00149       int size = element->getNum("sound");
00150       for (int x = 0; x < size; ++x)
00151       {
00152          jccl::ConfigElementPtr sound_element =
00153             element->getProperty<jccl::ConfigElementPtr>("sound", x);
00154          std::string alias(sound_element->getName());
00155          sonix::instance()->remove(alias);
00156       }
00157 
00158       return true;
00159    }

bool vrj::SoundManagerSonix::configCanHandle jccl::ConfigElementPtr    element [virtual]
 

Can the handler handle the given element?

Returns:
true if we can handle it; false if not

Reimplemented from vrj::SoundManager.

Definition at line 165 of file SoundManagerSonix.cpp.

Referenced by configAdd.

00166    {
00167       const std::string element_type(element->getID());
00168       if(std::string("sound_manager") == element_type)
00169       {
00170          return true;
00171       }
00172       else
00173       {
00174          return false;
00175       }
00176    }

void vrj::SoundManagerSonix::update   [virtual]
 

Enables a frame to be drawn.

Reimplemented from vrj::SoundManager.

Definition at line 179 of file SoundManagerSonix.cpp.

00180    {
00181       float time_delta = 0.1f; // TODO: get real time since last frame...
00182       sonix::instance()->step( time_delta );
00183    }

void vrj::SoundManagerSonix::sync   [virtual]
 

Blocks until the end of the frame.

Postcondition:
The frame has been rendered.

Reimplemented from vrj::SoundManager.

Definition at line 189 of file SoundManagerSonix.cpp.

00190    {
00191       // whatever...
00192    }


The documentation for this class was generated from the following files:
Generated on Sun May 2 15:11:16 2004 for VR Juggler by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002