You are on page 1of 4

Networks I

Course No. 0909-201-01 Fall 1997, 2nd Quarter Making Music with M !" # #e$ore we actuall% start &aking &usic, let's re(ise a $ew C wa(e$or& )asics. Consider the sine wa(e shown in the $igure )elow* !he sine wa(e shown here can )e descri)ed &athe&aticall% as* ( + sin 2 , $ t where is the &,litude -(ar%ing units., $ is the $re/uenc% -0ert1. and t is the ti&e -seconds.. ! is known as the ti&e ,eriod -seconds. and !+12$ #ased on the e/uation, when t+03 ( + sin 2 , $-0. + 0 when t+!243 ( + sin 2 , $ -!24. + sin 2 , $-124$. + sin - ,22. + 3 when t+!223 ( + sin 2 , $ -!22. + sin 2 , $-122$. + sin - ,. + 03 and so on. 5ound wa(es are created when a wa(e$or& as shown here is used to (i)rate &olecules in a &aterial &ediu& at audio $re/uencies -600 01 7+ $ 7+ 6 k01.. I$ %ou wish to create a wa(e$or& such as the one shown in the $igure, %ou would need to e(aluate the $unction, ( + sin 2 , $ t, at discrete ti&es, t -shown as the ti&e instants o$ the red dots., t%,icall% at e/ual ti&e inter(als. !hese ti&e inter(als &ust )e 8su$$icientl%8 s&all -how s&all is s&all9 :e&e&)er the N%/uist criterion9........... to o)tain a 8s&ooth8 wa(e$or&. !his ti&e inter(al is called the 85a&,ling Inter(al8 and the ,rocess o$ )reaking u, a continuous wa(e$or& )% s,eci$%ing it onl% at discrete ,oints in ti&e is called sa&,ling. -%ou should alread% know &uch o$ this stu$$ $ro& the ,re(ious Clinic on ;ata c/uisition #asics.. !he sa&,ling inter(al, shown here is !s3 corres,onding to that there e<ists a 85a&,ling Fre/uenc%8, $s + 12!s. s an e<a&,le, the M !" # code to create a sine

wa(e o$ a&,litude + 1, at audio $re/uenc% o$ 4==.1= 01 -corres,onds to > in the ?/ual !e&,ered Chro&atic 5cale. would )e* @@ ( + sin-2A,iA4==.1=AB0*0.0012C*1.0D.3 !he (ector, (, now contains sa&,les o$ the sine wa(e, starting at t+0 s, to t+1.0 s, in sa&,les s,aced 0.0012C s a,art -the sa&,ling inter(al !s.. !his corres,onds to a sa&,ling $re/uenc% o$ E F01, which is standard $or (oice grade audio channel. hear itGGG Now, %ou can either ,lot this sine wa(e3 or %ou can !o ,lot, si&,l% do @@ ,lot-(.3 !o hear (, %ou need to con(ert the data contained in ( to so&e standard audio $or&at that can )e ,la%ed using a 5ound Card and 5,eakers on %our HC. Ine such standard audio $or&at is called the 8wa(8 $or&at. Matla) ,ro(ides a $unction called wa(write to con(ert a (ector into wa( $or&at and sa(e it on disk. ;o @@ hel, wa(write $or &ore details. Now, to create a wa( $ile, do @@ wa(write-(, 'ashar,.wa('.3 -%ou can gi(e an% $ile na&e )etween the ' ' s. Now, %ou can 8,la%8 this wa( $ile called ashar,.wa( using an% &ulti&edia ,la%er. For e<a&,le, %ou could use the 5ound :ecorder ,rogra&. 5tart this )% ,ointing to 5tart Hrogra&s - ccessories - Multi&edia - 5ound :ecorder. I,en the wa( $ile using the File Menu and ,ress Hla%. I$ %ou ha(e installed a sound card and a ,air o$ s,eakers on %our HC, %ou should )e a)le to hear a short note. Now that %ou can &ake a single note, %ou can ,ut notes together and &ake &usicGGG -Josh, I $eel like we're in the 5ound o$ Music here................. "et's look at the $ollowing ,iece o$ &usic*

? ? F> F> ? ? ; ; C>C> # # ? ? ; ; C> C> # # -re,eat once. -re,eat $irst two lines once. !he * #* C>* ;* ?* F>* &erican 5tandard Hitch $or each o$ this notes is* 440.00 01 496.EE 01 CC4.67 01 CE7.66 01 =C9.2= 01 769.99 01

ssu&ing each note lasts $or 0.C seconds, the M !" # &-$ile $or creating a wa( $ile $or this ,iece o$ &usic would )e* clear3 a+sin-2A,iA440A-0*0.00012C*0.C..3 )+sin-2A,iA496.EEA-0*0.00012C*0.C..3 cs+sin-2A,iACC4.67A-0*0.00012C*0.C..3 d+sin-2A,iACE7.66A-0*0.00012C*0.C..3 e+sin-2A,iA=C9.2=A-0*0.00012C*0.C..3 $s+sin-2A,iA769.99A-0*0.00012C*0.C..3 line1+Ba,a,e,e,$s,$s,e,e,D3 line2+Bd,d,cs,cs,),),a,a,D3 line6+Be,e,d,d,cs,cs,),)D3 song+Bline1,line2,line6,line6,line1,line2D3 wa(write-song,'song.wa('.3 0IN!* #e$ore %ou code the entire song, Kust code the $irst line, create a wa( $ile, ,la% it and &ake sure e(er%thing works. ;o %ou recogni1e this ,iece9 -I$ not, then we ha(e a lot o$ work ahead o$ us............... ?nKo%GGGGG Calling ll Musicians in the Class* I$ %ou ha(e notes $or other songs3 %ou can code the&

too. lso, using 5ound :ecorder, %ou can create har&onics, s%nthesi1e chords, etc. a$ter generating the ,ure notes in Matla). #ack to Course 0o&e,age

You might also like