Hello,

I record successfully the sound signal by ADC, which gives enough data-points. After that, I need to do signal processing to detect the envelop of the signal. What is the best way to do that with Photon?

Thanks

Hello,

I record successfully the sound signal by ADC, which gives enough data-points. After that, I need to do signal processing to detect the envelop of the signal. What is the best way to do that with Photon?

Thanks

Hi @tn0432

With the sampled points, you have the “envelope” of the audio signal, so I am having trouble understanding what you are trying to do.

Can you say exactly what you want to accomplish with this audio signal?

Are you trying to detect some specific sound or maybe threshold to separate loud from quiet?

Hello @bko

Yup, my record signal looks like the red line in the figure. I would like to detect its envelope. I also intend to separate loud from quiet. Hope you can help! Very appreciate!

Hi @tn0432

Fair warning: the math gets a bit harder to understand here, but the usual way to create the envelope of the “red” signal above would be to create the analytic signal using a Hilbert transformer (a special kind of filter) and then the envelope is just the complex magnitude or abs or sqrt(I^2+Q^2). Normally you low-pass filter the input and Hilbert transformed signals to avoid measuring both the upper and lower sidebands, but that is optional.

It looks like you are using MATLAB or similar for your plot there, so in MATLAB you would do:

```
% assume xin is real-only input signal
H = hilbert(xin); % complex result
Env = abs(H); % or sqrt(real(H)^2+imag(H)^2)
plot(Env)
```

So if you want to do this on your Photon, you need to decide things like:

- Floating point or integer math?
- How accurate a frequency response do I need? This controls the filter length.
- Low-pass filtering on the real and imag parts-do I need it?
- Real-time or offline? There is a fair bit of math to do.
- This algorithm is very sensitive to the phase angle between the input and analytic signal so many times the output signal is rotated 45 degrees so that both I and Q are generated by the Hilbert transformer. This can improve accuracy but it is more math per input sample.

Or you could do something cheesy and rectify the signal, then take the derivative and make a piecewise-linear function out of the places where dy/dx changes sign and y != 0.

edit: (alternatively, plotting y where dy/dx changes from + to -, ignoring - to +)