WavDecoder
Coding Challenge for ParadoxCat
WavHeaderReader
This class takes the ByteArray which supposed to be a 44 bytes length array from the very start of the WAV file. Then WavHeaderReader parses every header field into a corresponding class field.
WavDataDecoder
In this file all the work is done. The decoding process is:
- reading WAV data section bytes.
- transforming those bytes into a samples (blocks of size of number of channels) and normalize them. Since the samples data might not be an ideal rectangle those samples should be normalized by fitting them to the maximum or minimum value.
- transforming the normalized samples to rectangle signals. The resulted rectangle signals should also be normalized by the similar mechanism as at point 2.
- the resulted list of rectangle signals could be transformed into the bits string according to the modulation system given.
- from the resulted bits string encrypted bytes could be extracted (for this purpose the Regex pattern matching on the bits string is used).
- from the resulted list of encrypted bytes the real bytes should be extracted. It means to drop one first (start) and two last (stop) bits, and reverse the remaining bits string to get the byte representation in MSBF system.
- from the resulted list of decrypted bytes the data message could be found by dropping first 0xFF bytes, then "ID" section containing 0x42 and 0x03 bytes and taking all the bytes until the 0x00 byte was reached. The resulted amount of bytes should be equal to 1984.
- these bytes could be mapped into a tone data chunks with 30 bytes of data and 1 check sum byte.
- as the final step the checksum of 30 bytes of each tone data chunk is calculated and compared to the parsed check sum byte. The program returns true if only every of calculated check sum byte equal to the corresponding parsed one.