Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Utility Software II

lab 9

Jacek Wilicki, jacenty@kis.p.lodz.pl

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

Jacek Wilicki, jacenty@kis.p.lodz.pl

+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#$

Exercise 2 (15 points)


2ewrite the function from the previous exercise so that it ta3es one more argument de)a* denoting the delay of sound beginning. The function should return a sound wave. )rite another function p)a*er combining the octave waves (properly delayed) into a melody according to the notes: g e e f d d c- e g g e e f d d c- f cThe final melody should sound li3e: http:445acenty.3is.p.lod'.pl4utility6software6ii4melody.mp0. Hint: there may be need to increase a stac3 si'e in order to process the waves.

page 2 of 2

You might also like