# Delta between two decibel signal

**URL:** https://discourse.processing.org/t/delta-between-two-decibel-signal/41442
**Category:** Coding Questions
**Created:** [March 25, 2023, 4:57pm UTC](https://discourse.processing.org/t/delta-between-two-decibel-signal/41442 "2023-03-25T16:57:01Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![bking](https://avatars.discourse-cdn.com/v4/letter/b/dc4da7/32.png) [@bking](https://discourse.processing.org/u/bking)
#### Post date: [March 25, 2023, 4:57pm UTC](https://discourse.processing.org/t/delta-between-two-decibel-signal/41442/1 "2023-03-25T16:57:01Z")

</div>

Hi,  
I’m trying to return the difference between to signal.  
The difference is L1  
 ![Capture d’écran 2023-03-25 à 17.53.04](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/4/4/44fb4a81907a2145045c0e040a9a57e76e59276e.png)  
I tried this but the problem is with pow  
Thanks for helping 😉

```auto

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));
}

```

---

<div class="post-metadata">

### Author: ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)
#### Post date: [March 25, 2023, 5:28pm UTC](https://discourse.processing.org/t/delta-between-two-decibel-signal/41442/2 "2023-03-25T17:28:49Z")

</div>

Hi @bking,

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

[https://processing.org/reference/pow\_.html](https://processing.org/reference/pow_.html)

Cheers  
— mnse

---

<div class="post-metadata">

### Author: ![bking](https://avatars.discourse-cdn.com/v4/letter/b/dc4da7/32.png) [@bking](https://discourse.processing.org/u/bking)
#### Post date: [March 25, 2023, 5:50pm UTC](https://discourse.processing.org/t/delta-between-two-decibel-signal/41442/3 "2023-03-25T17:50:15Z")

</div>

I tried this but not good

```auto
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));
}

```

---

<div class="post-metadata">

### Author: ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)
#### Post date: [March 25, 2023, 5:57pm UTC](https://discourse.processing.org/t/delta-between-two-decibel-signal/41442/4 "2023-03-25T17:57:56Z")

</div>

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

Cheers  
— mnse

---

<div class="post-metadata">

### Author: ![bking](https://avatars.discourse-cdn.com/v4/letter/b/dc4da7/32.png) [@bking](https://discourse.processing.org/u/bking)
#### Post date: [March 25, 2023, 6:27pm UTC](https://discourse.processing.org/t/delta-between-two-decibel-signal/41442/5 "2023-03-25T18:27:51Z")

</div>

i have infinity as result

```auto
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));
}

```

---

<div class="post-metadata">

### Author: ![bking](https://avatars.discourse-cdn.com/v4/letter/b/dc4da7/32.png) [@bking](https://discourse.processing.org/u/bking)
#### Post date: [March 25, 2023, 6:29pm UTC](https://discourse.processing.org/t/delta-between-two-decibel-signal/41442/6 "2023-03-25T18:29:04Z")

</div>

I think it is ok now !

```auto
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!

---

<div class="post-metadata">

### Author: ![bking](https://avatars.discourse-cdn.com/v4/letter/b/dc4da7/32.png) [@bking](https://discourse.processing.org/u/bking)
#### Post date: [March 25, 2023, 6:34pm UTC](https://discourse.processing.org/t/delta-between-two-decibel-signal/41442/7 "2023-03-25T18:34:42Z")

</div>

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

```auto
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));
}

```

---

<div class="post-metadata">

### Author: ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)
#### Post date: [March 26, 2023, 3:17pm UTC](https://discourse.processing.org/t/delta-between-two-decibel-signal/41442/8 "2023-03-26T15:17:29Z")

</div>

> [@bking](#):
>
> Maybe the difference between two signals have to respect a rule?

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. 😄
