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 |
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 |
} |
} |
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); |
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); |
605 |
|
|
606 |
return successResult(); |
return successResult(); |
607 |
} |
} |
608 |
|
|
609 |
|
#define VM_FILTER_PAR_MAX_VALUE 1000000 |
610 |
|
#define VM_EG_PAR_MAX_VALUE 1000000 |
611 |
|
|
612 |
|
// change_cutoff() function |
613 |
|
|
614 |
|
InstrumentScriptVMFunction_change_cutoff::InstrumentScriptVMFunction_change_cutoff(InstrumentScriptVM* parent) |
615 |
|
: m_vm(parent) |
616 |
|
{ |
617 |
|
} |
618 |
|
|
619 |
|
bool InstrumentScriptVMFunction_change_cutoff::acceptsArgType(int iArg, ExprType_t type) const { |
620 |
|
if (iArg == 0) |
621 |
|
return type == INT_EXPR || type == INT_ARR_EXPR; |
622 |
|
else |
623 |
|
return INT_EXPR; |
624 |
|
} |
625 |
|
|
626 |
|
VMFnResult* InstrumentScriptVMFunction_change_cutoff::exec(VMFnArgs* args) { |
627 |
|
int cutoff = args->arg(1)->asInt()->evalInt(); |
628 |
|
if (cutoff > VM_FILTER_PAR_MAX_VALUE) { |
629 |
|
wrnMsg("change_cutoff(): argument 2 may not be larger than 1000000"); |
630 |
|
cutoff = VM_FILTER_PAR_MAX_VALUE; |
631 |
|
} else if (cutoff < 0) { |
632 |
|
wrnMsg("change_cutoff(): argument 2 may not be negative"); |
633 |
|
cutoff = 0; |
634 |
|
} |
635 |
|
|
636 |
|
AbstractEngineChannel* pEngineChannel = |
637 |
|
static_cast<AbstractEngineChannel*>(m_vm->m_event->cause.pEngineChannel); |
638 |
|
|
639 |
|
if (args->arg(0)->exprType() == INT_EXPR) { |
640 |
|
const ScriptID id = args->arg(0)->asInt()->evalInt(); |
641 |
|
if (!id) { |
642 |
|
wrnMsg("change_cutoff(): note ID for argument 1 may not be zero"); |
643 |
|
return successResult(); |
644 |
|
} |
645 |
|
if (!id.isNoteID()) { |
646 |
|
wrnMsg("change_cutoff(): argument 1 is not a note ID"); |
647 |
|
return successResult(); |
648 |
|
} |
649 |
|
|
650 |
|
NoteBase* pNote = pEngineChannel->pEngine->NoteByID( id.noteID() ); |
651 |
|
if (!pNote) return successResult(); |
652 |
|
|
653 |
|
const float fCutoff = float(cutoff) / float(VM_FILTER_PAR_MAX_VALUE); |
654 |
|
|
655 |
|
Event e = m_vm->m_event->cause; // copy to get fragment time for "now" |
656 |
|
e.Init(); // clear IDs |
657 |
|
e.Type = Event::type_note_synth_param; |
658 |
|
e.Param.NoteSynthParam.NoteID = id.noteID(); |
659 |
|
e.Param.NoteSynthParam.Type = Event::synth_param_cutoff; |
660 |
|
e.Param.NoteSynthParam.Delta = fCutoff; |
661 |
|
e.Param.NoteSynthParam.Relative = false; |
662 |
|
|
663 |
|
pEngineChannel->ScheduleEventMicroSec(&e, 0); |
664 |
|
} else if (args->arg(0)->exprType() == INT_ARR_EXPR) { |
665 |
|
VMIntArrayExpr* ids = args->arg(0)->asIntArray(); |
666 |
|
for (int i = 0; i < ids->arraySize(); ++i) { |
667 |
|
const ScriptID id = ids->evalIntElement(i); |
668 |
|
if (!id || !id.isNoteID()) continue; |
669 |
|
|
670 |
|
NoteBase* pNote = pEngineChannel->pEngine->NoteByID( id.noteID() ); |
671 |
|
if (!pNote) continue; |
672 |
|
|
673 |
|
const float fCutoff = float(cutoff) / float(VM_FILTER_PAR_MAX_VALUE); |
674 |
|
|
675 |
|
Event e = m_vm->m_event->cause; // copy to get fragment time for "now" |
676 |
|
e.Init(); // clear IDs |
677 |
|
e.Type = Event::type_note_synth_param; |
678 |
|
e.Param.NoteSynthParam.NoteID = id.noteID(); |
679 |
|
e.Param.NoteSynthParam.Type = Event::synth_param_cutoff; |
680 |
|
e.Param.NoteSynthParam.Delta = fCutoff; |
681 |
|
e.Param.NoteSynthParam.Relative = false; |
682 |
|
|
683 |
|
pEngineChannel->ScheduleEventMicroSec(&e, 0); |
684 |
|
} |
685 |
|
} |
686 |
|
|
687 |
|
return successResult(); |
688 |
|
} |
689 |
|
|
690 |
|
// change_reso() function |
691 |
|
|
692 |
|
InstrumentScriptVMFunction_change_reso::InstrumentScriptVMFunction_change_reso(InstrumentScriptVM* parent) |
693 |
|
: m_vm(parent) |
694 |
|
{ |
695 |
|
} |
696 |
|
|
697 |
|
bool InstrumentScriptVMFunction_change_reso::acceptsArgType(int iArg, ExprType_t type) const { |
698 |
|
if (iArg == 0) |
699 |
|
return type == INT_EXPR || type == INT_ARR_EXPR; |
700 |
|
else |
701 |
|
return INT_EXPR; |
702 |
|
} |
703 |
|
|
704 |
|
VMFnResult* InstrumentScriptVMFunction_change_reso::exec(VMFnArgs* args) { |
705 |
|
int resonance = args->arg(1)->asInt()->evalInt(); |
706 |
|
if (resonance > VM_FILTER_PAR_MAX_VALUE) { |
707 |
|
wrnMsg("change_reso(): argument 2 may not be larger than 1000000"); |
708 |
|
resonance = VM_FILTER_PAR_MAX_VALUE; |
709 |
|
} else if (resonance < 0) { |
710 |
|
wrnMsg("change_reso(): argument 2 may not be negative"); |
711 |
|
resonance = 0; |
712 |
|
} |
713 |
|
|
714 |
|
AbstractEngineChannel* pEngineChannel = |
715 |
|
static_cast<AbstractEngineChannel*>(m_vm->m_event->cause.pEngineChannel); |
716 |
|
|
717 |
|
if (args->arg(0)->exprType() == INT_EXPR) { |
718 |
|
const ScriptID id = args->arg(0)->asInt()->evalInt(); |
719 |
|
if (!id) { |
720 |
|
wrnMsg("change_reso(): note ID for argument 1 may not be zero"); |
721 |
|
return successResult(); |
722 |
|
} |
723 |
|
if (!id.isNoteID()) { |
724 |
|
wrnMsg("change_reso(): argument 1 is not a note ID"); |
725 |
|
return successResult(); |
726 |
|
} |
727 |
|
|
728 |
|
NoteBase* pNote = pEngineChannel->pEngine->NoteByID( id.noteID() ); |
729 |
|
if (!pNote) return successResult(); |
730 |
|
|
731 |
|
const float fResonance = float(resonance) / float(VM_FILTER_PAR_MAX_VALUE); |
732 |
|
|
733 |
|
Event e = m_vm->m_event->cause; // copy to get fragment time for "now" |
734 |
|
e.Init(); // clear IDs |
735 |
|
e.Type = Event::type_note_synth_param; |
736 |
|
e.Param.NoteSynthParam.NoteID = id.noteID(); |
737 |
|
e.Param.NoteSynthParam.Type = Event::synth_param_resonance; |
738 |
|
e.Param.NoteSynthParam.Delta = fResonance; |
739 |
|
e.Param.NoteSynthParam.Relative = false; |
740 |
|
|
741 |
|
pEngineChannel->ScheduleEventMicroSec(&e, 0); |
742 |
|
} else if (args->arg(0)->exprType() == INT_ARR_EXPR) { |
743 |
|
VMIntArrayExpr* ids = args->arg(0)->asIntArray(); |
744 |
|
for (int i = 0; i < ids->arraySize(); ++i) { |
745 |
|
const ScriptID id = ids->evalIntElement(i); |
746 |
|
if (!id || !id.isNoteID()) continue; |
747 |
|
|
748 |
|
NoteBase* pNote = pEngineChannel->pEngine->NoteByID( id.noteID() ); |
749 |
|
if (!pNote) continue; |
750 |
|
|
751 |
|
const float fResonance = float(resonance) / float(VM_FILTER_PAR_MAX_VALUE); |
752 |
|
|
753 |
|
Event e = m_vm->m_event->cause; // copy to get fragment time for "now" |
754 |
|
e.Init(); // clear IDs |
755 |
|
e.Type = Event::type_note_synth_param; |
756 |
|
e.Param.NoteSynthParam.NoteID = id.noteID(); |
757 |
|
e.Param.NoteSynthParam.Type = Event::synth_param_resonance; |
758 |
|
e.Param.NoteSynthParam.Delta = fResonance; |
759 |
|
e.Param.NoteSynthParam.Relative = false; |
760 |
|
|
761 |
|
pEngineChannel->ScheduleEventMicroSec(&e, 0); |
762 |
|
} |
763 |
|
} |
764 |
|
|
765 |
|
return successResult(); |
766 |
|
} |
767 |
|
|
768 |
|
// change_attack() function |
769 |
|
|
770 |
|
InstrumentScriptVMFunction_change_attack::InstrumentScriptVMFunction_change_attack(InstrumentScriptVM* parent) |
771 |
|
: m_vm(parent) |
772 |
|
{ |
773 |
|
} |
774 |
|
|
775 |
|
bool InstrumentScriptVMFunction_change_attack::acceptsArgType(int iArg, ExprType_t type) const { |
776 |
|
if (iArg == 0) |
777 |
|
return type == INT_EXPR || type == INT_ARR_EXPR; |
778 |
|
else |
779 |
|
return INT_EXPR; |
780 |
|
} |
781 |
|
|
782 |
|
VMFnResult* InstrumentScriptVMFunction_change_attack::exec(VMFnArgs* args) { |
783 |
|
int attack = args->arg(1)->asInt()->evalInt(); |
784 |
|
if (attack > VM_EG_PAR_MAX_VALUE) { |
785 |
|
wrnMsg("change_attack(): argument 2 may not be larger than 1000000"); |
786 |
|
attack = VM_EG_PAR_MAX_VALUE; |
787 |
|
} else if (attack < 0) { |
788 |
|
wrnMsg("change_attack(): argument 2 may not be negative"); |
789 |
|
attack = 0; |
790 |
|
} |
791 |
|
const float fAttack = float(attack) / float(VM_EG_PAR_MAX_VALUE); |
792 |
|
|
793 |
|
AbstractEngineChannel* pEngineChannel = |
794 |
|
static_cast<AbstractEngineChannel*>(m_vm->m_event->cause.pEngineChannel); |
795 |
|
|
796 |
|
if (args->arg(0)->exprType() == INT_EXPR) { |
797 |
|
const ScriptID id = args->arg(0)->asInt()->evalInt(); |
798 |
|
if (!id) { |
799 |
|
wrnMsg("change_attack(): note ID for argument 1 may not be zero"); |
800 |
|
return successResult(); |
801 |
|
} |
802 |
|
if (!id.isNoteID()) { |
803 |
|
wrnMsg("change_attack(): argument 1 is not a note ID"); |
804 |
|
return successResult(); |
805 |
|
} |
806 |
|
|
807 |
|
NoteBase* pNote = pEngineChannel->pEngine->NoteByID( id.noteID() ); |
808 |
|
if (!pNote) return successResult(); |
809 |
|
|
810 |
|
Event e = m_vm->m_event->cause; // copy to get fragment time for "now" |
811 |
|
e.Init(); // clear IDs |
812 |
|
e.Type = Event::type_note_synth_param; |
813 |
|
e.Param.NoteSynthParam.NoteID = id.noteID(); |
814 |
|
e.Param.NoteSynthParam.Type = Event::synth_param_attack; |
815 |
|
e.Param.NoteSynthParam.Delta = fAttack; |
816 |
|
e.Param.NoteSynthParam.Relative = false; |
817 |
|
|
818 |
|
pEngineChannel->ScheduleEventMicroSec(&e, 0); |
819 |
|
} else if (args->arg(0)->exprType() == INT_ARR_EXPR) { |
820 |
|
VMIntArrayExpr* ids = args->arg(0)->asIntArray(); |
821 |
|
for (int i = 0; i < ids->arraySize(); ++i) { |
822 |
|
const ScriptID id = ids->evalIntElement(i); |
823 |
|
if (!id || !id.isNoteID()) continue; |
824 |
|
|
825 |
|
NoteBase* pNote = pEngineChannel->pEngine->NoteByID( id.noteID() ); |
826 |
|
if (!pNote) continue; |
827 |
|
|
828 |
|
Event e = m_vm->m_event->cause; // copy to get fragment time for "now" |
829 |
|
e.Init(); // clear IDs |
830 |
|
e.Type = Event::type_note_synth_param; |
831 |
|
e.Param.NoteSynthParam.NoteID = id.noteID(); |
832 |
|
e.Param.NoteSynthParam.Type = Event::synth_param_attack; |
833 |
|
e.Param.NoteSynthParam.Delta = fAttack; |
834 |
|
e.Param.NoteSynthParam.Relative = false; |
835 |
|
|
836 |
|
pEngineChannel->ScheduleEventMicroSec(&e, 0); |
837 |
|
} |
838 |
|
} |
839 |
|
|
840 |
|
return successResult(); |
841 |
|
} |
842 |
|
|
843 |
|
// change_decay() function |
844 |
|
|
845 |
|
InstrumentScriptVMFunction_change_decay::InstrumentScriptVMFunction_change_decay(InstrumentScriptVM* parent) |
846 |
|
: m_vm(parent) |
847 |
|
{ |
848 |
|
} |
849 |
|
|
850 |
|
bool InstrumentScriptVMFunction_change_decay::acceptsArgType(int iArg, ExprType_t type) const { |
851 |
|
if (iArg == 0) |
852 |
|
return type == INT_EXPR || type == INT_ARR_EXPR; |
853 |
|
else |
854 |
|
return INT_EXPR; |
855 |
|
} |
856 |
|
|
857 |
|
VMFnResult* InstrumentScriptVMFunction_change_decay::exec(VMFnArgs* args) { |
858 |
|
int decay = args->arg(1)->asInt()->evalInt(); |
859 |
|
if (decay > VM_EG_PAR_MAX_VALUE) { |
860 |
|
wrnMsg("change_decay(): argument 2 may not be larger than 1000000"); |
861 |
|
decay = VM_EG_PAR_MAX_VALUE; |
862 |
|
} else if (decay < 0) { |
863 |
|
wrnMsg("change_decay(): argument 2 may not be negative"); |
864 |
|
decay = 0; |
865 |
|
} |
866 |
|
const float fDecay = float(decay) / float(VM_EG_PAR_MAX_VALUE); |
867 |
|
|
868 |
|
AbstractEngineChannel* pEngineChannel = |
869 |
|
static_cast<AbstractEngineChannel*>(m_vm->m_event->cause.pEngineChannel); |
870 |
|
|
871 |
|
if (args->arg(0)->exprType() == INT_EXPR) { |
872 |
|
const ScriptID id = args->arg(0)->asInt()->evalInt(); |
873 |
|
if (!id) { |
874 |
|
wrnMsg("change_decay(): note ID for argument 1 may not be zero"); |
875 |
|
return successResult(); |
876 |
|
} |
877 |
|
if (!id.isNoteID()) { |
878 |
|
wrnMsg("change_decay(): argument 1 is not a note ID"); |
879 |
|
return successResult(); |
880 |
|
} |
881 |
|
|
882 |
|
NoteBase* pNote = pEngineChannel->pEngine->NoteByID( id.noteID() ); |
883 |
|
if (!pNote) return successResult(); |
884 |
|
|
885 |
|
Event e = m_vm->m_event->cause; // copy to get fragment time for "now" |
886 |
|
e.Init(); // clear IDs |
887 |
|
e.Type = Event::type_note_synth_param; |
888 |
|
e.Param.NoteSynthParam.NoteID = id.noteID(); |
889 |
|
e.Param.NoteSynthParam.Type = Event::synth_param_decay; |
890 |
|
e.Param.NoteSynthParam.Delta = fDecay; |
891 |
|
e.Param.NoteSynthParam.Relative = false; |
892 |
|
|
893 |
|
pEngineChannel->ScheduleEventMicroSec(&e, 0); |
894 |
|
} else if (args->arg(0)->exprType() == INT_ARR_EXPR) { |
895 |
|
VMIntArrayExpr* ids = args->arg(0)->asIntArray(); |
896 |
|
for (int i = 0; i < ids->arraySize(); ++i) { |
897 |
|
const ScriptID id = ids->evalIntElement(i); |
898 |
|
if (!id || !id.isNoteID()) continue; |
899 |
|
|
900 |
|
NoteBase* pNote = pEngineChannel->pEngine->NoteByID( id.noteID() ); |
901 |
|
if (!pNote) continue; |
902 |
|
|
903 |
|
Event e = m_vm->m_event->cause; // copy to get fragment time for "now" |
904 |
|
e.Init(); // clear IDs |
905 |
|
e.Type = Event::type_note_synth_param; |
906 |
|
e.Param.NoteSynthParam.NoteID = id.noteID(); |
907 |
|
e.Param.NoteSynthParam.Type = Event::synth_param_decay; |
908 |
|
e.Param.NoteSynthParam.Delta = fDecay; |
909 |
|
e.Param.NoteSynthParam.Relative = false; |
910 |
|
|
911 |
|
pEngineChannel->ScheduleEventMicroSec(&e, 0); |
912 |
|
} |
913 |
|
} |
914 |
|
|
915 |
|
return successResult(); |
916 |
|
} |
917 |
|
|
918 |
|
// change_release() function |
919 |
|
|
920 |
|
InstrumentScriptVMFunction_change_release::InstrumentScriptVMFunction_change_release(InstrumentScriptVM* parent) |
921 |
|
: m_vm(parent) |
922 |
|
{ |
923 |
|
} |
924 |
|
|
925 |
|
bool InstrumentScriptVMFunction_change_release::acceptsArgType(int iArg, ExprType_t type) const { |
926 |
|
if (iArg == 0) |
927 |
|
return type == INT_EXPR || type == INT_ARR_EXPR; |
928 |
|
else |
929 |
|
return INT_EXPR; |
930 |
|
} |
931 |
|
|
932 |
|
VMFnResult* InstrumentScriptVMFunction_change_release::exec(VMFnArgs* args) { |
933 |
|
int release = args->arg(1)->asInt()->evalInt(); |
934 |
|
if (release > VM_EG_PAR_MAX_VALUE) { |
935 |
|
wrnMsg("change_release(): argument 2 may not be larger than 1000000"); |
936 |
|
release = VM_EG_PAR_MAX_VALUE; |
937 |
|
} else if (release < 0) { |
938 |
|
wrnMsg("change_release(): argument 2 may not be negative"); |
939 |
|
release = 0; |
940 |
|
} |
941 |
|
const float fRelease = float(release) / float(VM_EG_PAR_MAX_VALUE); |
942 |
|
|
943 |
|
AbstractEngineChannel* pEngineChannel = |
944 |
|
static_cast<AbstractEngineChannel*>(m_vm->m_event->cause.pEngineChannel); |
945 |
|
|
946 |
|
if (args->arg(0)->exprType() == INT_EXPR) { |
947 |
|
const ScriptID id = args->arg(0)->asInt()->evalInt(); |
948 |
|
if (!id) { |
949 |
|
wrnMsg("change_release(): note ID for argument 1 may not be zero"); |
950 |
|
return successResult(); |
951 |
|
} |
952 |
|
if (!id.isNoteID()) { |
953 |
|
wrnMsg("change_release(): argument 1 is not a note ID"); |
954 |
|
return successResult(); |
955 |
|
} |
956 |
|
|
957 |
|
NoteBase* pNote = pEngineChannel->pEngine->NoteByID( id.noteID() ); |
958 |
|
if (!pNote) return successResult(); |
959 |
|
|
960 |
|
Event e = m_vm->m_event->cause; // copy to get fragment time for "now" |
961 |
|
e.Init(); // clear IDs |
962 |
|
e.Type = Event::type_note_synth_param; |
963 |
|
e.Param.NoteSynthParam.NoteID = id.noteID(); |
964 |
|
e.Param.NoteSynthParam.Type = Event::synth_param_release; |
965 |
|
e.Param.NoteSynthParam.Delta = fRelease; |
966 |
|
e.Param.NoteSynthParam.Relative = false; |
967 |
|
|
968 |
|
pEngineChannel->ScheduleEventMicroSec(&e, 0); |
969 |
|
} else if (args->arg(0)->exprType() == INT_ARR_EXPR) { |
970 |
|
VMIntArrayExpr* ids = args->arg(0)->asIntArray(); |
971 |
|
for (int i = 0; i < ids->arraySize(); ++i) { |
972 |
|
const ScriptID id = ids->evalIntElement(i); |
973 |
|
if (!id || !id.isNoteID()) continue; |
974 |
|
|
975 |
|
NoteBase* pNote = pEngineChannel->pEngine->NoteByID( id.noteID() ); |
976 |
|
if (!pNote) continue; |
977 |
|
|
978 |
|
Event e = m_vm->m_event->cause; // copy to get fragment time for "now" |
979 |
|
e.Init(); // clear IDs |
980 |
|
e.Type = Event::type_note_synth_param; |
981 |
|
e.Param.NoteSynthParam.NoteID = id.noteID(); |
982 |
|
e.Param.NoteSynthParam.Type = Event::synth_param_release; |
983 |
|
e.Param.NoteSynthParam.Delta = fRelease; |
984 |
|
e.Param.NoteSynthParam.Relative = false; |
985 |
|
|
986 |
|
pEngineChannel->ScheduleEventMicroSec(&e, 0); |
987 |
|
} |
988 |
|
} |
989 |
|
|
990 |
|
return successResult(); |
991 |
|
} |
992 |
|
|
993 |
|
// event_status() function |
994 |
|
|
995 |
|
InstrumentScriptVMFunction_event_status::InstrumentScriptVMFunction_event_status(InstrumentScriptVM* parent) |
996 |
|
: m_vm(parent) |
997 |
|
{ |
998 |
|
} |
999 |
|
|
1000 |
|
VMFnResult* InstrumentScriptVMFunction_event_status::exec(VMFnArgs* args) { |
1001 |
|
AbstractEngineChannel* pEngineChannel = |
1002 |
|
static_cast<AbstractEngineChannel*>(m_vm->m_event->cause.pEngineChannel); |
1003 |
|
|
1004 |
|
const ScriptID id = args->arg(0)->asInt()->evalInt(); |
1005 |
|
if (!id) { |
1006 |
|
wrnMsg("event_status(): note ID for argument 1 may not be zero"); |
1007 |
|
return successResult(EVENT_STATUS_INACTIVE); |
1008 |
|
} |
1009 |
|
if (!id.isNoteID()) { |
1010 |
|
wrnMsg("event_status(): argument 1 is not a note ID"); |
1011 |
|
return successResult(EVENT_STATUS_INACTIVE); |
1012 |
|
} |
1013 |
|
|
1014 |
|
NoteBase* pNote = pEngineChannel->pEngine->NoteByID( id.noteID() ); |
1015 |
|
return successResult(pNote ? EVENT_STATUS_NOTE_QUEUE : EVENT_STATUS_INACTIVE); |
1016 |
|
} |
1017 |
|
|
1018 |
|
// wait() function (overrides core wait() implementation) |
1019 |
|
|
1020 |
|
InstrumentScriptVMFunction_wait::InstrumentScriptVMFunction_wait(InstrumentScriptVM* parent) |
1021 |
|
: CoreVMFunction_wait(parent) |
1022 |
|
{ |
1023 |
|
} |
1024 |
|
|
1025 |
|
VMFnResult* InstrumentScriptVMFunction_wait::exec(VMFnArgs* args) { |
1026 |
|
InstrumentScriptVM* m_vm = (InstrumentScriptVM*) vm; |
1027 |
|
|
1028 |
|
// this might be set by passing 1 with the 2nd argument of built-in stop_wait() function |
1029 |
|
if (m_vm->m_event->ignoreAllWaitCalls) return successResult(); |
1030 |
|
|
1031 |
|
return CoreVMFunction_wait::exec(args); |
1032 |
|
} |
1033 |
|
|
1034 |
|
// stop_wait() function |
1035 |
|
|
1036 |
|
InstrumentScriptVMFunction_stop_wait::InstrumentScriptVMFunction_stop_wait(InstrumentScriptVM* parent) |
1037 |
|
: m_vm(parent) |
1038 |
|
{ |
1039 |
|
} |
1040 |
|
|
1041 |
|
VMFnResult* InstrumentScriptVMFunction_stop_wait::exec(VMFnArgs* args) { |
1042 |
|
AbstractEngineChannel* pEngineChannel = |
1043 |
|
static_cast<AbstractEngineChannel*>(m_vm->m_event->cause.pEngineChannel); |
1044 |
|
|
1045 |
|
const script_callback_id_t id = args->arg(0)->asInt()->evalInt(); |
1046 |
|
if (!id) { |
1047 |
|
wrnMsg("stop_wait(): callback ID for argument 1 may not be zero"); |
1048 |
|
return successResult(); |
1049 |
|
} |
1050 |
|
|
1051 |
|
RTList<ScriptEvent>::Iterator itCallback = pEngineChannel->ScriptCallbackByID(id); |
1052 |
|
if (!itCallback) return successResult(); // ignore if callback is i.e. not alive anymore |
1053 |
|
|
1054 |
|
const bool disableWaitForever = |
1055 |
|
(args->argsCount() >= 2) ? (args->arg(1)->asInt()->evalInt() == 1) : false; |
1056 |
|
|
1057 |
|
pEngineChannel->ScheduleResumeOfScriptCallback( |
1058 |
|
itCallback, m_vm->m_event->cause.SchedTime(), disableWaitForever |
1059 |
|
); |
1060 |
|
|
1061 |
|
return successResult(); |
1062 |
|
} |
1063 |
|
|
1064 |
} // namespace LinuxSampler |
} // namespace LinuxSampler |