Sound waves exhibits behaviours like reflection, absorption, refraction, diffusion and diffraction. In a closed space, these collectively cause a phenomenon commonly known as reverberation. In reverberation, the sound waves remain persistent in an indoor environment for some time. This depends on the environmental composition and time it takes for sound waves energy to become negligible. Our encoding and decoding algorithms are designed to overcome such reverberation.
1) Encoding Algorithm: Encoding of the service code in the ultra-sound audio signal is achieved by custom version of Four Frequency Shift Keying (4-FSK) after applying a Base64 compression to the string. The whole encoding process has two steps. Base64 is an encoding scheme in which each character is represented by 6 bits instead of 8-bits. As in our case the string to be encoded is always textual data, Base64 compression is viable. This allows us to compress the original string by 25 percent. The Base64 compression algorithm also converts the compressed string into a stream of bits so that they can be passed to the 4-FSK encoding algorithm for conversion into an audio signal.
We use a custom version of four frequency shift keying encoding scheme with two synchronizing frequencies. In this encoding scheme four unique frequencies carry the actual data while two frequencies are used to indicate the start and/or end of the data. The algorithm reads a pack of two bits, turn by turn, from the bit stream provided by the Base64 compressor and generates an audio file with packets of sinusoidal waves individually comprising of different frequencies depending on the data encoded. The audio file generated has bit depth of 16 bits and has a sampling rate of 48 kHz.
The generated audio files encodes the data in form of audio packets, each carrying information of two bits of the original data. A data packet carries three different frequencies; synchronization frequency, silence frequency, and data frequency
and is divided into four sections. The synchronization frequency in the audio packet signifies that a new packet has begun and that upcoming acoustic signals will be a part of it until another synchronization frequency is received. The silent signal is introduced in between synchronization frequencies and data frequencies to make it possible to distinguish them separately. This causes the client device to detect the synchronization frequencies and the data frequencies at the same time with modified amplitudes resulting in wrong detection of the broadcasted signals. There are four data frequencies in 4-FSK encoding scheme, ranging from 20.00 kHz to 20.60 kHz. After the data frequency a silence is generated so that in reverberating environments two audio packets do not bleed into each other. The data packet is arranged in a sequence of synchronization frequency, silence frequency, data frequency, and finally silence frequency. To optimize length of the audio signal and resolve errors in the communication, lengths of each of the parts of the packets can be modified as they greatly affect the operation of the algorithm.
2) Decoding Algorithm: The decoding algorithm receives a stream of audio buffers equivalent to a single audio packet received by the microphone. It decodes each buffer, by processing the values of amplitudes of the received coding frequencies using a Fourier transform. Signals are then converted into audio data packets and audio data packets to a stream of bits. The algorithm continues to pass audio buffers to the decoding function until synchronization frequency in any of the buffers is identified which indicates start of a new packet. The algorithm then waits for the time equivalent to length of Silence 1 and starts accumulating the amplitudes of each data frequencies as received in each buffer. The algorithm then waits for the time equivalent to Length of the data signal and starts looking for the other synchronization frequency. As it receives the buffer with the traces of the other synchronization frequency, it completes the current audio packet. The data frequency with the biggest sum of the amplitudes is considered to be the data frequency for the current packet and its corresponding bits set is added to the decoded stream of bits. The pseudocode of the decoding algorithm, divided into different sections based on the task, is shown in Listings 1. After every service code a silence of 200 ms is introduced. This helps the client to differentiate between two different broadcasts. When enough number of bits are decoded, they are sent through the Base64 extractor to get the original service code.