/[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 3246 by schoenebeck, Sun May 28 22:22:56 2017 UTC revision 3251 by schoenebeck, Mon May 29 22:19:19 2017 UTC
# Line 23  namespace LinuxSampler { Line 23  namespace LinuxSampler {
23      VMFnResult* InstrumentScriptVMFunction_play_note::exec(VMFnArgs* args) {      VMFnResult* InstrumentScriptVMFunction_play_note::exec(VMFnArgs* args) {
24          int note = args->arg(0)->asInt()->evalInt();          int note = args->arg(0)->asInt()->evalInt();
25          int velocity = (args->argsCount() >= 2) ? args->arg(1)->asInt()->evalInt() : 127;          int velocity = (args->argsCount() >= 2) ? args->arg(1)->asInt()->evalInt() : 127;
         int sampleoffset = (args->argsCount() >= 3) ? args->arg(2)->asInt()->evalInt() : 0;  
26          int duration = (args->argsCount() >= 4) ? args->arg(3)->asInt()->evalInt() : 0; //TODO: -1 might be a better default value instead of 0          int duration = (args->argsCount() >= 4) ? args->arg(3)->asInt()->evalInt() : 0; //TODO: -1 might be a better default value instead of 0
27    
28          if (note < 0 || note > 127) {          if (note < 0 || note > 127) {
# Line 36  namespace LinuxSampler { Line 35  namespace LinuxSampler {
35              return errorResult(0);              return errorResult(0);
36          }          }
37    
         if (sampleoffset < 0) {  
             errMsg("play_note(): argument 3 may not be a negative sample offset");  
             return errorResult(0);  
         } else if (sampleoffset != 0) {  
             wrnMsg("play_note(): argument 3 does not support a sample offset other than 0 yet");  
         }  
   
38          if (duration < -1) {          if (duration < -1) {
39              errMsg("play_note(): argument 4 must be a duration value of at least -1 or higher");              errMsg("play_note(): argument 4 must be a duration value of at least -1 or higher");
40              return errorResult(0);              return errorResult(0);
# Line 67  namespace LinuxSampler { Line 59  namespace LinuxSampler {
59    
60          const note_id_t id = pEngineChannel->ScheduleNoteMicroSec(&e, 0);          const note_id_t id = pEngineChannel->ScheduleNoteMicroSec(&e, 0);
61    
62            // if a sample offset is supplied, assign the offset as override
63            // to the previously created Note object
64            if (args->argsCount() >= 3) {
65                int sampleoffset = args->arg(2)->asInt()->evalInt();
66                if (sampleoffset >= 0) {
67                    NoteBase* pNote = pEngineChannel->pEngine->NoteByID(id);
68                    if (pNote) {
69                        pNote->Override.SampleOffset = sampleoffset;
70                    }
71                } else if (sampleoffset < -1) {
72                    errMsg("play_note(): sample offset of argument 3 may not be less than -1");
73                }
74            }
75    
76          // if a duration is supplied (and play-note event was scheduled          // if a duration is supplied (and play-note event was scheduled
77          // successfully above), then schedule a subsequent stop-note event          // successfully above), then schedule a subsequent stop-note event
78          if (id && duration > 0) {          if (id && duration > 0) {

Legend:
Removed from v.3246  
changed lines
  Added in v.3251

  ViewVC Help
Powered by ViewVC