Home AMX User Forum AMX Technical Discussion

BIAMP volume control, using rs232

i had a project which is needed to interface with biamp's rs232.
no matter what the code is, just would like to know how to convert the scale of the fader to a percentage for feedback, it makes me pull my head out.

ok.
1st i ask for biamp's fader value,
then i can use increase vol code to ramp it up,or down
however the feedback is needed to be a percentage, as if you know, the scale of a fader is not that smooth when it close to 0 db especially in the range of 0 - 12db.
i need to scale it at the site as well.

is that any code i can just convert and define a scale by myself in amx?

Comments

  • JohnMichnrJohnMichnr Posts: 279
    I've worked a bunch with Biamps, and I hate to admit it but I don't query the volume level. I just send it a level to go to. I query the level at power on for the system in case the audio guy has changed it.

    I have not found the need to sclae teh volume any differently depending on where the level is.

    The Biamp runs from -100 to +12 a total of 112 steps. Realistically anything lower than -40 is probably pointless, so for most things I set a minimum level of -40, althought I have a constant to adjust that and the maximum level.

    I use a signed integer and run my volume from my nminimum to my maximum, note that either can be negative. I also use a constant to allow me to change my increment/decrement amount, Usually I use 2.

    note that all of these can be arrays
    define_constant
    sinteger nVolMax = -40 //minimum volume
    sinteger nVolMax = 12 // mamimum volume
    sinteger nVOlChange = 2 //increment/decrement amount
    
    
    define_variable
    sinteger sVolLevel //the volume level
    
    //vol up command - this can be in teh button press or in a timeline for multiples
    if(sVolLevel<nVolMax-nVolChange)
    {
      sVolLevel = sVolLevel+nVolChange
    }
    else
      sVolLevel = nVolMax
    
    
    //vol down command 
    if(sVolLevel>nVolMin+nVolChange)
    {
      sVolLevel = sVolLevel-nVolChange
    }
    else
      sVolLevel = nVolMin
    
    
    Level scaling
    
    Send_level, TP, 1, ((svolLevel-nVolMin) * 255/(sVolMax-sVolMin))
    
    
    
    

    that takes your range of volume levels from your minium to your maximum and scales it to the 0-255 for the bar graph
  • kbeattyAMXkbeattyAMX Posts: 358
    i had a project which is needed to interface with biamp's rs232.
    no matter what the code is, just would like to know how to convert the scale of the fader to a percentage for feedback, it makes me pull my head out.

    ok.
    1st i ask for biamp's fader value,
    then i can use increase vol code to ramp it up,or down
    however the feedback is needed to be a percentage, as if you know, the scale of a fader is not that smooth when it close to 0 db especially in the range of 0 - 12db.
    i need to scale it at the site as well.

    is that any code i can just convert and define a scale by myself in amx?

    Just general information.

    To scale a range of values:
    Determine the Range of values to be scaled. Subtract the low from the high. If you are working with signed values remove the negative sign and add the 2 values.
    Determine the Range you want to go to. Percent is 100. AMX bars are 255 (default)
    Now multiply the unscaled value by the range you want to go to.
    Then divide it by the range that you are coming from.
    So you have this: ( UnScaledValue*NewRange)/OldRange = ScaledValue
    Example: (25*255)/100 = 63 (integer math dropping the float) So 25% of 255 is 63.
  • THX for the code and explainations, they are useful

    However, for more details, as if you are a audio tech u will know that, 2 db is a lot when close to 0db, because 3 db is doubled the volume already.

    however the 2 db when close to -40 db is nth.

    so if just simply write 2 db per press, the volume will go up really fast at the end.

    will that be sth like:

    if nCurVol < -5

    nCurVol = nCurVol + 2

    else if nCurVol>-5

    nCurVol = nCurVol + 0.5

    however there have no data type to support negative floating point, may be just multi it by 10 then divide it back when doing the scaling
  • JohnMichnrJohnMichnr Posts: 279
    you can certianly scale the increment value if you chose by where the current gain level is. for the lower levels increment/decrement by a greater level and by a lessor level in the upper regions.

    if(cVolLevel<=-30 && cVolLevel >=-40)
    nVolChange = 5

    etc.


    But I don't believe you really need to do that. I started in audio production doing live sound and recording before going into programming. A dB is a ratio between 2 levels. It is a linear scale. The electrical, or accoustical, power is changing non-linearly, but we convert that with logs to a linear change. 2 dB is 2dB no matter where it is is the overall level scale.

    Anytime you double the electrical power of a circuit you increase by 3dB the audio level. That happens between -40dB and -37dB, as well as 0dB to +3dB.
  • yuriyuri Posts: 861
    normally we scale the volume to stop at -40 db or something.
    The AMX level gets somewhat more accurate this way...
  • csappcsapp Posts: 10
    Requesting current level values from a nexia unit

    I know this thread is a year old, but I wanted to post code that can detect the current level value. I have it set to call this for each of my microphone levels whenever the "Volume" page is selected on a nxt-cv7 touchpanel. There are several levels above this one, so I have a wait statement that increments by 5 before each new level check. It does take up to 6 seconds for the page to refresh every level, so I am thinking about only doing this on a power loss event from one of the panels. However, people do adjust volume from davinci also, so I might just leave this and mess with the wait timing. I am connected via rs-232 to a biamp nexiavc and a nexiaTC but I will just list what I have for one of the VC levels since the code would be the same for either. I had a lot of trial and error with this to get the wait times down but found that removing them resulted in no data feedback.

    Data_event[BIAMPVC]

    {
    Online:
    {
    SEND_COMMAND BIAMPVC,'SET BAUD 38400,N,8,1'
    }

    Offline:
    {
    }
    String:
    {

    s_buffervc="data.text"

    }
    }




    button_event[vTP,4] //volume page selected from menu
    [
    PUSH:

    wait 50 //there are several volume levels before this one and the wait is incremented by 10 for each one. Try lowering the wait times to see what the threshold is.
    {
    {
    s_buffervc = "" // clears out any previous values
    wait 3
    {
    SEND_STRING BIAMPVC,"'GET 0 AECINPLVL 11 1',10"
    {
    WAIT 1
    {
    SET_LENGTH_STRING(S_BUFFERVC,LENGTH_STRING(s_buffervc)-8) //the -8 takes out the extra decimal places in the response. In their manual it says that it will output 4 decimals places but I have found that it is much more.
    {
    SEND_COMMAND vTP,"'^TXT-5,0,',S_BUFFERVC" //I have the level feedback in numeric form instead of bargraph form due to space limitations but it still looks really nice.
    }
    }

    }

    }
    }
    }
    }
  • Scaling function

    you may use the fnScaleRange() function from the attached Math.axi. Pretty simple to use.
    It's attached as "Math.axs", because uploading an AXI is not possible. Simply rename the filetype.

    Regarding the Audia/Nexia protocol: there are also commands implemented SETD and GETD. Using these command types, the unit will respond with the full parameter path, instead of just responding with a +OK (SET/SETL) or a value (GET/GETL). More data to parse, but much more reliable, and it is also not required to remember what control object you have set or requested previously. Protocols attached.
  • HedbergHedberg Posts: 671
    edit:[So, this is basically the same as Marc's suggestion which beat mine by a couple minutes.]
    csapp wrote: »
    I know this thread is a year old, but I wanted to post code that can detect the current level value. I have it set to call this for each of my microphone levels whenever the "Volume" page is selected on a nxt-cv7 touchpanel. There are several levels above this one, so I have a wait statement that increments by 5 before each new level check. It does take up to 6 seconds for the page to refresh every level, so I am thinking about only doing this on a power loss event from one of the panels. However, people do adjust volume from davinci also, so I might just leave this and mess with the wait timing. I am connected via rs-232 to a biamp nexiavc and a nexiaTC but I will just list what I have for one of the VC levels since the code would be the same for either. I had a lot of trial and error with this to get the wait times down but found that removing them resulted in no data feedback.

    Ok, you are using the GET command which will just spit back a numeric response without any identification as to which GET command it is a response to. You are keeping track of which query it is a response to by timing. There are two ways that you can speed this up.

    1. You can queue your queries and time them with a wait_until and a variable.

    2. Probably easier, you can use the GETD command which will include details of the command that the response is a response to. Then you can parse and sort the response rather than relying on query timing. With a biamp, I do this with a timeline that fires every 100 ms (.1 sec). I suspect that the Biamp probably responds quickly enough (or has a sufficient buffer) so that you could run the queue at 50 ms, but I've never tried it.

    here's a bit of how you might do this parsing:
    float float_Mic_Level[12]
    integer nIndx
    
    
    if(find_string(bufferVC, 'AECINPLVL 11 ' ))
    {
       sTempBuff = remove_string(bufferVC,'AECINPLVL 11 ')
       nIndx = atoi(bufferVC)
       sTempBuff = remove_string(bufferVC,' ')
       float_mic_level[nIndx] = atof(bufferVC)
    }
    

    Then you may scale the gain value for a gauge display, if you like, or use ftoa for an ascii display. Won't have to bother with those pesky zeroes.

    Anyway, that's something for you to consider.
  • Explanations above are really all you need, but after you parse the incoming string for the Biamp level (0 to 1120) you could use the following function to scale the % for your touch panel. Just make sure that your UI is set up for 0 to 100 on the level in TPD4.
  • csappcsapp Posts: 10
    thanks!

    Wow these methods are awesome! Thanks! I have a nasty habit of making things more complicated than they need to be.
  • DHawthorneDHawthorne Posts: 4,584
    If you are using a G4 panel and the bargraph is not displaying multiple devices with different scales, you don't have to scale it at all. Just adjust the range high and range low values in the bargraph properties. They even accept negative values.
Sign In or Register to comment.