[Scilab-users] How to convert .wav to formula?

classic Classic list List threaded Threaded
5 messages Options
Илья Илья Илья Илья
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] How to convert .wav to formula?

How to convert .wav to formula?

In scilab I can write like:

    t=soundsec(0.5);
    s=[sin(2*%pi*440*t)];
    savewave('foo.wav', s);

and by this convert formula to .wav.

But how can I convert .wav to formula? If I use

    analyze(loadwave('foo.wav'));

I only got graphic? What to do?
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Rafael Guerra Rafael Guerra
Reply | Threaded
Open this post in threaded view
|

Re: How to convert .wav to formula?

Hi,

Q: "I only got graphic? What to do?"
A: look at Fourier synthesis of periodic waveforms.

For the toy example provided of a monochromatic wave, the simple code here below finds the approximate solution.
More general waveform case, needs much more programming effort.

// START OF CODE
clear; clf;
fs = 22050; // default sampling rate (Hz)
t=soundsec(0.5,fs);
s=[sin(2*%pi*440*t)];
savewave('foo.wav', s);

y = loadwave('foo.wav');
y = [y zeros(y)];  // make #samples even & increase spectral resolution
Yf = abs(fftshift(fft(y)));
N = length(Yf);
Yf = Yf(N/2+1:$);
f = linspace(0,fs/2-fs/N,N/2);
[y0 k] = max(Yf);
plot(f,Yf,'blue',f(k),Yf(k),'*red')
xlabel("Frequency [Hz]")
printf("sinusoid frequency = %.1f Hz",f(k))
// END OF CODE

Regards,
Rafael
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Rafael Guerra Rafael Guerra
Reply | Threaded
Open this post in threaded view
|

Re: How to convert .wav to formula?

Пожалуйста




--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Hermes Hermes
Reply | Threaded
Open this post in threaded view
|

Re: How to convert .wav to formula?

another way to get the graph

clear;
[x,S,bits]=wavread("foo.wav")
analyze(x);
mclose('all');

How to use the variables of the weer function analyze:fmin, fmax, rate,
points?




--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Hermes Hermes
Reply | Threaded
Open this post in threaded view
|

Re: How to convert .wav to formula?

In reply to this post by Rafael Guerra
another way to get the graph

clear;
[x,S,bits]=wavread("foo.wav")
analyze(x);
mclose('all');

How to use the variables of the  function analyze:fmin, fmax, rate, points?




--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users