Utility code for some common DSP tasks