Automation of Slider

Oh right. Yes I think that will work as well. There are some subtle differences between the two but I think that callback will always be called when the actual value of the parameter changes.

I have a technician coming out to troubleshoot my Internet connection this morning, so I must keep my responses brief. But I will post my working code later, and you can see what I am doing (and for the benefit of others).

Thank you.

The goal here is to provide the connection between the volumeSlider component and the track automation. I will outline my approach to this for the benefit of others. Please feel free to critique.

In my Track footer class;

class TrackFooterComponent : public Component, public te::AutomatableParameter::Listener

I set up my parameter connection;

te::AudioTrack* audioTrackPtr{ dynamic_cast<te::AudioTrack*>(trackPtr.get()) };
te::AutomatableParameter::Ptr volumeParameterPtr{ audioTrackPtr->getVolumePlugin()->getAutomatableParameterByID("volume") };

Then, in the constructor;

volumeSlider.onValueChange = [this]
{
	volumeParameterPtr->setParameter(float(volumeSlider.getValue()), dontSendNotification);
};
volumeParameterPtr->addListener(this);

And then the callbacks;

void curveHasChanged(te::AutomatableParameter&) override
{
	// empty
}

void currentValueChanged(te::AutomatableParameter& autoParam, float newValue) override
{
	if (&autoParam == volumeParameterPtr)
	{
		volumeSlider.setValue(newValue, dontSendNotification);
	}
}

In my testing so far this is working great. If you would recommend any changes, please let me know?

To the above code you may need to add;

volumeSlider.setValue(te::volumeFaderPositionToGain(audioTrackPtr->getVolumePlugin()->getSliderPos()), dontSendNotification);

This is to initialize the volume slider to its last known position.

For avoiding a crash, I would test for nullptr after every dynamic cast.

Technically you are correct, of course. But, we have inside knowledge, and, in this case we would not even be there if trackPtr.get() was not valid and cast-able. So, the risk is acceptable in this case.