We have used Matlab to read, write, plot, and play audio files. We begin by taking the fast fourier transforms (fft) of these audio files and manipulated the locations of the frequencies using different methods.
Original Sample
1. changing the sample rate
Audio files have a given sample rate at which they are recorded, usually 44.1 kHz. If you play the audio file back at a different sample rate the pitch of the audio is changed. For example, if you play the audio at 88.2kHz the frequency of the sound is higher due to the wave function being read faster; this however also changes the length of time of the audio sample (something we want to avoid in our project).
Half the Sample Frequency
Twice the Sample Frequency
2. upsampling/downsampling
By adding samples to the array of the sound file, but playing it back at the original sampling rate, changes the pitch of the audio file when played back. This is done by either adding elements to the array every nth element (upsampling) or deleting every nth sample of the array (downsampling). Upsampling decreases the frequency and downsampling raises the frequency. This also changes the amount of time the sound file takes on playback because it changes the length of the array being read, but not the speed at which it is read.
Upsampling
Downsampling
3. phase shifting
When taking the fft of a wavefunction, you get an array of amplitudes, and the matrix element it the frequency of which the amplitude value is representative. When phase shifting , the elements get shifted down or up and the elements at the end of the array are looped to the beginning.
Phase Shifting
4. finding peaks
If you use a peak finding function of the fft of a wavefunction, you could use those values to rebuild the signal using sinusoidal function of frequencies of the locations of the peaks. if you were to shift the values of those peaks before rebuilding the wavefunction, you could in theory create a wavefunction of a different pitch without changing the amount of time. We have yet to implement this method, but it is part of our next trials.
Please find the Matlab code here:
https://drive.google.com/a/vassar.edu/file/d/0B4quZV7NVNf7ako4RlBkeUNETXc/view?usp=sharing
Sound File Source:
http://eleceng.dit.ie/dorran/matlab/