Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

SoundImplementation.h

Go to the documentation of this file.
00001 
00002 /****************** <SNX heading BEGIN do not edit this line> *****************
00003  *
00004  * sonix
00005  *
00006  * Original Authors:
00007  *   Kevin Meinert, Carolina Cruz-Neira
00008  *
00009  * -----------------------------------------------------------------
00010  * File:          $RCSfile: SoundImplementation.h,v $
00011  * Date modified: $Date: 2003/06/30 16:28:47 $
00012  * Version:       $Revision: 1.24 $
00013  * -----------------------------------------------------------------
00014  *
00015  ****************** <SNX heading END do not edit this line> ******************/
00016 /*************** <auto-copyright.pl BEGIN do not edit this line> **************
00017  *
00018  * VR Juggler is (C) Copyright 1998-2003 by Iowa State University
00019  *
00020  * Original Authors:
00021  *   Allen Bierbaum, Christopher Just,
00022  *   Patrick Hartling, Kevin Meinert,
00023  *   Carolina Cruz-Neira, Albert Baker
00024  *
00025  * This library is free software; you can redistribute it and/or
00026  * modify it under the terms of the GNU Library General Public
00027  * License as published by the Free Software Foundation; either
00028  * version 2 of the License, or (at your option) any later version.
00029  *
00030  * This library is distributed in the hope that it will be useful,
00031  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00032  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00033  * Library General Public License for more details.
00034  *
00035  * You should have received a copy of the GNU Library General Public
00036  * License along with this library; if not, write to the
00037  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00038  * Boston, MA 02111-1307, USA.
00039  *
00040  *************** <auto-copyright.pl END do not edit this line> ***************/
00041 
00042 /* Generated by Together */
00043 
00044 #ifndef SNXSOUNDIMPLEMENTATION_H
00045 #define SNXSOUNDIMPLEMENTATION_H
00046 
00047 #include <snx/snxConfig.h>
00048 
00049 #include <assert.h>
00050 #include <string>
00051 #include <map>
00052 #include <boost/concept_check.hpp>
00053 #include <gmtl/Matrix.h>
00054 
00055 #include <snx/SoundInfo.h>
00056 #include <snx/SoundAPIInfo.h>
00057 #include <snx/ISoundImplementation.h>
00058 
00059 namespace snx
00060 {
00061 
00062 class SNX_CLASS_API SoundImplementation : public ISoundImplementation
00063 {
00064 public:
00068    SoundImplementation() : ISoundImplementation(), 
00069                            mName( "unknown" ),
00070                            mSoundAPIInfo(),
00071                            mSounds(),
00072                            mListenerPos()
00073    {
00074    }
00075 
00079    virtual void clone( ISoundImplementation* &newCopy ) = 0; 
00080    
00084    virtual ~SoundImplementation()
00085    {
00086       // make sure the API has gracefully exited.
00087       this->shutdownAPI();
00088    }
00089 
00094    void copy( const SoundImplementation& si );
00095 
00096 public:
00097 
00104    virtual void trigger( const std::string & alias, const int & repeat = 1 )
00105    {
00106       assert( this->isStarted() == true && "must call startAPI prior to this function" );
00107       
00108       this->lookup( alias ).repeat = repeat;
00109       this->lookup( alias ).repeatCountdown = repeat;
00110    }
00111 
00115    virtual bool isPlaying( const std::string& alias )
00116    {
00117       boost::ignore_unused_variable_warning(alias);
00118       return false;
00119    }   
00120    
00126    virtual void setRetriggerable( const std::string& alias, bool onOff )
00127    {
00128       this->lookup( alias ).retriggerable = onOff;
00129    }
00130    
00134    virtual bool isRetriggerable( const std::string& alias )
00135    {
00136       return bool( this->lookup( alias ).retriggerable == true );
00137    }
00138 
00143    virtual void stop( const std::string& alias )
00144    {
00145       assert( this->isStarted() == true && "must call startAPI prior to this function" );
00146       this->lookup( alias ).repeatCountdown = 0;
00147    }
00148 
00152    virtual void pause( const std::string& alias )
00153    {
00154       this->stop( alias );
00155    }
00156 
00160    virtual void unpause( const std::string& alias )
00161    {
00162       this->trigger( alias, this->lookup( alias ).repeat );
00163    }
00164 
00166    virtual bool isPaused( const std::string& alias )
00167    {
00168       boost::ignore_unused_variable_warning(alias);
00169       return false;
00170    }   
00171    
00178    virtual void setAmbient( const std::string& alias, bool ambient = false )
00179    {
00180       this->lookup( alias ).ambient = ambient;
00181    }
00182    
00187    virtual bool isAmbient( const std::string& alias )
00188    {
00189       return this->lookup( alias ).ambient;
00190    }
00191 
00193    virtual void setPitchBend( const std::string& alias, float amount )
00194    {
00195       this->lookup( alias ).pitchbend = amount;
00196    }
00197    
00199    virtual void setVolume( const std::string& alias, float amount )
00200    {
00201       this->lookup( alias ).volume = amount;
00202    }
00203    
00207    virtual void setCutoff( const std::string& alias, float amount )
00208    {
00209       this->lookup( alias ).cutoff = amount;
00210    }
00211    
00215    virtual void setPosition( const std::string& alias, float x, float y, float z )
00216    {
00217       assert( this->isStarted() == true && "must call startAPI prior to this function" );
00218       this->lookup( alias ).position[0] = x;
00219       this->lookup( alias ).position[1] = y;
00220       this->lookup( alias ).position[2] = z;
00221    }
00222 
00228    virtual void getPosition( const std::string& alias, float& x, float& y, float& z )
00229    {
00230       assert( this->isStarted() == true && "must call startAPI prior to this function" );
00231       
00232       x = this->lookup( alias ).position[0];
00233       y = this->lookup( alias ).position[1];
00234       z = this->lookup( alias ).position[2];
00235    }
00236 
00240    virtual void setListenerPosition( const gmtl::Matrix44f& mat )
00241    {
00242       assert( this->isStarted() == true && "must call startAPI prior to this function" );
00243       mListenerPos = mat;
00244    }
00245 
00249    virtual void getListenerPosition( gmtl::Matrix44f& mat )
00250    {
00251       assert( this->isStarted() == true && "must call startAPI prior to this function" );
00252       mat = mListenerPos;
00253    }
00254 
00261    virtual int startAPI() = 0;
00262 
00267    virtual bool isStarted() const = 0;   
00268    
00274    virtual void shutdownAPI() {}
00275 
00276    /*
00277     * configure/reconfigure the sound API global settings
00278     */
00279    virtual void configure( const snx::SoundAPIInfo& sai )
00280    {
00281       mSoundAPIInfo = sai;
00282    }
00283 
00292    virtual void configure( const std::string& alias, const snx::SoundInfo& description );
00293 
00298    virtual void remove(const std::string& alias);
00299 
00304    virtual void step( const float& timeElapsed )
00305    {
00306       boost::ignore_unused_variable_warning(timeElapsed);
00307    }   
00308 
00313    virtual void clear()
00314    {
00315       this->unbindAll();
00316    }   
00317 
00322    virtual void bindAll();
00323 
00328    virtual void unbindAll();
00329 
00334    virtual void bind( const std::string& alias ) = 0;
00335 
00340    virtual void unbind( const std::string& alias ) = 0;
00341 
00342    snx::SoundInfo& lookup( const std::string& alias )
00343    {
00344       return mSounds[alias];
00345    }
00346 
00347    void setName( const std::string& name )
00348    {
00349       mName = name;
00350    }
00351    
00352    std::string& name()
00353    {
00354       return mName;
00355    }   
00356       
00357 protected:
00358    
00359    /*
00360     * name of this impl...
00361     */
00362    std::string mName;
00363 
00364    snx::SoundAPIInfo mSoundAPIInfo;
00365    std::map<std::string, snx::SoundInfo> mSounds;
00366    /*
00367     * position of the observer/listener
00368     */
00369    gmtl::Matrix44f mListenerPos;
00370 };
00371 
00372 } // end namespace
00373 
00374 #endif //SNXSOUNDIMPLEMENTATION_H

Generated on Sun May 2 14:39:26 2004 for Juggler Sonix by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002