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