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 |
* |
* |
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 |