Home AMX User Forum AMX General Discussion
Options

Volume up and down in a NXC_VOL4

I have to control a NXC_VOL4 with a keypad (MIO8) but I have only two buttons available to control de sound, and the client wants up and down. Normally I program the volume card with 4 or 5 fixed levels and I use the commands that come in the user manual.

But for this UP and DOWN issue I'm not sure how I can do. Something like create_level and send_level? How I use them?

Elena

Comments

  • Options
    AuserAuser Posts: 506
    Not sure what channels you need to control on the vol card, but here's a very basic example that should get you started.
    DEFINE_DEVICE
    dvKP      = 85:1:0  // The device should match whatever you're using
    
    DEFINE_CONSTANT
    char      LVL_VOL_CARD_CHANNEL_LEFT   = 1
    char      LVL_VOL_CARD_CHANNEL_RIGHT  = 2
    char      KP_VOL_UP                   = 6  // Or whatever they may be
    char      KP_VOL_DN                   = 7
    integer   KP_VOLUME_BUTTONS[]         = {KP_VOL_UP,KP_VOL_DN}
    
    DEFINE_VARIABLE
    integer    nVolume       = 0
    dev        dvVOL_CARD[]  = {1:1:0,1:2:0}   // The device should match whatever you're using
    
    DEFINE_EVENT
    button_event[dvKP,KP_VOLUME_BUTTONS]
    {
      hold[.9]:
      {
        switch(button.input.channel)
        {
          case KP_VOL_UP:
          {
            if(nVolume<255)
              nVolume++
          }
          case KP_VOL_DN:
          {
            if(nVolume>0)
              nVolume--
          }
        }
        send_level dvVOL_CARD, LVL_VOL_CARD_CHANNEL_LEFT, nVolume
        send_level dvVOL_CARD, LVL_VOL_CARD_CHANNEL_RIGHT, nVolume
      }
    }
    

    A few things to note:

    * The volume card channels can be controlled via levels 1 and 2 on each of ports 1 and 2 on the vol card device. Presumably AMX split them up like this so that programmatically the card behaves like two stereo pairs. The above code should ramp all four channels on the card together.
  • Options
    Joe HebertJoe Hebert Posts: 2,159
    Another way to ramp volume up or down from its current level is with the TO command inside the PUSH of the BUTTON_EVENT for your Mio Keypad. For example:
    BUTTON_EVENT[dvMio,5] { //volume up button
    
       PUSH: {
          
          TO[dvVol4,1] //ramps volume up on audio channels 1 and 2 of Vol4 card while button is held down
       }
    }
    
    BUTTON_EVENT[dvMio,6] { //volume down button
    
       PUSH: {
          
          TO[dvVol4,2] //ramps volume down on audio channels 1 and 2 of Vol4 card while button is held down
       }
    }
    

    The channel numbers for the Vol4 card are listed in a table on page 2 of the quick start guide.

    HTH
  • Options
    Assignment channels

    Thanks, I'll try both solutions to see what's the one that matcher better with my prog.

    Btw, the channels you are talking about are the assignment channels? I thought about using them because it seemed the easiest way but I didn't know how to use them. But I've call AMX UK yesterday and they told me no to use them :(

    I start to see some light :P
  • Options
    Joe HebertJoe Hebert Posts: 2,159
    lomeraniel wrote:
    Btw, the channels you are talking about are the assignment channels? I thought about using them because it seemed the easiest way but I didn't know how to use them. But I've call AMX UK yesterday and they told me no to use them :(
    Yes, the assignment channels. Not sure why UK would tell you not to use them. I've used them in the past without any problems.

    Good luck.
  • Options
    AuserAuser Posts: 506
    Joe Hebert wrote:
    Yes, the assignment channels. Not sure why UK would tell you not to use them. I've used them in the past without any problems.

    Either are quite acceptable, though I do tend to be fairly explicit in controlling devices and tracking their current state for various reasons. The choice really depends on what you're doing.
  • Options
    Nxc Vol 4

    I've tested on site yesterday with the TO inside the push and worked perfectly. Thanks ;)
Sign In or Register to comment.