#ifndef _DSP_H #define _DSP_H #define BlockLen 64 inline short clamp(long a) { return ((a > 32767) ? 32767 : (a < -32768 ? -32768 : a)); } inline short _rnd(long a) { return a + (1<<15); } inline short _sadd(short a, short b) { return clamp(long(a) + long(b)); } inline short _ssub(short a, short b) { return clamp(long(a) - long(b)); } inline long _lsadd(long a, long b) { long sum = a + b; if (a > 0 && b > 0) { if (sum < a || sum < b) sum = 0x7fffffff; } else if (a < 0 && b < 0) { if (sum > a || sum > b) sum = 0x80000000; } return sum; } inline short _smpy(short a, short b) { return (long(a)*long(b)) >> 15; } inline long _smac(long src, short a, short b) { return _lsadd(src, _smpy(a, b)); } inline float to_float(short a) { return a/32768.0f; } inline short from_float(float f) { return clamp(long(f*32768.0f)); } void WaitAudio(short** precv, short** pxmit); void SerialTX(int ch); int SerialRX(); extern short used_recv_chans; extern short used_xmit_chans; extern short xmit_append; extern char* xmit_prefix; extern char* recv_prefix; #endif // header guard