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

Diff of /linuxsampler/trunk/src/engines/gig/InstrumentScriptVMFunctions.cpp

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

revision 3227 by schoenebeck, Tue Apr 19 14:07:53 2016 UTC revision 3228 by schoenebeck, Sun May 28 14:46:14 2017 UTC
# Line 1  Line 1 
1  /*  /*
2   * Copyright (c) 2014-2016 Christian Schoenebeck   * Copyright (c) 2014-2017 Christian Schoenebeck
3   *   *
4   * http://www.linuxsampler.org   * http://www.linuxsampler.org
5   *   *
# Line 117  namespace LinuxSampler { namespace gig { Line 117  namespace LinuxSampler { namespace gig {
117          return successResult();          return successResult();
118      }      }
119    
120      /////////////////////////////////////////////////////////////////////////
121      // Function:
122      //     same_region(key1, key2)
123    
124        InstrumentScriptVMFunction_same_region::InstrumentScriptVMFunction_same_region(InstrumentScriptVM* parent)
125        : m_vm(parent)
126        {
127        }
128    
129        VMFnResult* InstrumentScriptVMFunction_same_region::exec(VMFnArgs* args) {
130            EngineChannel* pEngineChannel =
131                static_cast<EngineChannel*>(m_vm->m_event->cause.pEngineChannel);
132    
133            int key1 = args->arg(0)->asInt()->evalInt();
134            int key2 = args->arg(1)->asInt()->evalInt();
135    
136            if (key1 < 0 || key1 > 127) {
137                wrnMsg("same_region(): key number for argument 1 out of range");
138                return successResult(-1);
139            }
140            if (key2 < 0 || key2 > 127) {
141                wrnMsg("same_region(): key number for argument 2 out of range");
142                return successResult(-1);
143            }
144    
145            ::gig::Region* pRgn1 = pEngineChannel->pInstrument->GetRegion(key1);
146            ::gig::Region* pRgn2 = pEngineChannel->pInstrument->GetRegion(key2);
147    
148            if (!pRgn1 && !pRgn2)
149                return successResult(5);
150            if (pRgn1 == pRgn2)
151                return successResult(1);
152            if (pRgn1 && !pRgn2)
153                return successResult(3);
154            if (!pRgn1 && pRgn2)
155                return successResult(4);
156            if (pRgn1->KeyRange.overlaps(pRgn2->KeyRange))
157                return successResult(2);
158            return successResult(0);
159        }
160    
161  }} // namespace LinuxSampler::gig  }} // namespace LinuxSampler::gig

Legend:
Removed from v.3227  
changed lines
  Added in v.3228

  ViewVC Help
Powered by ViewVC