0

I'm trying to write a modular audio-processing aplication. Modular means, well, I have 'modules' (I call them nodes), which have inputs and outputs (there are a few different types, which are color-coded, for example green means an audio output, blue means a single-number output etc.). I also try to keep UI and program logic seperated.

To implement this system, I have written classes derived from my custom 'datablock' class, which are essentially just the different data type stores, so I have a 'IntDataBlock', I have a 'AudioDataBlock', etc. All this classes have the same variable ('data'), but with different data types. For example, a IntDataBlock, has just a int type 'data', but a AudioDataBlock has for example a list of floats as 'data'.

Also, I have written a class 'connection', which connects a output of a node with the input of another node. 'connection' takes two node pointers as constructor arguments, so it knows which nodes to connect. Now you have to know, that each node has 'datablock' derived objects as input/output value stores.

'connection' has functions to attach it to two datablocks (one output and one input), so as soon as node 1 processes it's data and has output data, it updates it output datablocks, and then the 'connection' class should work directly as a bridge, transferring the data from the output of node 1 to the input of node 2. But I have a problem: Since I cannot put the 'data' variable of the datablocks in the parent class 'dataclass' (because each derived class as a different type of 'data'), I cannot write:

void NodeConnection::establishConnection()
{
    node2.inputDatablock.data = node1.outputDataBlock.data;
}

...because 'data' isn't in the parent class 'datablock', so technically not every 'datablock' actually has to have a variable 'data'.

Do you have any idea how to solve this? I would also appreciate if somebody, who knows a better way of implementing such a connection, shows that to me. Thanks!

Ben
  • 201
  • 1
  • 10
  • I think you're planning to implement media processing frameworks such as DirectShow filters or GStreamer. What about checking their class diagram first to get some hints? Because all those frameworks look similar each other. In case of GStreamer, you can look into the source code as well. – Kay Mar 01 '18 at 22:40

1 Answers1

0

Ok guys, I solved the problem. Instead of transferring only the variable data, I exchange the whole datablock, which I found has some advantages, because there are more variables in a datablock that also have to be copied.

Ben
  • 201
  • 1
  • 10