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

vos/metaobjects/sound/sound.hh

Go to the documentation of this file.
00001 /* $Id: sound.hh,v 1.6 2003/07/22 05:08:34 tetron Exp $ */
00002 
00003 /*
00004     Copyright (C) 2002 Reed Hedges
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Lesser General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Lesser General Public License for more details.
00015 
00016     You should have received a copy of the GNU Lesser General Public
00017     License along with this library; if not, write to the Free Software
00018     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00019 
00020 
00021     This file was generated by otd2cpp.pl, a script for VOS by Reed Hedges <reed@zerohour.net>. 
00022 
00023    I can make no garuntee that this code will work, or even that it even is safe to run.
00024    Use it at your own risk.
00025 */
00026 
00027 /** @file sound.hh Defines MetaObject class for Sound type (revision 0).
00028 
00029 */ 
00030 
00031 #ifndef _SOUND_HH_
00032 #define _SOUND_HH_
00033 
00034 #include <vos/corelibs/vos/vos.hh>
00035 #include <vos/metaobjects/property/property.hh>
00036 
00037 /** MetaObject implementing Sound Object Type. 
00038     
00039         This object type contains sound data and information regarding playback of the sound effect or stream, and sends and receives messages to control playback of the associated sounds.  It may be combined with other object types to place the sound in a particular context, for example, in a 3D space using object3d.
00040         The behavior of remote and local objects is different: remote objects recieve updates from the local object, and should perform the acctual sound playback (on their local host).  The local sound may (optinally) accept the same messages from remote objects, and just forward the message to all local objects (allowing remote objects to control the sound as heard by all remote instances). 
00041     
00042 */
00043 
00044 class Sound : public virtual MetaObject
00045 {
00046 
00047 public:
00048 
00049     /** Constructor */
00050     Sound(MetaObject* superobject);
00051 
00052 
00053     /** Return type string ("sound") */
00054     const string getType();
00055 
00056     /** Register Extenders */
00057     static void registerExtenders();
00058 
00059 
00060     /** @name Access Subobjects */
00061     //@{
00062 
00063     /** Get the value of sound property (
00064             The sound data. Recommended types to support are the various MOD formats (sound/x-mod, sound/x-s3m, sound/x-xm, sound/x-it), raw wave samples (sound/wav, sound/aiff), Ogg Vorbis (sound/x-ogg), and MP3 (sound/mp3), and URL to Ogg or MP3 ("Shoutcast") stream (sound/x-mp3-stream? sound/x-ogg-stream?). 
00065         ). */
00066     void* getSound();
00067 
00068     /** Get the length of the sound */
00069     unsigned int getSoundLength();
00070 
00071     /** Get the datatype of sound property. */
00072     string getSoundDatatype();
00073 
00074     /** Set sound property. 
00075         @param value The sound data
00076         @param value The size of the data (bytes)
00077         @param datatype The new datatype: if omitted, then the existing datatype will be preserved. */
00078     void setSound(void* data, unsigned int length, const string& datatype = "?");
00079 
00080     /** Get the value of sound:loop property (
00081         If this value is true, then playback of the sound should loop; that is, when the end of the sound is reached, it should begin again.  
00082         ). */
00083     bool getLoop();
00084 
00085     /** Set sound:loop property. 
00086         @param value The new value
00087     */
00088     void setLoop(const bool value);
00089 
00090     /** Get the value of sound:immediate property (
00091         If this value is true, then the sound should be played as soon as the "sound" property changes, or is first recieved (that is, when a "property-update" message is recieved for "sound").
00092         ). */
00093     bool getImmediate();
00094 
00095     /** Set sound:immediate property. 
00096         @param value The new value
00097     */
00098     void setImmediate(const bool value);
00099 
00100     //@}
00101 };
00102 
00103 
00104 
00105 /** Local version of Sound. 
00106     Stores sound information. Use the object to control remote objects
00107     which perform the actual playback
00108 */
00109 
00110 class LocalSound : public virtual Sound
00111 {
00112 public:
00113 
00114     /** Constructor */
00115     LocalSound(MetaObject* superobject);
00116 
00117     /** Initialize subproperties */
00118     virtual void initialize();
00119 
00120     /** Static generator, for factory. */
00121     static MetaObject* new_LocalSound(MetaObject* superobject, const string& type);
00122 
00123     /** Called when this object gets a message */
00124     virtual void sendMessage(Message* m);
00125 
00126     /**  @name Actuators. These are user-functions corresponding to messages. */
00127     //@{
00128 
00129     /** Play the sound from the beginning.
00130         Sends remote-update message sound:play */
00131     void play();
00132 
00133     /** Stop playing the sound.
00134         Sends remote-update message sound:stop */
00135     void stop();
00136 
00137     /** Pause the sound. 
00138         Sends remote update message sound:pause */
00139     void pause();
00140 
00141     /** Resume after pausing.
00142         Sends remote update message sound:resume */
00143     void resume();
00144 
00145     //@}
00146 
00147  
00148 };
00149 
00150 
00151 /** Remote version of Sound. 
00152     This object listens to the local object's properties, responds to
00153     update messages from the local object, and performs the actual
00154     playback
00155 */
00156 
00157 class RemoteSound : public virtual Sound
00158 {
00159 
00160 public:
00161 
00162     /** Constructor */
00163     RemoteSound(MetaObject* superobject);
00164 
00165     /** Static generator, for factory. */
00166     static MetaObject* new_RemoteSound(MetaObject* superobject, const string& type);
00167 
00168     /** Called when this object gets an update message from its Local master across the network. */
00169     void sendUpdateMessage(Message *m);
00170 
00171 
00172 
00173 protected:
00174 
00175     /** @name Update Handlers. Handlers for remote update messages */
00176     //@{
00177 
00178     /** Handle remote-update message sound:play */
00179     void handlePlay(Message* m);
00180 
00181     /** Handle remote-update message sound:stop */
00182     void handleStop(Message* m);
00183 
00184     /** Handle remote-update message sound:pause */
00185     void handlePause(Message* m);
00186 
00187     /** Handle remote-update message sound:resume */
00188     void handleResume(Message* m);
00189 
00190     //@}
00191 
00192 };
00193 
00194 
00195 #endif // #ifdef _SOUND_HH_
00196 

Generated on Tue Aug 12 03:55:46 2003 for Interreality Project - VOS by doxygen 1.3.2