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

input_mod.hpp

Go to the documentation of this file.
00001 #ifndef INPUT_MOD_HPP
00002 #define INPUT_MOD_HPP
00003 
00004 
00005 #include <mikmod.h>  // 
00006 #include <uniform.h> // mikmod headers
00007 #include <mplayer.h> //
00008 #include "config.h"
00009 #include "input.hpp"
00010 
00011 
00012 // should match the C runtime's calling convention
00013 
00014 #ifdef _WIN32
00015   #define CRT_CALL __cdecl
00016 #else
00017   #define CRT_CALL
00018 #endif
00019 
00020 
00021 class MODInputStream : public ISampleSource
00022 {
00023 public:
00024   MODInputStream();
00025   ~MODInputStream();
00026 
00027   bool Initialize(IFile* file);
00028 
00029   void GetFormat(
00030     int& channel_count,
00031     int& sample_rate,
00032     int& bits_per_sample);
00033   int Read(int sample_count, void* samples);
00034   bool Reset();
00035 
00036 private:
00037   // MMIO file callbacks
00038   static int CRT_CALL MMRead(
00039     void* buffer, size_t size, size_t count, FILE* stream);
00040   static int CRT_CALL MMWrite(
00041     const void* buffer, size_t size, size_t count, FILE* stream);
00042   static int CRT_CALL MMGetC(FILE* stream);
00043   static int CRT_CALL MMPutC(int c, FILE* stream);
00044   static int CRT_CALL MMSeek(FILE* stream, long offset, int origin);
00045   static int CRT_CALL MMTell(FILE* stream);
00046   static int CRT_CALL MMEof(FILE* stream);
00047 
00048   // MikMod driver implementation
00049   static BOOL ACQ_IsThere();
00050   static BOOL ACQ_Init(MDRIVER* md, uint latency, void* optstr);
00051   static void ACQ_Exit(MDRIVER* md);
00052   static void ACQ_Update(MDRIVER* md);
00053   static BOOL ACQ_SetSoftVoices(MDRIVER* md, uint voices);
00054   static BOOL ACQ_SetMode(MDRIVER* md, uint mixspeed, uint mode,
00055                           uint channels, uint cpumode);
00056   static void ACQ_GetMode(MDRIVER* md, uint* mixspeed, uint* mode,
00057                           uint* channels, uint* cpumode);
00058 
00059 private:
00060   enum { SAMPLE_BUFFER_SIZE = 4096 };
00061 
00062   IFile* m_file;
00063 
00064   // MikMod handles
00065   MDRIVER* m_driver;
00066   UNIMOD*  m_module;
00067   MPLAYER* m_player;
00068 
00069   MMSTREAM m_stream;
00070 
00071   adr_u32  m_samples_left;
00072   adr_u32* m_next_sample;
00073   adr_u32  m_sample_buffer[SAMPLE_BUFFER_SIZE];
00074 
00075   bool m_at_eof;
00076 
00077   // mikmod driver description
00078   static MD_DEVICE drv_acq;
00079 };
00080 
00081 
00082 #endif

Generated at Mon Jun 10 02:55:12 2002 for audiere by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001