Question: Question 4 : Sound Synthesis [ 3 0 marks ] Square waves are particularly useful in electronics as they can represent low and high states

Question 4: Sound Synthesis [30 marks]
Square waves are particularly useful in electronics as they can represent low and high states (they only have 2 states). We can also create audio forms with square waves. Like any periodic waveform, square waves will have an amplitude and frequency.
In WAVE files, this square wave can be represented using the minimum and maximum values of bit depth, i.e. in a WAVE file with a bit depth of 16, high states will be represented with the number 32767 and low states will be represented with the number -32768.
Write a MIPS program, called question4.asm, that will generate square waves. You will need to obtain, from the user (in this order), the full output file name (the entire path), the tone frequency (how many times a wave period will appear within a second, an integer), the sample frequency (how many sound samples will be measured in a second, an integer), and the length of the tone (an integer in seconds).
Your output file should have 1 channel only and a bit depth of 16. You should ignore the contents of the header: set all 44 bytes of the header to 0. Your tone should always start with the high state. You may assume that the tone frequency, sample frequency and length will be such that there will always be an even number of samples per wave period.
Note: for this question, the Automarker will not check your console output (and there should not be console output, only input). It will only check your output file. When it prints your output file, it will convert your binary file to a textual hexadecimal form.
Sample Console Input (do not place the comments in the program input):
/home/lynn/Documents/CSC2002S/assign1/q4_t1_out.wav
2 # tone frequency
20 # sample frequency
1 # length of the tone
Sample File Output (represented as text using xxd):
00000000: 00000000000000000000000000000000
00000010: 00000000000000000000000000000000
00000020: 000000000000000000000000 ff 7f ff 7f
00000030: ff 7f ff 7f ff 7f 00800080008000800080
00000040: ff 7f ff 7f ff 7f ff 7f ff 7f 008000800080
00000050: 00800080

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!