Home AMX User Forum NetLinx Studio

SEND LEVEL TO MET-6N

I am trying to send volume info from an Autopatch 18x18 Precis DSP matrix switcher to the bargraph on a MET-6N keypad. The string from the device displays volume from '( -700 )' to '( 100 )' which is -70dB to +10dB. How do I store this info and then change the range to 0-255 so I can display the volume on the bargraph? I'm running into issues with type conversions.

Comments

  • Yeah I've seen that post. I actually have the code saved as an include file. My issue is when I ATOI the string I get a signed integer. I then add 700 multiply by 255 and divide by 800 to scale it. For some reason this returns zero.

    To solve the problem I ended up doing this...
    IF(FIND_STRING(sAUDIO_SWITCH_VOLUME,'M',1))
    		{
    		    nAUDIO_SWITCH_VOLUME[nAUDIO_SWITCH_OUTPUT] = -700
    		    ON[nAUDIO_SWITCH_MUTE[nAUDIO_SWITCH_OUTPUT]]
    		    nVOL = 0
    		}
    		ELSE IF(FIND_STRING(sAUDIO_SWITCH_VOLUME,'-',1))
    		{
    		    nAUDIO_SWITCH_VOLUME[nAUDIO_SWITCH_OUTPUT] = (ATOL(RIGHT_STRING(sAUDIO_SWITCH_VOLUME,(nSTRING_LENGTH -1))) * (-1))
    		    OFF[nAUDIO_SWITCH_MUTE[nAUDIO_SWITCH_OUTPUT]]
    		    GET_BUFFER_CHAR(sAUDIO_SWITCH_VOLUME)
    		    nVOL = (((700 - ATOI(sAUDIO_SWITCH_VOLUME)) * 255) / 800)
    		    
    		}
    		ELSE
    		{
    		    nAUDIO_SWITCH_VOLUME[nAUDIO_SWITCH_OUTPUT] = (ATOL(sAUDIO_SWITCH_VOLUME))
    		    OFF[nAUDIO_SWITCH_MUTE[nAUDIO_SWITCH_OUTPUT]]
    		    nVOL = ((((ATOI(sAUDIO_SWITCH_VOLUME))+700) * 255) / 800)
    		}
                    fnAUDIO_SWITCH_VOLUME_UPDATE(nAUDIO_SWITCH_OUTPUT,nVOL)
    

    This works fine when I send nVOL to my update level function.
  • ericmedleyericmedley Posts: 4,177
    what I do is add an offset to the value coming in so it is always positve. It's lazy, but it does work.
Sign In or Register to comment.