/[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 3212 by schoenebeck, Thu May 25 13:17:47 2017 UTC revision 3214 by schoenebeck, Thu May 25 14:46:47 2017 UTC
# Line 1555  namespace LinuxSampler { Line 1555  namespace LinuxSampler {
1555                      wrnMsg("set_event_par(): note number of argument 3 is out of range");                      wrnMsg("set_event_par(): note number of argument 3 is out of range");
1556                      return successResult();                      return successResult();
1557                  }                  }
1558                  if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime)                  if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) {
1559                      pNote->cause.Param.Note.Key = value;                      pNote->cause.Param.Note.Key = value;
1560                  else                      m_vm->m_event->cause.Param.Note.Key = value;
1561                    } else {
1562                      wrnMsg("set_event_par(): note number can only be changed when note is new");                      wrnMsg("set_event_par(): note number can only be changed when note is new");
1563                    }
1564                  return successResult();                  return successResult();
1565              case EVENT_PAR_VELOCITY:              case EVENT_PAR_VELOCITY:
1566                  if (value < 0 || value > 127) {                  if (value < 0 || value > 127) {
1567                      wrnMsg("set_event_par(): velocity of argument 3 is out of range");                      wrnMsg("set_event_par(): velocity of argument 3 is out of range");
1568                      return successResult();                      return successResult();
1569                  }                  }
1570                  if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime)                  if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) {
1571                      pNote->cause.Param.Note.Velocity = value;                      pNote->cause.Param.Note.Velocity = value;
1572                  else                      m_vm->m_event->cause.Param.Note.Velocity = value;
1573                    } else {
1574                      wrnMsg("set_event_par(): velocity can only be changed when note is new");                      wrnMsg("set_event_par(): velocity can only be changed when note is new");
1575                    }
1576                  return successResult();                  return successResult();
1577              case EVENT_PAR_VOLUME:              case EVENT_PAR_VOLUME:
1578                  wrnMsg("set_event_par(): changing volume by this function is currently not supported, use change_vol() instead");                  wrnMsg("set_event_par(): changing volume by this function is currently not supported, use change_vol() instead");
# Line 1594  namespace LinuxSampler { Line 1598  namespace LinuxSampler {
1598          return successResult();          return successResult();
1599      }      }
1600    
1601        // change_note() function
1602    
1603        InstrumentScriptVMFunction_change_note::InstrumentScriptVMFunction_change_note(InstrumentScriptVM* parent)
1604        : m_vm(parent)
1605        {
1606        }
1607    
1608        VMFnResult* InstrumentScriptVMFunction_change_note::exec(VMFnArgs* args) {
1609            AbstractEngineChannel* pEngineChannel =
1610                static_cast<AbstractEngineChannel*>(m_vm->m_event->cause.pEngineChannel);
1611    
1612            const ScriptID id = args->arg(0)->asInt()->evalInt();
1613            if (!id) {
1614                wrnMsg("change_note(): note ID for argument 1 may not be zero");
1615                return successResult();
1616            }
1617            if (!id.isNoteID()) {
1618                wrnMsg("change_note(): argument 1 is not a note ID");
1619                return successResult();
1620            }
1621    
1622            NoteBase* pNote = pEngineChannel->pEngine->NoteByID( id.noteID() );
1623            if (!pNote) return successResult();
1624    
1625            const int value = args->arg(1)->asInt()->evalInt();
1626            if (value < 0 || value > 127) {
1627                wrnMsg("change_note(): note number of argument 2 is out of range");
1628                return successResult();
1629            }
1630    
1631            if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) {
1632                pNote->cause.Param.Note.Key = value;
1633                m_vm->m_event->cause.Param.Note.Key = value;
1634            } else {
1635                wrnMsg("change_note(): note number can only be changed when note is new");
1636            }
1637    
1638            return successResult();
1639        }
1640    
1641        // change_velo() function
1642    
1643        InstrumentScriptVMFunction_change_velo::InstrumentScriptVMFunction_change_velo(InstrumentScriptVM* parent)
1644        : m_vm(parent)
1645        {
1646        }
1647    
1648        VMFnResult* InstrumentScriptVMFunction_change_velo::exec(VMFnArgs* args) {
1649            AbstractEngineChannel* pEngineChannel =
1650                static_cast<AbstractEngineChannel*>(m_vm->m_event->cause.pEngineChannel);
1651    
1652            const ScriptID id = args->arg(0)->asInt()->evalInt();
1653            if (!id) {
1654                wrnMsg("change_velo(): note ID for argument 1 may not be zero");
1655                return successResult();
1656            }
1657            if (!id.isNoteID()) {
1658                wrnMsg("change_velo(): argument 1 is not a note ID");
1659                return successResult();
1660            }
1661    
1662            NoteBase* pNote = pEngineChannel->pEngine->NoteByID( id.noteID() );
1663            if (!pNote) return successResult();
1664    
1665            const int value = args->arg(1)->asInt()->evalInt();
1666            if (value < 0 || value > 127) {
1667                wrnMsg("change_velo(): velocity of argument 2 is out of range");
1668                return successResult();
1669            }
1670    
1671            if (m_vm->m_event->scheduleTime == pNote->triggerSchedTime) {
1672                pNote->cause.Param.Note.Velocity = value;
1673                m_vm->m_event->cause.Param.Note.Velocity = value;
1674            } else {
1675                wrnMsg("change_velo(): velocity can only be changed when note is new");
1676            }
1677    
1678            return successResult();
1679        }
1680    
1681      // event_status() function      // event_status() function
1682    
1683      InstrumentScriptVMFunction_event_status::InstrumentScriptVMFunction_event_status(InstrumentScriptVM* parent)      InstrumentScriptVMFunction_event_status::InstrumentScriptVMFunction_event_status(InstrumentScriptVM* parent)

Legend:
Removed from v.3212  
changed lines
  Added in v.3214

  ViewVC Help
Powered by ViewVC