Graphics Programs Reference
In-Depth Information
Sound
You can use sound to generate sound on your computer (provided that your
computer is suitably equipped). Although, strictly speaking, sound is not a
graphics command, we have placed it in this chapter since we think of “sight”
and“sound”asbeingalliedfeatures.Thecommand sound takesavector,views
itasthewaveformofasound,and“plays”it.Thelengthofthevector,dividedby
8192, is the length of the sound in seconds. A “sinusoidal” vector corresponds
to a pure tone, and the frequency of the sinusoidal signal determines the pitch.
Thus the following example plays the motto from Beethoven's 5th Symphony:
>> x=0:0.1*pi:250*pi; y=zeros(1,200); z=0:0.1*pi:1000*pi;
>> sound([sin(x),y,sin(x),y,sin(x),y,sin(z*4/5),y,...
sin(8/9*x),y,sin(8/9*x),y,sin(8/9*x),y,sin(z*3/4)]);
Note that the zero vector y in this example creates a very short pause between
successive notes.
Search WWH ::




Custom Search