Notes
- Work on this assignment individually.
- Feel free to ask your TA or your fellow students questions. But don’t share code.
- If you find a bug or typo feel free to reach out to me and I’ll fix it.
Introduction:
In this assignment you write a program that takes ASCII characters and generates FSK (Frequency-shift Keying) modulated signal.
Instead of transmitting your encoded signal over the telephone, you’ll write it wav file. Download Audacity https://www.audacityteam.org. Audacity will help visualize visualize the wav files your program produces.

Pulse Generation
Download the skeleton code from here.
Let’s begin by implementing the generate_pulse function. This function generate a float array contain the samples associated with pulse. Your system should transmit at a rate of 120 bits per second (Yeah really slow, but it make easy to visualize your signal and debug it). The system will operate at 48 Kilo samples per second (48000). The zero frequency will be 1.4KHz and the one frequency will be 2.4 KHz. Waves will have an amplitude of 3.
Below is the general formula for a wave. All you wave’s will have zero phase ( ϕ)
y(t) = A*sin(2πft + ϕ)
float * generate_pulse( bool is_a_one){
........
}
Converting ASCII
Next we’ll convert the ASCII word supplied into a binary string 1s and 0s. Since this may focus on this assignment we’ll use the text_to_binary function written by @gowrath
char* text_to_binary(char * text){
int text_length = strlen(text);
char* binary = malloc(text_length * 8 + 1);
binary[0] = '\0';
for(size_t i = 0; i < text_length; ++i) {
char ch = text[i];
for(int j = 7; j >= 0; --j){
if(ch & (1 << j)) {
strcat(binary,"1");
} else {
strcat(binary,"0");
}
}
}
return binary;
}
Convert Binary to Samples
Now that you have string 1s and 0 representing your ascii characters, let’s convert this binary string FSK modulated wave. Implement the binary_to_audio_sample
float * binary_to_audio_samples(char* binary){
}
Write to Wave File
Now let’s write you samples to the wav file. Implement the write_wav_file function. You’ll use the TinyWav library write the wave file. You find more information on the TinyWav on the GitHub page https://github.com/mhroth/tinywav I included the c files associated with TinyWav libary
void write_wav_file(float* samples, char* outputPath, int length){
}
What to Submit
Encode the following phrase “The Good Old Song” and submit the generated file to collab.