Home AMX User Forum NetLinx Studio

Clearone Level 2 TP Bargraph

Since the clearone calculates all its ramping and gaining on a "DB" figure how should I throw this value to a TP bargraph I know there is some setting and or formula involved


level_event [dvClear1,1]
{
ClearVolResp = Level.sourcedev
send_level dvTP, 1, level.value
}


I get a error on compile, convert type dev to integer

Comments

  • avi_dave wrote:
    Since the clearone calculates all its ramping and gaining on a "DB" figure how should I throw this value to a TP bargraph I know there is some setting and or formula involved


    level_event [dvClear1,1]
    {
    ClearVolResp = Level.sourcedev
    send_level dvTP, 1, level.value
    }


    I get a error on compile, convert type dev to integer

    The compile error is probably because of

    ClearVolResp = Level.sourcedev

    The RHS is a device, presumably the LHS is not.

    Here is my code to adjust from the ClearOne AP800's range of -20..+20 to a range of 0..255
    sinteger siVolumeMinimum = -20 (* or -66 depending on model *)
    sinteger siVolumeMaximum = 20
    
    sMyValue = itoa(type_cast(SignedAdjustFrom255(nArgVolume,siVolumeMinimum,siVolumeMaximum)))
    
    (******************************************************************************)
    define_function sinteger SignedAdjustFrom255( (* Result in range below        *)
       integer  nArgValue                  , (* Input  - Value in range 0 - 255   *)
       sinteger siArgMinimum               , (* Input  - Minimum input value      *)
       sinteger siArgMaximum               ) (* Input  - Maximum input value      *)
    (******************************************************************************)                 
    {
    stack_var sinteger siMyValue
    
    (* Have to do this to avoid a compiler warning *)
    siMyValue                                        = type_cast(nArgValue)
    
    return ((siMyValue * (siArgMaximum - siArgMinimum)) / 255) + siArgMinimum;
    } (* SignedAdjustFrom255 *)   
    

    However that's the wrong direction. I haven't yet had to code SignedAdjustTo255 but here is the unsigned version:
    (******************************************************************************)
    define_function integer AdjustTo255    ( (* Output - Result in range 0 - 255  *)                                                             
       integer nArgValue                   , (* Input  - Value to convert         *)
       integer nArgMinimum                 , (* Input  - Minimum input value      *)
       integer nArgMaximum                 ) (* Input  - Maximum input value      *)
    (******************************************************************************)                 
    {
    return (((nArgValue - nArgMinimum) * 255) / (nArgMaximum - nArgMinimum));
    } (* AdjustTo255 *) 
    
Sign In or Register to comment.