/[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 2600 by schoenebeck, Sat Jun 7 00:16:03 2014 UTC revision 2629 by schoenebeck, Thu Jun 12 18:25:11 2014 UTC
# Line 57  namespace LinuxSampler { Line 57  namespace LinuxSampler {
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          e.Format = {}; // init format speific stuff with zero          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    
# Line 77  namespace LinuxSampler { Line 77  namespace LinuxSampler {
77              static_cast<AbstractEngineChannel*>(m_vm->m_event->cause.pEngineChannel);              static_cast<AbstractEngineChannel*>(m_vm->m_event->cause.pEngineChannel);
78    
79          Event e = m_vm->m_event->cause;          Event e = m_vm->m_event->cause;
80          e.Format = {}; // init format speific stuff with zero          memset(&e.Format, 0, sizeof(e.Format)); // init format speific stuff with zero
81          if (controller == CTRL_TABLE_IDX_AFTERTOUCH) {          if (controller == CTRL_TABLE_IDX_AFTERTOUCH) {
82              e.Type = Event::type_channel_pressure;              e.Type = Event::type_channel_pressure;
83              e.Param.ChannelPressure.Value = value & 127;              e.Param.ChannelPressure.Value = value & 127;
# Line 137  namespace LinuxSampler { Line 137  namespace LinuxSampler {
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

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

  ViewVC Help
Powered by ViewVC