Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

channel.h

Go to the documentation of this file.
00001 /*
00002 Copyright (c) 2002 Xavier Trochu
00003 
00004 This software is provided 'as-is', without any express or implied warranty. In no event
00005 will the authors be held liable for any damages arising from the use of this software.
00006 
00007 Permission is granted to anyone to use this software for any purpose, including commercial
00008 applications, and to alter it and redistribute it freely, subject to the following
00009 restrictions:
00010 
00011 1. The origin of this software must not be misrepresented; you must not claim that you
00012    wrote the original software. If you use this software in a product, an acknowledgment
00013    in the product documentation would be appreciated but is not required.
00014 
00015 2. Altered source versions must be plainly marked as such, and must not be misrepresented 
00016    as being the original software.
00017 
00018 3. This notice may not be removed or altered from any source distribution.
00019 */
00020 #ifndef __CHANNEL_H_
00021 #define __CHANNEL_H_
00022 
00023 #ifdef HAVE_CONFIG_H
00024 #include "config.h"
00025 #endif
00026 
00027 #ifdef DEBUG
00028 # ifndef NO_DEBUG_CHANNEL
00029 #  define DEBUG_CHANNEL
00030 # endif
00031 #else
00032 # ifdef DEBUG_CHANNEL
00033 #  error DEBUG_CHANNEL defined without DEBUG
00034 # endif
00035 #endif
00036 
00037 #include <exception>
00038 
00039 class chunck;
00040 class cont_chunck;
00041     
00046 class channel {
00047 public:
00048     virtual ~channel() throw() {};
00057     virtual bool is_terminated() const throw() = 0;
00067     virtual bool append_data(chunck & b, int size) throw(std::exception) = 0;
00076     virtual int available_sound_data() const throw() = 0;
00088     virtual void read_sound_data(short * sound_buffer, int size) throw(std::exception) = 0;
00094     virtual bool set_parameters(int, int, int, int) throw(std::exception) = 0;
00100     virtual bool check_parameters(int, int, int, int, int) throw(std::exception) = 0;
00101 };
00102 
00107 class saud_channel : public channel {
00108 private:
00109     int _track;             
00110     int _nbframes;          
00111     unsigned char * _buffer;    
00112     int _buffer_size;           
00113     int _frequency;         
00114     int _cur_buffer_write_pos;  
00115     int _cur_buffer_read_pos;   
00116     int _data_start;            
00117     int _data_size;         
00118     bool _mark_reached;     
00119     int _flags;             
00120     int _volume;            
00121     int _balance;           
00122     int _index;             
00123     short _voltable[2][256];    
00124     int _rdata_start;           
00125     int _rdata_size;            
00126 protected:
00133     void handleStrk(chunck & c) throw(std::exception);
00140     void handleSmrk(chunck & c) throw(std::exception);
00147     void handleShdr(chunck & c) throw(std::exception);
00154     bool processBuffer() throw(std::exception);
00160     void recalcVolumeTable() throw(std::exception);
00161 public:
00162     saud_channel(int track, int freq) throw();
00163     virtual ~saud_channel() throw();
00164     bool is_terminated() const throw();
00165     bool set_parameters(int duration, int flags, int vol1, int vol2) throw(std::exception);
00166     bool check_parameters(int index, int duration, int flags, int vol1, int vol2) throw(std::exception);
00167     bool append_data(chunck & b, int size) throw(std::exception);
00168     int available_sound_data() const throw();
00169     void read_sound_data(short * sound_buffer, int size) throw(std::exception);
00170 };
00171 
00178 class imuse_channel : public channel {
00179 private:
00180     int _track;             
00181     unsigned char * _buffer;    
00182     short * _decoded_buffer;    
00183     short * _resampled_buffer;  
00184     int _buffer_size;           
00185     int _frequency;         
00186     int _cur_buffer_write_pos;  
00187     int _cur_buffer_read_pos;   
00188     int _data_start;            
00189     int _data_size;         
00190     int _size;
00191     int _nbframes;
00192     int _unk1;
00193     int _unk2;
00194     int _index;
00195     int _bitsize;           
00196     int _rate;              
00197     int _channels;          
00198     int _imuse_start;
00199     int _imuse_length;
00200     int _imuse_stop;
00201     int _rdata_start;           
00202     int _rdata_size;            
00203 protected:
00204     int resample_mono(int size) throw(std::exception);
00205     int resample_stereo(int size) throw(std::exception);
00206     int decode(int size, int &) throw(std::exception);
00207     bool processBuffer() throw(std::exception);
00208     bool handleMap(chunck &);
00209     bool handleFormat(chunck &);
00210     bool handleText(chunck &);
00211     bool handleRegion(chunck &);
00212     bool handleStop(chunck &);
00213 public:
00214     imuse_channel(int track, int freq) throw();
00215     virtual ~imuse_channel() throw();
00216     bool is_terminated() const throw();
00217     bool set_parameters(int nbframes, int size, int unk1, int unk2) throw(std::exception);
00218     bool check_parameters(int index, int nbframes, int size, int unk1, int unk2) throw(std::exception);
00219     bool append_data(chunck & b, int size) throw(std::exception);
00220     int available_sound_data() const throw();
00221     void read_sound_data(short * sound_buffer, int size) throw(std::exception);
00222 };
00223 
00224 #endif

Generated on Fri Aug 9 22:54:29 2002 for san_player by doxygen1.2.16