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:
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 +)