% showscale.m plays a 0.8 second scale and graphs speaker position versus time L=0.8; p=2^(1/12); % frequency multiplier between notes t=(1/40000):(1/40000):(L/8); % vector of time indices a =sin(440*2*pi*t); % define naturals and sharps %as=sin(440*(p^1)*2*pi*t); b =sin(440*(p^2)*2*pi*t); %c =sin(440*(p^3)*2*pi*t); cs=sin(440*(p^4)*2*pi*t); d =sin(440*(p^5)*2*pi*t); %ds=sin(440*(p^6)*2*pi*t); e =sin(440*(p^7)*2*pi*t); %f =sin(440*(p^8)*2*pi*t); fs=sin(440*(p^9)*2*pi*t); %g =sin(440*(p^10)*2*pi*t); gs=sin(440*(p^11)*2*pi*t); a2=sin(440*(p^12)*2*pi*t); % a one octave up a3=sin(440*(p^24)*2*pi*t); % another octave up fastt = (1/40000):(1/40000):L; fastscale=[a b cs d e fs gs a2]; subplot(4,1,1) plot(fastt, fastscale) axis([0 L/4 -1.1 1.3]); title('A-major scale') ylabel('Speaker position') xlabel('Time') text(0.02, 1.1, 'A 440 Hz'); text(0.12, 1.1, 'B 493.88 Hz'); subplot(4,1,2) plot(fastt, fastscale) axis([L/4 2*L/4 -1.1 1.3]); text(0.22, 1.1, 'C# 554.37 Hz'); text(0.32, 1.1, 'D 587.33 Hz'); subplot(4,1,3) plot(fastt, fastscale) axis([2*L/4 3*L/4 -1.1 1.3]); text(0.42, 1.1, 'E 659.26 Hz'); text(0.52, 1.1, 'F# 739.99 Hz'); subplot(4,1,4) plot(fastt, fastscale) axis([3*L/4 L -1.1 1.3]); text(0.62, 1.1, 'G# 830.61 Hz'); text(0.72, 1.1, 'A 880 Hz'); orient landscape print -deps scale.eps sound(fastscale, 40000);