/[svn]/linuxsampler/trunk/src/engines/sfz/sfz.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/engines/sfz/sfz.cpp

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

revision 2101 by persson, Sun May 30 11:40:31 2010 UTC revision 2106 by persson, Sun Jul 4 12:50:51 2010 UTC
# Line 32  Line 32 
32  #include "../../common/File.h"  #include "../../common/File.h"
33  #include "../../common/Path.h"  #include "../../common/Path.h"
34  #include "../../common/global_private.h"  #include "../../common/global_private.h"
35    #include "LookupTable.h"
36    
37  namespace sfz  namespace sfz
38  {  {
# Line 108  namespace sfz Line 109  namespace sfz
109      }      }
110    
111      bool Region::OnKey(const Query& q) {      bool Region::OnKey(const Query& q) {
112            // As the region comes from a LookupTable search on the query,
113            // the following parameters are not checked here: chan, key,
114            // vel, chanaft, polyaft, prog, sw_previous, cc. They are all
115            // handled by the lookup table.
116          bool is_triggered(          bool is_triggered(
             q.chan    >= lochan     &&  q.chan    <= hichan     &&  
             q.key     >= lokey      &&  q.key     <= hikey      &&  
             q.vel     >= lovel      &&  q.vel     <= hivel      &&  
117              q.bend    >= lobend     &&  q.bend    <= hibend     &&              q.bend    >= lobend     &&  q.bend    <= hibend     &&
118              q.bpm     >= lobpm      &&  q.bpm     <  hibpm      &&              q.bpm     >= lobpm      &&  q.bpm     <  hibpm      &&
             q.chanaft >= lochanaft  &&  q.chanaft <= hichanaft  &&  
             q.polyaft >= lopolyaft  &&  q.polyaft <= hipolyaft  &&  
             q.prog    >= loprog     &&  q.prog    <= hiprog     &&  
119              q.rand    >= lorand     &&  q.rand    <  hirand     &&              q.rand    >= lorand     &&  q.rand    <  hirand     &&
120              q.timer   >= lotimer    &&  q.timer   <= hitimer    &&              q.timer   >= lotimer    &&  q.timer   <= hitimer    &&
121    
# Line 129  namespace sfz Line 128  namespace sfz
128              ( sw_up   == -1 ||              ( sw_up   == -1 ||
129                ((sw_up   >= sw_lokey && (sw_hikey == -1 || sw_up   <= sw_hikey)) ? (!q.sw[sw_up]) : true) )  &&                ((sw_up   >= sw_lokey && (sw_hikey == -1 || sw_up   <= sw_hikey)) ? (!q.sw[sw_up]) : true) )  &&
130    
             ( sw_previous == -1 ||  
               q.prev_sw_key == sw_previous )  &&  
   
131              ((trigger & q.trig) != 0)              ((trigger & q.trig) != 0)
132          );          );
133    
134          if (!is_triggered)          if (!is_triggered)
135              return false;              return false;
136    
         for (int i = 0; i < 128; ++i) {  
             if (locc[i] != -1 && hicc[i] != -1 && !(q.cc[i] >= locc[i] && q.cc[i] <= hicc[i]))  
                 return false;  
         }  
   
137          // seq_position has to be checked last, so we know that we          // seq_position has to be checked last, so we know that we
138          // increment the right counter          // increment the right counter
139          is_triggered = (seq_counter == seq_position);          is_triggered = (seq_counter == seq_position);
# Line 244  namespace sfz Line 235  namespace sfz
235      {      {
236          this->name = name;          this->name = name;
237          this->pSampleManager = pSampleManager ? pSampleManager : this;          this->pSampleManager = pSampleManager ? pSampleManager : this;
238            pLookupTable = 0;
239      }      }
240    
241      Instrument::~Instrument()      Instrument::~Instrument()
242      {      {
243          for(int i = 0; i < regions.size(); i++) {          for (int i = 0; i < regions.size(); i++) {
244              delete (regions[i]);              delete regions[i];
245          }          }
246          regions.clear();          delete pLookupTable;
247      }      }
248    
249      Query::Query(const Instrument& instrument) {      void Query::search(const Instrument* pInstrument) {
250          i = instrument.regions.begin();          pRegionList = &pInstrument->pLookupTable->query(*this);
251          regions_end = instrument.regions.end();          regionIndex = 0;
252      }      }
253    
254      Region* Query::next() {      Region* Query::next() {
255          while (i != regions_end) {          for ( ; regionIndex < pRegionList->size() ; regionIndex++) {
256              if ((*i++)->OnKey(*this)) return *i;              if ((*pRegionList)[regionIndex]->OnKey(*this)) {
257                    return (*pRegionList)[regionIndex++];
258                }
259          }          }
260          return 0;          return 0;
261      }      }
# Line 894  namespace sfz Line 888  namespace sfz
888                  }                  }
889              }              }
890          }          }
891    
892            _instrument->pLookupTable = new LookupTable(_instrument);
893      }      }
894    
895      File::~File()      File::~File()
# Line 1005  namespace sfz Line 1001  namespace sfz
1001          else if ("hivel"  == key) pCurDef->hivel = ToInt(value);          else if ("hivel"  == key) pCurDef->hivel = ToInt(value);
1002          else if ("lobend" == key) pCurDef->lobend = ToInt(value);          else if ("lobend" == key) pCurDef->lobend = ToInt(value);
1003          else if ("hibend" == key) pCurDef->hibend = ToInt(value);          else if ("hibend" == key) pCurDef->hibend = ToInt(value);
1004          else if ("lobpm"  == key) pCurDef->lobpm = ToInt(value);          else if ("lobpm"  == key) pCurDef->lobpm = ToFloat(value);
1005          else if ("hibpm"  == key) pCurDef->hibpm = ToInt(value);          else if ("hibpm"  == key) pCurDef->hibpm = ToFloat(value);
1006          else if ("lochanaft" == key) pCurDef->lochanaft = ToInt(value);          else if ("lochanaft" == key) pCurDef->lochanaft = ToInt(value);
1007          else if ("hichanaft" == key) pCurDef->hichanaft = ToInt(value);          else if ("hichanaft" == key) pCurDef->hichanaft = ToInt(value);
1008          else if ("lopolyaft" == key) pCurDef->lopolyaft = ToInt(value);          else if ("lopolyaft" == key) pCurDef->lopolyaft = ToInt(value);

Legend:
Removed from v.2101  
changed lines
  Added in v.2106

  ViewVC Help
Powered by ViewVC