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

streamed_mikmod_sample.h

Go to the documentation of this file.
00001 /*
00002         $Id: streamed_mikmod_sample.h,v 1.6 2001/03/06 18:51:05 japj Exp $
00003 
00004         ------------------------------------------------------------------------
00005         ClanLib, the platform independent game SDK.
00006 
00007         This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE
00008         version 2. See COPYING for details.
00009 
00010         For a total list of contributers see CREDITS.
00011 
00012         ------------------------------------------------------------------------
00013 
00014         File purpose:
00015                 Streamed sample header file
00016 */
00017 
00019 
00020 #ifndef header_streamed_mikmod_sample
00021 #define header_streamed_mikmod_sample
00022 
00023 #include <stdlib.h>
00024 #include "../core.h"
00025 #include "API/Sound/stream_soundprovider.h"
00026 #include "API/Sound/soundbuffer.h"
00027 
00028 extern "C"
00029 {
00030         #include <mikmod.h>
00031 }
00032 
00033 class CL_Streamed_MikModSample : public CL_StreamSoundProvider
00034 //: CL_Streamed_MikModSample is used to store MikMod modules in memory.
00035 // This class stores the ClanLib sample the way the MikMod MODULE struct
00036 // does. It's only intended to store the module in memory, not to play
00037 // it directly. To play the module, use CL_Streamed_MikModSample_Session
00038 // instead.
00039 {
00040 protected:
00041         std::string filename;
00042         bool looped;
00043 
00044         MODULE *module;
00045 public:
00046         static CL_SoundBuffer *create(
00047                 const char *filename, 
00048                 CL_InputSourceProvider *inputprovider = NULL, 
00049                 bool looped = false);
00050         //: Use this function to create a module from a file for instance
00051 
00052         static CL_SoundBuffer *load(
00053                 const char *res_id, 
00054                 CL_ResourceManager *manager, 
00055                 bool looped = false);
00056         //: Loads a module from a resource file (.scr or .dat)
00057 
00058         CL_Streamed_MikModSample(
00059                 const char *filename, 
00060                 CL_InputSourceProvider *inputprovider = NULL, 
00061                 bool looped = false);
00062         //: Use this functino to create a module from a file for instance
00063 
00064         CL_Streamed_MikModSample(
00065                 const char *res_id, 
00066                 CL_ResourceManager *manager, 
00067                 bool looped = false);
00068         //: Loads a module from a resource file (.scr or .dat)
00069 
00070         virtual ~CL_Streamed_MikModSample();
00071 
00072         virtual CL_StreamSoundProvider_Session *begin_session();
00073         //: Starts playing the module
00074 
00075         virtual void end_session(CL_StreamSoundProvider_Session *session);
00076         //: Ends the session
00077 
00078 };
00079 
00080 class CL_Streamed_MikModSample_Session : public CL_StreamSoundProvider_Session
00081 {
00082 //: CL_Streamed_MikModSample_Session is used to play and control a module.
00083 //
00084 protected:
00085         friend CL_Streamed_MikModSample;
00086 
00087         CL_Streamed_MikModSample_Session(MODULE *_module, bool _looped);
00088 
00089         MODULE *module;
00090         bool looped;
00091 
00092         SoundFormat sample_format;
00093         int sample_size;
00094         int sample_freq;
00095         int sample_left;
00096 
00097 public:
00098 /*
00099         CL_Streamed_MikModSample_Session::CL_Streamed_MikModSample_Session(
00100         CL_InputSource *_input, bool _looped, const char* filename)
00101 */
00102         virtual ~CL_Streamed_MikModSample_Session();
00103 
00104         virtual void stop();
00105         virtual bool play();
00106         virtual bool set_position(int pos);
00107         
00108         virtual bool eof() const;
00109         virtual int get_data(void *data_ptr, int data_requested);
00110         virtual int get_frequency() const;
00111         virtual SoundFormat get_format() const;
00112         
00113         static BOOL clanMikMod_IsPresent () { return 1; } 
00114         static void clanMikMod_Update () { /* do nothing */ } 
00115 };
00116 
00117 #endif
00118 
00119 
00120 
00121 
00122 
00123 
00124 
00125 
00126 
00127 
00128 
00129 
00130 
00131 
00132 
00133 
00134 

Generated at Wed Apr 4 19:54:04 2001 for ClanLib by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001