1

I have a graph of a sound wave in a linear display :

enter image description here

I need to get a graph of the sound wave in logarithmic form, namely :

enter image description here

The wave values are displayed in symmetrical mode. Here's what the wave display will look like without symmetric mode:

enter image description here

The boundaries of this graph are between 0 and 127.

My task is to convert the received linear points (from 0 to 127) into logarithmic points (also from 0 to 127).

What formula should I use ?

bbdd
  • 13

1 Answers1

0

Let $(x_1,y_1)=(0,0)$ be a start point and $(x_2,y_2)=(127,127)$ be a end point. Moreover let $c>1$ be a logarithm base. We have to find linear function $$h(x)=ax+b\quad\quad (1)$$ such that $$\begin{cases} h(0)=1\\ h(127)=c^{127} \end{cases}\quad\quad (2) $$ then final formula (or function) will be: $$ f(x)=\log_c h(x)$$ becouse $f(0)=\log_c h(0)=\log_c 1=0$ and $f(127)=\log_c h(127)=\log_c c^{127}=127$. Lets find now $a$ and $b$ in (1) using conditions from (2): $$\begin{cases} h(0)=1\\ h(127)=c^{127} \end{cases}\Rightarrow \begin{cases} a\cdot 0 + b = 1\\ a\cdot 127 + b=c^{127} \end{cases}\Rightarrow \begin{cases} b = 1\\ a =\frac{c^{127}-1}{127} \end{cases}, $$ so $h(x)=ax+b=\frac{c^{127}-1}{127}x + 1$ and thus your formula is: $$ f(x)=\log_c\left(\frac{c^{127}-1}{127}x + 1\right) \quad\quad (3) $$ I assume, that you will use it to processing sound data on computer, whereas $c^{127}$ is huge number. We can (3) write also as: $$ f(x)=\log_c\left(\frac{c^{y_2}-1}{y_1}x + 1\right) $$ and now if you first get formula for e.g. $y_2=30$ and then miltiple this logarithm by $\frac{127}{y_2}$ then the result will be similar, but with smaller numbers, i.e.: $$ f(x)=\frac{127}{30}\cdot\log_c\left(\frac{c^{30}-1}{127}x + 1\right) $$ Also choice of $c$ will has impact on final result and calculation speed, I supose.

jorlinski
  • 394