| 5030 | } |
| 5031 | |
| 5032 | var ScriptingObjects::ScriptNeuralNetwork::process(var input) |
| 5033 | { |
| 5034 | #if HISE_INCLUDE_RT_NEURAL |
| 5035 | auto isSingleOut = nn->getNumOutputs() == 1; |
| 5036 | auto isSingleIn = nn->getNumInputs() == 1; |
| 5037 | |
| 5038 | if(isSingleOut) |
| 5039 | { |
| 5040 | float out = 0.0f; |
| 5041 | |
| 5042 | if(isSingleIn) |
| 5043 | { |
| 5044 | float in = (float)input; |
| 5045 | nn->process(0, &in, &out); |
| 5046 | } |
| 5047 | else if (input.isArray()) |
| 5048 | { |
| 5049 | if(isPositiveAndBelow(inputBuffer->size, input.size())) |
| 5050 | { |
| 5051 | int idx = 0; |
| 5052 | for(const auto& v: *input.getArray()) |
| 5053 | inputBuffer->setSample(idx++, (float)v); |
| 5054 | |
| 5055 | nn->process(0, getConnectionPtr(true), &out); |
| 5056 | } |
| 5057 | } |
| 5058 | else if (input.isBuffer()) |
| 5059 | { |
| 5060 | if(isPositiveAndBelow(nn->getNumInputs(), input.getBuffer()->size)) |
| 5061 | { |
| 5062 | auto ptr = input.getBuffer()->buffer.getReadPointer(0); |
| 5063 | nn->process(0, ptr, &out); |
| 5064 | } |
| 5065 | } |
| 5066 | |
| 5067 | if(outputCableUntyped != nullptr) |
| 5068 | { |
| 5069 | auto typed = dynamic_cast<scriptnode::routing::GlobalRoutingManager::CableTargetBase*>(outputCableUntyped.get()); |
| 5070 | typed->sendValue(out); |
| 5071 | } |
| 5072 | |
| 5073 | return var(out); |
| 5074 | } |
| 5075 | else |
| 5076 | { |
| 5077 | if(isSingleIn) |
| 5078 | { |
| 5079 | float in = (float)input; |
| 5080 | nn->process(0, &in, getConnectionPtr(false)); |
| 5081 | } |
| 5082 | else if (input.isArray()) |
| 5083 | { |
| 5084 | if(isPositiveAndBelow(inputBuffer->size, input.size())) |
| 5085 | { |
| 5086 | int idx = 0; |
| 5087 | for(const auto& v: *input.getArray()) |
| 5088 | inputBuffer->setSample(idx++, (float)v); |
| 5089 |
no test coverage detected