1 / 14

ENGI 2420 Structured Programming (Lab Tutorial 7)

ENGI 2420 Structured Programming (Lab Tutorial 7). Memorial University of Newfoundland. Preferences in Eclipse. Warning message “no newline at end of file” How to enable automatic newline insertion in Eclipse

ismael
Download Presentation

ENGI 2420 Structured Programming (Lab Tutorial 7)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ENGI 2420Structured Programming (Lab Tutorial 7) Memorial University of Newfoundland

  2. Preferences in Eclipse • Warning message “no newline at end of file” • How to enable automatic newline insertion in Eclipse check Window -> Preferences -> C/C++ -> Editor -> Ensure newline at end of file when saving • How to show line number in Eclipse check Window -> Preferences -> General -> Editors -> Text Editors -> Show line numbers

  3. Assignment-7 • Purpose of this assignment a filter to implement a fuzzbox effect on a sound (music) file or an echo effect • Structure of C++ files - assign7.h (downloadable): contains the declarations for the functions - a7main.cpp (downloadable): main function that can be used as test code - assign7.cpp: contains your implemented functions (only submit this one via web-submit) - you may want to create your own test code in a separate .cpp file (do NOT submit your test code)

  4. readSoundData • int readSoundData(int snd[]) • Read the sound data from cin and store it in snd, which can be assumed to be big enough for at least MAX_SND_SIZE (500000) samples. Return the number of samples read, if successful. If the number of samples input is invalid, then return 0

  5. Data Format • Must be strictly adhered to so that your program can interact with MMGood • The data consists of a sequence of integers each on a separate line • The first number is to be interpreted as the number of samples to follow (i.e., the size of the data), while the remaining numbers are the data 10 45 -80 23 78 -39 -65 -20 30 79 65

  6. writeSoundData • void writeSoundData(int snd[], int size) • Output (to cout) the size samples in snd using the format described above

  7. fuzzBox • int fuzzBox(int snd[], int size, int clip) • Clip the size samples in snd to a maximum amplitude (magnitude) of clip. Elements of snd whose magnitude is greater than clip should be set to clip or -clip appropriately, so as not to change the sample's sign. Return the number of samples that had their value changed.

  8. fuzzBox • Example: • Initial value of the array. +200 +10 -190 -150 +20 • clip = 100 • Final value of the array +100 +10 -100 -100 +20

  9. echoBox • void echoBox(int snd[], int size, int delayTime) • Add a delayed copy of the sound to the sound • Example 90 -100 50 60 70and the delay time is 2, then the final value of the sample will be 90 -100 140 -40 120

  10. Running the Program • Our main program uses a "program argument" to select the effect (fuzz or echo). 0 is for fuzz and 1 is for echo • Windows: from the (windows) command line you launch your program as follows: C:\My Documents\courses\sp\workspace\A7> .\debug\A7 0 or C:\My Documents\courses\sp\workspace\A7> .\debug\A7 1 • In Eclipse, you can use the "Run > Open Run Dialog..." command and then edit the "program arguments" to be either "0" or "1" to select fuzzBox or echoBox respectively

  11. Running with MMGood • MMGood is a java program that will execute your program on actual.wav files so you can hear them working • Download mmgood.jar to your hard drive • Download the sample .wav files: engage.wav and guitar.wav • For windows • Download mmgood.bat and put it in the same directory • Double click on mmgood.bat • For unix/linux/mac • Download mmgood.sh to the same directory • Make this file executable. • Execute the mmgood.sh file

  12. Running with MMGood • Once mmgood's main window has appeared, and you have compiled your project, you can • Load an input .wav file • Play the input .wav file

  13. Running with MMGood • Select your assignment 7 executable. (It is in the Debug subdirectory of your project directory and, in Windows, its name will end with ".exe".) • Set the argument to be 0 or 1 • Run the executable • Wait patiently for your program to finish • Play the output sound

  14. Running with MMGood • Wait patiently for your program to finish • Play the output sound

More Related