Home AMX User Forum NetLinx Studio

Multi-Zone Volume Page/Control ?help?

I have created a zones page to quickly adjust volume up, down, or mute for my 3 zones. I am, however, having a problem determining the best structure for programming this. I was considering creating an array for all 3 volume up buttons, another for all 3 volume down buttons, and another for all 3 mute buttons. I am trying to get away from creating button events for each button, but I can't seem to get the variables down. here is what I have so far:
NON_VOLATILE INTEGER nZoneUp[] = {1,2,3} //Vol Up Commands for 3 Zones
NON_VOLATILE INTEGER nZoneDn[] = {4,5,6}  //Vol Dn Commands for 3 Zones
NON_VOLATILE INTEGER nZoneMute[] = {7,8,9}  //Mute Commands for 3 Zones
NON_VOLATILE INTEGER nVol //current volume level

BUTTON_EVENT[dvCV7Tp,nZoneUp]  //Zone VOL3 Up Commands
{
	PUSH:
	{
		nVol ++
		SEND_COMMAND dvVOL1, "'P0L',itoa(nVol),'%'"  //vol3 box
		SEND_LEVEL dvCV7Tp, 10,nVol
        }
}
BUTTON_EVENT[dvCV7Tp,nZoneDn]  //Zone Vol3 Dn Commands
{
	PUSH:
	{
		nVol --
		SEND_COMMAND dvVOL1, "'P0L',itoa(nVol),'%'"  //vol3 box
		SEND_LEVEL dvCV7Tp, 10,nVol
        }
}
I know there is a better way to organize several arrays so that I can use multi-zone functions like this, but I can't seem to find the post I saw it on. Something where I can do a single event for all zones volume up, another for down...etc. Help?

