Home AMXForums Archive Threads AMX Applications and Solutions

Nxc-vol4

Hi guys

I'm working with a VOL4 device and experiencing a strange behaviour.
I've used 4 bars to control the volume levels as you can see from the image attached.
Sometimes the bars stop showing the current volume and start to behave like a vu-meter: level values go up and down without any evident reason!
Here is some code
vVOLUME		=	33003:1:0
MIXER_CH1	=	32001:1:1	
MIXER_CH2	=	32001:2:1
// used to store volume levels when power goes down
PERSISTENT INTEGER MIXER_VOLUMES[4]

// used to store current volume levels
INTEGER MIXER_VAL[4]

DEFINE_CONNECT_LEVEL
(vVOLUME,1,vTP2,2,MIXER_CH1,1)
(vVOLUME,2,vTP2,3,MIXER_CH1,2)
(vVOLUME,3,vTP2,4,MIXER_CH2,1)
(vVOLUME,4,vTP2,5,MIXER_CH2,2)
DEFINE_START

CREATE_LEVEL MIXER_CH1,1,MIXER_VAL[1]
CREATE_LEVEL MIXER_CH1,2,MIXER_VAL[2]
CREATE_LEVEL MIXER_CH2,1,MIXER_VAL[3]
CREATE_LEVEL MIXER_CH2,2,MIXER_VAL[4]

SEND_LEVEL vVOLUME,0,MIXER_VOLUMES[1]
SEND_LEVEL vVOLUME,1,MIXER_VOLUMES[2]
SEND_LEVEL vVOLUME,2,MIXER_VOLUMES[3]
SEND_LEVEL vVOLUME,3,MIXER_VOLUMES[4]
// volume +
BUTTON_EVENT[vTP2,180]
BUTTON_EVENT[vTP2,181]
BUTTON_EVENT[vTP2,182]
BUTTON_EVENT[vTP2,183]
{
    PUSH:
    {
	LOCAL_VAR INTEGER SELECTED_CH
	
	//  [1..4]
	SELECTED_CH = (BUTTON.INPUT.CHANNEL%180)+1
	
	IF(MIXER_VAL[SELECTED_CH] < 255)
	{
	    SEND_LEVEL vVOLUME,SELECTED_CH,MIXER_VAL[SELECTED_CH]+1
	    MIXER_VOLUMES[SELECTED_CH] = MIXER_VAL[SELECTED_CH]
	}
	[vTP2,188+SELECTED_CH-1] = FALSE // mute off
    }
}

// VOLUME-
BUTTON_EVENT[vTP2,184]
BUTTON_EVENT[vTP2,185]
BUTTON_EVENT[vTP2,186]
BUTTON_EVENT[vTP2,187]
{
    PUSH:
    {
 	LOCAL_VAR INTEGER SELECTED_CH
	
	// [1..4]
	SELECTED_CH = (BUTTON.INPUT.CHANNEL%184)+1
	
	IF(MIXER_VAL[SELECTED_CH] > 0) 
	{
	    SEND_LEVEL vVOLUME,SELECTED_CH,MIXER_VAL[SELECTED_CH]-1
	    MIXER_VOLUMES[SELECTED_CH] = MIXER_VAL[SELECTED_CH]
	}

	IF(MIXER_VAL[SELECTED_CH] > 0)
	    [vTP2,188+SELECTED_CH-1] = FALSE // mute off
    }
}

// MUTE on
BUTTON_EVENT[vTP2,188]
BUTTON_EVENT[vTP2,189]
BUTTON_EVENT[vTP2,190]
BUTTON_EVENT[vTP2,191]
{
    PUSH:
    {
 	LOCAL_VAR INTEGER SELECTED_CH
	
	// [1..4]
	SELECTED_CH = (BUTTON.INPUT.CHANNEL%188)+1
	
	SEND_LEVEL vVOLUME,SELECTED_CH,0
	MIXER_VOLUMES[SELECTED_CH] = 0


	[vTP2,187+SELECTED_CH] = TRUE
    }
}

