function y=play_scale(start_note,ss) % Plays any major scale. % Notes C D E F G A B C B A G F E D C for start_note = 40. % Key #40 is middle C. % SS: enter string 'sound' to play scale by SOUND command. % keys = [40 42 44 45 47 49 51 52 51 49 47 45 44 42 40 0]; keys = keys + (start_note-40);% adjusting the the starting % for the major scale. dur = 0.125* ones(1,length(keys));% 1/8 sec. duration fs = 11025; % Sample rate y = zeros(1,sum(dur)*fs + 1); n1 = 1; for kk = 1:length(keys);%creates long vector of tones keynum = keys(kk); tone = note(keynum, dur(kk)); n2 = n1 + length(tone) - 1; y(n1:n2) = y(n1:n2) + tone; n1 = n2; end y=y/max(abs(y)); if ss=='sound', sound(y,fs); end % --------- End play_scale.m ----------