How to make the volume ramp with calculation.
espen.sandorf
Posts: 29
Hi all..
I have a Mixer / volume control which i want to use to change the volume. the problem is that it needs a string where the last to digits represents the ascii of the numbers 0 - 255. How can i make this ramp using calculation. i've added the code i'm trying to use. and a cutout from the manual of the mixer.
Thanks in advance.
Sent to Unit
!04SR01XX<CR>
Set Source Volume
XX = Volume setting ranging from 00 – FF with FF being volume control at
full and 00 being minimum volume. The 256 volume steps are internally
scaled in the IN600 from the 65 available volume steps.
Received from Unit
*01SR01XX<CR>
Source volume value
XX = Volume setting ranging from 00 – FF with FF being volume control at
full and 00 being minimum volume. The 256 volume steps are internally
scaled in the IN600 from the 65 available volume steps.
See note below for more information on volume scaling
I have a Mixer / volume control which i want to use to change the volume. the problem is that it needs a string where the last to digits represents the ascii of the numbers 0 - 255. How can i make this ramp using calculation. i've added the code i'm trying to use. and a cutout from the manual of the mixer.
Thanks in advance.
Sent to Unit
!04SR01XX<CR>
Set Source Volume
XX = Volume setting ranging from 00 – FF with FF being volume control at
full and 00 being minimum volume. The 256 volume steps are internally
scaled in the IN600 from the 65 available volume steps.
Received from Unit
*01SR01XX<CR>
Source volume value
XX = Volume setting ranging from 00 – FF with FF being volume control at
full and 00 being minimum volume. The 256 volume steps are internally
scaled in the IN600 from the 65 available volume steps.
See note below for more information on volume scaling
BUTTON_EVENT[dvTP,cVolButs]//998=VOL NED, 999=VOL OPP { hold[1,repeat]: { SWITCH(BUTTON.INPUT.CHANNEL) { CASE 999: SEND_STRING dvMixer,"'!04SR01'(nVolume+01),$0D" CASE 998: SEND_STRING dvMixer,"'!04SR01'(nVolume-01),$0D" } } } DATA_EVENT[dvMixer] { STRING: { SELECT { ACTIVE(FIND_STRING(DATA.TEXT,'*01SR01',1)): { nVolume = Right_String(DATA.TEXT,2) SEND_LEVEL dvTP,5,nVolume SEND_COMMAND dvTP,"'^TXT-5,0,',ITOA((nVolume*100)/255),'%'" } } } }
0
Comments
Might want to add some more logic to keep the volume from wrapping around (over 255 or under 0, which would underflow into 65535)
[/QUOTE]
I think that will do what you need. For the raise/lower buttons, you were not saving the value changes to the volume, so the volume would never change. You might also want to consider moving more than a value of 1 each time. If you are happy with the ramp speed, you could just change to nVolume = nVolume +/- 5 and increase the hold time to 5. This will reduce traffic considerably and I doubt you will notice the difference audibly.
I also changed the incoming string handler a little. First, you were not accounting for the <CR> at the end of the string, so you were only grabbing the last hex digit in the volume, not both of them. Second, I would recommend using CREATE_BUFFER and parsing the buffer on a string event. The code provided can easily be changed to work on a buffer variable. This will handle messages that are split by the processor into two or more string events.
Jeff
The button event looks good and i understand what it's doing. But i will have a problem with the data_event if it does not work. cause i have no idea what it actually does. i'm not to experienced so i'm trying to keep the code simple so i can modifie it myself if needed. Would the previos data_event work.
Thank you very much for your help.
Thanks
Jeff
I guess no one will go to max or min so its really no big deal.
espen
s_theHexValue = right_string("'0',itohex(i_theDecValue)",2);
This will make sure it's always padded by a zero when needed.
s_theHexValue = format('%02X',i_theDecValue)
Thats probably why the feedback stops at 6 percent, where in this code will i do the formatting?
Joe - I *ALWAYS* forget about the FORMAT command, probably because the documentation is poor in my opinion, and needs more examples with what you could do with it. It confuses the heck out of me, so I just do stuff like I posted. :-)