Android Question which is the corresponding to basic 4 android

Enthousiastic

Active Member
Licensed User
Hello i have the following formula ( i think is in c or vb ) :

input is the sample from a sound file and in in_db is converted to db

in_db=log(abs(input) *6/log(2))

x is the point of x axis in db volume meter

x=floor(exp(log(1.55)*2.1 * in_db ) * 285)

Can you tell me which is the corresponding code to basic 4 android for in_db and x ?

I have question about exp .

Can you help me please ?
 

RandomCoder

Well-Known Member
Licensed User
I don't know what numbers to punch into the variable 'input' or what to expect to get out of 'x' but I think that the equation would look something like my code below, however I have a feeling that this is not working correctly! I've assumed that all logarithms are working on base 10?
B4X:
Sub Convert_dB(input As Float) As Double
    Dim in_db As Float
    Dim x As Double
    Dim lBase As Float: lBase = 10
    in_db = Logarithm(Abs(input)*6/Logarithm(2,lBase),lBase)
    x = Floor(Power(1, Logarithm(1.55,lBase)*2.1*in_db)*285)
    Return x
End Sub
 
Top