AppEasy Core SDK  1.5.0
Cross platform mobile and desktop app and game development SDK - The easy way to make apps
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines
CzAudio.h
Go to the documentation of this file.
00001 // 
00002 //
00003 // AppEasy SDK - Cross Platform Multi-purpose Game and App Engine
00004 //
00005 // Developed by Matthew Hopwood of Pocketeers Limited - www.pocketeers.co.uk
00006 //
00007 // For updates, tutorials and more details check out www.appeasymobile.com
00008 //
00009 // This code is provided free of charge and without any warranty whatsoever. You must ensure that this whole notice is present in all files and derivatives, so the reader knows its origin.
00010 // If you use this SDK in your product then please ensure that you credit AppEasy's usage appropriately. Please see www.appeasymobile.com for licensing details and support
00011 //
00012 //
00013 
00014 #if !defined(_CZ_AUDIO_H_)
00015 #define _CZ_AUDIO_H_
00016 
00017 #include "CzUtil.h"
00018 #include "CzString.h"
00019 #include "CzXoml.h"
00020 #include "IzPlatformAudio.h"
00021 
00022 class CzAudio;
00023 class CzScene;
00024 class CzFile;
00025 class CzSoundCollection;
00026 
00027 /**
00028  @addtogroup Audio
00029  @{
00030  */
00031 
00032 /**
00033  @def   CZ_AUDIO
00034 
00035  @brief A short cut macro that calls the global audio manager singleton
00036 
00037  */
00038  
00039 #define CZ_AUDIO    CzAudio::getInstance()
00040 
00041 /**
00042  @class CzSound
00043 
00044  @brief CzSound - A sound effect.
00045 
00046  */
00047 
00048 class CzSound : public IzXomlResource
00049 {
00050 public:
00051 
00052     /**
00053      @enum  eState
00054     
00055      @brief Values that sound loaded states
00056      */
00057 
00058     enum eState
00059     {
00060         State_Invalid,  ///< Sound effect is invalid
00061         State_Loaded,   ///< Sound effect jas been loaded
00062     };
00063 
00064     // Proprties
00065 protected:
00066     eState              State;              ///< State of sound
00067 //  CIwResGroup*        ResourceGroup;      ///< Resource group that our image lives in
00068     CzSoundInst         SoundInstance;      ///< Sound instance
00069 public:
00070     eState              getState() const                    { return State; }
00071     CzSoundSpec         getSoundSpec()                      { if (Load()) return SoundSpec; return NULL; }
00072     // Properties end
00073 
00074 protected:
00075     CzSoundData         SoundData;          ///< Sound data
00076     CzSoundSpec         SoundSpec;          ///< Sound info
00077     CzFile*             File;               ///< File object (if sound is file based)
00078 public:
00079 
00080     CzSound() : IzXomlResource(), File(NULL), SoundSpec(NULL), SoundData(NULL), /*ResourceGroup(NULL),*/ State(State_Invalid) { setClassType("sound"); }
00081     virtual ~CzSound();
00082 
00083 /*  void            Init(const char* ResourceName, CIwResGroup* resource_group)     // Init an sound from an soundspec located within a resource group
00084     {
00085         setName(ResourceName);
00086         ResourceGroup = resource_group;
00087     }*/
00088 
00089     bool            Init(void* memory_file, int memory_file_size);  // Init a sound from a memory based file (sound is loaded)
00090     void            Init(const char* filename);                     // Init a sound from a file (sound is not loaded)
00091     bool            Load(bool blocking = true);                     // Force load the sound
00092 
00093     CzSoundInst     Play(float volume = 1.0f, float pitch = 1.0f, float pan = 0, bool looped = false);
00094 
00095     // Implementation of IzXomlResource interface
00096     int             LoadFromXoml(IzXomlResource* parent, bool load_children, CzXmlNode* node);
00097 
00098     // Internal
00099     void            FinishLoad();                                   // Called back when aysnc loading is completed
00100 };
00101 
00102 /**
00103  @class CzSoundCreator
00104 
00105  @brief CzSoundCreator - Creates an instance of a sound object.
00106 
00107  */
00108 
00109 class CzSoundCreator : public IzXomlClassCreator
00110 {
00111 public:
00112     CzSoundCreator()
00113     {
00114         setClassName("sound");
00115     }
00116     IzXomlResource* CreateInstance(IzXomlResource* parent)  { return new CzSound(); }
00117 };
00118 
00119 /// @}
00120 
00121 #endif  // _CAUDIO_H_