Assignment 1: Basic Sound Production

Goal

To understand the basic parameters of digital sound: waveform, sampling rate, frequency, sample size, number of channels and encoding method.

Task list

  1. Write a C program to generate a sine wave with these parameters
    1. sampling rate 44100 samples per sec.
    2. frequency 440 cycles per sec (A above middle C)
    3. one channel (mono)
    4. 2 signed bytes per sample
    5. linear encoding
    6. length 4 secs.
  2. Verify that your program works by using the utility aplay with the same parameters as above on the file that the program produces. What sound do you hear?
  3. Use aplay again, but vary the playback parameters. What happens when you alter the sampling rate? What happens when you change the number of channels to 2? What happens when you change the number of bytes per sample to three?
  4. Alter the program to 'clip' the output. i.e. if the numbers grow larger than two bytes will hold, keep the output value at the maximum value. Play it with aplay. What sound do you hear?
  5. Alter the original version to add in the second third and fourth harmonics with amplitude in inverse proportion to the number of the harmonic. Play the file again with aplay. What sound do you hear?

Hints

Deliverables

Due Date

February 6th . before midnight. Please submit your assignment using the homework submission page.