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

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

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

revision 2628 by persson, Sun Jun 8 05:42:56 2014 UTC revision 2629 by schoenebeck, Thu Jun 12 18:25:11 2014 UTC
# Line 138  namespace LinuxSampler { Line 138  namespace LinuxSampler {
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

Legend:
Removed from v.2628  
changed lines
  Added in v.2629

  ViewVC Help
Powered by ViewVC