If the editors cpp calls a function in the processors .cpp, is the processor Thread executing the function?

Its a basic c++ question coming down to the understanding of threads:
if my audioprocessor has a function for example for parameter cooking, and I call it from the editors .cpp file, does this affect the performance of the audioprocessor thread?

The thread that executes a function does not depend on what cpp defines that function.

So, if you are on the main/message/UI thread and call a method in the audioprocessor class, there is no magic trickery that will make it happen on the audio/realtime thread that’s also processing the audio.

The message thread and the audio thread can both be executing the same function without any of the two noticing a difference performance wise. BUT if such a concurrent execution can happen in your code, then you must make that function thread-safe.
If it’s a function that only works on its arguments and local variables, it’s safe by definition.

But if the function also reads/writes some shared state, e.g. a member variable in its object, then you must take particular care at making sure that both execution paths see a consistent value for that variable. This is typically done using atomic variables, whose update is guaranteed to happen atomically and cannot be interrupted by a switch to another thread which may access the variable in an inconsistent state, or via locks, which are used when there is a more complex state to be updated.

1 Like

thanks!