/[svn]/libgig/trunk/src/gig.cpp
ViewVC logotype

Diff of /libgig/trunk/src/gig.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1627 by persson, Sun Jan 6 10:53:53 2008 UTC revision 1713 by persson, Thu Mar 6 20:42:22 2008 UTC
# Line 25  Line 25 
25    
26  #include "helper.h"  #include "helper.h"
27    
28    #include <algorithm>
29  #include <math.h>  #include <math.h>
30  #include <iostream>  #include <iostream>
31    
# Line 2965  MidiRuleCtrlTrigger::MidiRuleCtrlTrigger Line 2966  MidiRuleCtrlTrigger::MidiRuleCtrlTrigger
2966          PianoReleaseMode = false;          PianoReleaseMode = false;
2967          DimensionKeyRange.low = 0;          DimensionKeyRange.low = 0;
2968          DimensionKeyRange.high = 0;          DimensionKeyRange.high = 0;
2969            pMidiRules = new MidiRule*[3];
2970            pMidiRules[0] = NULL;
2971    
2972          // Loading          // Loading
2973          RIFF::List* lart = insList->GetSubList(LIST_TYPE_LART);          RIFF::List* lart = insList->GetSubList(LIST_TYPE_LART);
# Line 2982  MidiRuleCtrlTrigger::MidiRuleCtrlTrigger Line 2985  MidiRuleCtrlTrigger::MidiRuleCtrlTrigger
2985    
2986                  if (_3ewg->GetSize() > 32) {                  if (_3ewg->GetSize() > 32) {
2987                      // read MIDI rules                      // read MIDI rules
2988                        int i = 0;
2989                      _3ewg->SetPos(32);                      _3ewg->SetPos(32);
2990                      uint8_t id1 = _3ewg->ReadUint8();                      uint8_t id1 = _3ewg->ReadUint8();
2991                      uint8_t id2 = _3ewg->ReadUint8();                      uint8_t id2 = _3ewg->ReadUint8();
2992    
2993                      if (id1 == 4 && id2 == 16) {                      if (id1 == 4 && id2 == 16) {
2994                          MidiRules.push_back(new MidiRuleCtrlTrigger(_3ewg));                          pMidiRules[i++] = new MidiRuleCtrlTrigger(_3ewg);
2995                      }                      }
2996                      //TODO: all the other types of rules                      //TODO: all the other types of rules
2997    
2998                        pMidiRules[i] = NULL;
2999                  }                  }
3000              }              }
3001          }          }
# Line 3027  MidiRuleCtrlTrigger::MidiRuleCtrlTrigger Line 3033  MidiRuleCtrlTrigger::MidiRuleCtrlTrigger
3033      }      }
3034    
3035      Instrument::~Instrument() {      Instrument::~Instrument() {
3036            delete[] pMidiRules;
3037      }      }
3038    
3039      /**      /**
# Line 3142  MidiRuleCtrlTrigger::MidiRuleCtrlTrigger Line 3149  MidiRuleCtrlTrigger::MidiRuleCtrlTrigger
3149      }      }
3150    
3151      /**      /**
3152       * Returns the first MIDI rule of the instrument. You have to call       * Returns a MIDI rule of the instrument.
      * this method once before you use GetNextMidiRule().  
3153       *       *
3154       * The list of MIDI rules, at least in gig v3, always contains at       * The list of MIDI rules, at least in gig v3, always contains at
3155       * most two rules. The second rule can only be the DEF filter       * most two rules. The second rule can only be the DEF filter
3156       * (which currently isn't supported by libgig).       * (which currently isn't supported by libgig).
3157       *       *
3158       * @returns  pointer address to first MIDI rule or NULL if there is none       * @param i - MIDI rule number
3159       * @see      GetNextMidiRule()       * @returns   pointer address to MIDI rule number i or NULL if there is none
      */  
     MidiRule* Instrument::GetFirstMidiRule() {  
         MidiRulesIterator = MidiRules.begin();  
         return MidiRulesIterator != MidiRules.end() ? *MidiRulesIterator : NULL;  
     }  
   
     /**  
      * Returns the next MIDI rule of the instrument. You have to call  
      * GetFirstMidiRule() once before you can use this method. By  
      * calling this method multiple times it iterates through the  
      * available rules.  
      *  
      * @returns  pointer address to the next MIDI rule or NULL if end reached  
      * @see      GetFirstMidiRule()  
3160       */       */
3161      MidiRule* Instrument::GetNextMidiRule() {      MidiRule* Instrument::GetMidiRule(int i) {
3162          MidiRulesIterator++;          return pMidiRules[i];
         return MidiRulesIterator != MidiRules.end() ? *MidiRulesIterator : NULL;  
3163      }      }
3164    
3165    
# Line 3413  MidiRuleCtrlTrigger::MidiRuleCtrlTrigger Line 3404  MidiRuleCtrlTrigger::MidiRuleCtrlTrigger
3404          pSamples->erase(iter);          pSamples->erase(iter);
3405          delete pSample;          delete pSample;
3406    
3407            SampleList::iterator tmp = SamplesIterator;
3408          // remove all references to the sample          // remove all references to the sample
3409          for (Instrument* instrument = GetFirstInstrument() ; instrument ;          for (Instrument* instrument = GetFirstInstrument() ; instrument ;
3410               instrument = GetNextInstrument()) {               instrument = GetNextInstrument()) {
# Line 3427  MidiRuleCtrlTrigger::MidiRuleCtrlTrigger Line 3419  MidiRuleCtrlTrigger::MidiRuleCtrlTrigger
3419                  }                  }
3420              }              }
3421          }          }
3422            SamplesIterator = tmp; // restore iterator
3423      }      }
3424    
3425      void File::LoadSamples() {      void File::LoadSamples() {

Legend:
Removed from v.1627  
changed lines
  Added in v.1713

  ViewVC Help
Powered by ViewVC