[Scilab-users] Simulating phase modulation

Claus Futtrup cfuttrup at gmail.com
Sun May 27 15:15:58 CEST 2018


Hi Gary

Thanks for your input. I went the analytic route for now, and simplified a
bit (as you often do with analytic solutions). You're right that from an
electro-mechanical point of view, superposition applies, but as the waves
transmit in acoustics in air - not, I'm afraid, this is where we see the
distortion, simply because the speaker cone moves several millimeter.

Best regards,
Claus

On Sat, May 26, 2018 at 10:55 PM Gary Nelson <porpoiseseeker at gmail.com>
wrote:

> Claus,
>
> Back in the late 60s, I did my PhD research using analytic signal. Yes,it
> works, and the implementation details are more complex that we find on the
> link. A few years ago, I implemented a system for analyzing harbor porpoise
> vocalizations using scilab. For example, instantaneous phase(t) wants to be
> differentiable if instantaneous frequency is to be positive. I found that
> octave bands are the widest that preserves this feature. Yes, you can
> calculate phase(t) = atan(imaginary/real), but you have to add 2PI when
> atan wraps around in order to make phase monotonically increase.
>
>
>
> Also, I am not convinced that a loudspeaker does phase modulation.
> Certainly, if the speaker is linear, then superposition applies. If phase
> modulation occurs, it is a non-linear effect. Perhaps that effect is real,
> but we need to see a model to show how it comes to be.
>
>
>
> I might be able to help you write analytic signal  code.
>
>
>
> Good wishes
>
> Gary Nelson
>
>
>
>
>
> Sent from my Windows 10 phone
>
>
>
> *From: *Claus Futtrup <cfuttrup at gmail.com>
> *Sent: *Saturday, May 26, 2018 7:41 AM
> *To: *International users mailing list for Scilab.
> <users at lists.scilab.org>
> *Subject: *Re: [Scilab-users] Simulating phase modulation
>
>
>
> Hi Rafael
>
>
>
> Thank you, I shall print and study. :-)
>
>
>
> Cheers,
>
> Claus
>
>
>
> On Fri, May 25, 2018 at 8:42 PM Rafael Guerra <jrafaelbguerra at hotmail.com>
> wrote:
>
> Hi Claus,
>
>
>
> I am not aware of such function. However, you can find simple code here
> below for both phase modulation and demodulation, which is straightforward
> to translate in Scilab:
>
>
> https://www.gaussianwaves.com/2017/06/phase-demodulation-using-hilbert-transform-application-of-analytic-signal/
>
>
>
> Note that the phase modulation is coded differently from you snippet below.
>
>
>
> Regards,
>
> Rafael
>
>
>
> *From:* users [mailto:users-bounces at lists.scilab.org] *On Behalf Of *Claus
> Futtrup
> *Sent:* Friday, May 25, 2018 7:17 PM
> *To:* International users mailing list for Scilab. <users at lists.scilab.org
> >
> *Subject:* [Scilab-users] Simulating phase modulation
>
>
>
> Hi there
>
>
>
> In a loudspeaker the driver can move several millimeter in an attempt to
> reproduce a low-frequency note. If the speaker also at the same time
> produce a higher tone, this second tone is phase modulated by the first
> one. This is a distortion of the original signal which I'd like to simulate
> / illustrate with some simple Scilab code, if possible.
>
>
>
> In Matlab this can be simulated with pmmod.
>
> https://matlabandsimulink.wordpress.com/2013/03/12/phase-modulation/
>
>
>
> Is there a similar function in Scilab? (name - please ?)
>
>
>
> Here's the code I have written so far - this is the part that shows the
> input signal (the un-distorted signal):
>
>
>
> sample_rate=20000;
>
> t = 0:1/sample_rate:0.6;
>
> N=size(t,'*'); *//number of samples*
>
> y1 = sin(2*%pi*50*t);
>
> y2 = 0.5*sin(2*%pi*500*t);
>
> *// y2 = 0.5*sin(2*%pi*500*t+%pi/4);*
>
> s=y1+y2+grand(1,N,'nor',0,1);
>
>
>
> *// Plot time-domain*
>
> endplot = round(N/15);
>
> twoplots = scf(); *// Set Current Figure (Graphics Window)*
>
> subplot(211);
>
> plot(t(1:endplot),y1(1:endplot),t(1:endplot),y2(1:endplot));
>
> subplot(212);
>
> plot(t(1:endplot),y1(1:endplot)+y2(1:endplot));
>
>
>
> y=fft(s);
>
> ymax = max(abs(y));
>
> y = y ./ ymax; *// Normalize*
>
>
>
> *// s is real so the fft response is conjugate symmetric*
>
> *// and we retain only the first N/2 points*
>
> f=sample_rate*(0:(N/2))/N; *//associated frequency vector*
>
> n=size(f,'*');
>
> fftplots = scf();
>
> plot(f(2:$),abs(y(2:n))); *// drop first datapoint, f = 0 (it prevents log-plot)*
>
> a = gca();
>
> a.log_flags = "lnn";
>
>
>
> Best regards,
>
> Claus
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
>
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20180527/4d715dee/attachment.htm>


More information about the users mailing list