1 ENGI 2420 Structured Programming (Lab Tutorial 7) Memorial University of Newfoundland.
-
Upload
doris-bradley -
Category
Documents
-
view
212 -
download
0
Transcript of 1 ENGI 2420 Structured Programming (Lab Tutorial 7) Memorial University of Newfoundland.
1
ENGI 2420Structured Programming
(Lab Tutorial 7)
Memorial University of Newfoundland
2 ENGI 2420 – Structured Programming
Lab Tutorial 7
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 ENGI 2420 – Structured Programming
Lab Tutorial 7
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 ENGI 2420 – Structured Programming
Lab Tutorial 7
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 ENGI 2420 – Structured Programming
Lab Tutorial 7
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
1045 -8023 78 -39 -65 -20 30 79 65
6 ENGI 2420 – Structured Programming
Lab Tutorial 7
writeSoundData
void writeSoundData(int snd[], int size)
Output (to cout) the size samples in snd using the format described above
7 ENGI 2420 – Structured Programming
Lab Tutorial 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 ENGI 2420 – Structured Programming
Lab Tutorial 7
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
9 ENGI 2420 – Structured Programming
Lab Tutorial 7
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
10 ENGI 2420 – Structured Programming
Lab Tutorial 7
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
11 ENGI 2420 – Structured Programming
Lab Tutorial 7
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
– 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