DOC PREVIEW
Purdue ECE 462 - Sound

This preview shows page 1-2-3-4-5-34-35-36-37-38-69-70-71-72-73 out of 73 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 73 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 73 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 73 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 73 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 73 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 73 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 73 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 73 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 73 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 73 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 73 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 73 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 73 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 73 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 73 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 73 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

SoundJava SoundMIDIQt SoundJava Play Wave FilePerformance ProfileProgram PerformancePerformance ImprovementProfiling in NetbeansInclude Java CoreNetbeans ProfilerC++ Performance ProfileUsing gprofPass by ReferenceImprove PerformanceProcedureDon’t Do It OftenInteractive ProgramsCompiler OptimizationMemory Management in JavaGarbage CollectionObject Creation in JavaECE 462Object-Oriented Programmingjggusing C++ and JavaSoundYung-Hsiang Lul@ d [email protected] Sound 1Java SoundJava SoundYHL Sound 2YHL Sound 3YHL Sound 4YHL Sound 5MIDI(f)(Musical Instrument Digital Interface)• instructions for sound synthesizers (sequencers)y(q)• .mid not recording (such as .wav files)• music has not been played yet• usually much smaller in file sizes• may have high quality by good sound cardsFil fil Fil ("b t id")File file = new File("betsy.mid");currentSound = MidiSystem.getSequence(file);player = MidiSystem.getSequencer();player.open();player.setSequence(currentSound);player.start();YHL Sound 6player.start();YHL Sound 7YHL Sound 8Qt SoundQt SoundYHL Sound 9YHL Sound 10YHL Sound 11Java Play Wave FileJava Play Wave FileYHL Sound 12YHL Sound 13YHL Sound 14YHL Sound 15ECE 462Object-Oriented Programmingjggusing C++ and JavaPerformance ProfileYung-Hsiang Lul@ d [email protected] Performance Profile 1Program PerformanceProgram Performance•In many cases, performance decides success.y,p– # transactions– response time for collision detection and avoidance on airplanes– multimedia (video, music, voice ...)interactive games–interactive games– handwriting or voice recognition•A successful software developer must pay attention toA successful software developer must pay attention to performance.YHL Performance Profile 2Performance ImprovementPerformance Improvement• make programs modular ⇒ easier to understand where pgtime is spent • Keep It Simple (KIS)• learn better algorithms and use well-known algorithms• understand problems’ requirements and limitationsfind approximate solutions if they are good enough•find approximate solutions, if they are good enough• put your efforts at the right place ⇒ know what mattersYHL Performance Profile 3Profiling in NetbeansProfiling in NetbeansYHL Performance Profile 4YHL Performance Profile 5YHL Performance Profile 6YHL Performance Profile 7YHL Performance Profile 8YHL Performance Profile 9YHL Performance Profile 10YHL Performance Profile 11YHL Performance Profile 12YHL Performance Profile 13Include Java CoreInclude Java CoreYHL Performance Profile 14YHL Performance Profile 15YHL Performance Profile 16YHL Performance Profile 17YHL Performance Profile 18YHL Performance Profile 19YHL Performance Profile 20Netbeans ProfilerNetbeans ProfilerYHL Performance Profile 21YHL Performance Profile 22ECE 462Object-Oriented Programmingjggusing C++ and JavaC++ Performance ProfileYung-Hsiang Lul@ d [email protected] C++ Profile 1Using gprofUsing gprofYHL C++ Profile 2YHL C++ Profile 3YHL C++ Profile 4YHL C++ Profile 5YHL C++ Profile 6YHL C++ Profile 7YHL C++ Profile 8YHL C++ Profile 9YHL C++ Profile 10YHL C++ Profile 11add –p to the pcompiler flagYHL C++ Profile 12hkflcheck –p flagYHL C++ Profile 13execute the programYHL C++ Profile 14fil i f tiprofile informationYHL C++ Profile 15YHL C++ Profile 16YHL C++ Profile 17YHL C++ Profile 18YHL C++ Profile 19Performance Improvementusing Pass by ReferenceYHL C++ Profile 20YHL C++ Profile 21YHL C++ Profile 22ECE 462Object-Oriented Programmingjggusing C++ and JavaImprove PerformanceYung-Hsiang Lul@ d [email protected] Improve Performance 1ProcedureProcedure• find performance bottlenecksp– use profilers– select appropriate data and metrics• develop a strategy to reduce or remove the bottleneck– change a better algorithm don’tdoit–don t do it– don’t do it so often– don’t do it now• evaluate the benefits of the strategy• implement the changestth dYHL Improve Performance 2• repeat the procedureDon’t Do It OftenDon t Do It OftenX& operator=( const X& other ) X& operator=( const X& other ) { if ( this == &other ){ return*this; }{ if ( this == &other ){ return*this; }{ return this; }// release memory// allocate memory // l t{ return this; }if (they have the different amounts of memory){// copy elementsreturn *this; } {// release memory// allocate memory }// copy elementsreturn *this; YHL Improve Performance 3;}Performance in Interactive ProgramsPerformance in Interactive Programs• show progresspg• allow other activities simultaneously• give users options • remain responsive (by using multiple threads)• anticipate a user’s actions and pre-computeYHL Improve Performance 4YHL Improve Performance 5YHL Improve Performance 6Compiler OptimizationCompiler Optimizationadd –O to g++ flagYHL Improve Performance 7YHL Improve Performance 8Memory Management in JavaMemory Management in JavaYHL Improve Performance 9Garbage CollectionGarbage CollectionCar c1 = new Car(“B14937”);c1B14937();c1 = new Car(“N86213”);B14937c1B14937N86213c1 = null;1B14937c1 = null;c1B14937N86213YHL Improve Performance 10Garbage CollectionGarbage CollectionCar c1 = new Car(“B14937”);c1B14937();Car c2;c1 = new Car(“N86213”);B14937c1B14937N86213c2 = c1c1 = null;1B14937c1 = null;c1B14937N86213c2YHL Improve Performance 11Object Creation in JavaObject Creation in Java• set unneeded objects to nullj• reuse objects’ (by changing some attributes), avoid creating short-life objects• set objects’ attributes to be sufficiently large to prevent frequent resizing•use static attributes when applicable•use static attributes when applicable• avoid creating intermediate objectsString str = new String(“11”);int sval = Integer.parseInt(str);String str = new String(“11”);int sval = new Integer(str).intValue();YHL Improve Performance 12YHL Improve Performance 13YHL Improve Performance


View Full Document

Purdue ECE 462 - Sound

Download Sound
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Sound and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Sound 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?