// LEVEL_EVENT PER MIXER VOLUME
LEVEL_EVENT[vTP2,2]
LEVEL_EVENT[vTP2,3]
LEVEL_EVENT[vTP2,4]
LEVEL_EVENT[vTP2,5]
{
    SEND_LEVEL vVOLUME,LEVEL.INPUT.LEVEL-1,LEVEL.VALUE
    
    //SEND_STRING 0:1:0,"'LEVEL.INPUT.LEVEL=',ITOA(LEVEL.INPUT.LEVEL)"
    //SEND_STRING 0:1:0,"'LEVEL.VALUE=',ITOA(LEVEL.VALUE)"
    MIXER_VOLUMES[LEVEL.INPUT.LEVEL-1] = LEVEL.VALUE
    
    IF(LEVEL.VALUE > 0)
	[vTP2,188+LEVEL.INPUT.LEVEL-2] = FALSE
    ELSE
	[vTP2,188+LEVEL.INPUT.LEVEL-2] = TRUE
}


Any hint?

Comments

  • lattanzilattanzi Junior Member Posts: 22
    No help?
    Have i been clear enough?

    :-(
  • JustinCJustinC Junior Member Posts: 74
    I have had this problem before but with a XAP800 as the source from where I was getting my level information.

    I have never experienced it with an AMX Vol Controller.

    My problem was the the processor was parsing the data from the XAP and was getting stuck in a kind of loop. The only way to fix it was to go to a "fake feedback" setup and then just update the XAP blindly. It doesn't help that when a panel goes offline any combined levels go to zero. It would help if they would just stay where they are currently at and then update once the panel comes back online, I feel this is an AMX design flaw in G4 panels.
  • JustinCJustinC Junior Member Posts: 74
    In your code snippet above, in your DEFINE_START

    you are sending the level to level 0,1,2,3

    and in your code above that you are using levels 1,2,3,4

    that seems incorrect to me

    also,

    in your button events below that, I think you should use

    (BUTTON.INPUT.CHANNEL-179) and remove the +1, instead of

    (BUTTON.INPUT.CHANNEL%180)+1

    its less for the processor to do and its more definitive, IMO
  • JustinCJustinC Junior Member Posts: 74
    If you can give me a tp file with just that volume page you linked above I can show you a much easier way that you can handle this data in a G4 TP.
  • lattanzilattanzi Junior Member Posts: 22
    JustinC, i'm not using g4 touchpanel. Unfortunately my customer wants to use a web interface >>TPD3 html saveas option...

    You were right in your first post: in define_start i use 0,1,2,3 while in my button_event i use 1,2,3,4

    I also think that here:
    LEVEL_EVENT[vTP2,2]
    LEVEL_EVENT[vTP2,3]
    LEVEL_EVENT[vTP2,4]
    LEVEL_EVENT[vTP2,5]
    {
        
        // probabilemnte non serve!!!!
        // con define_connect_level ho gi? l'associazione
        SEND_LEVEL vVOLUME,LEVEL.INPUT.LEVEL-1,LEVEL.VALUE
        
        MIXER_VOLUMES[LEVEL.INPUT.LEVEL-1] = LEVEL.VALUE
        
        IF(LEVEL.VALUE > 0)
    	[vTP2,188+LEVEL.INPUT.LEVEL-2] = FALSE
        ELSE
    	[vTP2,188+LEVEL.INPUT.LEVEL-2] = TRUE
    }
    

    this line is superflous:
    SEND_LEVEL vVOLUME,LEVEL.INPUT.LEVEL-1,LEVEL.VALUE
    

    the level is automatically updated...isn't it?
    Thanks for your patience
  • JustinCJustinC Junior Member Posts: 74
    Whenever you do the define_connect_level, the processor automatically keeps everything updated. So I believe you are correct when it comes to that line being superfluous
Sign In or Register to comment.