57 |
e.Type = Event::type_note_on; |
e.Type = Event::type_note_on; |
58 |
e.Param.Note.Key = note; |
e.Param.Note.Key = note; |
59 |
e.Param.Note.Velocity = velocity; |
e.Param.Note.Velocity = velocity; |
60 |
|
memset(&e.Format, 0, sizeof(e.Format)); // init format speific stuff with zero |
61 |
|
|
62 |
int id = pEngineChannel->ScheduleEvent(&e, duration); |
int id = pEngineChannel->ScheduleEvent(&e, duration); |
63 |
|
|
64 |
return successResult(id); |
return successResult(id); |
65 |
} |
} |
66 |
|
|
67 |
|
InstrumentScriptVMFunction_set_controller::InstrumentScriptVMFunction_set_controller(InstrumentScriptVM* parent) |
68 |
|
: m_vm(parent) |
69 |
|
{ |
70 |
|
} |
71 |
|
|
72 |
|
VMFnResult* InstrumentScriptVMFunction_set_controller::exec(VMFnArgs* args) { |
73 |
|
int controller = args->arg(0)->asInt()->evalInt(); |
74 |
|
int value = args->arg(1)->asInt()->evalInt(); |
75 |
|
|
76 |
|
AbstractEngineChannel* pEngineChannel = |
77 |
|
static_cast<AbstractEngineChannel*>(m_vm->m_event->cause.pEngineChannel); |
78 |
|
|
79 |
|
Event e = m_vm->m_event->cause; |
80 |
|
memset(&e.Format, 0, sizeof(e.Format)); // init format speific stuff with zero |
81 |
|
if (controller == CTRL_TABLE_IDX_AFTERTOUCH) { |
82 |
|
e.Type = Event::type_channel_pressure; |
83 |
|
e.Param.ChannelPressure.Value = value & 127; |
84 |
|
} else if (controller == CTRL_TABLE_IDX_PITCHBEND) { |
85 |
|
e.Type = Event::type_pitchbend; |
86 |
|
e.Param.Pitch.Pitch = value; |
87 |
|
} else if (controller >= 0 && controller <= 127) { |
88 |
|
e.Type = Event::type_control_change; |
89 |
|
e.Param.CC.Controller = controller; |
90 |
|
e.Param.CC.Value = value; |
91 |
|
} else { |
92 |
|
errMsg("set_controller(): argument 1 is an invalid controller"); |
93 |
|
return errorResult(); |
94 |
|
} |
95 |
|
|
96 |
|
int id = pEngineChannel->ScheduleEvent(&e, 0); |
97 |
|
|
98 |
|
return successResult(id); |
99 |
|
} |
100 |
|
|
101 |
InstrumentScriptVMFunction_ignore_event::InstrumentScriptVMFunction_ignore_event(InstrumentScriptVM* parent) |
InstrumentScriptVMFunction_ignore_event::InstrumentScriptVMFunction_ignore_event(InstrumentScriptVM* parent) |
102 |
: m_vm(parent) |
: m_vm(parent) |
103 |
{ |
{ |
137 |
|
|
138 |
return successResult(); |
return successResult(); |
139 |
} |
} |
140 |
|
|
141 |
|
InstrumentScriptVMFunction_note_off::InstrumentScriptVMFunction_note_off(InstrumentScriptVM* parent) |
142 |
|
: m_vm(parent) |
143 |
|
{ |
144 |
|
} |
145 |
|
|
146 |
|
VMFnResult* InstrumentScriptVMFunction_note_off::exec(VMFnArgs* args) { |
147 |
|
int id = args->arg(0)->asInt()->evalInt(); |
148 |
|
int velocity = (args->argsCount() >= 2) ? args->arg(1)->asInt()->evalInt() : 127; |
149 |
|
|
150 |
|
if (id < 0) { |
151 |
|
wrnMsg("note_off(): argument 1 may not be a negative event ID"); |
152 |
|
return successResult(); |
153 |
|
} |
154 |
|
|
155 |
|
if (velocity < 0 || velocity > 127) { |
156 |
|
errMsg("note_off(): argument 2 is an invalid velocity value"); |
157 |
|
return errorResult(); |
158 |
|
} |
159 |
|
|
160 |
|
AbstractEngineChannel* pEngineChannel = |
161 |
|
static_cast<AbstractEngineChannel*>(m_vm->m_event->cause.pEngineChannel); |
162 |
|
|
163 |
|
RTList<Event>::Iterator itEvent = pEngineChannel->pEngine->EventByID(id); |
164 |
|
if (!itEvent) return successResult(); |
165 |
|
|
166 |
|
Event e = *itEvent; |
167 |
|
e.Type = Event::type_note_off; |
168 |
|
e.Param.Note.Velocity = velocity; |
169 |
|
memset(&e.Format, 0, sizeof(e.Format)); // init format speific stuff with zero |
170 |
|
|
171 |
|
int releaseEventID = pEngineChannel->ScheduleEvent(&e, 0); |
172 |
|
|
173 |
|
return successResult(); |
174 |
|
} |
175 |
|
|
176 |
} // namespace LinuxSampler |
} // namespace LinuxSampler |