DSP(3)

DSP(3) ๐Ÿ’–โœจ

okay bestie, welcome to DSP(3) from the Library Functions Manual โ€” this is the digital signal processing girlie page and honestly? it's giving modem core ๐ŸŽ€


โœจ NAME โœจ

initdp, freedp, dotprod, sumsq, peakval โ€” SIMD-assisted digital signal processing primitives ๐Ÿ’…


๐ŸŒธ SYNOPSIS ๐ŸŒธ

#include "fec.h"

void *initdp(signed short *coeffs,int len);
long dotprod(void *p,signed short *a);
void freedp(void *p);

unsigned long long sumsq(signed short *in,int cnt);

int peakval(signed short *b,int cnt);

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

so these functions are the little squad of basic primitives that are useful in digital signal processing (DSP), especially in modems. ๐Ÿซถ

  • initdp, dotprod and freedp together implement an integer dot product, which is useful in correlation and filtering operations on signed 16-bit integers. iykyk ๐Ÿ”ฅ
  • sumsq computes the sum of the squares of an array of signed 16-bit integers โ€” so useful for measuring the energy of a signal โšก
  • peakval returns the absolute value of the largest magnitude element in the input array โ€” great for scaling a signal's amplitude, periodt ๐Ÿ“ˆ

and the best part?? each function uses IA32 or PowerPC Altivec instructions when they're available ๐Ÿ’€โœจ otherwise a portable C version is used. no cap, it just adapts. main character energy fr fr.


๐Ÿ’œ USAGE ๐Ÿ’œ

okay so here's how you actually use these:

to create a FIR filter or correlator, call initdp with the coefficients in coeff and their number in len. this creates the appropriate data structures and returns a handle. ๐ŸŽ€

to compute a dot product, pass the handle from initdp and the input array to dotprod. No length field is needed as the number of samples will be taken from the len parameter originally given to initdp. โš ๏ธ there must be at least as many samples in the input array as there were coefficients passed to initdp. don't play with that.

when the filter or correlator is no longer needed, the data structures may be freed by passing the handle to freedp. bye bestie ๐Ÿ‘‹๐Ÿ’–

the user is responsible for scaling the inputs to initdp and dotprod, because the 32-bit result from dotprod will silently wrap around in the event of overflow. SILENTLY. it will not tell you. it will not warn you. it will just wrap. ๐Ÿ˜ญ be careful.

to compute the sum of the squares of an array of signed 16-bit integers, use sumsq. this returns a 64 bit sum. ๐Ÿงฎโœจ

peakval computes the absolute value of each 16-bit element in the input array and returns the largest. ๐Ÿ‘‘


โญ RETURN VALUES โญ

  • initdp returns a handle that points to a control block, or NULL in the event of an error (such as a memory allocation failure). ๐Ÿ˜ญ
  • sumsq and peakval have no error returns. they simply do not miss. ๐Ÿ’…

Phil Karn, KA9Q (karn@ka9q.net) โ€” an absolute legend, we stan ๐Ÿซถ๐ŸŒธ


and that's the whole page bestie!! ๐Ÿ’– this was DSP(3) from the Library Functions Manual, so if you see DSP(3) down at the bottom of your terminal, that's just this page saying hi. go forth and filter those signals, you got this ๐ŸŽ€โœจ๐Ÿฆ‹