So I am writing a program in Java that does amplitude demodulation. I am reading in a sine wave value by value and determining whether I have a '1' or a '0'. For now I am saving them as chars, but am open to suggestions. I know the number of samples per bit, so determining the bit is not an issue.
I can't figure out a way to convert every set of 8 bits in to a byte, so I can then decode the final array of bytes using UTF-8. Is there an effective way of doing that?
Try this, from the Byte Java API
String myBitString = "10101010";
int radixTwo = 2;
byte myByteValue = Byte.parseByte(myBitString, radixTwo)
Obviously you can add the byte values to a byte[]
array and then use a loop afterwards to display / decode them.