How to relay a slider value change to the main component when coming from a non MainComponent file

Im making window in main component, that window in main component has an external component that has a view port, that view port component contains a third external component.

Im trying to relay the slider values from the third component in the viewport to the getNextAudioBlock in mainComponent

However upon trying to change the values or relay any message to the main component I get a EXC_BAD_ACCESS

This is often the case because you have coupled your gui and business logic. GUI components should operate on a data model that is the state of things. I use ValueTrees for this. All the GUI components receive and set data through this mechanism, which removes this type of issue you are running into.

so when I set up the value tree that should be in the component that’s in the view port or in the main component?

My system is pretty robust, so there were a fair number of up front details to get in place. Basically it creates a root level valuetree in the main app class, which is passed into the business logic classes which either put context specific VT’s (things like the playback transport, a song library, a preset library, a device properties (for our hardware)) and the main component class (which then passes this along to the child components). I also create classes called ValueTreeWrappers which hide the ValueTreeness of this behind a set of setters/getters/callbacks. So, for example, the transport GUI would have a member of TransportProperties (which is a VT wrapper) and it would find this on the main VT passed in with something like transportProperties.wrap (runtimeVT). And could then use it’s api for things like transportProperties.onStateChange = [this] (TransportState ts) { updateTransportGuiState (ts); }; or updateTransportGuiState (transportProperties.getState ())'

Once you get used to doing this separation, your coding style adapts to it quickly, and and you can start enjoying the benefits. No more unneeded coupling of GUI components. they truly just become view ports into the underlying data. :slight_smile:


I’ll go ahead and try that approach using the Value Tree you mentioned. Ill make the root in the MainComponent then try to get it to receive values etc. etc. from the other Components in the other files from the source.

Thank you for your help,
it is much appreciated.