# Delta between two decibel signal

Hi,
I’m trying to return the difference between to signal.
The difference is L1 I tried this but the problem is with pow
Thanks for helping float splitTimeLfo, oldSplitTimeLfo;

void setup() {
int i = 12;
println(log(i));
println(log10(i));
//  float differenceSignal=  splitTimeLfo + log10( 1 - 10 * pow (-(splitTimeLfo-oldSplitTimeLfo)/10));

print ( differenceSignal);
}

// Calculates the base-10 logarithm of a number
float log10 (float x) {
return (log(x) / log(10));
}



Hi @bking,

What is the problem with pow ?
Just use 1-pow(10,…)

https://processing.org/reference/pow_.html

Cheers
— mnse

I tried this but not good

float splitTimeLfo = 5;

float oldSplitTimeLfo = 15;

void setup() {
int i = 12;
println(log(i));
println(log10(i));
//  float differenceSignal=  splitTimeLfo + log10( 1 - 10 * pow (-(splitTimeLfo-oldSplitTimeLfo)/10));
float differenceSignal=  splitTimeLfo + log10( 1 - 10 -1-pow(10,-(splitTimeLfo-oldSplitTimeLfo)/10));

print ( differenceSignal);
}

// Calculates the base-10 logarithm of a number
float log10 (float x) {
return (log(x) / log(10));
}


Try to use floating point notation for your numbers.
Means not 10, but 10.0 etc …

Cheers
— mnse

i have infinity as result

float splitTimeLfo = 5;

float oldSplitTimeLfo = 15;

void setup() {
int i = 12;
println(log(i));
println(log10(i));
//  float differenceSignal=  splitTimeLfo + log10( 1 - 10 * pow (-(splitTimeLfo-oldSplitTimeLfo)/10));
float differenceSignal=  splitTimeLfo + log10( 1.0 - 10.0 -pow(1-10.0,-(splitTimeLfo-oldSplitTimeLfo)/10.0));

print ( differenceSignal);
}

// Calculates the base-10 logarithm of a number
float log10 (float x) {
return (log(x) / log(10));
}


I think it is ok now !

float splitTimeLfo = 5;

float oldSplitTimeLfo = 15;

void setup() {
int i = 12;
println(log(i));
println(log10(i));
//  float differenceSignal=  splitTimeLfo + log10( 1 - 10 * pow (-(splitTimeLfo-oldSplitTimeLfo)/10));
float differenceSignal=  splitTimeLfo + log10( 1.0 - 10.0 *pow(1-10.0,-(splitTimeLfo-oldSplitTimeLfo)/10.0));

print ( differenceSignal);
}

// Calculates the base-10 logarithm of a number
float log10 (float x) {
return (log(x) / log(10));
}


Thank u very much!

it works but not always.
Maybe the difference between two signals have to respect a rule?

float splitTimeLfo = 6;

float oldSplitTimeLfo = 5;

void setup() {
int i = 12;
//  println(log(i));
//  println(log10(i));
//  float differenceSignal=  splitTimeLfo + log10( 1 - 10 * pow (-(splitTimeLfo-oldSplitTimeLfo)/10));
float differenceSignal=  splitTimeLfo + log10( 1.0 - 10.0 *pow(1-10.0,-(splitTimeLfo-oldSplitTimeLfo)/10.0));

print (" differenceSignal " + differenceSignal);
}

// Calculates the base-10 logarithm of a number
float log10 (float x) {
return (log(x) / log(10));
}


The problem is that the log_{10} of a number \le0 is undefined. This means that the following must be true for a meaningful result

1 - 10^\left({-(L-L_2)\over10}\right) > 0

Rearrange the formula and we get
10^\left({-(L-L_2)\over10}\right) < 1

Now take the log_{10} of both sides are we get
\left({-(L-L_2)\over10}\right) < 0

multilply both sides by 10 and simplify the LHS we get
-L + L_2 < 0

Again after rearrangement
L > L_2

So (L > L_2) must be true for a meaningful result. 1 Like