Midterm project

Music By Matlab

Nothing Special

Play Music Bottom

function pushbutton1_Callback(hObject, eventdata, handles)

% hObject handle to pushbutton1 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

song_menu = get(handles.popupmenu1,'value');

global tt;

tt=str2double(get(handles.edit1,'String'));

ff=str2double(get(handles.edit2,'String'));

v = str2double(get(handles.edit3,'String'));

set(handles.slider4, 'value', v);

switch song_menu

case 1

Music;

Fs = ff;

axes(handles.axes5);

t = (1:length(A))/Fs;

plot(t, A*v);

axes(handles.axes6);

plot(t, Right*v);

axes(handles.axes9);

plot(t, Left*v);

soundsc(A*v, Fs);

case 2

Music1;

Fs = ff;

axes(handles.axes5);

t = (1:length(A))/Fs;

plot(t, A*v);

axes(handles.axes6);

plot(t, Right*v);

axes(handles.axes9);

plot(t, Left*v);

soundsc(A*v, Fs);

case 3

Music2;

Fs = ff;

axes(handles.axes5);

t = (1:length(A))/Fs;

plot(t, A*v);

axes(handles.axes6);

plot(t, Right*v);

axes(handles.axes9);

plot(t, Left*v);

soundsc(A*v, Fs);

case 4

Music3;

Fs = ff;

axes(handles.axes5);

t = (1:length(A))/Fs;

plot(t, A*v);

axes(handles.axes6);

plot(t, Right*v);

axes(handles.axes9);

plot(t, Left*v);

soundsc(A*v, Fs);

case 5

Music4;

Fs = ff;

axes(handles.axes5);

t = (1:length(A))/Fs;

plot(t, A*v);

axes(handles.axes6);

plot(t, Right*v);

axes(handles.axes9);

plot(t, Left*v);

soundsc(A*v, Fs);

end

Stop Music Bottom

function pushbutton5_Callback(hObject, eventdata, handles)

% hObject handle to pushbutton5 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

clear sound

Clear Wave Bottom

function pushbutton6_Callback(hObject, eventdata, handles)

% hObject handle to pushbutton6 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

axes(handles.axes5);

hold off;

plot(0);

title('Waveform');

xlabel('Time(s)')

ylabel('Magnitude');

grid on;hold on;

axes(handles.axes6);

hold off;

plot(0);

title('Right');

xlabel('Time(s)')

ylabel('Magnitude');

grid on;hold on;

axes(handles.axes9);

hold off;

plot(0);

title('Left');

xlabel('Time(s)')

ylabel('Magnitude');

grid on;hold on;

Original Music Bottom

function pushbutton7_Callback(hObject, eventdata, handles)

% hObject handle to pushbutton7 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

song_menu = get(handles.popupmenu1,'value');

g = get(handles.checkbox1,'value');

switch song_menu

case 1

[y, Fs] = audioread('C:\Users\張凱雋\Desktop\Midterm project\01. One more time, One more chance.mp3');

axes(handles.axes5);

t = (1:length(y))/Fs;

plot(t, y);

sound(y, Fs);

case 2

if g==1

[y, Fs] = audioread('C:\Users\張凱雋\Desktop\Midterm project\op1.mp3');

axes(handles.axes5);

t = (1:length(y))/Fs;

plot(t, y);

sound(y, Fs);

else

[y, Fs] = audioread('C:\Users\張凱雋\Desktop\Midterm project\op3.mp3');

axes(handles.axes5);

t = (1:length(y))/Fs;

plot(t, y);

sound(y, Fs);

end

case 3

if g==1

[y, Fs] = audioread('C:\Users\張凱雋\Desktop\Midterm project\POPSTARS.mp3');

axes(handles.axes5);

t = (1:length(y))/Fs;

plot(t, y);

sound(y, Fs);

else

[y, Fs] = audioread('C:\Users\張凱雋\Desktop\Midterm project\KDA - POPSTARS .mp3');

axes(handles.axes5);

t = (1:length(y))/Fs;

plot(t, y);

sound(y, Fs);

end

case 4

if g==1

[y, Fs] = audioread('C:\Users\張凱雋\Desktop\Midterm project\Lemon_edit.mp3');

axes(handles.axes5);

t = (1:length(y))/Fs;

plot(t, y);

sound(y, Fs);

else

[y, Fs] = audioread('C:\Users\張凱雋\Desktop\Midterm project\Lemon.mp3');

axes(handles.axes5);

t = (1:length(y))/Fs;

plot(t, y);

sound(y, Fs);

end

case 5

if g==1

[y, Fs] = audioread('C:\Users\張凱雋\Desktop\Midterm project\gincola.mp3');

axes(handles.axes5);

t = (1:length(y))/Fs;

plot(t, y);

sound(y, Fs);

else

[y, Fs] = audioread('C:\Users\張凱雋\Desktop\Midterm project\drug.mp3');

axes(handles.axes5);

t = (1:length(y))/Fs;

plot(t, y);

sound(y, Fs);

end

end

Demo