MATLAB: How to convert an audio or mp3 signal to a binary signal

audio conversionModulation

I have to read the audio signal
then covert the audio signal to the Binary SIgnal to be ready for the modulation.
How to perform the COnversion of the Audio SIgnal to Binary signal that could be domedulated in the end to give the original voice signal?

Best Answer

filename = 'YourFileNameGoesHere.mp3';
fid = fopen(filename, 'r');
file_bits = fread(fid, [1 inf], 'bit1=>uint8');
fclose(fid);
file_bits is now a vector of binary values ready for modulation.
At the other end, demodulate into a vector of uint8, and do any appropriate error correction. Then
filename = 'YourOutputFileNameGoesHere.mp3';
outfid = fopen(filename, 'w');
fwrite(outfid, file_bits, 'bit1');
fclose(outfid);
The other end will now have a copy of the mp3 file, which can be played through whatever mp3 player the other end has.
Note: if there was uncorrected transmission noise, then the file that is written might be corrupted in a way that makes it impossible to play. So be sure to put in enough error detection and correction for the circumstances.
Related Question