Professional Documents
Culture Documents
Scilab - Sounds
Scilab - Sounds
lab 9
SCILAB SOUNDS
Scilab offers many utilities for signal generation and processing. The following exercises concentrate on sounds. In order to generate a sound (a wave) use the code as bellow:
// At first we create 0.5 seconds of sound parameters. t=soundsec(0.5); // Then we generate the sound. s=sin(440*t)+sin( 0*t)/ +sin(!!0*t)/ ; "nr#nc$=si%e(t); s(nc/ &nc)=sin(''0*t(nc/ &nc)); // (e can easi)* ma+e a ,ourier ana)*sis of it. ana)*%e(s);
The result of the code is a 0. s long wave with the fre!uencies of ""0# $$0 and %%0 &' and its spectral analysis ((ourier) reveals:
In order to hear the signal save it to a file (test.wav). The signal can be also reloaded and visuali'ed:
// -a.e the fi)e in (A/ format. // we renorma)i%e s in order to chec+ that sa.e+)oad is in.ariant s=s0sum(s)/prod(si%e(s)); s=s/ma1(a2s(s)); sa.ewa.e(3test.wa.3#s); // 4oad it 2ac+. s5=)oadwa.e(3test.wa.3); if ma1i(a2s(s50s)) 6 5.e04; end // 7ow we can ma+e a comp)ete picture of the sound. mapsound(s);
Exercise 1 (5 points)
)rite a function enabling generation of a single*fre!uency wave of a given duration:
note(fre8uenc*# duration) page 1 of 2
Utility Software II
lab 9
+alling the function note should result in saving the sound to a .wav file named according to a pattern: fre !ency"d!ration.wav# e.g. note(400# 5.5) generates a file #$$"1.%.wav. ,enerate a basic octave sounds (e.g. 0. s long) according to their fre!uencies presented in the table: sound frequency [Hz] cd e f g a h c$ $.-#. $/0#1 0$/#. 0"/#. 0/-#/ ""0#0 "/0#/ $0#$
page 2 of 2