Programming NXC-VOL4
undrtkr
Posts: 35
in AMX Hardware
This is the first time I've had to program one of these devices and unfortunately it has been shipped to site before I've had a chance to play with it. Looking at the quick start guide I think I have an idea of how to ramp the channels but I wanted to run by some code with you guys first to make sure it will work.
The plan is to ramp all four channels simultaneously with the same volume level. I plan on setting a variable to ramp between 0-255 and send it out to the card. I'm not interesting in parsing the volume state from the card. Here is the basic code I plan to use.
DEFINE_DEVICE
dvVolume1 = 5002:1:0 //Port 1 for NXC-VOL4 Card
dvVolume2 = 5002:2:0 //Port 2 for NXC-VOL4 Card
dvTP1 = 10001:1:0
vdvVolume = 33002:1:0 //Virtual Device for Volume
DEFINE_COMBINE
(vdvVolume, dvVolume1, dvVolume1)
DEFINE_CONSTANT
cVolumeMin = 0
cVolumeMax = 255
cVolumeRampSpeed = 8
DEFINE_VARIABLE
PERSISTENT INTEGER nVolumeLevel //Tracks Volume Level Status
DEFINE_EVENT
BUTTON_EVENT[dvTP1,8] //Volume Up
BUTTON_EVENT[dvTP1,9] //Volume Down
{
PUSH:
{
SELECT
{
ACTIVE(BUTTON.INPUT.CHANNEL = 8):
{
IF(nVolumeLevel < cVolumeMax)
{ //Will not Ramp Volume Up if Volume Max has Been Reached
IF(nVolumeLevel < (cVolumeMax - cVolumeRampSpeed))
{ //If Threshold isn't met Volume Level is Incremented by Volume Speed
nVolumeLevel = nVolumeLevel + cVolumeRampSpeed
}
ELSE
{ //If Threshold is met Volume Level is Incremented by 1
nVolumeLevel = nVolumeLevel + 1
}
}
}
ACTIVE(BUTTON.INPUT.CHANNEL = 9):
{
IF(nVolumeLevel > cVolumeMin)
{ //Will not Ramp Volume Down if Volume Min has Been Reached
IF(nVolumeLevel > (cVolumeMin + cVolumeRampSpeed))
{ //If Threshold isn't met Volume Level is Decreased by Volume Speed
nVolumeLevel = nVolumeLevel - cVolumeRampSpeed
}
ELSE
{ //If Threshold is met Volume Level is Decreased by 1
nVolumeLevel = nVolumeLevel - 1
}
}
}
}
SEND_COMMAND vdvVolume, "'P0L',ITOA(nVolumeLevel)" //Send Level to NXC-VOL4
SEND_LEVEL dvTP1,1,nVolumeLevel //Bargraph on Touch panel
}
}
The plan is to ramp all four channels simultaneously with the same volume level. I plan on setting a variable to ramp between 0-255 and send it out to the card. I'm not interesting in parsing the volume state from the card. Here is the basic code I plan to use.
DEFINE_DEVICE
dvVolume1 = 5002:1:0 //Port 1 for NXC-VOL4 Card
dvVolume2 = 5002:2:0 //Port 2 for NXC-VOL4 Card
dvTP1 = 10001:1:0
vdvVolume = 33002:1:0 //Virtual Device for Volume
DEFINE_COMBINE
(vdvVolume, dvVolume1, dvVolume1)
DEFINE_CONSTANT
cVolumeMin = 0
cVolumeMax = 255
cVolumeRampSpeed = 8
DEFINE_VARIABLE
PERSISTENT INTEGER nVolumeLevel //Tracks Volume Level Status
DEFINE_EVENT
BUTTON_EVENT[dvTP1,8] //Volume Up
BUTTON_EVENT[dvTP1,9] //Volume Down
{
PUSH:
{
SELECT
{
ACTIVE(BUTTON.INPUT.CHANNEL = 8):
{
IF(nVolumeLevel < cVolumeMax)
{ //Will not Ramp Volume Up if Volume Max has Been Reached
IF(nVolumeLevel < (cVolumeMax - cVolumeRampSpeed))
{ //If Threshold isn't met Volume Level is Incremented by Volume Speed
nVolumeLevel = nVolumeLevel + cVolumeRampSpeed
}
ELSE
{ //If Threshold is met Volume Level is Incremented by 1
nVolumeLevel = nVolumeLevel + 1
}
}
}
ACTIVE(BUTTON.INPUT.CHANNEL = 9):
{
IF(nVolumeLevel > cVolumeMin)
{ //Will not Ramp Volume Down if Volume Min has Been Reached
IF(nVolumeLevel > (cVolumeMin + cVolumeRampSpeed))
{ //If Threshold isn't met Volume Level is Decreased by Volume Speed
nVolumeLevel = nVolumeLevel - cVolumeRampSpeed
}
ELSE
{ //If Threshold is met Volume Level is Decreased by 1
nVolumeLevel = nVolumeLevel - 1
}
}
}
}
SEND_COMMAND vdvVolume, "'P0L',ITOA(nVolumeLevel)" //Send Level to NXC-VOL4
SEND_LEVEL dvTP1,1,nVolumeLevel //Bargraph on Touch panel
}
}
0
Comments
I'm not sure why you plan to vary the volume ramp speed. I have done that on quite a few things (such as camera pan/tilt depending upon the zoom/wide) I really don't think you need to do variable ramp speed on the AMX vol cards. They're really setup pretty well as it is.
Having said that, and, if you agree to that, here's a very easy way to accomplish controlling volume of all four channels at once.
DEFINE_DEVICE
dv_VOL_PORT_1 = 5002:01:0
dv_VOL_PORT_2 = 5002:02:0
dv_TP=10001:01:0
BUTTON_EVENT[dv_TP,1] // volume up
BUTTON_EVENT[dv_TP,2] // volume down
{
PUSH:
{
vTP_Button_Pushed=BUTTON.INPUT.CHANNEL
TO[dv_VOL_PORT_1,vTP_Button_Pushed+3] // 4=ramp ch1 up 5=ramp ch 1 down
} // END PUSH:
} // END BUTTON_EVENT
LEVEL_EVENT[dv_VOL_PORT_1,1]
{
vCurrent_Volume_Level=LEVEL.VALUE
SEND_LEVEL dv_VOL_PORT_1,2,vCurrent_Volume_Level
SEND_LEVEL dv_VOL_PORT_2,1,vCurrent_Volume_Level
SEND_LEVEL dv_VOL_PORT_2,2,vCurrent_Volume_Level
}
Using the level event to manage the other levels will ensure that you're keeping all 4 levels the same.
You can obviously capture the level coming back to store in a variable and / or send the level to a fader on the touch panel.
The manual pages are pretty helpful with this stuff.
Hope that helps
I would suggest that allowing a volume of zero is a potential user trap - it's possible to set the volume so low that it looks like it's broken or muted - so set a minimum volume which is just audible in the room(s). Might be 2, might be 200.
Likewise a maximum volume of 255 might be a very bad idea - experiment and find the loudest bearable volume and limit it to that.
Then set your ramping increment at 5% of the difference between the minimum and maximum, or 7%, or 3%, or whatever feels right for subtle control of program volume at normal levels eg listening to music and talking over it.
Of course you also need to set a "normal" level to default to at start of session, day, week, or reboot.