Matlab is a high level language software where you can do so many interesting things. Here is another example where you can play music. Who knows, maybe you can be the next Mozart by creating a unique song.

In this code, zz and zzz randomly simulates 8 notes each and z combines all simulates notes. After each simulated 8 notes, there is a pause listen the melody easier. You can save the file as an .m file, execute and listen melodies that never been heard before.

Enjoy and if you want to read more on the following url: http://nlolab.swarthmore.edu/webstuff/Phys22/MatlabWkShpII/MatlabWkShpII.pdf as it was the main inspiration of this code.

 

x=1:5000;
x=x/10000;
aa(:,1)=sin(2*pi*440*x); %do
aa(:,2)=sin(2*pi*9/8*440*x); %re
aa(:,3)=sin(2*pi*5/4*440*x); %mi
aa(:,4)=sin(2*pi*4/3*440*x); %fa
aa(:,5)=sin(2*pi*3/2*440*x); %so
aa(:,6)=sin(2*pi*5/3*440*x); %la
aa(:,7)=sin(2*pi*15/8*440*x); %ti
aa(:,8)=sin(2*pi*2*440*x); %do2
%z=[do re mi fa so la ti do2];

zz=ceil(rand(1,8)*8);
zzz=ceil(rand(1,8)*8);
ps=aa(:,zz(1))'*0;

z=[aa(:,zz(1))'  aa(:,zz(2))' aa(:,zz(3))'  aa(:,zz(4))' aa(:,zz(5))'  aa(:,zz(6))' aa(:,zz(7))'  aa(:,zz(8))' ps ps ps ps ...
    aa(:,zzz(1))'  aa(:,zzz(2))' aa(:,zzz(3))'  aa(:,zzz(4))' aa(:,zzz(5))'  aa(:,zzz(6))' aa(:,zzz(7))'  aa(:,zzz(8))' ps ps ps ps ...
    aa(:,zz(1))'  aa(:,zz(2))' aa(:,zz(3))'  aa(:,zz(4))' aa(:,zz(5))'  aa(:,zz(6))' aa(:,zz(7))'  aa(:,zz(8))' ps ps ps ps ...
    aa(:,zzz(1))'  aa(:,zzz(2))' aa(:,zzz(3))'  aa(:,zzz(4))' aa(:,zzz(5))'  aa(:,zzz(6))' aa(:,zzz(7))'  aa(:,zzz(8))' ps ps ps ps];

sound(z,10000);

Related Posts

  • How to create complex passwords in Matlab
  • How to check the mail size of Outlook
  • How to detect fake Morgan Dollar
  • How to send money overseas in 10 minutes
  • How to send fax over the internet
  • How to access or manipulate Nicedit editor with PHP/MySQL
  • How to search keywords in a folder or file
  • How to access email attachments blocked in Outlook
  • How to recover the previous tabs in Mozilla Firefox
  • How to print out pages with low ink cartridge