Demodulation/filtering of a binary signal
Assuming the data has an approximately equal mix of 0 and 1, set the decision threshold equal to the long-term average amplitude of the signal.

Otherwise, you can do a peak detection and set the threshold to the appropriate fraction of the detected peak level.