Closed georgkrause closed 6 years ago
It looked like a lot of boilerplate to me. At least the getType() method could be done via templates. -> but hey, that wouldn't worth the hazzle.
But there were many subtle differences which i've overlooked :).
(I am even more of a nooby.)
One could just create data containers as events dynamically via a very terse syntax, but that's very complicated.
The reason to use simple structs instead of C++ templates and fancy goodness is that the Event struct is POD (Plain Old Data). The exact binary layout of each event is known, and can be easily inspected. Try that with a C++ class that has virtual functions - it won't work. Templates might - but at the cost of complexity.
There is immense value in keeping it simple - for example, creating a Python wrapper to the POD data structures would be trivial - it may take effort, but it is simple, Python's CTypes module already provides the required parts.
If I was to re-work this, I'd take inspiration from the LV2 Atom infrastructure, and find a way to enhance that to be easier to use. (Long story short, you build up the Event struct dynamically using all high-performance data types like int float char, but it can be de-serialized back into human readable events easily). Dynamic events like that (if easy to use from the code) would enable us to add events new events with less effort - that would be nice.
I know message-passing "async" style coding can be hard - but it pays off because the DSP is known to be real-time safe, and assuming the design of the Events is sane, it scales pretty well...
Opinions and thoughts welcome - but so far I don't think there is sufficient value in changing from the current solution. The only thing I see as a worthy candidate is LV2 Atom type infrastructure, however that adds a lot of complexity for the dev right now :/
Some thoughts from me, please take with care.
But templates would obfuscate the pod's. There wouldn't be a canonical way to easily know how the data types are structured.
Need to think about why, but nice input to learn. If i am getting this right, there is nothing to be changed no, so i am going to close this and keep learning. thank you both :)
@vale981
I checked this. We could do this, but would need an templated class for the events but still one class per Event for the Information which should be transported because all events carry different information. I am not sure if this is really better, but I am just a nooby :D So lets discuss this ;)