Problem in using audiowrite function

hi, i want to make matlab song
here is the code :
b=sin(2*pi*493.88*(0:0.000125:0.5));
d=sin(2*pi*587.33*(0:0.000125:0.5));
d=sin(2*pi*587.33*(0:0.000125:0.5));
f=sin(2*pi*698.45*(0:0.000125:0.5));
c=sin(2*pi*554.37*(0:0.000125:0.5));
e=sin(2*pi*659.26*(0:0.000125:0.5));
line1=[b,d,d];
line2=[d,d,c,c,b,b];
line3=[e,e,d,d,c,c,b,b];
song=[line1,line2,line3,line3,line1,line2];
audiowrite('Epi.wav',song,Fs);
[x,Fs] = audioread('Epi.wav');
sound(x);
but it show an error at line audiowrite('Epi.wav');
how can i fix it?

Respuestas (2)

Mehmed Saad
Mehmed Saad el 17 de Abr. de 2020
Editada: Mehmed Saad el 17 de Abr. de 2020
Define sampling Rate
Fs = 1/0.000125;
t = (0:1/Fs:0.5);
b=sin(2*pi*493.88*t);
d=sin(2*pi*587.33*t);
d=sin(2*pi*587.33*t);
f=sin(2*pi*698.45*t);
c=sin(2*pi*554.37*t);
e=sin(2*pi*659.26*t);
line1=[b,d,d];
line2=[d,d,c,c,b,b];
line3=[e,e,d,d,c,c,b,b];
song=[line1,line2,line3,line3,line1,line2];
audiowrite('Epi.wav',song,Fs);
[x,Fs] = audioread('Epi.wav');
sound(x,Fs)
NUR HANIS SHAZANA JAMALUDIN
NUR HANIS SHAZANA JAMALUDIN el 18 de Abr. de 2020

0 votos

Thank you.
I want to ask how i can make song in matlab but it sound like piano?

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by