gig.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                                                         *
00003  *   libgig - C++ cross-platform Gigasampler format file access library    *
00004  *                                                                         *
00005  *   Copyright (C) 2003-2010 by Christian Schoenebeck                      *
00006  *                              <cuse@users.sourceforge.net>               *
00007  *                                                                         *
00008  *   This library is free software; you can redistribute it and/or modify  *
00009  *   it under the terms of the GNU General Public License as published by  *
00010  *   the Free Software Foundation; either version 2 of the License, or     *
00011  *   (at your option) any later version.                                   *
00012  *                                                                         *
00013  *   This library is distributed in the hope that it will be useful,       *
00014  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00015  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00016  *   GNU General Public License for more details.                          *
00017  *                                                                         *
00018  *   You should have received a copy of the GNU General Public License     *
00019  *   along with this library; if not, write to the Free Software           *
00020  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston,                 *
00021  *   MA  02111-1307  USA                                                   *
00022  ***************************************************************************/
00023 
00024 #ifndef __GIG_H__
00025 #define __GIG_H__
00026 
00027 #include "DLS.h"
00028 
00029 #if WORDS_BIGENDIAN
00030 # define LIST_TYPE_3PRG 0x33707267
00031 # define LIST_TYPE_3EWL 0x3365776C
00032 # define LIST_TYPE_3GRI 0x33677269
00033 # define LIST_TYPE_3GNL 0x33676E6C
00034 # define CHUNK_ID_3GIX  0x33676978
00035 # define CHUNK_ID_3EWA  0x33657761
00036 # define CHUNK_ID_3LNK  0x336C6E6B
00037 # define CHUNK_ID_3EWG  0x33657767
00038 # define CHUNK_ID_EWAV  0x65776176
00039 # define CHUNK_ID_3GNM  0x33676E6D
00040 # define CHUNK_ID_EINF  0x65696E66
00041 # define CHUNK_ID_3CRC  0x33637263
00042 #else  // little endian
00043 # define LIST_TYPE_3PRG 0x67727033
00044 # define LIST_TYPE_3EWL 0x6C776533
00045 # define LIST_TYPE_3GRI 0x69726733
00046 # define LIST_TYPE_3GNL 0x6C6E6733
00047 # define CHUNK_ID_3GIX  0x78696733
00048 # define CHUNK_ID_3EWA  0x61776533
00049 # define CHUNK_ID_3LNK  0x6B6E6C33
00050 # define CHUNK_ID_3EWG  0x67776533
00051 # define CHUNK_ID_EWAV  0x76617765
00052 # define CHUNK_ID_3GNM  0x6D6E6733
00053 # define CHUNK_ID_EINF  0x666E6965
00054 # define CHUNK_ID_3CRC  0x63726333
00055 #endif // WORDS_BIGENDIAN
00056 
00058 namespace gig {
00059 
00060     typedef std::string String;
00061 
00063     struct range_t {
00064         uint8_t low;  
00065         uint8_t high; 
00066     };
00067 
00069     struct buffer_t {
00070         void*         pStart;            
00071         unsigned long Size;              
00072         unsigned long NullExtensionSize; 
00073         buffer_t() {
00074             pStart            = NULL;
00075             Size              = 0;
00076             NullExtensionSize = 0;
00077         }
00078     };
00079 
00081     typedef enum {
00082         loop_type_normal        = 0x00000000,  
00083         loop_type_bidirectional = 0x00000001,  
00084         loop_type_backward      = 0x00000002   
00085     } loop_type_t;
00086 
00088     typedef enum {
00089         smpte_format_no_offset          = 0x00000000,  
00090         smpte_format_24_frames          = 0x00000018,  
00091         smpte_format_25_frames          = 0x00000019,  
00092         smpte_format_30_frames_dropping = 0x0000001D,  
00093         smpte_format_30_frames          = 0x0000001E   
00094     } smpte_format_t;
00095 
00097     typedef enum {
00098         curve_type_nonlinear = 0,
00099         curve_type_linear    = 1,
00100         curve_type_special   = 2,
00101         curve_type_unknown   = 0xffffffff
00102     } curve_type_t;
00103 
00105     typedef enum {
00106         dim_bypass_ctrl_none,
00107         dim_bypass_ctrl_94,   
00108         dim_bypass_ctrl_95    
00109     } dim_bypass_ctrl_t;
00110 
00112     typedef enum {
00113         lfo3_ctrl_internal            = 0x00, 
00114         lfo3_ctrl_modwheel            = 0x01, 
00115         lfo3_ctrl_aftertouch          = 0x02, 
00116         lfo3_ctrl_internal_modwheel   = 0x03, 
00117         lfo3_ctrl_internal_aftertouch = 0x04  
00118     } lfo3_ctrl_t;
00119 
00121     typedef enum {
00122         lfo2_ctrl_internal            = 0x00, 
00123         lfo2_ctrl_modwheel            = 0x01, 
00124         lfo2_ctrl_foot                = 0x02, 
00125         lfo2_ctrl_internal_modwheel   = 0x03, 
00126         lfo2_ctrl_internal_foot       = 0x04  
00127     } lfo2_ctrl_t;
00128 
00130     typedef enum {
00131         lfo1_ctrl_internal            = 0x00, 
00132         lfo1_ctrl_modwheel            = 0x01, 
00133         lfo1_ctrl_breath              = 0x02, 
00134         lfo1_ctrl_internal_modwheel   = 0x03, 
00135         lfo1_ctrl_internal_breath     = 0x04  
00136     } lfo1_ctrl_t;
00137 
00139     typedef enum {
00140         vcf_cutoff_ctrl_none         = 0x00,
00141         vcf_cutoff_ctrl_none2        = 0x01,  
00142         vcf_cutoff_ctrl_modwheel     = 0x81,  
00143         vcf_cutoff_ctrl_effect1      = 0x8c,  
00144         vcf_cutoff_ctrl_effect2      = 0x8d,  
00145         vcf_cutoff_ctrl_breath       = 0x82,  
00146         vcf_cutoff_ctrl_foot         = 0x84,  
00147         vcf_cutoff_ctrl_sustainpedal = 0xc0,  
00148         vcf_cutoff_ctrl_softpedal    = 0xc3,  
00149         vcf_cutoff_ctrl_genpurpose7  = 0xd2,  
00150         vcf_cutoff_ctrl_genpurpose8  = 0xd3,  
00151         vcf_cutoff_ctrl_aftertouch   = 0x80   
00152     } vcf_cutoff_ctrl_t;
00153 
00155     typedef enum {
00156         vcf_res_ctrl_none        = 0xffffffff,
00157         vcf_res_ctrl_genpurpose3 = 0,           
00158         vcf_res_ctrl_genpurpose4 = 1,           
00159         vcf_res_ctrl_genpurpose5 = 2,           
00160         vcf_res_ctrl_genpurpose6 = 3            
00161     } vcf_res_ctrl_t;
00162 
00171     struct leverage_ctrl_t {
00172         typedef enum {
00173             type_none              = 0x00, 
00174             type_channelaftertouch = 0x2f, 
00175             type_velocity          = 0xff, 
00176             type_controlchange     = 0xfe  
00177         } type_t;
00178 
00179         type_t type;              
00180         uint   controller_number; 
00181     };
00182 
00188     typedef leverage_ctrl_t attenuation_ctrl_t;
00189 
00195     typedef leverage_ctrl_t eg1_ctrl_t;
00196 
00202     typedef leverage_ctrl_t eg2_ctrl_t;
00203 
00211     typedef enum {
00212         dimension_none              = 0x00, 
00213         dimension_samplechannel     = 0x80, 
00214         dimension_layer             = 0x81, 
00215         dimension_velocity          = 0x82, 
00216         dimension_channelaftertouch = 0x83, 
00217         dimension_releasetrigger    = 0x84, 
00218         dimension_keyboard          = 0x85, 
00219         dimension_roundrobin        = 0x86, 
00220         dimension_random            = 0x87, 
00221         dimension_smartmidi         = 0x88, 
00222         dimension_roundrobinkeyboard = 0x89, 
00223         dimension_modwheel          = 0x01, 
00224         dimension_breath            = 0x02, 
00225         dimension_foot              = 0x04, 
00226         dimension_portamentotime    = 0x05, 
00227         dimension_effect1           = 0x0c, 
00228         dimension_effect2           = 0x0d, 
00229         dimension_genpurpose1       = 0x10, 
00230         dimension_genpurpose2       = 0x11, 
00231         dimension_genpurpose3       = 0x12, 
00232         dimension_genpurpose4       = 0x13, 
00233         dimension_sustainpedal      = 0x40, 
00234         dimension_portamento        = 0x41, 
00235         dimension_sostenutopedal    = 0x42, 
00236         dimension_softpedal         = 0x43, 
00237         dimension_genpurpose5       = 0x30, 
00238         dimension_genpurpose6       = 0x31, 
00239         dimension_genpurpose7       = 0x32, 
00240         dimension_genpurpose8       = 0x33, 
00241         dimension_effect1depth      = 0x5b, 
00242         dimension_effect2depth      = 0x5c, 
00243         dimension_effect3depth      = 0x5d, 
00244         dimension_effect4depth      = 0x5e, 
00245         dimension_effect5depth      = 0x5f  
00246     } dimension_t;
00247 
00252     typedef enum {
00253         split_type_normal,         
00254         split_type_bit             
00255     } split_type_t;
00256 
00258     struct dimension_def_t {
00259         dimension_t  dimension;  
00260         uint8_t      bits;       
00261         uint8_t      zones;      
00262         split_type_t split_type; 
00263         float        zone_size;  
00264     };
00265 
00267     typedef enum {
00268         vcf_type_lowpass      = 0x00,
00269         vcf_type_lowpassturbo = 0xff, 
00270         vcf_type_bandpass     = 0x01,
00271         vcf_type_highpass     = 0x02,
00272         vcf_type_bandreject   = 0x03
00273     } vcf_type_t;
00274 
00282     struct crossfade_t {
00283         #if WORDS_BIGENDIAN
00284         uint8_t out_end;    
00285         uint8_t out_start;  
00286         uint8_t in_end;     
00287         uint8_t in_start;   
00288         #else // little endian
00289         uint8_t in_start;   
00290         uint8_t in_end;     
00291         uint8_t out_start;  
00292         uint8_t out_end;    
00293         #endif // WORDS_BIGENDIAN
00294     };
00295 
00297     struct playback_state_t {
00298         unsigned long position;          
00299         bool          reverse;           
00300         unsigned long loop_cycles_left;  
00301     };
00302 
00315     struct progress_t {
00316         void (*callback)(progress_t*); 
00317         float factor;                  
00318         void* custom;                  
00319         float __range_min;             
00320         float __range_max;             
00321         progress_t();
00322     };
00323 
00324     // just symbol prototyping
00325     class File;
00326     class Instrument;
00327     class Sample;
00328     class Region;
00329     class Group;
00330 
00343     class DimensionRegion : protected DLS::Sampler {
00344         public:
00345             uint8_t            VelocityUpperLimit;            
00346             Sample*            pSample;                       
00347             // Sample Amplitude EG/LFO
00348             uint16_t           EG1PreAttack;                  
00349             double             EG1Attack;                     
00350             double             EG1Decay1;                     
00351             double             EG1Decay2;                     
00352             bool               EG1InfiniteSustain;            
00353             uint16_t           EG1Sustain;                    
00354             double             EG1Release;                    
00355             bool               EG1Hold;                       
00356             eg1_ctrl_t         EG1Controller;                 
00357             bool               EG1ControllerInvert;           
00358             uint8_t            EG1ControllerAttackInfluence;  
00359             uint8_t            EG1ControllerDecayInfluence;   
00360             uint8_t            EG1ControllerReleaseInfluence; 
00361             double             LFO1Frequency;                 
00362             uint16_t           LFO1InternalDepth;             
00363             uint16_t           LFO1ControlDepth;              
00364             lfo1_ctrl_t        LFO1Controller;                
00365             bool               LFO1FlipPhase;                 
00366             bool               LFO1Sync;                      
00367             // Filter Cutoff Frequency EG/LFO
00368             uint16_t           EG2PreAttack;                  
00369             double             EG2Attack;                     
00370             double             EG2Decay1;                     
00371             double             EG2Decay2;                     
00372             bool               EG2InfiniteSustain;            
00373             uint16_t           EG2Sustain;                    
00374             double             EG2Release;                    
00375             eg2_ctrl_t         EG2Controller;                 
00376             bool               EG2ControllerInvert;           
00377             uint8_t            EG2ControllerAttackInfluence;  
00378             uint8_t            EG2ControllerDecayInfluence;   
00379             uint8_t            EG2ControllerReleaseInfluence; 
00380             double             LFO2Frequency;                 
00381             uint16_t           LFO2InternalDepth;             
00382             uint16_t           LFO2ControlDepth;              
00383             lfo2_ctrl_t        LFO2Controller;                
00384             bool               LFO2FlipPhase;                 
00385             bool               LFO2Sync;                      
00386             // Sample Pitch EG/LFO
00387             double             EG3Attack;                     
00388             int16_t            EG3Depth;                      
00389             double             LFO3Frequency;                 
00390             int16_t            LFO3InternalDepth;             
00391             int16_t            LFO3ControlDepth;              
00392             lfo3_ctrl_t        LFO3Controller;                
00393             bool               LFO3Sync;                      
00394             // Filter
00395             bool               VCFEnabled;                    
00396             vcf_type_t         VCFType;                       
00397             vcf_cutoff_ctrl_t  VCFCutoffController;           
00398             bool               VCFCutoffControllerInvert;     
00399             uint8_t            VCFCutoff;                     
00400             curve_type_t       VCFVelocityCurve;              
00401             uint8_t            VCFVelocityScale;              
00402             uint8_t            VCFVelocityDynamicRange;       
00403             uint8_t            VCFResonance;                  
00404             bool               VCFResonanceDynamic;           
00405             vcf_res_ctrl_t     VCFResonanceController;        
00406             bool               VCFKeyboardTracking;           
00407             uint8_t            VCFKeyboardTrackingBreakpoint; 
00408             // Key Velocity Transformations
00409             curve_type_t       VelocityResponseCurve;         
00410             uint8_t            VelocityResponseDepth;         
00411             uint8_t            VelocityResponseCurveScaling;  
00412             curve_type_t       ReleaseVelocityResponseCurve;  
00413             uint8_t            ReleaseVelocityResponseDepth;  
00414             uint8_t            ReleaseTriggerDecay;           
00415             // Mix / Layer
00416             crossfade_t        Crossfade;
00417             bool               PitchTrack;                    
00418             dim_bypass_ctrl_t  DimensionBypass;               
00419             int8_t             Pan;                           
00420             bool               SelfMask;                      
00421             attenuation_ctrl_t AttenuationController;         
00422             bool               InvertAttenuationController;   
00423             uint8_t            AttenuationControllerThreshold;
00424             uint8_t            ChannelOffset;                 
00425             bool               SustainDefeat;                 
00426             bool               MSDecode;                      
00427             uint16_t           SampleStartOffset;             
00428             double             SampleAttenuation;             
00429             uint8_t            DimensionUpperLimits[8];       
00430 
00431             // derived attributes from DLS::Sampler
00432             DLS::Sampler::UnityNote;
00433             DLS::Sampler::FineTune;
00434             DLS::Sampler::Gain;
00435             DLS::Sampler::SampleLoops;
00436             DLS::Sampler::pSampleLoops;
00437 
00438             // own methods
00439             double GetVelocityAttenuation(uint8_t MIDIKeyVelocity);
00440             double GetVelocityRelease(uint8_t MIDIKeyVelocity);
00441             double GetVelocityCutoff(uint8_t MIDIKeyVelocity);
00442             void SetVelocityResponseCurve(curve_type_t curve);
00443             void SetVelocityResponseDepth(uint8_t depth);
00444             void SetVelocityResponseCurveScaling(uint8_t scaling);
00445             void SetReleaseVelocityResponseCurve(curve_type_t curve);
00446             void SetReleaseVelocityResponseDepth(uint8_t depth);
00447             void SetVCFCutoffController(vcf_cutoff_ctrl_t controller);
00448             void SetVCFVelocityCurve(curve_type_t curve);
00449             void SetVCFVelocityDynamicRange(uint8_t range);
00450             void SetVCFVelocityScale(uint8_t scaling);
00451             Region* GetParent() const;
00452             // derived methods
00453             DLS::Sampler::AddSampleLoop;
00454             DLS::Sampler::DeleteSampleLoop;
00455             // overridden methods
00456             virtual void SetGain(int32_t gain);
00457             virtual void UpdateChunks();
00458         protected:
00459             uint8_t* VelocityTable; 
00460             DimensionRegion(Region* pParent, RIFF::List* _3ewl);
00461             DimensionRegion(RIFF::List* _3ewl, const DimensionRegion& src);
00462            ~DimensionRegion();
00463             friend class Region;
00464         private:
00465             typedef enum { 
00466                 _lev_ctrl_none              = 0x00,
00467                 _lev_ctrl_modwheel          = 0x03, 
00468                 _lev_ctrl_breath            = 0x05, 
00469                 _lev_ctrl_foot              = 0x07, 
00470                 _lev_ctrl_effect1           = 0x0d, 
00471                 _lev_ctrl_effect2           = 0x0f, 
00472                 _lev_ctrl_genpurpose1       = 0x11, 
00473                 _lev_ctrl_genpurpose2       = 0x13, 
00474                 _lev_ctrl_genpurpose3       = 0x15, 
00475                 _lev_ctrl_genpurpose4       = 0x17, 
00476                 _lev_ctrl_portamentotime    = 0x0b, 
00477                 _lev_ctrl_sustainpedal      = 0x01, 
00478                 _lev_ctrl_portamento        = 0x19, 
00479                 _lev_ctrl_sostenutopedal    = 0x1b, 
00480                 _lev_ctrl_softpedal         = 0x09, 
00481                 _lev_ctrl_genpurpose5       = 0x1d, 
00482                 _lev_ctrl_genpurpose6       = 0x1f, 
00483                 _lev_ctrl_genpurpose7       = 0x21, 
00484                 _lev_ctrl_genpurpose8       = 0x23, 
00485                 _lev_ctrl_effect1depth      = 0x25, 
00486                 _lev_ctrl_effect2depth      = 0x27, 
00487                 _lev_ctrl_effect3depth      = 0x29, 
00488                 _lev_ctrl_effect4depth      = 0x2b, 
00489                 _lev_ctrl_effect5depth      = 0x2d, 
00490                 _lev_ctrl_channelaftertouch = 0x2f, 
00491                 _lev_ctrl_velocity          = 0xff  
00492             } _lev_ctrl_t;
00493             typedef std::map<uint32_t, double*> VelocityTableMap;
00494 
00495             static uint              Instances;                  
00496             static VelocityTableMap* pVelocityTables;            
00497             double*                  pVelocityAttenuationTable;  
00498             double*                  pVelocityReleaseTable;      
00499             double*                  pVelocityCutoffTable;       
00500             Region*                  pRegion;
00501 
00502             leverage_ctrl_t DecodeLeverageController(_lev_ctrl_t EncodedController);
00503             _lev_ctrl_t     EncodeLeverageController(leverage_ctrl_t DecodedController);
00504             double* GetReleaseVelocityTable(curve_type_t releaseVelocityResponseCurve, uint8_t releaseVelocityResponseDepth);
00505             double* GetCutoffVelocityTable(curve_type_t vcfVelocityCurve, uint8_t vcfVelocityDynamicRange, uint8_t vcfVelocityScale, vcf_cutoff_ctrl_t vcfCutoffController);
00506             double* GetVelocityTable(curve_type_t curveType, uint8_t depth, uint8_t scaling);
00507             double* CreateVelocityTable(curve_type_t curveType, uint8_t depth, uint8_t scaling);
00508     };
00509 
00525     class Sample : public DLS::Sample {
00526         public:
00527             uint32_t       Manufacturer;      
00528             uint32_t       Product;           
00529             uint32_t       SamplePeriod;      
00530             uint32_t       MIDIUnityNote;     
00531             uint32_t       FineTune;          
00532             smpte_format_t SMPTEFormat;       
00533             uint32_t       SMPTEOffset;       
00534             uint32_t       Loops;             
00535             uint32_t       LoopID;            
00536             loop_type_t    LoopType;          
00537             uint32_t       LoopStart;         
00538             uint32_t       LoopEnd;           
00539             uint32_t       LoopSize;          
00540             uint32_t       LoopFraction;      
00541             uint32_t       LoopPlayCount;     
00542             bool           Compressed;        
00543             uint32_t       TruncatedBits;     
00544             bool           Dithered;          
00545 
00546             // own methods
00547             buffer_t      LoadSampleData();
00548             buffer_t      LoadSampleData(unsigned long SampleCount);
00549             buffer_t      LoadSampleDataWithNullSamplesExtension(uint NullSamplesCount);
00550             buffer_t      LoadSampleDataWithNullSamplesExtension(unsigned long SampleCount, uint NullSamplesCount);
00551             buffer_t      GetCache();
00552             // own static methods
00553             static buffer_t CreateDecompressionBuffer(unsigned long MaxReadSize);
00554             static void     DestroyDecompressionBuffer(buffer_t& DecompressionBuffer);
00555             // overridden methods
00556             void          ReleaseSampleData();
00557             void          Resize(int iNewSize);
00558             unsigned long SetPos(unsigned long SampleCount, RIFF::stream_whence_t Whence = RIFF::stream_start);
00559             unsigned long GetPos();
00560             unsigned long Read(void* pBuffer, unsigned long SampleCount, buffer_t* pExternalDecompressionBuffer = NULL);
00561             unsigned long ReadAndLoop(void* pBuffer, unsigned long SampleCount, playback_state_t* pPlaybackState, DimensionRegion* pDimRgn, buffer_t* pExternalDecompressionBuffer = NULL);
00562             unsigned long Write(void* pBuffer, unsigned long SampleCount);
00563             Group*        GetGroup() const;
00564             virtual void  UpdateChunks();
00565         protected:
00566             static unsigned int  Instances;               
00567             static buffer_t      InternalDecompressionBuffer; 
00568             Group*               pGroup;                  
00569             unsigned long        FrameOffset;             
00570             unsigned long*       FrameTable;              
00571             unsigned long        SamplePos;               
00572             unsigned long        SamplesInLastFrame;      
00573             unsigned long        WorstCaseFrameSize;      
00574             unsigned long        SamplesPerFrame;         
00575             buffer_t             RAMCache;                
00576             unsigned long        FileNo;                  
00577             RIFF::Chunk*         pCk3gix;
00578             RIFF::Chunk*         pCkSmpl;
00579             uint32_t             crc;                     
00580 
00581             Sample(File* pFile, RIFF::List* waveList, unsigned long WavePoolOffset, unsigned long fileNo = 0);
00582            ~Sample();
00583 
00584             // Guess size (in bytes) of a compressed sample
00585             inline unsigned long GuessSize(unsigned long samples) {
00586                 // 16 bit: assume all frames are compressed - 1 byte
00587                 // per sample and 5 bytes header per 2048 samples
00588 
00589                 // 24 bit: assume next best compression rate - 1.5
00590                 // bytes per sample and 13 bytes header per 256
00591                 // samples
00592                 const unsigned long size =
00593                     BitDepth == 24 ? samples + (samples >> 1) + (samples >> 8) * 13
00594                                    : samples + (samples >> 10) * 5;
00595                 // Double for stereo and add one worst case sample
00596                 // frame
00597                 return (Channels == 2 ? size << 1 : size) + WorstCaseFrameSize;
00598             }
00599 
00600             // Worst case amount of sample points that can be read with the
00601             // given decompression buffer.
00602             inline unsigned long WorstCaseMaxSamples(buffer_t* pDecompressionBuffer) {
00603                 return (unsigned long) ((float)pDecompressionBuffer->Size / (float)WorstCaseFrameSize * (float)SamplesPerFrame);
00604             }
00605         private:
00606             void ScanCompressedSample();
00607             friend class File;
00608             friend class Region;
00609             friend class Group; // allow to modify protected member pGroup
00610     };
00611 
00612     // TODO: <3dnl> list not used yet - not important though (just contains optional descriptions for the dimensions)
00614     class Region : public DLS::Region {
00615         public:
00616             unsigned int            Dimensions;               
00617             dimension_def_t         pDimensionDefinitions[8]; 
00618             uint32_t                DimensionRegions;         
00619             DimensionRegion*        pDimensionRegions[256];   
00620             unsigned int            Layers;                   
00621 
00622             // own methods
00623             DimensionRegion* GetDimensionRegionByValue(const uint DimValues[8]);
00624             DimensionRegion* GetDimensionRegionByBit(const uint8_t DimBits[8]);
00625             Sample*          GetSample();
00626             void             AddDimension(dimension_def_t* pDimDef);
00627             void             DeleteDimension(dimension_def_t* pDimDef);
00628             // overridden methods
00629             virtual void     SetKeyRange(uint16_t Low, uint16_t High);
00630             virtual void     UpdateChunks();
00631         protected:
00632             Region(Instrument* pInstrument, RIFF::List* rgnList);
00633             void LoadDimensionRegions(RIFF::List* rgn);
00634             void UpdateVelocityTable();
00635             Sample* GetSampleFromWavePool(unsigned int WavePoolTableIndex, progress_t* pProgress = NULL);
00636            ~Region();
00637             friend class Instrument;
00638     };
00639 
00641     class MidiRule {
00642         public:
00643             virtual ~MidiRule() { }
00644     };
00645 
00647     class MidiRuleCtrlTrigger : public MidiRule {
00648         public:
00649             uint8_t ControllerNumber;   
00650             uint8_t Triggers;           
00651             struct trigger_t {
00652                 uint8_t TriggerPoint;   
00653                 bool    Descending;     
00654                 uint8_t VelSensitivity; 
00655                 uint8_t Key;            
00656                 bool    NoteOff;        
00657                 uint8_t Velocity;       
00658                 bool    OverridePedal;  
00659             } pTriggers[32];
00660 
00661         protected:
00662             MidiRuleCtrlTrigger(RIFF::Chunk* _3ewg);
00663             friend class Instrument;
00664     };
00665 
00667     class Instrument : protected DLS::Instrument {
00668         public:
00669             // derived attributes from DLS::Resource
00670             DLS::Resource::pInfo;
00671             DLS::Resource::pDLSID;
00672             // derived attributes from DLS::Instrument
00673             DLS::Instrument::IsDrum;
00674             DLS::Instrument::MIDIBank;
00675             DLS::Instrument::MIDIBankCoarse;
00676             DLS::Instrument::MIDIBankFine;
00677             DLS::Instrument::MIDIProgram;
00678             DLS::Instrument::Regions;
00679             // own attributes
00680             int32_t   Attenuation;       
00681             uint16_t  EffectSend;
00682             int16_t   FineTune;          
00683             uint16_t  PitchbendRange;    
00684             bool      PianoReleaseMode;
00685             range_t   DimensionKeyRange; 
00686 
00687 
00688             // derived methods from DLS::Resource
00689             DLS::Resource::GetParent;
00690             // overridden methods
00691             Region*   GetFirstRegion();
00692             Region*   GetNextRegion();
00693             Region*   AddRegion();
00694             void      DeleteRegion(Region* pRegion);
00695             virtual void UpdateChunks();
00696             // own methods
00697             Region*   GetRegion(unsigned int Key);
00698             MidiRule* GetMidiRule(int i);
00699         protected:
00700             Region*   RegionKeyTable[128]; 
00701 
00702             Instrument(File* pFile, RIFF::List* insList, progress_t* pProgress = NULL);
00703            ~Instrument();
00704             void UpdateRegionKeyTable();
00705             friend class File;
00706             friend class Region; // so Region can call UpdateRegionKeyTable()
00707         private:
00708             MidiRule** pMidiRules;
00709     };
00710 
00726     class Group {
00727         public:
00728             String Name; 
00729 
00730             Sample* GetFirstSample();
00731             Sample* GetNextSample();
00732             void AddSample(Sample* pSample);
00733         protected:
00734             Group(File* file, RIFF::Chunk* ck3gnm);
00735             virtual ~Group();
00736             virtual void UpdateChunks();
00737             void MoveAll();
00738             friend class File;
00739         private:
00740             File*        pFile;
00741             RIFF::Chunk* pNameChunk;
00742     };
00743 
00745     class File : protected DLS::File {
00746         public:
00747             static const DLS::version_t VERSION_2;
00748             static const DLS::version_t VERSION_3;
00749 
00750             // derived attributes from DLS::Resource
00751             DLS::Resource::pInfo;
00752             DLS::Resource::pDLSID;
00753             // derived attributes from DLS::File
00754             DLS::File::pVersion;
00755             DLS::File::Instruments;
00756 
00757             // derived methods from DLS::Resource
00758             DLS::Resource::GetParent;
00759             // derived methods from DLS::File
00760             DLS::File::Save;
00761             // overridden  methods
00762             File();
00763             File(RIFF::File* pRIFF);
00764             Sample*     GetFirstSample(progress_t* pProgress = NULL); 
00765             Sample*     GetNextSample();      
00766             Sample*     AddSample();
00767             void        DeleteSample(Sample* pSample);
00768             Instrument* GetFirstInstrument(); 
00769             Instrument* GetNextInstrument();  
00770             Instrument* GetInstrument(uint index, progress_t* pProgress = NULL);
00771             Instrument* AddInstrument();
00772             void        DeleteInstrument(Instrument* pInstrument);
00773             Group*      GetFirstGroup(); 
00774             Group*      GetNextGroup();  
00775             Group*      GetGroup(uint index);
00776             Group*      AddGroup();
00777             void        DeleteGroup(Group* pGroup);
00778             void        DeleteGroupOnly(Group* pGroup);
00779             void        SetAutoLoad(bool b);
00780             bool        GetAutoLoad();
00781             virtual    ~File();
00782             virtual void UpdateChunks();
00783         protected:
00784             // overridden protected methods from DLS::File
00785             virtual void LoadSamples();
00786             virtual void LoadInstruments();
00787             virtual void LoadGroups();
00788             // own protected methods
00789             virtual void LoadSamples(progress_t* pProgress);
00790             virtual void LoadInstruments(progress_t* pProgress);
00791             void SetSampleChecksum(Sample* pSample, uint32_t crc);
00792             friend class Region;
00793             friend class Sample;
00794             friend class Group; // so Group can access protected member pRIFF
00795         private:
00796             std::list<Group*>*          pGroups;
00797             std::list<Group*>::iterator GroupsIterator;
00798             bool                        bAutoLoad;
00799     };
00800 
00809     class Exception : public DLS::Exception {
00810         public:
00811             Exception(String Message);
00812             void PrintMessage();
00813     };
00814 
00815     String libraryName();
00816     String libraryVersion();
00817 
00818 } // namespace gig
00819 
00820 #endif // __GIG_H__

Generated on Sun May 1 03:22:46 2011 for libgig by  doxygen 1.5.2