1 |
/* |
/* |
2 |
* Copyright (c) 2014 Christian Schoenebeck |
* Copyright (c) 2014-2016 Christian Schoenebeck |
3 |
* |
* |
4 |
* http://www.linuxsampler.org |
* http://www.linuxsampler.org |
5 |
* |
* |
34 |
int zone = args->arg(2)->asInt()->evalInt(); |
int zone = args->arg(2)->asInt()->evalInt(); |
35 |
|
|
36 |
if (args->arg(0)->exprType() == INT_EXPR) { |
if (args->arg(0)->exprType() == INT_EXPR) { |
37 |
int id = args->arg(0)->asInt()->evalInt(); |
const ScriptID id = args->arg(0)->asInt()->evalInt(); |
38 |
if (id < 0) { |
if (!id) { |
39 |
wrnMsg("gig_set_dim_zone(): argument 1 may not be a negative event ID"); |
wrnMsg("gig_set_dim_zone(): note ID for argument 1 may not be zero"); |
40 |
|
return successResult(); |
41 |
|
} |
42 |
|
if (!id.isNoteID()) { |
43 |
|
wrnMsg("gig_set_dim_zone(): argument 1 is not a note ID"); |
44 |
return successResult(); |
return successResult(); |
45 |
} |
} |
46 |
|
|
47 |
RTList<Event>::Iterator itEvent = pEngineChannel->pEngine->EventByID(id); |
NoteBase* pNote = pEngineChannel->pEngine->NoteByID( id.noteID() ); |
48 |
if (!itEvent) { |
if (!pNote) { |
49 |
dmsg(2,("gig_set_dim_zone(): no active event with ID %d\n", id)); |
dmsg(2,("gig_set_dim_zone(): no active note with ID %d\n", int(id))); |
50 |
return successResult(); |
return successResult(); |
51 |
} |
} |
52 |
|
|
53 |
int note = itEvent->Param.Note.Key; |
int note = pNote->cause.Param.Note.Key; |
54 |
|
|
55 |
::gig::Region* pRegion = pEngineChannel->pInstrument->GetRegion(note); |
::gig::Region* pRegion = pEngineChannel->pInstrument->GetRegion(note); |
56 |
if (!pRegion) { |
if (!pRegion) { |
75 |
int mask = 0; |
int mask = 0; |
76 |
for (int i = 0; i < bits; ++i) mask |= (1 << (baseBits + i)); |
for (int i = 0; i < bits; ++i) mask |= (1 << (baseBits + i)); |
77 |
|
|
78 |
itEvent->Format.Gig.DimMask |= mask; |
pNote->Format.Gig.DimMask |= mask; |
79 |
itEvent->Format.Gig.DimBits |= (zone << baseBits) & mask; |
pNote->Format.Gig.DimBits |= (zone << baseBits) & mask; |
80 |
|
|
81 |
dmsg(3,("gig_set_dim_zone(): success, mask=%d bits=%d\n", itEvent->Format.Gig.DimMask, itEvent->Format.Gig.DimBits)); |
dmsg(3,("gig_set_dim_zone(): success, mask=%d bits=%d\n", pNote->Format.Gig.DimMask, pNote->Format.Gig.DimBits)); |
82 |
} else if (args->arg(0)->exprType() == INT_ARR_EXPR) { |
} else if (args->arg(0)->exprType() == INT_ARR_EXPR) { |
83 |
VMIntArrayExpr* ids = args->arg(0)->asIntArray(); |
VMIntArrayExpr* ids = args->arg(0)->asIntArray(); |
84 |
for (int i = 0; i < ids->arraySize(); ++i) { |
for (int i = 0; i < ids->arraySize(); ++i) { |
85 |
int id = ids->evalIntElement(i); |
const ScriptID id = ids->evalIntElement(i); |
86 |
if (id < 0) continue; |
if (!id || !id.isNoteID()) continue; |
87 |
|
|
88 |
RTList<Event>::Iterator itEvent = pEngineChannel->pEngine->EventByID(id); |
NoteBase* pNote = pEngineChannel->pEngine->NoteByID( id.noteID() ); |
89 |
if (!itEvent) continue; |
if (!pNote) continue; |
90 |
|
|
91 |
int note = itEvent->Param.Note.Key; |
int note = pNote->cause.Param.Note.Key; |
92 |
|
|
93 |
::gig::Region* pRegion = pEngineChannel->pInstrument->GetRegion(note); |
::gig::Region* pRegion = pEngineChannel->pInstrument->GetRegion(note); |
94 |
if (!pRegion) continue; |
if (!pRegion) continue; |
107 |
int mask = 0; |
int mask = 0; |
108 |
for (int i = 0; i < bits; ++i) mask |= (1 << (baseBits + i)); |
for (int i = 0; i < bits; ++i) mask |= (1 << (baseBits + i)); |
109 |
|
|
110 |
itEvent->Format.Gig.DimMask |= mask; |
pNote->Format.Gig.DimMask |= mask; |
111 |
itEvent->Format.Gig.DimBits |= (zone << baseBits) & mask; |
pNote->Format.Gig.DimBits |= (zone << baseBits) & mask; |
112 |
|
|
113 |
dmsg(3,("gig_set_dim_zone(): success, mask=%d bits=%d\n", itEvent->Format.Gig.DimMask, itEvent->Format.Gig.DimBits)); |
dmsg(3,("gig_set_dim_zone(): success, mask=%d bits=%d\n", pNote->Format.Gig.DimMask, pNote->Format.Gig.DimBits)); |
114 |
} |
} |
115 |
} |
} |
116 |
|
|