home *** CD-ROM | disk | FTP | other *** search
/ Game Audio Programming / GameAudioProgramming.iso / Game_Audio / audio_sdk / include / AudioLib / IAudio.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-07-25  |  50.2 KB  |  1,475 lines

  1. /***********************************************************\
  2. Copyright (C) James Boer, 2002. 
  3. All rights reserved worldwide.
  4.  
  5. This software is provided "as is" without express or implied
  6. warranties. You may freely copy and compile this source into
  7. applications you distribute provided that the copyright text
  8. below is included in the resulting source code, for example:
  9. "Portions Copyright (C) James Boer, 2002"
  10. \***********************************************************/
  11. #ifndef __IAUDIO_H__
  12. #define __IAUDIO_H__
  13.  
  14. #ifndef DOXYGEN_SHOULD_SKIP_THIS
  15. namespace Audio
  16. {
  17. #endif /* DOXYGEN_SHOULD_SKIP_THIS */
  18.  
  19. /*! \file IAudio.h*/ 
  20.  
  21. //! VOLUME_MIN represents the minimum sound on any audio system volume control.
  22. static const float VOLUME_MIN            = 0.0f;
  23. //! VOLUME_MAX represents the maximum sound on any audio system volume control.
  24. static const float VOLUME_MAX            = 1.0f;
  25. //! Represents the leftmost value for pan settings
  26. static const float PAN_LEFT                = -1.0f;
  27. //! Represents the center value for pan settings
  28. static const float PAN_CENTER            = 0.0f;
  29. //! Represents the rightmost value for pan settings
  30. static const float PAN_RIGHT            = 1.0f;
  31. //! Represents the original sound's pitch
  32. static const float PITCH_ORIGINAL        = 1.0f;
  33. //! Sets a 3D object to normal listening mode
  34. static const uint32 MODE_NORMAL            = 0x00000000;
  35. //! Sets a 3D object to position itself relative to the listener position
  36. static const uint32 MODE_HEADRELATIVE    = 0x00000001;
  37. //! Disables all 3D positional processing of a 3D sound object
  38. static const uint32 MODE_DISABLE        = 0x00000002;
  39.  
  40.  
  41. //! Base class defining common interface of all managed audio components 
  42. /*!
  43. IAudioBase defines the common interface to which all basic audio components (such as 
  44. sounds, scripts, and DLS collections must conform.  Objects are obtained from
  45. the AudioMgr, and are destroyed by using the Destroy() function, which internally
  46. cleans up and deletes the object.  Once the object is initialized via its own Init()
  47. function, the audio data may be loaded and unloaded at will using the Load() and
  48. Unload() functions.  The audio manager may also call Load() or Unload() at its
  49. discretion, since these are defined as no argument functions, and operate entirly
  50. using cached information from the object's original initialization.
  51. */
  52. class IAudioBase 
  53. {
  54. public:
  55.     /*!
  56.     Destroys an audio object, discarding any information stored from the original
  57.     object initialization.  The object should be considered invalid for any use
  58.     after this function is called.  The audio manager will automatically destroy 
  59.     the object when IAudioManager::Term() is called.
  60.     */
  61.     virtual void Destroy() = 0;
  62.  
  63.     /*!
  64.     Determines whether an audio object is currently initialized.
  65.     \return true indicates the object is initialized, false indicates it is not
  66.     */
  67.     virtual bool IsInitialized() const = 0;
  68.  
  69.     /*!
  70.     Loads the audio file from disk or memory and creates internal structures
  71.     to hold this data as appropriate.  In general, objects derived from
  72.     IPlayable will load data in a background thread, but all other
  73.     objects will finish loading before the function returns.
  74.     \return true indicates success, false indicates failure.
  75.     \sa Unload(), IsLoaded()
  76.     */
  77.     virtual bool Load() = 0;
  78.     /*!
  79.     Destroys the internal data container (buffer, segment, etc) currently holding
  80.     audio data.
  81.     \return true indicates success, false indicates failure.
  82.     \sa Load(), IsLoaded()
  83.     */
  84.     virtual bool Unload() = 0;
  85.     /*!
  86.     Determines if an audio object is currently loaded.
  87.     \return true indicates the object is loaded, false indicates it is not loaded
  88.     \sa Load(), Unload()
  89.     */
  90.     virtual bool IsLoaded() const = 0;
  91.  
  92. #ifndef DOXYGEN_SHOULD_SKIP_THIS
  93. protected:
  94.     virtual ~IAudioBase() {};
  95. #endif /* DOXYGEN_SHOULD_SKIP_THIS */
  96.  
  97. };
  98.  
  99.  
  100. //! Base class defining common interface of all playable audio components 
  101. /*!
  102. IPlayable defines the common interface to which all basic audio components 
  103. which can play sound or music must conform.  Basic control functions such
  104. as Play(), Pause(), and Stop() are defined, as well as status functions
  105. to ascertain the current state of the object.  Playable objects will
  106. automatically attempt to call Load() if the object is not currently 
  107. loaded when it first attempts to play.  If needed, the object will load
  108. in a background thread and begin playback immediately after the loading
  109. is completed.
  110. */
  111. class IPlayable : public IAudioBase
  112. {
  113. public:
  114.  
  115.     /*!
  116.     Plays the audio data as appropriate.  Note that looping is considered to be
  117.     a property of the audio object, not a parameter of the play function.
  118.     \return true indicates success, false indicates failure.
  119.     */
  120.     virtual bool Play() = 0;
  121.     /*!
  122.     Pauses the object playback, leaving the play cursor where it is.  Calling Play()
  123.     after Pause() causes playback to resume where it was stopped, if seeking is
  124.     supported (note - Segments will start playback from the beginning when paused).
  125.     \return true indicates success, false indicates failure.
  126.     \sa IsPaused()
  127.     */
  128.     virtual bool Pause() = 0;
  129.     /*!
  130.     Stops the audio object playback, resetting the play cursor to the beginning.
  131.     \return true indicates success, false indicates failure.
  132.     */
  133.     virtual bool Stop() = 0;
  134.  
  135.     /*!
  136.     Checks to see if the audio object is currently playing.
  137.     \return true indicates the audio object is playing, otherwise returns false.
  138.     \sa Play(), Stop(), Pause()
  139.     */
  140.     virtual bool IsPlaying() const = 0;
  141.     /*!
  142.     Checks to see if Pause() if this audio object has been paused.
  143.     \return true indicates the audio object is playing, otherwise returns false.
  144.     \sa Pause()
  145.     */
  146.     virtual bool IsPaused() const = 0;
  147.     /*!
  148.     This function checks to see if the object is set to continuously loop.
  149.     \return true if the audio object is set to continuously loop
  150.     */
  151.     virtual bool IsLooping() const = 0;
  152. };
  153.  
  154. //! 2D sound properties structure
  155. /*!
  156. Structure containing general runtime-alterable properties
  157. of a 2D sound.
  158. \sa ISound::SetProperties(), ISound::GetProperties()
  159. */
  160. struct SoundProp
  161. {
  162.     /*!
  163.     SoundProp constructor automatically calls Clear() to initialize the structure.
  164.     */
  165.     SoundProp()    { Clear(); }
  166.     /*!
  167.     Sets all members either to an appropriate default value if it exists, or else to zero.
  168.     */
  169.     void Clear()
  170.     {
  171.         m_fVolume = VOLUME_MAX;
  172.         m_fPan = PAN_CENTER;
  173.         m_fPitch = PITCH_ORIGINAL;
  174.         m_nReadCursor = 0;
  175.     }
  176.     //! Set the volume from VOLUME_MIN (0.0) to VOLUME_MAX (1.0)
  177.     float    m_fVolume;
  178.     //! Set the pan from PAN_LEFT (-1.0) to PAN_RIGHT (1.0)
  179.     float    m_fPan;
  180.     //! Sets the target pitch
  181.     float    m_fPitch;
  182.     //! Sets the position of the read cursor
  183.     uint32    m_nReadCursor;
  184.  
  185. };
  186.  
  187. //! 2D sound initialization structure
  188. /*!
  189. Initialization structure for the 2D ISound class.  All initial parameters can be
  190. set in this structure.  Generally speaking, parameters listed in this structure
  191. are crucial to the initial contruction of the sound object, and so cannot be
  192. modified at run-time.
  193. \sa ISound::Init()
  194. */
  195. struct SoundInit
  196. {
  197.     /*!
  198.     SoundInit constructor automatically calls Clear() to initialize the structure.
  199.     */
  200.     SoundInit()    { Clear(); }
  201.     /*!
  202.     Sets all members either to an appropriate default value if it exists, or else to zero.
  203.     */
  204.     void Clear()
  205.     {
  206.         m_sFileName.erase();
  207.         m_bStreaming = false;
  208.         m_bLooping = false;
  209.         m_bMusic = false;
  210.         m_nPriority = 0;
  211.         m_Prop.Clear();
  212.     }
  213.     //! The file from which to load the sound data
  214.     std::string m_sFileName;
  215.     //! Should the file be incrementally streamed from the disk?
  216.     bool        m_bStreaming;
  217.     //! Should the sound be continously looped?
  218.     bool        m_bLooping;
  219.     //! Is this music?
  220.     bool        m_bMusic;
  221.     //! User-defined sound priority setting.
  222.     /*!
  223.     This value is used (among other determinations) when deciding which sound
  224.     should be discarded if the buffer limit is reached.
  225.     */
  226.     uint32        m_nPriority;
  227.     //! Used to set the initial properties of the sound
  228.     /*!
  229.     All values in in SoundProp can also be set at run-time
  230.     \sa SoundProp
  231.     */
  232.     SoundProp    m_Prop;
  233. };
  234.  
  235.  
  236. //! ISound is the interface for 2D sound objects.
  237. /*!
  238. ISound-derived objects are representation of 2D sounds.  These objects should be used
  239. for any sound that does not require true 3D positioning.  The interface provides specific
  240. initalization routines, pan controls, and read cursor controls.
  241. */
  242. class ISound : public IPlayable
  243. {
  244. public:
  245.     /*!
  246.     Initializes the 2D sound parameters.  This must be the first function
  247.     called on the sound after the object is created.
  248.     \param init is the initialization structure for 2D sounds, containing
  249.     pamrameters needed to create the sound.
  250.     \return true indicates success, false indicates failure
  251.     \sa SoundInit, Destroy()
  252.     */
  253.     virtual bool Init(const SoundInit& init) = 0;
  254.  
  255.     /*!
  256.     Sets all properties simultaneously.
  257.     \param prop contains all properties to set.
  258.     \return true indicates success, false indicates failure
  259.     \sa GetProperties()
  260.     */
  261.     virtual bool SetProperties(const SoundProp& prop) = 0;
  262.     /*!
  263.     Gets all properties simultaneously.
  264.     \param prop is a structure holding all modifiable properties.
  265.     \return true indicates success, false indicates failure.
  266.     \sa SetProperties()
  267.     */
  268.     virtual bool GetProperties(SoundProp& prop) const = 0;
  269.  
  270.     /*!
  271.     Sets the individual volume of a 2D sound.  This value will decrease
  272.     the volume in addition to any decrease from maximum volume set in the master
  273.     volume controls.
  274.     \param fVolume sets the volume desired
  275.     \return true indicates success, false indicates failure.
  276.     \sa GetVolume()
  277.     */
  278.     virtual bool SetVolume(float fVolume) = 0;
  279.     /*!
  280.     Gets the volume for this audio object.
  281.     \param fVolume retrieves the current object's volume
  282.     \return true indicates success, false indicates failure.
  283.     \sa SetVolume()
  284.     */
  285.     virtual bool GetVolume(float& fVolume) const = 0;
  286.  
  287.     /*!
  288.     Sets the pan value on the sound.  This function could fail if the buffers is
  289.     not allowed to make pan changes due to hardware limitations or conflicting
  290.     parameters.
  291.     \param fPan is automatically clamped between AUD_PAN_LEFT and AUD_PAN_RIGHT.  
  292.     \return true indicates success, false indicates failure.
  293.     \sa GetPan()
  294.     */
  295.     virtual bool SetPan(float fPan) = 0;
  296.     /*!
  297.     Gets the current pan value.
  298.     \param fPan will contain the current pan value for this buffer.  The value will
  299.     be between AUD_PAN_LEFT and AUD_PAN_RIGHT.
  300.     \return true indicates success, false indicates failure.
  301.     \sa SetPan()
  302.     */
  303.     virtual bool GetPan(float& fPan) const = 0;
  304.  
  305.     /*!
  306.     Sets the desired frequency of the audio object relative to its original
  307.     frequency.  For instance, a value of 0.5 sets it to half the original pitch,
  308.     and a value of 2.0 doubles the pitch.  Note that the pitch range may be 
  309.     constained by the sample's original pitch and the range allowed in hardware.
  310.     \return true indicates success, false indicates failure.
  311.     \sa GetPitch()
  312.     */
  313.     virtual bool SetPitch(float fPitch) = 0;
  314.     /*!
  315.     Gets the objects frequency in hertz
  316.     \return true indicates success, false indicates failure.
  317.     \sa SetPitch()
  318.     */
  319.     virtual bool GetPitch(float& fPitch) const = 0;
  320.  
  321.     /*!
  322.     Sets the current read cursor position in bytes in the current source.
  323.     \param nBytes sets the number of bytes from the beginning of the source.
  324.     \return true indicates success, false indicates failure.
  325.     \sa GetReadCursor()
  326.     */
  327.     virtual bool SetReadCursor(uint32 nBytes) = 0;
  328.     /*!
  329.     Gets the current read cursor position in bytes.
  330.     \param nBytes will be the number of bytes from the beginning of the source.
  331.     \return true indicates success, false indicates failure.
  332.     \sa SetReadCursor()
  333.     */
  334.     virtual bool GetReadCursor(uint32& nBytes) const = 0;
  335.  
  336.     /*!
  337.     Retrieves the total size of the current source in bytes.
  338.     \param nBytes total size retrieved of the source in bytes.
  339.     \return true indicates success, false indicates failure.
  340.     */
  341.     virtual bool GetSourceSize(uint32& nBytes) const = 0;
  342. };
  343.  
  344.  
  345. //! Property class representing all commonly modified run-time sound properties
  346. /*!
  347. This class represents all 3D parameters commonly modified at run-time.  They are
  348. presented in a common structure to allow the game (or the engine) to retrieve and/or
  349. modify all 3D parameters of a sound with a single function call.
  350. */
  351. struct Sound3DProp
  352. {
  353.     /*!
  354.     Sound3DProp constructor automatically calls Clear() to initialize the structure.
  355.     */
  356.     Sound3DProp()    { Clear(); }
  357.     /*!
  358.     Sets all members either to an appropriate default value if it exists, or else to zero.
  359.     */
  360.     void Clear()
  361.     {
  362.         m_vPosition.x = 0;  m_vPosition.y = 0;  m_vPosition.z = 0;
  363.         m_vVelocity.x = 0;  m_vVelocity.y = 0;  m_vVelocity.z = 0;
  364.         m_vConeOrientation.x = 0;  m_vConeOrientation.y = 0;  m_vConeOrientation.z = 1.0f;
  365.         m_nInsideConeAngle = 360;
  366.         m_nOutsideConeAngle = 360;
  367.         m_fConeOutsideVolume = VOLUME_MAX;
  368.         m_fMinDistance = 1.0f;
  369.         m_fMaxDistance = 1000.0f;
  370.         m_nMode = MODE_NORMAL;
  371.         m_fVolume = VOLUME_MAX;
  372.         m_fPitch = PITCH_ORIGINAL;
  373.         m_nReadCursor = 0;
  374.     }
  375.     //! Represents the sound's current position
  376.     AUDIOVECTOR    m_vPosition;
  377.     //! Represents the sound's current velocity
  378.     AUDIOVECTOR    m_vVelocity;
  379.     //! Represents the sound's current orientation
  380.     AUDIOVECTOR    m_vConeOrientation;
  381.     //! Represents the inside angle of the sound cone in degrees.
  382.     /*!
  383.     This value is only valid from 0 to 360.
  384.     */
  385.     uint32        m_nInsideConeAngle;
  386.     //! Represents the outside angle of the sound cone in degrees.
  387.     /*!
  388.     This value is only valid from 0 to 360.
  389.     */
  390.     uint32        m_nOutsideConeAngle;
  391.     //! Volume outside the outer cone angle from AUD_VOLUME_MIN to AUD_VOLUME_MAX.
  392.     float        m_fConeOutsideVolume;
  393.     //! Minimum distance at which a sound begins to attenuate with distance.
  394.     float        m_fMinDistance;
  395.     //! Maximum range at which a sound can be heard.
  396.     float        m_fMaxDistance;
  397.     //! Specifies the processing mode for this 3D sound.
  398.     /*!
  399.     \sa ISound3D::SetMode()
  400.     */
  401.     uint32        m_nMode;
  402.     //! Set the volume from VOLUME_MIN (0.0) to VOLUME_MAX (1.0)
  403.     float    m_fVolume;
  404.     //! Sets the target pitch
  405.     float    m_fPitch;
  406.     //! Sets the position of the read cursor
  407.     uint32    m_nReadCursor;
  408. };
  409.  
  410.  
  411. //! Initialization structure for the 3D ISound3D class.  
  412. /*!
  413. All initial parameters can be set in this structure.  Generally speaking, parameters 
  414. listed in this structure are crucial to the initial contruction of the sound object, 
  415. and so cannot be modified at run-time.
  416. \sa ISound3D::Init()
  417. */
  418. struct Sound3DInit
  419. {
  420.     /*!
  421.     Sound3DInit constructor automatically calls Clear() to initialize the structure.
  422.     */
  423.     Sound3DInit()    { Clear(); }
  424.     /*!
  425.     Sets all members either to an appropriate default value if it exists, or else to zero.
  426.     */
  427.     void Clear()
  428.     {
  429.         m_sFileName.erase();
  430.         m_bStreaming = false;
  431.         m_bLooping = false;
  432.         m_bMusic = false;
  433.         m_nPriority = 0;
  434.         m_Prop.Clear();
  435.     }
  436.     //! The file from which to load the sound data
  437.     std::string m_sFileName;
  438.     //! Should the file be incrementally streamed from the disk?
  439.     bool        m_bStreaming;
  440.     //! Should the sound be continously looped?
  441.     bool        m_bLooping;
  442.     //! Is this music?
  443.     bool        m_bMusic;
  444.     //! User-defined sound priority setting.
  445.     /*!
  446.     This value is used (among other determinations) when deciding which sound
  447.     should be discarded if the buffer limit is reached.
  448.     */
  449.     uint32        m_nPriority;
  450.     //! Used to set the initial properties of the sound
  451.     /*!
  452.     All values in in Sound3DProp can also be set at run-time
  453.     \sa Sound3SProp
  454.     */
  455.     Sound3DProp    m_Prop;
  456. };
  457.  
  458.  
  459. //! ISound3D is the interface for 3D sound objects.
  460. /*!
  461. ISound3D-derived objects represent sounds located in 3D world or local space.  
  462. The ISound3D interface provides specific initalization routines and 3d functions,
  463. as well as functions for setting the read cursor position and getting the source
  464. size.
  465. */
  466. class ISound3D : public IPlayable
  467. {
  468. public:
  469.     /*!
  470.     Initializes the 2D sound parameters.  This must be the first function
  471.     called on the sound after the object is created.
  472.     \param init is the initialization structure for 2D sounds, containing
  473.     pamrameters needed to create the sound.
  474.     \return true indicates success, false indicates failure.
  475.     \sa Sound3DInit, Destroy()
  476.     */
  477.     virtual bool Init(const Sound3DInit& init) = 0;
  478.     
  479.     /*!
  480.     Sets all 3D properties simultaneously.
  481.     \param prop contains all 3d properties to set.
  482.     \return true indicates success, false indicates failure
  483.     \sa GetProperties()
  484.     */
  485.     virtual bool SetProperties(const Sound3DProp& prop) = 0;
  486.     /*!
  487.     Gets all 3D properties simultaneously.
  488.     \param prop is a structure holding all 3d properties.
  489.     \return true indicates success, false indicates failure.
  490.     \sa Set3DProperties()
  491.     */
  492.     virtual bool GetProperties(Sound3DProp& prop) const = 0;
  493.  
  494.     /*!
  495.     Sets the current position of the sound source.
  496.     \param vPosition sets the position in 3D space.
  497.     \return true indicates success, false indicates failure.
  498.     \sa GetPosition()
  499.     */
  500.     virtual bool SetPosition(const AUDIOVECTOR& vPosition) = 0;
  501.     /*!
  502.     Retrieves the current position of the sound source.
  503.     \param vPosition gets the position in 3D space.
  504.     \return true indicates success, false indicates failure.
  505.     \sa SetPosition()
  506.     */
  507.     virtual bool GetPosition(AUDIOVECTOR& vPosition) const = 0;
  508.  
  509.     /*!
  510.     Sets the current velocity of the sound source.
  511.     \param vPosition sets the velocity in 3D space.
  512.     \return true indicates success, false indicates failure.
  513.     \sa GetVelocity()
  514.     */
  515.     virtual bool SetVelocity(const AUDIOVECTOR& vVelocity) = 0;
  516.     /*!
  517.     Retrieves the current velocity of the sound source.
  518.     \param vPosition gets the velocity in 3D space.
  519.     \return true indicates success, false indicates failure.
  520.     \sa SetVelocity()
  521.     */
  522.     virtual bool GetVelocity(AUDIOVECTOR& vVelocity) const = 0;
  523.  
  524.     /*!
  525.     Sets the maximum distance at which a sound can be heard.
  526.     \param fMaxDist is distance to set in world units.
  527.     \return true indicates success, false indicates failure.
  528.     \sa GetMaxDistance()
  529.     */
  530.     virtual bool SetMaxDistance(float fMaxDist) = 0;
  531.     /*!
  532.     Gets the maximum distance at which a sound can be heard.
  533.     \param fMaxDist is distance to get in world units.
  534.     \return true indicates success, false indicates failure.
  535.     \sa SetMaxDistance()
  536.     */
  537.     virtual bool GetMaxDistance(float& fMaxDist) const = 0;
  538.  
  539.     /*!
  540.     Sets the minimum distance at which a sound begins to attenuate with distance.
  541.     \param fMinDist is distance to set in world units.
  542.     \return true indicates success, false indicates failure.
  543.     \sa GetMinDistance()
  544.     */
  545.     virtual bool SetMinDistance(float fMinDist) = 0;
  546.     /*!
  547.     Gets the minimum distance at which a sound begins to attenuate with distance.
  548.     \param fMinDist is distance to get in world units.
  549.     \return true indicates success, false indicates failure.
  550.     \sa SetMinDistance()
  551.     */
  552.     virtual bool GetMinDistance(float& fMinDist) const = 0;
  553.  
  554.     /*!
  555.     Sets the inside and outside cone angles of the sound.  Paramater values are in
  556.     degrees, and valid ranges are 0 to 360.
  557.     \param nInside is the inside angle in degrees.
  558.     \param nOutside is the outside angle in degrees.
  559.     \return true indicates success, false indicates failure.
  560.     \sa GetConeAngles()
  561.     */
  562.     virtual bool SetConeAngles(uint32 nInside, uint32 nOutside) = 0;
  563.     /*!
  564.     Gets the inside and outside cone angles of the sound.  Paramater values are in
  565.     degrees, and valid ranges are 0 to 360.
  566.     \param nInside is the inside angle in degrees.
  567.     \param nOutside is the outside angle in degrees.
  568.     \return true indicates success, false indicates failure.
  569.     \sa SetConeAngles()
  570.     */
  571.     virtual bool GetConeAngles(uint32& nInside, uint32& nOutside) const = 0;
  572.  
  573.     /*!
  574.     Sets the orientation of the sound cone.
  575.     \param vOrientation is the orientation of the sound.
  576.     \return true indicates success, false indicates failure.
  577.     \sa GetConeOrientation()
  578.     */
  579.     virtual bool SetConeOrientation(const AUDIOVECTOR& vOrientation) = 0;
  580.     /*!
  581.     Gets the orientation of the sound cone.
  582.     \param vOrientation is the orientation of the sound.
  583.     \return true indicates success, false indicates failure.
  584.     \sa SetConeOrientation()
  585.     */
  586.     virtual bool GetConeOrientation(AUDIOVECTOR& vOrientation) const = 0;
  587.  
  588.     /*!
  589.     Sets the volume outside the sound cone.
  590.     \param fVolume sets the outside cone volume.  Valid range is from
  591.     AUD_VOLUME_MIN to AUD_VOLUME_MAX.
  592.     \return true indicates success, false indicates failure.
  593.     \sa GetConeOutsideVolume()
  594.     */
  595.     virtual bool SetConeOutsideVolume(float fVolume) = 0;
  596.     /*!
  597.     Gets the volume outside the sound cone.
  598.     \param fVolume gets the outside cone volume.  Valid range is from
  599.     AUD_VOLUME_MIN to AUD_VOLUME_MAX.
  600.     \return true indicates success, false indicates failure.
  601.     \sa SetConeOutsideVolume()
  602.     */
  603.     virtual bool GetConeOutsideVolume(float& fVolume) const = 0;
  604.  
  605.     /*!
  606.     Sets the 3D sound processing mode.
  607.     \param nMode is the processing mode.  Possible values are:
  608.     - DS3DMODE_DISABLE: 3D processing is disabled.  Sound appears to originate from the
  609.     listener's head.
  610.     - DS3DMODE_HEADRELATIVE: All 3D parameters are relative to the listener's position and
  611.     orientation.
  612.     - DS3DMODE_NORMAL: This is the standard, default mode.  All 3D parameters are in
  613.     absolute world coordinates.
  614.     \return true indicates success, false indicates failure.
  615.     \sa GetMode()
  616.     */
  617.     virtual bool SetMode(uint32 nMode) = 0;
  618.     /*!
  619.     Sets the 3D sound processing mode.
  620.     \param nMode is the processing mode.  See SetMode() for possible values.
  621.     \return true indicates success, false indicates failure.
  622.     \sa SetMode()
  623.     */
  624.     virtual bool GetMode(uint32& nMode) const = 0;
  625.  
  626.     /*!
  627.     Sets the individual volume of a 3D sound.  This value will decrease
  628.     the volume in addition to any decrease from maximum volume set in the master
  629.     volume controls.
  630.     \param fVolume sets the volume desired
  631.     \return true indicates success, false indicates failure.
  632.     \sa GetVolume()
  633.     */
  634.     virtual bool SetVolume(float fVolume) = 0;
  635.     /*!
  636.     Gets the volume for this audio object.
  637.     \param fVolume retrieves the current object's volume
  638.     \return true indicates success, false indicates failure.
  639.     \sa SetVolume()
  640.     */
  641.     virtual bool GetVolume(float& fVolume) const = 0;
  642.  
  643.     /*!
  644.     Sets the desired frequency of the audio object relative to its original
  645.     frequency.  For instance, a value of 0.5 sets it to half the original pitch,
  646.     and a value of 2.0 doubles the pitch.  Note that the pitch range may be 
  647.     constained by the sample's original pitch and the range allowed in hardware.
  648.     \return true indicates success, false indicates failure.
  649.     \sa GetPitch()
  650.     */
  651.     virtual bool SetPitch(float fPitch) = 0;
  652.     /*!
  653.     Gets the objects frequency in hertz
  654.     \return true indicates success, false indicates failure.
  655.     \sa SetPitch()
  656.     */
  657.     virtual bool GetPitch(float& fPitch) const = 0;
  658.  
  659.     /*!
  660.     Sets the current read cursor position in bytes in the current source.
  661.     \param nBytes sets the number of bytes from the beginning of the source.
  662.     \return true indicates success, false indicates failure.
  663.     \sa GetReadCursor()
  664.     */
  665.     virtual bool SetReadCursor(uint32 nBytes) = 0;
  666.     /*!
  667.     Gets the current read cursor position in bytes.
  668.     \param nBytes will be the number of bytes from the beginning of the source.
  669.     \return true indicates success, false indicates failure.
  670.     \sa SetReadCursor()
  671.     */
  672.     virtual bool GetReadCursor(uint32& nBytes) const = 0;
  673.  
  674.     /*!
  675.     Retrieves the total size of the current source in bytes.
  676.     \param nBytes total size retrieved of the source in bytes.
  677.     \return true indicates success, false indicates failure.
  678.     */
  679.     virtual bool GetSourceSize(uint32& nBytes) const = 0;
  680.  
  681.     /*!
  682.     Retrieves the IEAXBuffer interface.  The function is guaranteed never to
  683.     fail, so there is no need to check the interface pointer for null.
  684.     \return The IEAXBuffer interface is returned.
  685.     \sa IEAXBuffer
  686.     */
  687.     virtual IEAXBuffer* EAX() = 0;
  688.  
  689.     /*!
  690.     Retrieves the IZoomFX interface.  The function is guaranteed never to
  691.     fail, so there is no need to check the interface pointer for null.
  692.     \return The IZoomFX interface is returned.
  693.     \sa IZoomFX
  694.     */
  695.     virtual IZoomFX* ZoomFX() = 0;
  696.  
  697.  
  698.     /*!
  699.     Generic property support (for driver-specific extensions).  Querying an object
  700.     allows a program to determine if driver-specific extensions are available on a
  701.     user's system.  By exposing this at the API level, it ensures that the application
  702.     has complete control over any property sets needed at the application level.
  703.     See the DirectX Audio documentation and the documentation for the property
  704.     set you wish to work with for details on how to use these parameters.
  705.     \return true indicates success, false indicates failure.
  706.     \sa Get(), Set()
  707.     */
  708.     virtual bool QuerySupport(const GUID& guid, uint32 nID, uint32* pTypeSupport) = 0;
  709.     /*!
  710.     This function allows an application to get property set information from a
  711.     driver.  See the DirectX Audio documentation and the documentation for the property
  712.     set you wish to work with for details on how to use these parameters.
  713.     \return true indicates success, false indicates failure.
  714.     \sa QuerySupport(), Set()
  715.     */
  716.     virtual bool Get(const GUID& guidProperty, uint32 nID, void* pInstanceData,
  717.         uint32 nInstanceLength, void* pPropData, uint32 nPropLength, 
  718.         uint32* pBytesReturned) = 0;
  719.     /*!
  720.     This function allows an application to set a driver-specific property.  
  721.     See the DirectX Audio documentation and the documentation for the property
  722.     set you wish to work with for details on how to use these parameters.
  723.     \param bStoreProperty This specific audio extention tells the audio object
  724.     to store this property setting and automatically restore the setting when
  725.     an object is unloaded, and then reloaded.
  726.     \return true indicates success, false indicates failure.
  727.     \sa Get(), QuerySupport()
  728.     */
  729.     virtual bool Set(const GUID& guidProperty, uint32 nID, void* pInstanceData,
  730.         uint32 nInstanceLength, void* pPropData, uint32 nPropLength,
  731.         bool bStoreProperty) = 0;
  732. };
  733.  
  734.  
  735. //! Initialization structure for the IDLS class.  
  736. /*!
  737. All initial parameters can be set in this structure.  Generally speaking, parameters 
  738. listed in this structure are crucial to the initial contruction of the sound object, 
  739. and so cannot be modified at run-time.
  740. \sa IDLS::Init()
  741. */
  742. struct DLSInit
  743. {
  744.     /*!
  745.     Sound3DProp constructor automatically calls Clear() to initialize the structure.
  746.     */
  747.     DLSInit()    {  Clear();  }
  748.     /*!
  749.     Sets all members either to an appropriate default value if it exists, or else to zero.
  750.     */
  751.     void Clear()
  752.     {
  753.         m_sFileName.erase();
  754.     }
  755.  
  756.     //! The file from which to load the DLS data
  757.     std::string        m_sFileName;
  758. };
  759.  
  760. //! Interface structure for DLS collections
  761. /*!
  762. The IDLS interface is designed to be used internally by segment objects.  A DLS
  763. collection may be associated with an ISegment object through the 
  764. SegmentInit::m_pDLS member.  Segments will internally call Lock() and Unlock()
  765. to load or unload the DLS member explicitly as appropriate.
  766. \sa DLSInit
  767. */
  768. class IDLS : public IAudioBase
  769. {
  770. public:
  771.  
  772.     /*!
  773.     Initializes the DLS object.  This must be the first function
  774.     called on the sound after the object is created.
  775.     \param init is the initialization structure for DLS objects, containing
  776.     pamrameters needed to prepare the DLS object for use.
  777.     \return true indicates success, false indicates failure.
  778.     \sa Destroy()
  779.     */
  780.     virtual bool Init(const DLSInit& init) = 0;
  781.     /*!
  782.     This loads all DLS data.  Unlike a typical load function, an internal 
  783.     reference count is incremented with each call to Lock(), and will force
  784.     the DLS data to remain loaded until either the reference count drops to
  785.     zero or the Destoy() function is called.
  786.     \return true if the lock was successful and/or the DLS collection was
  787.     succesfully loaded, and false if there was an error loading the data.
  788.     \sa Unlock()
  789.     */
  790.     virtual bool Lock() = 0;
  791.     /*!
  792.     Decreases an internal reference count incremented by the Lock() function.
  793.     When the reference count drops to zero, the DLS collection is unloaded.
  794.     \return true indicates success, false indicates failure.
  795.     \sa Lock()
  796.     */
  797.     virtual bool Unlock() = 0;
  798.  
  799. };
  800.  
  801.  
  802. //! Initialization structure for the ISegment class.  
  803. /*!
  804. All initial parameters can be set in this structure.  Generally speaking, 
  805. parameters listed in this structure are crucial to the initial contruction 
  806. of the sound object, and so cannot be modified at run-time.
  807. \sa ISegment::Init()
  808. */
  809. struct SegmentInit
  810. {
  811.     /*!
  812.     SegmentInit constructor automatically calls Clear() to initialize the structure.
  813.     */
  814.     SegmentInit()    { Clear(); }
  815.     /*!
  816.     Sets all members either to an appropriate default value if it exists, or else to zero.
  817.     */
  818.     void Clear()
  819.     {
  820.         m_sFileName.erase();
  821.         m_bMusic = true;
  822.         m_bLooping = false;
  823.         m_pDLS = 0;
  824.     }
  825.     //! Source file used when creating segment object.
  826.     /*!
  827.     For Win32/DirectX platform, valid file types include DirectMusic segments,
  828.     MIDI files, and wave files (uncompressed or ACM compressed).
  829.     */
  830.     std::string            m_sFileName;
  831.     //! Does the segment loop?
  832.     bool                m_bLooping;
  833.     //! Is this segment part of the music playback system? (defaults to true)
  834.     bool                m_bMusic;
  835.     //! This DLS object is used by the segment.
  836.     /*!
  837.     The segment will automatically call Lock() on the DLS interface, which
  838.     increments an internal reference count and loads the DLS file whenever
  839.     the segment is loaded, and calls Unlock() when it is unloaded.
  840.     */
  841.     IDLS*                m_pDLS;
  842.  
  843. };
  844.  
  845.  
  846. //! ISegment is the interface for segment audio objects
  847. /*!
  848. ISegment is the interface for sound and music segments.  Although segments are
  849. primarily used as discrete components in interactive musical playback, they can
  850. also be used as specialized sound effects.  Segments can contain either
  851. MIDI data or digital audio data, and can be associated with a specific DLS 
  852. collection using the SegmentInit::m_pDLS member.
  853. */
  854. class ISegment : public IPlayable
  855. {
  856. public:
  857.     /*!
  858.     Initializes the segment object with the data needed to load and play the 
  859.     segment.  
  860.     \param init SegmentInit structure contains all initialization parameters.
  861.     \return true indicates success, false indicates failure.
  862.     \sa SegmentInit, Destroy()
  863.     */
  864.     virtual bool Init(const SegmentInit& init) = 0;
  865.  
  866. };
  867.  
  868. //! Initialization structure for the IAudioScript class.  
  869. /*!
  870. All initial parameters can be set in this structure.  Generally speaking, parameters 
  871. listed in this structure are crucial to the initial contruction of the sound object, 
  872. and so cannot be modified at run-time.
  873. \sa IAudioScript::Init()
  874. */
  875. struct AudioScriptInit
  876. {
  877.     /*!
  878.     AudioScriptInit constructor automatically calls Clear() to initialize the structure.
  879.     */
  880.     AudioScriptInit()    { Clear(); }
  881.     /*!
  882.     Sets all members either to an appropriate default value if it exists, or else to zero.
  883.     */
  884.     void Clear()
  885.     {
  886.         m_sFileName.erase();
  887.         m_bMusic = true;
  888.     }
  889.     //! Name of the script file
  890.     std::string            m_sFileName;
  891.     //! Is this script part of the music playback system? (defaults to true)
  892.     bool                m_bMusic;
  893.  
  894. };
  895.  
  896. //! IAudioScript is the interface for DirectMusic script objects
  897. /*!
  898. Audio script objects allow an audio designer to perform custom actions through
  899. the use of variables and routines that can be set, retrieved, and executed
  900. from code.
  901. */
  902. class IAudioScript : public IAudioBase
  903. {
  904. public:
  905.     /*!
  906.     Initializes the script object with the data needed to load and execute
  907.     script functions.  
  908.     \param init SegmentInit structure contains all initialization parameters.
  909.     \return true indicates success, false indicates failure.
  910.     \sa SegmentInit, Destroy()
  911.     */
  912.     virtual bool Init(const AudioScriptInit& init) = 0;
  913.  
  914.     /*!
  915.     Sets a named variable in a script to a numerical value.
  916.     \param sVarName specifies the variable name to set
  917.     \param iVal is the value to which the variable will be set
  918.     \return true indicates success, false indicates failure.
  919.     \sa GetVariable(), CallRoutine()
  920.     */
  921.     virtual bool SetVariable(std::string sVarName, int32 iVal) = 0;
  922.     /*!
  923.     Retrieves the value of a named variable in a script.
  924.     \param sVarName specifies the variable name to retrieve
  925.     \param iVal which will hold the value of the script variable
  926.     \return true indicates success, false indicates failure.
  927.     \sa SetVariable(), CallRoutine()
  928.     */
  929.     virtual bool GetVariable(std::string sVarName, int32& iVal) = 0;
  930.  
  931.     /*!
  932.     Calls a specific routine in a script.
  933.     \param sRoutineName indicates the name of the routine to call
  934.     \return true indicates success, false indicates failure.
  935.     \sa GetVariable(), SetVariable()
  936.     */
  937.     virtual bool CallRoutine(std::string sRoutineName) = 0;
  938. #ifndef DOXYGEN_SHOULD_SKIP_THIS
  939. protected:
  940.     virtual ~IAudioScript() {};
  941. #endif /* DOXYGEN_SHOULD_SKIP_THIS */
  942. };
  943.  
  944.  
  945. //! This structure contains all the 3D properties of the listener.
  946. struct ListenerProp
  947. {
  948.     //! The structure clears all variables when the object is created
  949.     ListenerProp()    {  Clear();  }
  950.     //! Clear sets all variables to zero or to appropriate default values
  951.     void Clear()
  952.     {
  953.         m_vPosition.x = 0.0f; m_vPosition.y = 0.0f; m_vPosition.z = 0.0f;
  954.         m_vVelocity.x = 0.0f; m_vVelocity.y = 0.0f; m_vVelocity.z = 0.0f;
  955.         m_vOrientFront.x = 0.0f; m_vOrientFront.y = 0.0f; m_vOrientFront.z = 1.0f;
  956.         m_vOrientTop.x = 0.0f; m_vOrientTop.y = 1.0f; m_vOrientTop.z = 0.0f;
  957.         m_fDistanceFactor = 1.0f;
  958.         m_fRolloffFactor = 1.0f;
  959.         m_fDopplerFactor = 1.0f;
  960.     }
  961.     //! Current position of the listener.
  962.     AUDIOVECTOR    m_vPosition;
  963.     //! Current velocity of the listener.
  964.     AUDIOVECTOR    m_vVelocity;
  965.     //! Vector defining the forward orientation of the listener.
  966.     AUDIOVECTOR    m_vOrientFront;
  967.     //! Vector defining the upward orientation of the listener.
  968.     AUDIOVECTOR    m_vOrientTop;
  969.     //! Number of meters per vector unit.
  970.     float        m_fDistanceFactor;
  971.     //! Attenuation of sound over distance.
  972.     /*!
  973.     \sa IListener::SetRolloffFactor() for parameter info
  974.     */
  975.     float        m_fRolloffFactor;
  976.     //! Adjusts the global doppler factor.
  977.     /*!
  978.     \sa IListener::SetDopplerFactor() for parameter info
  979.     */
  980.     float        m_fDopplerFactor;
  981. };
  982.  
  983. //! This structure contains all parameters needed for the IListener initialization.
  984. struct ListenerInit
  985. {
  986.     //! The structure clears all variables when the object is created
  987.     ListenerInit()    {  Clear();  }
  988.     //! Clear sets all variables to zero or to appropriate default values
  989.     void Clear()
  990.     {
  991.         m_Prop.Clear();
  992.     }
  993.     ListenerProp    m_Prop;
  994. };
  995.  
  996.  
  997. //! IListener represents the listener around which 3D sounds are oriented and positioned
  998. /*!
  999. This class places a virtual "microphone" at a designated position and orientation, and 
  1000. controls how 3D sounds are heard.  Properties can also be set and retrieved on the
  1001. listener object.  One example of this is environmental reverberation, such as EAX.
  1002. */
  1003. class IListener
  1004. {
  1005. public:
  1006.     
  1007.     /*!
  1008.     Initializes the listener object with required initialization data.  
  1009.     \param init ListenerInit structure contains all initialization parameters.
  1010.     \return true indicates success, false indicates failure.
  1011.     \sa ListenerInit, Term()
  1012.     */
  1013.     virtual bool Init(const ListenerInit& init) = 0;
  1014.     /*!
  1015.     Shuts down the listener object.  An application normally does not have to call
  1016.     this function since the audio manager will automatically terminate the listener
  1017.     when it exits.
  1018.     \sa Init()
  1019.     */
  1020.     virtual void Term() = 0;
  1021.  
  1022.     /*!
  1023.     Sets all 3D listener properties in a single function call.
  1024.     \param prop ListenerProp sets all listener paramaters simultaneously.
  1025.     \return true indicates success, false indicates failure.
  1026.     \sa GetProperties()
  1027.     */
  1028.     virtual bool SetProperties(const ListenerProp& prop) = 0;
  1029.     /*!
  1030.     Gets all 3D listener properties in a single function call.
  1031.     \param prop ListenerProp gets all listener paramaters simultaneously.
  1032.     \sa SetProperties()
  1033.     */
  1034.     virtual void GetProperties(ListenerProp& prop) const = 0;
  1035.  
  1036.     /*!
  1037.     Sets the current listener position.
  1038.     \param vPos is the current position.
  1039.     \return true indicates success, false indicates failure.
  1040.     \sa GetPosition()
  1041.     */
  1042.     virtual bool SetPosition(const AUDIOVECTOR& vPos) = 0;
  1043.     /*!
  1044.     Gets the current listener position.
  1045.     \param vPos is the current position.
  1046.     \sa SetPosition()
  1047.     */
  1048.     virtual void GetPosition(AUDIOVECTOR& vPos) const = 0;
  1049.  
  1050.     /*!
  1051.     Sets the current listener velocity.
  1052.     \param vPos is the current velocity.
  1053.     \return true indicates success, false indicates failure.
  1054.     \sa GetVelocity()
  1055.     */
  1056.     virtual bool SetVelocity(const AUDIOVECTOR& vVel) = 0;
  1057.     /*!
  1058.     Gets the current listener velocity.
  1059.     \param vPos is the current velocity.
  1060.     \sa GetVelocity()
  1061.     */
  1062.     virtual void GetVelocity(AUDIOVECTOR& vVel) const = 0;
  1063.  
  1064.     /*!
  1065.     Sets the current listener orientation.
  1066.     \param vFront is the listener's forward orientation.
  1067.     \param vTop is the listener's topward orientation.
  1068.     \return true indicates success, false indicates failure.
  1069.     \sa GetOrientation()
  1070.     */
  1071.     virtual bool SetOrientation(const AUDIOVECTOR& vFront, const AUDIOVECTOR& vTop) = 0;
  1072.     /*!
  1073.     Gets the current listener orientation.
  1074.     \param vFront is the listener's forward orientation.
  1075.     \param vTop is the listener's topward orientation.
  1076.     \sa SetOrientation()
  1077.     */
  1078.     virtual void GetOrientation(AUDIOVECTOR& vFront, AUDIOVECTOR& vTop) const = 0;
  1079.  
  1080.     /*!
  1081.     Sets the listener's distance factor.
  1082.     \param fDistanceFactor is the number of meters per vector unit
  1083.     \return true indicates success, false indicates failure.
  1084.     \sa GetDistanceFactor()
  1085.     */
  1086.     virtual bool SetDistanceFactor(float fDistanceFactor) = 0;
  1087.     /*!
  1088.     Gets the listener's distance factor.  
  1089.     \param fDistanceFactor is the number of meters per vector unit
  1090.     \sa SetDistanceFactor()
  1091.     */
  1092.     virtual void GetDistanceFactor(float& fDistanceFactor) const = 0;
  1093.  
  1094.     /*!
  1095.     Sets the listener's doppler factor, which is the rate at which pitch will shift 
  1096.     when a sound is moving rapidly toward or away from the listener.  1.0,
  1097.     or DS3D_DEFAULTDOPPLERFACTOR is the default.  The range is from 0.0 to 10.0, 
  1098.     or DS3D_MINDOPPLERFACTOR to DS3D_MAXDOPPLERFACTOR.
  1099.     \param fDistanceFactor is the doppler factor value
  1100.     \return true indicates success, false indicates failure.
  1101.     \sa GetDopplerFactor()
  1102.     */
  1103.     virtual bool SetDopplerFactor(float fDopplerFactor) = 0;
  1104.     /*!
  1105.     Gets the listener's doppler factor.  See SetDopplerFactor() for addition parameter
  1106.     information.
  1107.     \param fDistanceFactor is the doppler factor value
  1108.     \sa SetDopplerFactor()
  1109.     */
  1110.     virtual void GetDopplerFactor(float& fDopplerFactor) const = 0;
  1111.  
  1112.     /*!
  1113.     The rolloff factor adjusts the amount a sound will attenuate over distance.  1.0,
  1114.     or DS3D_DEFAULTROLLOFFFACTOR is the default.  The range is from 0.0 to 10.0, 
  1115.     or DS3D_MINROLLOFFFACTOR to DS3D_MAXROLLOFFFACTOR.
  1116.     \param fRolloffFactor is the rolloff factor value
  1117.     \sa GetRolloffFactor()
  1118.     */
  1119.     virtual bool SetRolloffFactor(float fRolloffFactor) = 0;
  1120.     /*!
  1121.     Gets the listener's rolloff factor.  See SetRolloffFactor() for addition parameter
  1122.     information.
  1123.     \param fRolloffFactor is the rolloff factor value
  1124.     \sa SetRolloffFactor()
  1125.     */
  1126.     virtual void GetRolloffFactor(float& fRolloffFactor) const = 0;
  1127.  
  1128.     /*!
  1129.     Generic property support (for driver-specific extensions).  Querying an object
  1130.     allows a program to determine if driver-specific extensions are available on a
  1131.     user's system.  By exposing this at the API level, it ensures that the application
  1132.     has complete control over any property sets needed at the application level.
  1133.     See the DirectX Audio documentation and the documentation for the property
  1134.     set you wish to work with for details on how to use these parameters.
  1135.     \return true indicates success, false indicates failure.
  1136.     \sa Get(), Set()
  1137.     */
  1138.     virtual bool QuerySupport(const GUID& guid, uint32 nID, uint32* pTypeSupport) = 0;
  1139.     /*!
  1140.     This function allows an application to get property set information from a
  1141.     driver.  See the DirectX Audio documentation and the documentation for the property
  1142.     set you wish to work with for details on how to use these parameters.
  1143.     \return true indicates success, false indicates failure.
  1144.     \sa QuerySupport(), Set()
  1145.     */
  1146.     virtual bool Get(const GUID& guidProperty, uint32 nID, void* pInstanceData,
  1147.         uint32 nInstanceLength, void* pPropData, uint32 nPropLength, 
  1148.         uint32* pBytesReturned) = 0;
  1149.     /*!
  1150.     This function allows an application to set a driver-specific property.  
  1151.     See the DirectX Audio documentation and the documentation for the property
  1152.     set you wish to work with for details on how to use these parameters.
  1153.     \return true indicates success, false indicates failure.
  1154.     \sa Get(), QuerySupport()
  1155.     */
  1156.     virtual bool Set(const GUID& guidProperty, uint32 nID, void* pInstanceData,
  1157.         uint32 nInstanceLength, void* pPropData, uint32 nPropLength,
  1158.         bool bStoreProperty) = 0;
  1159.  
  1160.     virtual IEAXListener* EAX() = 0;
  1161. };
  1162.  
  1163. //! Music callback interface
  1164. /*!
  1165. This class allows an object derived from this interface to receive specific
  1166. notification messages from the audio manager's low-level segment playback
  1167. system.  Current the only message received is when a new segment starts
  1168. playback.
  1169. */
  1170. class IMusicCallback
  1171. {
  1172. public:
  1173.     /*!
  1174.     This function is called when a music segment begins playback.
  1175.     */
  1176.     virtual void OnSegmentStart()    {};
  1177. };
  1178.  
  1179.  
  1180. //! Initialization structure for the IAudioManager class.  
  1181. /*!
  1182. All initial audio manager options are set in this structure
  1183. \sa IAudioManager::Init()
  1184. */
  1185. struct AudioMgrInit
  1186. {
  1187.     /*!
  1188.     AudioMgrInit constructor automatically calls Clear() to initialize the structure.
  1189.     */
  1190.     AudioMgrInit()    { Clear(); }
  1191.     /*!
  1192.     Sets all members either to an appropriate default value if it exists, or else to zero.
  1193.     */
  1194.     void Clear()
  1195.     {
  1196.         m_hWnd = (HWND)0;
  1197.         m_bLoadAsyncronously = true;
  1198.         m_bForceSoftware = false;
  1199.         m_bUseMusicReverb = true;
  1200.         m_bUseEAX = true;
  1201.         m_bUseZoomFX = true;
  1202.         m_bAutoStream = false;
  1203.         m_bCacheBuffers = false;
  1204.         m_n2DHardwareBufferMin = 8;
  1205.         m_n3DHardwareBufferMin = 8;
  1206.         m_n2DHardwareBufferMax = 256;
  1207.         m_n3DHardwareBufferMax = 256;
  1208.         m_n2DSoftwareBufferMax = 256;
  1209.         m_n3DSoftwareBufferMax = 256;
  1210.         m_nSegmentMax = 256;
  1211.         m_nOptimalSampleBits = 16;
  1212.         m_nOptimalSampleRate = 44100;
  1213.         m_sWorkingPath.erase();
  1214.         m_pAudioStreamFactory = 0;
  1215.         m_pMusicCallback = 0;
  1216.     }
  1217.     //! HWND used for sound system initialization
  1218.     HWND                    m_hWnd;
  1219.     //! Load all audio files asyncronously
  1220.     bool                    m_bLoadAsyncronously;
  1221.     //! Force the system to use all software buffers
  1222.     bool                    m_bForceSoftware;
  1223.     //! Use the Waves Reverb filter on the DirectMusic music performance object
  1224.     bool                    m_bUseMusicReverb;
  1225.     //! Use EAX hardware extensions if available
  1226.     bool                    m_bUseEAX;
  1227.     //! Use ZoomFX hardware extensions if available
  1228.     bool                    m_bUseZoomFX;
  1229.     //! Automatically stream all large buffers
  1230.     bool                    m_bAutoStream;
  1231.     //! Automatically cache buffers for reuse
  1232.     bool                    m_bCacheBuffers;
  1233.     //! Threshold at which software buffers are used instead of hardware
  1234.     uint32                    m_n2DHardwareBufferMin;
  1235.     //! Threshold at which software buffers are used instead of hardware
  1236.     uint32                    m_n3DHardwareBufferMin;
  1237.     //! Maximum amount of 2D hardware buffers to allow
  1238.     uint32                    m_n2DHardwareBufferMax;
  1239.     //! Maximum amount of 3D hardware buffers to allow
  1240.     uint32                    m_n3DHardwareBufferMax;
  1241.     //! Maximum amount of 2D software buffers to allow
  1242.     uint32                    m_n2DSoftwareBufferMax;
  1243.     //! Maximum amount of 3D software buffers to allow
  1244.     uint32                    m_n3DSoftwareBufferMax;
  1245.     //! Maximum amount of segments to allow
  1246.     uint32                    m_nSegmentMax;
  1247.     //! Defines the optimal bit depth is for audio data
  1248.     uint32                    m_nOptimalSampleBits;
  1249.     //! Defines the optimal sample rate is for audio data
  1250.     uint32                    m_nOptimalSampleRate;
  1251.     //! Audio system default working path
  1252.     /*! 
  1253.     Specifies the working directory for the audio system.  
  1254.     If left blank, the audio manager will use the current working
  1255.     directory at the time of initialization.
  1256.     */
  1257.     std::string                m_sWorkingPath;
  1258.     //! Allows overriding of the default disk-based file system
  1259.     IAudioStreamFactory*    m_pAudioStreamFactory;
  1260.     //! Sets a music callback object for notification on specific music segment events
  1261.     IMusicCallback*            m_pMusicCallback;
  1262.     
  1263. };
  1264.  
  1265. //! Statistics structure for the IAudioManager class.  
  1266. /*!
  1267. All initial audio manager statistics are set in this structure
  1268. \sa IAudioManager::GetStats()
  1269. */
  1270. struct AudioMgrStats
  1271. {
  1272.     /*!
  1273.     AudioMgrStats constructor automatically calls Clear() to initialize the structure.
  1274.     */
  1275.     AudioMgrStats()    { Clear(); }
  1276.     /*!
  1277.     Sets all members either to an appropriate default value if it exists, or else to zero.
  1278.     */
  1279.     void Clear()
  1280.     {
  1281.         m_bForce2DSoftware = false;
  1282.         m_bForce3DSoftware = false;
  1283.         m_n2DSoundsLoaded = 0;
  1284.         m_n3DSoundsLoaded = 0;
  1285.         m_nSegmentsLoaded = 0;
  1286.     }
  1287.     //! Are 2D buffers restricted to software?
  1288.     bool    m_bForce2DSoftware;
  1289.     //! Are 3D buffers restricted to software?
  1290.     bool    m_bForce3DSoftware;
  1291.     //! Reports the number of 2D sounds currently loaded
  1292.     uint32    m_n2DSoundsLoaded;
  1293.     //! Reports the number of 3D sounds currently loaded
  1294.     uint32    m_n3DSoundsLoaded;
  1295.     //! Reports the number of segments currently loaded
  1296.     uint32    m_nSegmentsLoaded;
  1297. };
  1298.  
  1299.  
  1300. //! The audio manager controls all low-level audio components.
  1301. /*!
  1302. It is responsible for initializing the sound and music subsystems, and for creating and
  1303. managing all 2D and 3D sounds (both static and streaming), as well as for queueing
  1304. and playing music segments.  The manager is designed to allow nearly direct access to
  1305. low level buffers and segments while still providing an easy-to-use and high-level
  1306. management system.
  1307. */
  1308. class IAudioManager
  1309. {
  1310. public:
  1311.  
  1312.     /*!
  1313.     Initializes the audio manager.  This function is automatically called if using
  1314.     the standard engine framework.  Otherwise, you must call this manually before 
  1315.     attempting to play any sounds.
  1316.     \param init is the AudioMgrInit structure that contains initialization parameters 
  1317.     \return true indicates success, false indicates failure.
  1318.     \sa AudioMgrInit, Term()
  1319.     */
  1320.     virtual bool Init(const AudioMgrInit& init) = 0;
  1321.     /*!
  1322.     Terminates the audio manager.  This should be called before the application exits to
  1323.     properly shut down the sound system.  This function is called automatically if using
  1324.     the standard engine framework.
  1325.     \sa Init()
  1326.     */
  1327.     virtual void Term() = 0;
  1328.  
  1329.     /*!
  1330.     Determines whether an audio manager is currently initialized.
  1331.     \return true indicates the manager is initialized, false indicates it is not
  1332.     */
  1333.     virtual bool IsInitialized() const = 0;
  1334.  
  1335.     /*!
  1336.     Gets current usage statistics from the audio manager.
  1337.     \param init is the AudioMgrInit structure that contains statistics fields 
  1338.     \return true indicates success, false indicates failure.
  1339.     \sa AudioMgrStats
  1340.     */
  1341.     virtual bool GetStats(AudioMgrStats& stats) const = 0;
  1342.  
  1343.     /*!
  1344.     Creates a new sound object to be managed by the audio system.
  1345.     \param pSound holds the newly created ISound interface.
  1346.     \return true indicates success, false indicates failure.
  1347.     */
  1348.     virtual bool CreateSound(ISound*& pSound) = 0;
  1349.     /*!
  1350.     Creates a new 3D sound object to be managed by the audio system.
  1351.     \param pSound3D holds the newly created ISound3D interface.
  1352.     \return true indicates success, false indicates failure.
  1353.     */
  1354.     virtual bool CreateSound3D(ISound3D*& pSound3D) = 0;
  1355.     /*!
  1356.     Creates a new segment object to be managed by the audio system.
  1357.     \param pSegment holds the newly created ISegment interface.
  1358.     \return true indicates success, false indicates failure.
  1359.     */
  1360.     virtual bool CreateSegment(ISegment*& pSegment) = 0;
  1361.     /*!
  1362.     Creates a new DLS object to be managed by the audio system.
  1363.     \param pDLS holds the newly created IDLS interface.
  1364.     \return true indicates success, false indicates failure.
  1365.     */
  1366.     virtual bool CreateDLS(IDLS*& pDLS) = 0;
  1367.  
  1368.     /*!
  1369.     Creates a new audio script object to be managed by the audio system.
  1370.     \param pScript holds the newly created IAudioScript interface.
  1371.     \return true indicates success, false indicates failure.
  1372.     */
  1373.     virtual bool CreateAudioScript(IAudioScript*& pScript) = 0;
  1374.  
  1375.     /*!
  1376.     Retrives the listener object.  This function will return the same object on every call.
  1377.     \param pListener holds the acquired IListener interface.
  1378.     \return true indicates success, false indicates failure.
  1379.     \sa IListener
  1380.     */
  1381.     virtual bool GetListener(IListener*& pListener) = 0;
  1382.     
  1383.     /*!
  1384.     Sets the master volume for the audio system.
  1385.     \param fVolume sets the master volume.  Acceptable values range from AUD_VOLUME_MIN to
  1386.     AUD_VOLUME_MAX (0 to 1).  The volume control is linear.
  1387.     \return true indicates success, false indicates failure.
  1388.     \sa GetSoundVolume()
  1389.     */
  1390.     virtual bool SetSoundVolume(float fVolume) = 0;
  1391.     /*!
  1392.     Gets the master volume from the audio system.
  1393.     \param fVolume gets the master volume.
  1394.     \return true indicates success, false indicates failure.
  1395.     \sa SetSoundVolume()
  1396.     */
  1397.     virtual bool GetSoundVolume(float& fVolume) const = 0;
  1398.  
  1399.     /*!
  1400.     Sets the music volume.
  1401.     \param fVolume sets the music volume.  Acceptable values range from AUD_VOLUME_MIN to
  1402.     AUD_VOLUME_MAX (0 to 1).  The volume control is linear.
  1403.     \return true indicates success, false indicates failure.
  1404.     \sa GetMusicVolume()
  1405.     */
  1406.     virtual bool SetMusicVolume(float fVolume) = 0;
  1407.     /*!
  1408.     Gets the music volume.
  1409.     \param fVolume gets the music volume.
  1410.     \return true indicates success, false indicates failure.
  1411.     \sa SetMusicVolume()
  1412.     */
  1413.     virtual bool GetMusicVolume(float& fVolume) const = 0;
  1414.  
  1415.     /*!
  1416.     Stops all currently playing sounds and music.
  1417.     \return true indicates success, false indicates failure.
  1418.     \sa PauseAll(), ResumeAll()
  1419.     */
  1420.     virtual bool StopAll() = 0;
  1421.     /*!
  1422.     Pauses all currently playing sounds and music.
  1423.     \return true indicates success, false indicates failure.
  1424.     \sa StopAll(), ResumeAll()
  1425.     */
  1426.     virtual bool PauseAll() = 0;
  1427.     /*!
  1428.     Resumes all currently paused sounds and music.  Note that this will include 
  1429.     any sounds paused other than a call to PauseAll().
  1430.     \return true indicates success, false indicates failure.
  1431.     \sa StopAll(), PauseAll()
  1432.     */
  1433.     virtual bool ResumeAll() = 0;
  1434.  
  1435.     /*!
  1436.     Gets the currently playing music segment from the audio system.  
  1437.     \param pSegment is the currently playing primary segment.  pSegment 
  1438.     will be NULL if no segment is currently playing.
  1439.     \return true indicates success, false indicates failure.
  1440.     \sa GetNextSegment()
  1441.     */
  1442.     virtual bool GetCurrentSegment(ISegment*& pSegment) const = 0;
  1443.     /*!
  1444.     Gets the next queued music segment from the audio system.  
  1445.     \param pSegment is the next queued segment.  pSegment will be NULL if no segment
  1446.     is currently queued.
  1447.     \return true indicates success, false indicates failure.
  1448.     \sa GetCurrentSegment()
  1449.     */
  1450.     virtual bool GetNextSegment(ISegment*& pSegment) const = 0;
  1451.  
  1452.     /*!
  1453.     Creates a file object based either on the user-defined file creation
  1454.     factory if one was supplied, or returns a default disk-based file
  1455.     object.
  1456.     \param pAudioFile holds a valid IAudioFile object on success
  1457.     \return true indicates success, false indicates failure.
  1458.     \sa DestroyAudioFile(), IAudioFileFactory, IAudioFile, AudioMgrInit
  1459.     */
  1460.     virtual bool CreateAudioStream(IAudioStream*& pStream) = 0;
  1461. };
  1462.  
  1463. /*!
  1464. AudioMgr() is used to access a single static audio manager object from anywhere 
  1465. in the code.
  1466. \sa IAudioManager
  1467. */
  1468. inline IAudioManager* AudioMgr()
  1469. {  return AudioLibFactory::GetAudioMgr();  }
  1470.  
  1471. #ifndef DOXYGEN_SHOULD_SKIP_THIS
  1472. }; // namespace Audio
  1473. #endif /* DOXYGEN_SHOULD_SKIP_THIS */
  1474.  
  1475. #endif // __IAUDIO_H__