I need to make MUSIC on matlab

45 次查看(过去 30 天)
Annie
Annie 2013-11-3
So I have to make a song on matlab and then set up sine waves that correspond to the notes on the scale. The notes are AGGABCFG. can someone help me with this?

回答(3 个)

Azzi Abdelmalek
Azzi Abdelmalek 2013-11-3
编辑:Azzi Abdelmalek 2013-11-3
Look at these links
For your case
notes={'C' 'C#' 'D' 'Eb' 'E' 'F' 'F#' 'G' 'G#' 'A' 'Bb' 'B'}
freq=[261.6 277.2 293.7 311.1 329.6 349.2...
370.0 392.0 415.3 440.0 466.2 493.9]
song={'A' 'G' 'G' 'A' 'B' 'C' 'F' 'G'} % your song
a=[]
for k=1:numel(song)
note_value=0:0.000125:0.5 % You can change the note duration
a=[a sin(2*pi* freq(strcmp(notes,song{k}))*note_value)];
end
sound(a)
  2 个评论
Azzi Abdelmalek
Azzi Abdelmalek 2013-11-4
[Annie commented]
thank you for you help!
Haripriya K
Haripriya K 2020-6-15
hello can u say at what times these individual notes begin in the song?

请先登录,再进行评论。


Dan Po
Dan Po 2016-10-17
OMG I LOVE THIS POST
clear
tic
notes={'C' 'C#' 'D' 'Eb' 'E' 'F' 'F#' 'G' 'G#' 'A' 'Bb' 'B'};
freq=[261.6 277.2 293.7 311.1 329.6 349.2...
370.0 392.0 415.3 440.0 466.2 493.9];
song={'A' 'G' 'G' 'A' 'B' 'C' 'F' 'G'} ; % your song
a=[];
for i=2:70
for k=1:numel(song);
note_value=0:i*0.0001:0.5 ;% You can change the note duration
a=[a sin(2*pi* freq(strcmp(notes,song{k}))*note_value)];
end
end
sound(a);
toc

Erdal Yegenaga
Erdal Yegenaga 2020-11-1
I am doing research for my graduation project, but I could not reach enough code information.I want to assign music notes to computer keys for digital synthesizer. Can you write this code with adsr enveloping please?
  2 个评论
John D'Errico
John D'Errico 2020-11-1
编辑:John D'Errico 2020-11-1
This is not an answer to anything, but a direct request for someone to provide code to you to do your task. If this is research, will you give direct credit to the person who did the work for you when you hand in your project? Will their name be listed on front of your project as a direct contributor? Or, would you happily hand in someone else's efforts as your own?
Erdal Yegenaga
Erdal Yegenaga 2020-11-1
You r right. I asked my problem wrong way. Can you help me write to assign computer keys to play music notes?
clear ;
close all;
fs=8500;
t=0:0.000117:3;
note_do= sin(2*pi*261.6*t);
note_re= sin(2*pi*293.7*t);
note_mi= sin(2*pi*329.6*t);
note_fa= sin(2*pi*349.2*t);
note_sol= sin(2*pi*392*t);
note_la= sin(2*pi*440*t);
note_si= sin(2*pi*493.9*t);
note_do1= sin(2*pi*523.5*t);
y=note_do;
A = linspace(0, 0.9, (length(y)*0.10)); %rise 35% of signal
D = linspace(0.9, 0.7,(length(y)*0.05)); %drop of 5% of signal
S = linspace(0.7, 0.7,(length(y)*0.40)); %delay of 40% of signal
R = linspace(0.7, 0,(length(y)*0.20)); %drop of 25% of signal
ADSR = [A D S R] ;
x = zeros(size(y));
x(1:length(ADSR)) = ADSR;
tone=y.* x;
sound(tone,fs);

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Just for fun 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by