setSubPage on mOnProcess ValueChange

Hi,

I put a control in a subpage. e.g.:

page.makeValueBinding(surfaceElements.knob.mSurfaceValue, selectedChannel.mChannelEQ.mBand1.mFreq).setSubPage(subPageEQ)

That works just fine. However, how do I do that the other way around to display feedback on the device. If it would be static I would do:

selectedChannel.mChannelEQ.mBand1.mFreq.mOnProcessValueChange=function(activeDevice, activeMapping, value)
{ 
    sendMidi...
}

But how do I make that function subpage dependend? I mean if another page is active it has to display the feedback from the other page.

You can use the mOnActivate event of the subpage for this.

var yourSubPageIndex=0 // just an example
var yourSubPageName="EQ" // you can use names as well 

yourSubPage.mOnActivate=function(activeDevice,activeMapping){
            
	activeDevice.setState("subPageSelectedIndex",this.yourSubPageIndex.toString())
            
    activeDevice.setState("subPageSelected",this.yourSubPageName)
            
}.bind({yourSubPageIndex,yourSubPageName})


selectedChannel.mChannelEQ.mBand1.mFreq.mOnDisplayValueChange=function(activeDevice,activeMapping,displayvalue){

	if(activeDevice.getState("subPageSelectedIndex")==this.yourSubPageIndex.toString())
	//or activeDevice.getState("subPageSelected")==this.yourSubPageName

	{

		//display the change only when it happened while you're in the correct subPage 

	}

}.bind({yourSubPageIndex,yourSubPageName})

Note that if your page is made purely from subPages, you have to

activeDevice.setState("subPageSelectedIndex","0")
activeDevice.setState("subPageSelected","EQ")

in your page’s mOnActivate, because in many cases, the mOnActivate of the subPage fires AFTER some controls’ changes.

2 Likes

Thank you. I actually used this kind of workaround already. However in my optionion this doesn’t really fit into this whole subpage concept. There should be a nicer solution. This is something that could be improved.

@Peter8 Is there a reason you need to use selectedChannel.mChannelEQ.mBand1.mFreq.mOnProcessValueChange instead of surfaceElements.knob.mSurfaceValue.mOnProcessValueChange?

I am a little confused right now but I don’t think that makes sense. E.g.:

page.makeValueBinding(surfaceElements.knob.mSurfaceValue, selectedChannel.mChannelEQ.mBand1.mFreq).setSubPage(subPageEQ)
page.makeValueBinding(surfaceElements.knob.mSurfaceValue, selectedChannel.mChannelEQ.mBand2.mFreq).setSubPage(subPageEQ2)

What would happen now in?:

surfaceElements.knob.mSurfaceValue.mOnProcessValueChange

When subPageEQ is active, knob.mSurfaceValue.mOnProcessValueChange will be called with the value of mBand1.mFreq. Likewise, when subPageEQ1 is active, it will be called with mBand2.mFreq. This might be what you want according to

knob.mSurfaceValue.mOnProcessValueChange is also called when you switch subpages :slightly_smiling_face:

1 Like

You are right. This is exactly where my problem was. Thanks a lot.

1 Like