Separate demodulation code from webworker-specific code to make it easier to introduce new modulation schemes.