ThedesignofadigitalsignalgeneratorandasimpledigitalpianobasedonthematlabAbstractDigitalsignalgeneratorisakindofwaveformgeneratorbasedonsoftwareandhardware,cangenerateavarietyofbasicwaveform.Avarietyofcomplexengineeringsignalisgeneratedbythesuperpositionofthesebasicsignal,soit'swidelyusedinengineeringanalysisandexperimentteaching.MATLABisaverypracticalengineeringsoftwarefordataanalysisandprocessing,itsdataacquisitiontoolboxprovidesaveryconvenientfunctionsandcommandsfordatainputandoutput,anditisconvenientandpracticalinthedigitalsignalprocessing.ThispaperfirstintroducedthedesignprocessofdigitalsignalgeneratorbasedonMATLAB,realizedthespecificmethodstoachievethesimplewaveform(sinesquare,triangle,slope),andthenachievedasimpledigitalpianobythesinne.1.IntroductionWiththedevelopmentofcomputersoftwareandhardwaretechnology,moreandmorerealgoodsfunctionscanberealizedbyacomputer.,thatiswhatweoftensay.Thatthehardwarebecomessoftwarecanreducethecostandmaketheimplementmodifyandsimulationeasier.NowthereisalotofrelativelymaturesoftwaresuchasMATLAB.Basedonthisconsideration,ImadeasimpledigitalgeneratorwithMATLAB,andinordertomakeitlinkedtothepracticalapplication,Imakeasimpledigitalpiano.Ithinkitcanmakeacertainfoundationforfuturelearningandwork.1.1theintroductionofdigitalsignalgeneratorDigitalsignalgeneratorcanproducesine,square,triangle,saw,whitenoise,pulseandstepetc..Digitalsignalscanalsobecalledasdiscretesignal,itonlygivevaluesforafunctionindiscretetime,anditisasequenceofdiscontinuoustemporally.Theintervalofdiscretetimeisuniform,andusettoexpressit.Thevalueoftdeterminedbythesamplingfrequency--Fs.Inordertoensurethesampledsignalcanstaytruetotheoriginalanalogsignalinformation,samplingfrequencymustbeatleast2timesashighasthehighestfrequencycomponentoftheoriginalsignal.Thisisthebasicruleofsampling,calledthesamplingtheorem.Inthispaper,inordertomakedigitalsignalmoreclosetotheoriginalanalogsignal,thesamplingfrequencyisabout20timeshigherthantheoriginalsignalfrequency.TheMATLABprogramprovidesavarietyofcommonbasicsignalgeneratingfunction.Thisdesignsimulatedfourkindsofsignals,threearedirectlyusingthefunctionprovidedbyMATLAB,onlyonesignalisnotacalledfunction,directlywritten.1.2theintroductionofdigitalpianoThepromotionofdigitalpianoinChinabeganineightyyearstwentiethCentury,sofar,thetone,thequality,andtheconvenienceofperformancehavereachedaverymaturestage,withthedevelopmentofintegratedcircuittechnology,theupgradingcankeeptheoriginalstructureremainunchangedbythereplacementofasimplechip.However,thedigitalpianohaveobviousshortcomings:theconcertoproblemsbetwwenitandpiano,orchestrarestricttheuseofdigitalpianoinimportantplaceinmusic,whichgreatlyaffecttheapplicationandpopularizationofdigitalpiano.Thecoordinationofthedigitalpianoandnonelectronicmusicalinstrumentisapressingmattertothecurrentmusicprofessionalsanddevelopersofdigitalpiano.Inthispaper,IdesignasimpledigitalpianobyMATLAB,todeepentheunderstandingofthedigitalpiano.2.Method2.1therealizationofthedigitalsignalgeneratorIfirstanalytheGUIinterfaceofdigitalsignalgeneratoraccordingtotherequirementsofthedesign,andthenentertheguideintheMATLABworkplaceinterfacetoopentheGUIinterface.AndthenbuildagoodspecificinterfaceofdigitalsignalgeneratorintheGUIinterface,andwritethecallbackfunctionofeachwaveformcontrol,savetheMfile.Trytooperate,iftheresultiscorrect,observethesimulationresults.Ifthesimulationofdigitalsignalgeneratorisincorrectresults,checkthecallbackfunctionofthecontrolkey,modifyandsavetheMfile,runagain,andobservethesimulationresults.2.1.1buildtheGUIofthedigitalsignalgeneratorGUIundertheenvironmentofMatlabisauserinterfacecomposedofwindow,cursor,buttons,menus,textandotherobjects.Theuserthroughcertainmethods(suchasamouseorkeyboard)select,activatethesegraphicalobjects,tomakethecomputerproducesomeactionorchangesuchastherealizationofcalculation,drawingetc..Theoperationofagraphicaluserinterfacegenerallyhavetwoparts,firstofall,choosetheappropriategraphicalobjectstoestablishthereasonableGUIinterfaceinaccordancewiththerequirementsofdesign,principle,andtheneed;thenwritethecallbackfunctionofthecontrolsintheMfiletomaketheconstructedGUIinterfacerun.TheGUIinterfaceofthedesignofdigitalsignalgeneratorusegraphicsobjectssuchaspanel,Axes,pushbutton,StaticText,andsimulatefourkindsofsignal:sine,square,triangle,slope.GUIinterfaceofdigitalsignalgeneratorareasfollows:2.1.2thebasicprincipleofthewaveform2.1.2.1therealizationofthesinewavethemathematicalexpressionofsinsignalsareasfollows:)2sin()sin(ftAwtAyamongthem:Afortheamplitude,fforthefrequency,forphase.InMATLAB,becausetheprocessingobjectsarediscretedigitalsignal,discretizatethetimevariableandconstructaonedimensiongroup:0.1:/1:0sft;withthem:fsforthesamplingfrequency.Butthevaluecannotbetoolarge,otherwisethewaveformdisplaywillbeveryslow.thecorrespondingdigitalsignalexpressionofsine:)2sin()(tfnAtnyAftergettingthediscretevaluesoftandy,useplotmappingfunctiontoobtainthecorrespondingwaveformdisplay.2.1.2.2therealizationofsquarewaveThemathematicalexpressionforthesquare