Comments

  • DiogoDiogo Posts: 65
    Hi vegastech

    I don't if you would like to make al zones with the same volume, is this what you really want?
    Because I could see you only use one variable to storage the volume level you are sending on the send_string. Depending on the device, you could use the level value to storage the volume, but be careful when using more than one touchpanel, here is what I should do in your case
    NON_VOLATILE INTEGER nZoneUp[] = {1,2,3} //Vol Up Commands for 3 Zones
    NON_VOLATILE INTEGER nZoneDn[] = {4,5,6}  //Vol Dn Commands for 3 Zones
    NON_VOLATILE INTEGER nZoneMute[] = {7,8,9}  //Mute Commands for 3 Zones
    NON_VOLATILE INTEGER nVol[3] //current volume level
    
    
    
    
    LEVEL_EVENT[dvCV7Tp,10]
    LEVEL_EVENT[dvCV7Tp,11]
    LEVEL_EVENT[dvCV7Tp,12]
    {
        NVOL[LEVEL.INPUT.LEVEL - 9] = LEVEL.VALUE
    }
    
    
    
    BUTTON_EVENT[dvCV7Tp,nZoneUp]  //Zone VOL3 Up Commands
    {
            PUSH:
            {
    		nVol[nZONEUP] ++
    		SEND_COMMAND dvVOL1, "'P0L',itoa(nVol[NZONEUP]),'%'"  //vol3 box
    		SEND_LEVEL dvCV7Tp, 10,nZONEUP
            }
    }
    BUTTON_EVENT[dvCV7Tp,nZoneDn]  //Zone Vol3 Dn Commands
    {
    	PUSH:
    	{
    		nVol[nZONEDN - 3] - 1
    		SEND_COMMAND dvVOL1, "'P0L',itoa(nVol),'%'"  //vol3 box
    		SEND_LEVEL dvCV7Tp, 10,nVol
            }
    }
    
    
  • DHawthorneDHawthorne Posts: 4,584
    I agree with Diogo that nVol needs to be an array, but rather than the calculations in your PUSH handler, use GET_LAST on the channel array to get an index, and use that index to reference nVol.
    BUTTON_EVENT[dvCV7Tp,nZoneUp]  //Zone VOL3 Up Commands
    {
            PUSH:
            {
    		STACK_VAR CHAR nZone 
                    nZone = GET_LAST(nZoneUp)
    
                    nVol[nZone] ++
    		SEND_COMMAND dvVOL1, "'P0L',itoa(nVol[nZone]),'%'"  //vol3 box
    		SEND_LEVEL dvCV7Tp, 10,nZone
            }
    }
    BUTTON_EVENT[dvCV7Tp,nZoneDn]  //Zone Vol3 Dn Commands
    {
    	PUSH:
    	{
    		STACK_VAR CHAR nZone 
                    nZone = GET_LAST(nZoneDn)
    
    		nVol[nZone] --
    		SEND_COMMAND dvVOL1, "'P0L',itoa(nVol[nZone]),'%'"  //vol3 box
    		SEND_LEVEL dvCV7Tp, 10,nVol[nZone]
            }
    }
    

    That will make it more scalable (if more zones are added later, you can just expand the button array, and they don't need to have contiguous channel numbers). You may also want to bounds-check nVol before incrementing or decrementing it, so it doesn't roll into weird numbers if you get less than zero, or over you max volume level.
  • vegastechvegastech Posts: 369
    Thanks guys-that helps quite a bit. I guess what I want to do in addition to individual zone vol up and down is to link all of the zones together with an array ( i think ) so that I can do a party mode (all zones) vol up and down (and also mute, later). How would I reference that in a single button event? I started the long way - create a variable for each zone, and switch it between 0 and 1, where 0 is de-selected, 1 is selected, and then in the button press, if any of those variables were at 1, its respective zone would volume up or down.
  • DiogoDiogo Posts: 65
    I've done something like this, for a client, also know as my Boss.....
        +------------+    +------------+  +------------+
        | Kitchen    |    | Party room |  | All        |
        +------------+    +------------+  +------------+
    
    
    
        +----+
        |    |
        |    |
        |    |
        |    |
        |    | +------------+
        | VOl| |    MUTE    |
        |    | +------------+
        |____| 
        |    |
        |    |
        +----+
    
    
    

    You say like this, if touch kitchen goes to kitchen, if all, both rooms

    If you wanna do this, you should make this

    For the rooms buttons:
    BUTTON_EVENT[ROOMSBUTTONS]
    {
        PUSH:
        {
            BUTTON.INPUT = !BUTTON.INPUT
            OFF[ALLROOMSBUTTON]
        }
    }
    BUTTON_EVENT[ALLROOMSBUTTON]
    {
        PUSH:
        {
            OFF[ROOMSBUTTONS]
            BUTTON.INPUT = !BUTTON.INPUT
        }
    }
    
    

    then in the vol up button
    BUTTON_EVENT[dvCV7Tp,nZoneUp]  //Zone VOL3 Up Commands
    {
            PUSH:
            {
                    IF zone1active (*the respective button*) or ALLROOMSBUTTON
                    {
    		     nVol[1] ++
    	      	     SEND_COMMAND dvVOL1, "'P0L',itoa(nVol[1]),'%'"  //vol3 box
    		     SEND_LEVEL dvCV7Tp, 10,nVol[1]
                    }
    
                    IF zone2active (*the respective button*) or ALLROOMSBUTTON
                    {
    		     nVol[2] ++
    	      	     SEND_COMMAND dvVOL1, "'P0L',itoa(nVol[2]),'%'"  //vol3 box
    		     SEND_LEVEL dvCV7Tp, 10,nVol[2] 
                    }
    
                   // AND SO ON
            }
    }
    
    


    Sorry I could code it better, but today is friday, and the happy hour is aproaching... :)
  • DHawthorneDHawthorne Posts: 4,584
    A popular interface that Savant and AMX.home are both using is a grid with buttons for all the rooms that you select all the ones you want to control, then select a source, or volume control, or whatever, and it applies to all at once. Personally, I'm not real thrilled with giving clients a way to adjust volume strictly in an up/down fashion in a room they can't hear, but percentage buttons can work well if the rooms are set up properly. How you send it to your switcher is another matter ... you could do a loop for all controlled rooms and send it out one at a time,or, if the switcher supports it, send to multiple zones at once. That much will depend on your equipment.
  • vegastechvegastech Posts: 369
    Uh oh...

    I finally got back around to reviewing the suggestions you guys posted - I'm having an issue when I compile:
    ERROR: C:\laptop backup\RobsAMXFiles\Projects\Belzer Home\BelzerHome.axs(1073): C10508: Array index cannot be dimensioned, but number dimensions is [1]  
    

    It is referencing this line of code:
    nZoneLevel[nZoneUp] ++
    

    Here is what I have so far:
    DEFINE VARIABLE
    NON_VOLATILE INTEGER nZoneUp[] = {55,57} //Vol Up Commands for 3 Zones
    NON_VOLATILE INTEGER nZoneDn[] = {56,58}  //Vol Dn Commands for 3 Zones
    NON_VOLATILE INTEGER nZoneLevel[3]  //VOL3 variable for current volume, 1 for each zone
    DEFINE EVENT
    BUTTON EVENT
    BUTTON_EVENT[dvCV7Tp,nZoneUp]  //Zone VOL3 Up Commands
    {
    	PUSH:
    	{
    		nZoneLevel[nZoneUp] ++
    		//SEND_COMMAND dvVOL1, "'P',itoa(nZoneUp),'L',itoa(nZoneLevel[nZoneUp]),'%'"
    		//SEND_LEVEL dvCV7Tp, (nZoneUp),nZoneLevel[nZoneUp]
    	}
    }
    
    It just freaks out when I try to use the nZoneUp variable to reference which numbered array in nZoneLevel I wish to increment. Frustrated...
  • jjamesjjames Posts: 2,908
    You've created nZoneUp as an array (NON_VOLATILE INTEGER nZoneUp[] = {55,57}) but you are not using it as an array (nZoneLevel[nZoneUp] ++);

    Your button event could be along the lines of:
    BUTTON_EVENT[dvCV7Tp,nZoneUp]  //Zone VOL3 Up Commands
    {
    	PUSH:
    	{
    		nZoneLevel[[B]GET_LAST(nZoneUp)[/B]] ++
    		//SEND_COMMAND dvVOL1, "'P',itoa([B]GET_LAST(nZoneUp)[/B]),'L',itoa(nZoneLevel[[B]GET_LAST(nZoneUp)[/B]]),'%'"
    		//SEND_LEVEL dvCV7Tp, ([B]GET_LAST(nZoneUp)[/B]),nZoneLevel[[B]GET_LAST(nZoneUp)[/B]]
    	}
    }
    

    However, I'd insert a STACK_VAR INTEGER nIND in the start of the event, and then an nIND = GET_LAST(nZoneUp) right after it, then replace all the instances of GET_LAST in the modified code with nIND. So instead of nZoneLevel[GET_LAST(nZoneUp)], it'd be nZoneLevel[nIND].

    Hope that helps!
  • vegastechvegastech Posts: 369
    Thanks, That worked! I also added a little IF statement for the variable, so that it would not increase over 100 or decrease below 0:
    IF (nZoneLevel[nIND]<100)
    		{
    			nZoneLevel[nIND] ++
    		}
    
    The level bars and variables started acting oddly otherwise.
Sign In or Register to comment.