c Programming for music technology

C Language 

Project 1 - read and write WAV file

This is a program that reads a WAV file, adjusts the maximum absolute value of the amplitude of the signal, and saves the adjusted data in a new WAV file. The program has the following command line usage:

     ./process_wav –max amplitude ifile ofile
amplitude - the maximum absolute level in ofile on the scale of 0 to 32768
ifile - the input audio file in *.wav format
ofile - the output audio file in *.wav format

Github link : https://github.com/j4092627/ReadAndWriteWavFile

project 2 - Tone Generator

This is a program that will generate and play a tone. This program uses the PortAudio library.

Your program should have the following command line usage:

      tone_generator [–f freq_Hz] [–a level_dBFS] [-s sample_rate_fs]

All arguments are optional. Arguments that are not specified on the command line are set to the following default values:

     double f0 = 440; // frequency of tone to play out
     double fs = 48000; // sampling rate of play out
     int level_dBFS = -24; // level of play out, dBFS

Github link : https://github.com/j4092627/ToneGenerator

project 3 - Wav File Play

It is a program that will load and play a selected wav file. Add to the code in the instructor-supplied file play_wavfiles.c and fill in code under the comment blocks.

open ifile_list.txt and read each line which is a path to one of the WAV files that can be selected and played. Print list of input files paths with a number indicating order in the file. For example:

     0  file1.wav

     1  file2.wav

Use ncurses example code to receive key presses and take action. Possible actions based on key pressed are:

1-N Switch to playing input file corresponding to the number pressed. Q Quit the program.

If Q is selected, close all files and free all allocated storage before exiting.

Github link : https://github.com/j4092627/WavFilePlayAndReverb

project 4 - reverb

The program has the following usage:

     ./wav_reverb ifile.wav reverb_file.wav [ofile.wav]
ifile.wav - input audio file
reverb_file.wav - reverberation impulse response file
ofile.wav - output audio file

Process the input and reverb signals to create the output signal. The function should operate on an arbitrary number of channels (up to MAX_CHN ). Create three “versions,” selected via a #define MODE N preprocessor directive:

#define MODE 1
Just copy the input file values to the output file, and copy an additional rframes-1 zeros. This can be used to test the fread() and fwrite() code in your main program.

#define MODE 2
Convolve the input signal with the reverberation impulse response. The convolution result has iframes+rframes-1 samples.

Compute the RMS value of the input and output signals for all samples and all channels.

Normalize the output signal such that it has the same RMS value as the input signal.

#define MODE 3
Use the supplied convolve() function to perform the convolution via FFTs.

Github link : https://github.com/j4092627/WavFilePlayAndReverb

project 5 - Architectural Acoustics

The program takes an input WAV file and imposes a reverberation on the file due to a specified room, and writes out the result. It requires a parameter file, and the instructor has supplied example files parameter1.txt (small room) and parameter2.txt (large room).

This program must have the following command line syntax:

./room_acoustics parameters.txt ifile.wav ofile.wav

parameters.txt is the parameter file as described above

ifile.wav and ofile.wav are the input and output wav files

Github link : https://github.com/j4092627/ArchitechturalAcoustics

project 6 - Audio Effects

The file audioEffects.cpp is the main routine and uses portAudio, sndFile, and nCurses. In each portAudio callback, paCallback(), a full input buffer is received from the A/D and an empty output buffer is ready to send to the D/A. In addition, there is the option of replacing either the A/D input buffer or the D/A output buffer or both with reads from and writes to WAV files, with filenames specified on the command line.

The nCurses loop receives one of the following input key presses:

  • P  Pass Through: copy the input buffer to the output buffer

  • L  Low pass filter the input buffer and put the result in the output buffer 

  • H  High pass filter the input buffer and put

  • D  Apply a dynamic range control from input buffer to output buffer

  • Q  Quit: exit the program

Github link : https://github.com/j4092627/AudioEffect