/[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 2935 by schoenebeck, Sun Jul 10 14:24:13 2016 UTC revision 2948 by schoenebeck, Fri Jul 15 15:29:04 2016 UTC
# Line 53  namespace LinuxSampler { Line 53  namespace LinuxSampler {
53    
54          Event e = m_vm->m_event->cause; // copy to get fragment time for "now"          Event e = m_vm->m_event->cause; // copy to get fragment time for "now"
55          e.Init(); // clear IDs          e.Init(); // clear IDs
56          e.Type = Event::type_note_on;          e.Type = Event::type_play_note;
57          e.Param.Note.Key = note;          e.Param.Note.Key = note;
58          e.Param.Note.Velocity = velocity;          e.Param.Note.Velocity = velocity;
59          // make this new note dependent to the life time of the original note          // make this new note dependent to the life time of the original note
# Line 67  namespace LinuxSampler { Line 67  namespace LinuxSampler {
67    
68          const note_id_t id = pEngineChannel->ScheduleNoteMicroSec(&e, 0);          const note_id_t id = pEngineChannel->ScheduleNoteMicroSec(&e, 0);
69    
70          // if a duration is supplied (and note-on event was scheduled          // if a duration is supplied (and play-note event was scheduled
71          // successfully above), then schedule a subsequent note-off event          // successfully above), then schedule a subsequent stop-note event
72          if (id && duration > 0) {          if (id && duration > 0) {
73              e.Type = Event::type_note_off;              e.Type = Event::type_stop_note;
74                e.Param.Note.ID = id;
75              e.Param.Note.Velocity = 127;              e.Param.Note.Velocity = 127;
76              pEngineChannel->ScheduleEventMicroSec(&e, duration);              pEngineChannel->ScheduleEventMicroSec(&e, duration);
77          }          }
# Line 214  namespace LinuxSampler { Line 215  namespace LinuxSampler {
215              Event e = pNote->cause;              Event e = pNote->cause;
216              e.Init(); // clear IDs              e.Init(); // clear IDs
217              e.CopyTimeFrom(m_vm->m_event->cause); // set fragment time for "now"              e.CopyTimeFrom(m_vm->m_event->cause); // set fragment time for "now"
218              e.Type = Event::type_note_off;              e.Type = Event::type_stop_note;
219                e.Param.Note.ID = id.noteID();
220                e.Param.Note.Key = pNote->hostKey;
221              e.Param.Note.Velocity = velocity;              e.Param.Note.Velocity = velocity;
222    
223              pEngineChannel->ScheduleEventMicroSec(&e, 0);              pEngineChannel->ScheduleEventMicroSec(&e, 0);
# Line 230  namespace LinuxSampler { Line 233  namespace LinuxSampler {
233                  Event e = pNote->cause;                  Event e = pNote->cause;
234                  e.Init(); // clear IDs                  e.Init(); // clear IDs
235                  e.CopyTimeFrom(m_vm->m_event->cause); // set fragment time for "now"                  e.CopyTimeFrom(m_vm->m_event->cause); // set fragment time for "now"
236                  e.Type = Event::type_note_off;                  e.Type = Event::type_stop_note;
237                    e.Param.Note.ID = id.noteID();
238                    e.Param.Note.Key = pNote->hostKey;
239                  e.Param.Note.Velocity = velocity;                  e.Param.Note.Velocity = velocity;
240    
241                  pEngineChannel->ScheduleEventMicroSec(&e, 0);                  pEngineChannel->ScheduleEventMicroSec(&e, 0);
# Line 784  namespace LinuxSampler { Line 789  namespace LinuxSampler {
789          return successResult(pNote ? EVENT_STATUS_NOTE_QUEUE : EVENT_STATUS_INACTIVE);          return successResult(pNote ? EVENT_STATUS_NOTE_QUEUE : EVENT_STATUS_INACTIVE);
790      }      }
791    
792        // wait() function (overrides core wait() implementation)
793    
794        InstrumentScriptVMFunction_wait::InstrumentScriptVMFunction_wait(InstrumentScriptVM* parent)
795            : CoreVMFunction_wait(parent)
796        {    
797        }
798    
799        VMFnResult* InstrumentScriptVMFunction_wait::exec(VMFnArgs* args) {
800            InstrumentScriptVM* m_vm = (InstrumentScriptVM*) vm;
801    
802            // this might be set by passing 1 with the 2nd argument of built-in stop_wait() function
803            if (m_vm->m_event->ignoreAllWaitCalls) return successResult();
804    
805            return CoreVMFunction_wait::exec(args);
806        }
807    
808        // stop_wait() function
809    
810        InstrumentScriptVMFunction_stop_wait::InstrumentScriptVMFunction_stop_wait(InstrumentScriptVM* parent)
811            : m_vm(parent)
812        {    
813        }
814    
815        VMFnResult* InstrumentScriptVMFunction_stop_wait::exec(VMFnArgs* args) {
816            AbstractEngineChannel* pEngineChannel =
817                static_cast<AbstractEngineChannel*>(m_vm->m_event->cause.pEngineChannel);
818    
819            const script_callback_id_t id = args->arg(0)->asInt()->evalInt();
820            if (!id) {
821                wrnMsg("stop_wait(): callback ID for argument 1 may not be zero");
822                return successResult();
823            }
824    
825            RTList<ScriptEvent>::Iterator itCallback = pEngineChannel->ScriptCallbackByID(id);
826            if (!itCallback) return successResult(); // ignore if callback is i.e. not alive anymore
827    
828            const bool disableWaitForever =
829                (args->argsCount() >= 2) ? (args->arg(1)->asInt()->evalInt() == 1) : false;
830    
831            pEngineChannel->ScheduleResumeOfScriptCallback(
832                itCallback, m_vm->m_event->cause.SchedTime(), disableWaitForever
833            );
834    
835            return successResult();
836        }
837    
838  } // namespace LinuxSampler  } // namespace LinuxSampler

Legend:
Removed from v.2935  
changed lines
  Added in v.2948

  ViewVC Help
Powered by ViewVC