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

SoundHandle.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: SoundHandle.h,v $
00011  * Date modified: $Date: 2003/06/30 16:36:19 $
00012  * Version:       $Revision: 1.13 $
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 
00043 #ifndef SOUND_HANDLE
00044 #define SOUND_HANDLE
00045 
00046 #include <string>
00047 #include <gmtl/Math.h>
00048 #include <gmtl/Matrix.h>
00049 #include <gmtl/Vec.h>
00050 #include <gmtl/MatrixOps.h>
00051 #include <gmtl/VecOps.h>
00052 #include <gmtl/Xforms.h>
00053 
00054 #include <snx/sonix.h>
00055 
00061 namespace snx
00062 {
00073    class SoundHandle
00074    {
00075    public:
00076       
00081       SoundHandle() : mDefaultName( "unnamed_sound_handle" ), mAlias( mDefaultName )
00082       {
00083       }
00084       
00091       SoundHandle( const std::string& myUniqueName ) : mAlias( myUniqueName )
00092       {
00093       }
00094       
00108       void init( const std::string& myUniqueName )
00109       {
00110          mAlias = myUniqueName;
00111       }
00112       
00114       std::string getName() const { return mAlias; }
00115       
00116       //: virtual destructor
00117       virtual ~SoundHandle()
00118       {
00119          mAlias = "deleted";
00120       }
00121 
00122    public:
00123 
00130       virtual void trigger( const int& repeat = 1 )
00131       {
00132          sonix::instance()->trigger( mAlias, repeat );
00133       }
00134       
00138       virtual bool isPlaying()
00139       {
00140          return sonix::instance()->isPlaying( mAlias );
00141       }  
00142 
00143       /* specify whether sound retriggers from beginning when triggered while playing.
00144        * when sound is already playing then you call trigger,
00145        * does the sound restart from beginning?
00146        */
00147       virtual void setRetriggerable( bool onOff )
00148       {
00149          sonix::instance()->setRetriggerable( mAlias, onOff );
00150       }
00151       
00155       virtual bool isRetriggerable()
00156       {
00157          return sonix::instance()->isRetriggerable( mAlias );
00158       }
00159 
00165       virtual void stop()
00166       {
00167          sonix::instance()->stop( mAlias );
00168       }
00169 
00173       virtual void pause()
00174       {
00175          sonix::instance()->pause( mAlias );
00176       }
00177 
00181       virtual void unpause()
00182       {
00183          sonix::instance()->unpause( mAlias );
00184       }
00185       
00187       virtual bool isPaused()
00188       {
00189          return sonix::instance()->isPaused( mAlias );
00190       } 
00191 
00197       virtual void setAmbient( bool setting = false )
00198       {
00199          sonix::instance()->setAmbient( mAlias, setting );
00200       }
00201       
00203       virtual bool isAmbient()
00204       {
00205          return sonix::instance()->isAmbient( mAlias );
00206       }
00207 
00213       virtual void setPitchBend( float amount )
00214       {
00215          sonix::instance()->setPitchBend( mAlias, amount );
00216       }
00217       
00219       virtual void setVolume( float amount )
00220       {
00221          sonix::instance()->setVolume( mAlias, amount );
00222       }
00223 
00227       virtual void setCutoff( float amount )
00228       {
00229          sonix::instance()->setCutoff( mAlias, amount );
00230       }
00231       
00236       virtual void setPosition( const float& x, const float& y, const float& z )
00237       {
00238          sonix::instance()->setPosition( mAlias, x, y, z );
00239       }
00240 
00245       virtual void getPosition( float& x, float& y, float& z )
00246       {
00247          sonix::instance()->getPosition( mAlias, x, y, z );
00248       }
00249 
00253       virtual void setListenerPosition( const gmtl::Matrix44f& mat )
00254       {
00255          sonix::instance()->setListenerPosition( mat );
00256       }
00257 
00261       virtual void getListenerPosition( gmtl::Matrix44f& mat )
00262       {
00263          sonix::instance()->getListenerPosition( mat );
00264       }
00265 
00274       virtual void configure( const snx::SoundInfo& description )
00275       {
00276          assert( mAlias != mDefaultName && "you must call init to set your sound's name" );
00277          sonix::instance()->configure( mAlias, description );
00278       }
00279 
00284       virtual void remove()
00285       {
00286          sonix::instance()->remove( mAlias );
00287       }   
00288       
00289    private:
00290       std::string mDefaultName;
00291       std::string mAlias;
00292    };
00293 }
00294 
00295 #endif

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