10 |
#include "CoreVMFunctions.h" |
#include "CoreVMFunctions.h" |
11 |
|
|
12 |
#include <iostream> |
#include <iostream> |
13 |
|
#include <math.h> |
14 |
|
#include <stdlib.h> |
15 |
#include "tree.h" |
#include "tree.h" |
16 |
#include "ScriptVM.h" |
#include "ScriptVM.h" |
17 |
|
|
86 |
return &result; |
return &result; |
87 |
} |
} |
88 |
|
|
89 |
|
bool CoreVMFunction_abs::acceptsArgType(int iArg, ExprType_t type) const { |
90 |
|
return type == INT_EXPR; |
91 |
|
} |
92 |
|
|
93 |
|
VMFnResult* CoreVMFunction_abs::exec(VMFnArgs* args) { |
94 |
|
return successResult( ::abs(args->arg(0)->asInt()->evalInt()) ); |
95 |
|
} |
96 |
|
|
97 |
|
bool CoreVMFunction_random::acceptsArgType(int iArg, ExprType_t type) const { |
98 |
|
return type == INT_EXPR; |
99 |
|
} |
100 |
|
|
101 |
|
VMFnResult* CoreVMFunction_random::exec(VMFnArgs* args) { |
102 |
|
int iMin = args->arg(0)->asInt()->evalInt(); |
103 |
|
int iMax = args->arg(1)->asInt()->evalInt(); |
104 |
|
float f = float(::random()) / float(RAND_MAX); |
105 |
|
return successResult( |
106 |
|
iMin + roundf( f * float(iMax - iMin) ) |
107 |
|
); |
108 |
|
} |
109 |
|
|
110 |
|
bool CoreVMFunction_num_elements::acceptsArgType(int iArg, ExprType_t type) const { |
111 |
|
return type == INT_ARR_EXPR; |
112 |
|
} |
113 |
|
|
114 |
|
VMFnResult* CoreVMFunction_num_elements::exec(VMFnArgs* args) { |
115 |
|
return successResult( args->arg(0)->asIntArray()->arraySize() ); |
116 |
|
} |
117 |
|
|
118 |
} // namespace LinuxSampler |
} // namespace LinuxSampler |