CS 3733 Operating Systems, Spring 1997 Assignment 2
Due on February 25
In this assignment you will write and test an audio object similar to the one
Program 3.4 of PUP.
Learn how to use the audiotool to record and play sound files.
Make 10 audio files called audio.0 through audio.9.
Each file should contain a single word corresponding to a number from
0 to 9. For example, to create the file audio.7, record yourself
speaking the number seven. Edit the files so there is no noise before or
after the spoken word. Also make a file called audio.mine which
contains the phrase This program was written by ... where the phrase ends
with your full name. Make sure you speak your full name clearly so it
can be easily understood. Now record a file called audio.pid
which contains the phrase This is process.
Create a file called audioobj.c which will contain your audio object.
It will have the following functions which have external linkage.
No other functions or variables may have external linkage, but you may
have additional functions and variables with internal linkage.
Each one of these returns -1 on error and unless otherwise stated returns
0 on success. The functions in this file should not write to standard
output or standard error.
which opens the audio device for output.
which closes the audio device.
int audio_write_buffer(char *buf, int size);
which sends size bytes from the buffer buf
to the audio device.
int audio_read_a_file(char *name, char **bufp);
which reads in an audio file with name name into a buffer
and sets *bufp to point to that buffer.
The function must allocate space for the buffer.
Do not assume any maximum for the size of the file.
Use stat to determine how much space to allocate.
On success, return the size of the file read.
int audio_init_num(char *name);
which reads in 10 audio files with names name.0 through
name.9 for use by audio_speak_number.
int audio_speak_number(int n);
which speaks the number n which can be any non-negative integer.
This assumes that the function
audio_init_num has already been called. It should not do any disk I/O.
Write a main program which uses the above audio object. It should be in a file
When the program enters, it should print a line in the form:
This program was written by ... and then another line in the form
This is process .... The first line prints your name and the
second gives the process ID. It should then speak this same
information in your voice.
The main program should do complete error checking.
When an error occurs, output an appropriate
message, close the audio file and exit.
Be sure the close the audio file before exiting your program.
You should have a makefile which will compile and lint your programs.
Be prepared to turn in your lint output. There should not be any
unexplained warning messages.