MCPcopy Create free account
hub / github.com/christophhart/HISE / process

Method process

hi_scripting/scripting/api/ScriptingApiObjects.cpp:5032–5114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5030}
5031
5032var 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

Callers 1

sendValueMethod · 0.45

Calls 15

isPositiveAndBelowFunction · 0.85
varFunction · 0.85
roundToIntFunction · 0.85
makeCopyOfMethod · 0.80
createSpectrumBufferMethod · 0.80
createSpectrumImageMethod · 0.80
copyFunction · 0.50
getNumOutputsMethod · 0.45
getNumInputsMethod · 0.45
isArrayMethod · 0.45
sizeMethod · 0.45
getArrayMethod · 0.45

Tested by

no test coverage detected