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

cybsoundmanagerc.h

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2002  Malte Weiß, Carsten Winkelholz
00003 
00004 Malte Weiß, 06.08.2002: Sound manager class developed.
00005 
00006 Address:  FGAN Forschungsgesellschaft fr Angewandte Naturwissenschaften e. V.
00007       Neuenahrer Str. 20
00008       D - 53343 Wachtberg
00009       
00010 Email:    winkelholz@fgan.de
00011 
00012 This program is free software; you can redistribute it and/or
00013 modify it under the terms of the GNU General Public License
00014 as published by the Free Software Foundation; either version 2
00015 of the License, or (at your option) any later version.
00016 
00017 This program is distributed in the hope that it will be useful,
00018 but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 GNU General Public License for more details.
00021 
00022 You should have received a copy of the GNU General Public License
00023 along with this program; if not, write to the Free Software
00024 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00025 */
00026 
00027 #ifndef CYBSOUNDMANAGERC_H
00028 #define CYBSOUNDMANAGERC_H
00029 
00030 // Structure for a buffer
00031 #include "oaw/misc/urlc.h"
00032 #include "oaw/misc/stringc.h"
00033 #include "oaw/ctk/cybsensorc.h"
00034 #include "../oawconfig.h"
00035 #include "oaw/ctk/cybwrlfields.h"
00036 
00037 OAW_BEGIN_NAMESPACE
00038 
00039 class CybAudioClipC;
00040 class CybSoundC;
00041 
00042 typedef struct _Buffer
00043 {
00044   // File information
00045   UrlC          urlFile;    // URL
00046   StringC        strName;    // Name
00047 
00048   // Buffer properties
00049   unsigned int  nId;        // Buffer id
00050   int           nRef;       // Reference count
00051   double        fLength;    // Buffer length
00052 
00053   _Buffer       *pNext;     // Next buffer
00054 } Buffer;
00055 
00056 typedef Buffer* BUFFER;
00057 
00058 // Structure for a source
00059 
00060 typedef struct _Source
00061 {
00062   int           nName;      // Name of the source
00063   unsigned int  nId;        // Source id
00064   BUFFER        pBuffer;    // Used buffer
00065 
00066   // Source properties
00067   short         bEnabled;   // Enabled?
00068   short         bLoop;      // Looped?
00069   double        fPitch;     // Pitch
00070   double        fGain;      // Gain
00071   VectorC       vPosition;  // Position
00072   VectorC       vDirection; // Direction
00073 
00074   _Source       *pNext;     // Next source
00075   CybAudioClipC* pAudioClip;
00076 
00077 } Source;
00078 
00079 typedef Source* SOURCE;
00080   
00081 // Class definition
00082 
00083 class OAW_DLLMAPPING CybSoundManagerC : public CybSensorC
00084 {
00085 public:
00086   CybSoundManagerC(CybWorldC*);
00087   virtual ~CybSoundManagerC();
00088   virtual void RouteData();
00089 
00090   // Event outs
00091   void SendEventOut_isActive(CybAudioClipC*,SFBool b);
00092   void SendEventOut_durationChanged(CybAudioClipC*,SFTime t);
00093 
00094 protected:
00095   // Buffer functions
00096   BUFFER  LoadBuffer        (char *pUrl);
00097   BUFFER  FindBufferByName  (const StringC &strName);
00098   void    UnloadBuffer      (BUFFER &pBuffer);
00099   short   DeleteBuffer      (Buffer *pBuffer);
00100 
00101 protected:
00102   // Load buffer from url (should be derived)
00103   virtual short LoadBufferFromUrl(char *pUrl, BUFFER &pBuffer) { return 1; }
00104   CybAudioClipC* GetAudioClipToSourceName(long nName);
00105 
00106 public:
00107   // Source functions
00108   virtual SOURCE      AddSource            (char *pUrl, CybAudioClipC*);
00109   virtual short       DeleteSource         (SOURCE pSource);
00110   virtual void        EnableSource         (SOURCE pSource, short bEnable=1)  { }
00111 
00112   virtual void        SetListener          (Vector3C &vPos, Vector3C &vDir)   { }
00113   virtual void        UpdateSource         (SOURCE pSource)                   { }
00114 
00115   // Event outs
00116   void SendEventOut_isActive(SFBool b);
00117   void SendEventOut_durationChanged(SFTime t);
00118 
00119   //Interface functions for data exchange
00120   virtual void SetInterfaceData(AnyC&); 
00121   virtual void CopyInterfaceData (AnyC&,long maxLen); 
00122   virtual long GetInterfaceDataMinLength();
00123   virtual long GetInterfaceDataMaxLength();
00124 
00125   // Sound priotity
00126   void AddSound(CybSoundC *pSound);
00127   void RemoveSound(CybSoundC *pSound);
00128   void UpdateSoundList();
00129 
00130 protected:
00131   struct EventS{
00132     short m_eventType;
00133     long m_sourceName;
00134     SFBool m_active;
00135     double m_duration;
00136   };
00137   Buffer      *m_pBufferRoot;   // Root of buffer list
00138   Source      *m_pSourceRoot;   // Root of source list
00139   ArrayC<EventS> m_eventBuf;
00140   ArrayC<CybSoundC*> m_pSounds;             // List of sounds
00141   long m_nMaxSounds;
00142 };
00143 
00144 OAW_END_NAMESPACE
00145 
00146 
00147 #endif
00148 
00149 

Generated on Tue Jul 29 14:24:13 2003 for Open ActiveWrl by doxygen1.3-rc2