-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add bus nodes for multiplexing data. Also add imgui plot output nodes…
… that will be used as graph sources.
- Loading branch information
Showing
9 changed files
with
213 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
packages/nodegraph/include/nodegraph/operations/NodeGraphOpDataBus.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#pragma once | ||
#include "nodegraph/core/NodeGraphBase.h" | ||
|
||
#include "logging/LoggingAll.h" | ||
|
||
#include "hid/KeyboardPiano.h" | ||
#include "hid/Midi.h" | ||
|
||
#include "audio/PortAudio.h" | ||
#include "audio/AudioUtils.h" | ||
|
||
#include "math/MathFunc.h" | ||
|
||
#include <string> | ||
#include <vector> | ||
#include <map> | ||
#include <typeinfo> | ||
#include <type_traits> | ||
#include <math.h> | ||
#include <random> | ||
#include <unordered_set> | ||
|
||
namespace l::nodegraph { | ||
|
||
/*********************************************************************/ | ||
class GraphDataBusDataIn : public NodeGraphOp2 { | ||
public: | ||
GraphDataBusDataIn(NodeGraphBase* node, int32_t inputDataStride) : | ||
NodeGraphOp2(node, "Bus Data In x6"), | ||
mInputDataStride(inputDataStride) | ||
{ | ||
mInputManager.AddInput(InputIterationType::SAMPLED, AddInput("Bus Data", 0.0f, 2)); | ||
|
||
for (int32_t i = 0; i < mInputDataStride; i++) { | ||
AddOutput("Out " + std::to_string(i), 0.0f, 2); | ||
} | ||
} | ||
|
||
virtual void Process(int32_t numSamples, std::vector<NodeGraphInput>& inputs, std::vector<NodeGraphOutput>& outputs) override; | ||
protected: | ||
int32_t mInputDataStride = 1; | ||
}; | ||
|
||
/*********************************************************************/ | ||
class GraphDataBusDataOut : public NodeGraphOp2 { | ||
public: | ||
GraphDataBusDataOut(NodeGraphBase* node, int32_t outputDataStride) : | ||
NodeGraphOp2(node, "Bus Data Out x6"), | ||
mOutputDataStride(outputDataStride) | ||
{ | ||
for (int32_t i = 0; i < mOutputDataStride; i++) { | ||
mInputManager.AddInput(InputIterationType::SAMPLED, AddInput("In " + std::to_string(i), 0.0f, 2)); | ||
} | ||
AddOutput("Bus Data", 0.0f, 2); | ||
} | ||
|
||
virtual void Process(int32_t numSamples, std::vector<NodeGraphInput>& inputs, std::vector<NodeGraphOutput>& outputs) override; | ||
protected: | ||
int32_t mOutputDataStride = 1; | ||
}; | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
packages/nodegraph/source/common/operations/NodeGraphOpDataBus.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include "nodegraph/operations/NodeGraphOpDataBus.h" | ||
|
||
#include "logging/Log.h" | ||
#include "audio/AudioUtils.h" | ||
|
||
#include "math/MathFunc.h" | ||
|
||
#include <math.h> | ||
|
||
namespace l::nodegraph { | ||
|
||
/*********************************************************************/ | ||
void GraphDataBusDataIn::Process(int32_t numSamples, std::vector<NodeGraphInput>& inputs, std::vector<NodeGraphOutput>& outputs) { | ||
mInputManager.BatchUpdate(inputs, mInputDataStride * numSamples); | ||
|
||
float* input = mInputManager.GetArray(0); | ||
for (int32_t i = 0; i < mInputDataStride; i++) { | ||
float* output = &outputs.at(i).Get(numSamples); | ||
for (int32_t j = 0; j < numSamples; j++) { | ||
output[j] = input[mInputDataStride * j + i]; | ||
} | ||
} | ||
} | ||
|
||
/*********************************************************************/ | ||
void GraphDataBusDataOut::Process(int32_t numSamples, std::vector<NodeGraphInput>& inputs, std::vector<NodeGraphOutput>& outputs) { | ||
mInputManager.BatchUpdate(inputs, numSamples); | ||
|
||
float* output = &outputs.at(0).Get(mOutputDataStride * numSamples); | ||
for (int32_t i = 0; i < numSamples; i++) { | ||
for (int32_t j = 0; j < mOutputDataStride; j++) { | ||
output[mOutputDataStride * i + j] = mInputManager.GetValueNext(j); | ||
} | ||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters