Some specification/performance-related questions

Post Reply
User avatar
AndyMac
Posts: 148
Joined: Wed Sep 05, 2018 6:16 pm
Location: Wirral UK
Contact:

Some specification/performance-related questions

Post by AndyMac »

Having been building a number of "utility" modules, I'd like to understand the optimum way to code given the built-in JVM and its behaviour, so I have some questions which I am sure will be useful to other developers...

(1) Is there a performance difference between using private variables in code (i.e. @Override / public void … / { int WorkingValue; …) vs declaring them within the module, i.e. at the end with my own variables and functions - thinking about any time in creation and destruction of variables

(2) Obviously, if there is a lot of working the ProcessSample section then not doing this when a jack is not connected makes sense. However, what if the processing in this section is really simple, for example: outJack.SetValue( value ) or outJack.SetValue( inJack.GetValue() )?

Would it make sense to have "if( inJack.IsConnected() && outJack.IsConnected() ) { outJack.SetValue( inJack.GetValue(); }" or is the overhead of the test more than the saving of not processing SetValue?

(3) When using state information which have events that can tell you their state (i.e. IsConnected) a lot, does it make sense to use the events to keep state in a variable rather than always querying state - especially relevant when considered with question 2.

(4) For static values (used when internally configuring modules, e.g. for values as discussed in question 5), is there a performance benefit in using Statics and are there any limitations/issues with using Statics in this way?

(5) Is there a minimum time needed for a Trigger to be consistently recognised ... i.e. can we use the PercussionEnvelope with AttackHold 0 and Decay 0, or do we need AttackHold to be more than 0 - in which case, what?

The documentation could do with including some more around the gates, triggers and the other aspects of the library including the Audio Processing section - much of the rest is self-explanatory, but some of the Audio Processing section especially is not that obvious and any constraints like minimum or maximum values need to be documented somewhere.

And a final thought - some indication of processing time (obviously depends on the platform, but something relative might be possible) for major events/actions would be really useful in the documentation.

Maybe having the documentation available as a Wiki that can be easily updated by the team, but which can also have comments and clarifications added to it by developers would be helpful.
Cherry Dan
Site Admin
Posts: 256
Joined: Fri Jul 27, 2018 5:36 pm

Re: Some specification/performance-related questions

Post by Cherry Dan »

Hi,

I'll answer your questions to the best of my ability:

(1) Is there a performance difference between using private variables in code (i.e. @Override / public void … / { int WorkingValue; …) vs declaring them within the module, i.e. at the end with my own variables and functions - thinking about any time in creation and destruction of variables

To start with, check out this thread: https://stackoverflow.com/questions/216 ... cess-speed. If there is a different, it's pretty minor. But the best way to find out is to try some benchmark tests yourself.

(2) Obviously, if there is a lot of working the ProcessSample section then not doing this when a jack is not connected makes sense. However, what if the processing in this section is really simple, for example: outJack.SetValue( value ) or outJack.SetValue( inJack.GetValue() )?


When you call SetValue() on a jack, the first thing is does is check to see if a jack is connected. So it's not necessary to check if a jack is connected before setting its value. However, it is advantageous to skip DSP processing if there's no input and/or no output connected. At the same time, it's not ideal for a module with blinking LEDs or other feedback information to appear 'dead' when not hooked up. Part of creating a good module is making sure it is as CPU efficient as possible.

(3) When using state information which have events that can tell you their state (i.e. IsConnected) a lot, does it make sense to use the events to keep state in a variable rather than always querying state - especially relevant when considered with question 2.


You can use the Jack_Connected and Jack_Disconnected notifications to keep track of jack state for yourself. In practical terms, we hardly ever do this in our own modules. A call to jack.IsConnected() is not a time-consuming process, and we can usually avoid a lot of DSP with a quick jack check at the start of a ProcessSample() call.

(4) For static values (used when internally configuring modules, e.g. for values as discussed in question 5), is there a performance benefit in using Statics and are there any limitations/issues with using Statics in this way?

There are two very small performance benefits to using static variables, that I'm aware of. First, every class doesn't need to store its own variable, so you'll save a small amount of memory. Second, when referencing the static variable, the system does not have to dereference the "this" pointer to figure out which variable instance you're talking about. But again, these are fast functions for any modern computer, and it's unlikely you'd see any real-world performance difference.

(5) Is there a minimum time needed for a Trigger to be consistently recognised ... i.e. can we use the PercussionEnvelope with AttackHold 0 and Decay 0, or do we need AttackHold to be more than 0 - in which case, what?


In the Voltage system, a trigger can be a single sample set high. In fact, all of our modules that send trigger signals set a single sample to be high. However, all of our modules that read trigger signals will work with gate signals as well, so gates and triggers can be used interchangeably, e.g. to trigger a drum module.

Maybe having the documentation available as a Wiki that can be easily updated by the team, but which can also have comments and clarifications added to it by developers would be helpful.


That's a very good idea. We'll see what we can do!

Thanks,
Dan
User avatar
AndyMac
Posts: 148
Joined: Wed Sep 05, 2018 6:16 pm
Location: Wirral UK
Contact:

Re: Some specification/performance-related questions

Post by AndyMac »

Thank you Dan, very helpful
Post Reply

Return to “Module Designer”