Instrument Neutral Distributed Interface INDI  2.0.2
Macros | Functions
DSP API Buffer editing functions

Macros

#define dsp_buffer_stretch(buf, len, _mn, _mx)
 Stretch minimum and maximum values of the input stream. More...
 
#define dsp_buffer_set(buf, len, _val)
 Fill the buffer with the passed value. More...
 
#define dsp_buffer_normalize(buf, len, mn, mx)
 Normalize the input stream to the minimum and maximum values. More...
 
#define dsp_buffer_reverse(buf, len)
 Reverse the order of the buffer elements. More...
 
#define dsp_buffer_swap(in, len)
 Change the in buffer elements endianness. More...
 
#define dsp_buffer_copy(in, out, len)
 Fill the output buffer with the values of the elements of the input stream by casting them to the output buffer element type. More...
 
#define dsp_buffer_copy_stepping(in, out, inlen, outlen, instep, outstep)
 Fill the output buffer with the values of the elements of the input stream by casting them to the output buffer element type. More...
 

Functions

DLL_EXPORT void dsp_buffer_shift (dsp_stream_p stream)
 Shift a stream on each dimension. More...
 
DLL_EXPORT void dsp_buffer_removemean (dsp_stream_p stream)
 Subtract mean from stream. More...
 
DLL_EXPORT void dsp_buffer_max (dsp_stream_p stream, dsp_t *in, int len)
 Subtract elements of one stream from another's. More...
 
DLL_EXPORT void dsp_buffer_min (dsp_stream_p stream, dsp_t *in, int len)
 Sum elements of one stream to another's. More...
 
DLL_EXPORT void dsp_buffer_sub (dsp_stream_p stream, dsp_t *in, int len)
 Subtract elements of one stream from another's. More...
 
DLL_EXPORT void dsp_buffer_sum (dsp_stream_p stream, dsp_t *in, int len)
 Sum elements of one stream to another's. More...
 
DLL_EXPORT void dsp_buffer_div (dsp_stream_p stream, dsp_t *in, int len)
 Divide elements of one stream to another's. More...
 
DLL_EXPORT void dsp_buffer_mul (dsp_stream_p stream, dsp_t *in, int len)
 Multiply elements of one stream to another's. More...
 
DLL_EXPORT void dsp_buffer_pow (dsp_stream_p stream, dsp_t *in, int len)
 Expose elements of one stream to another's. More...
 
DLL_EXPORT void dsp_buffer_log (dsp_stream_p stream, dsp_t *in, int len)
 Logarithm elements of one stream using another's as base. More...
 
DLL_EXPORT void dsp_buffer_sub1 (dsp_stream_p stream, dsp_t val)
 Subtract a value from elements of the input stream. More...
 
DLL_EXPORT void dsp_buffer_1sub (dsp_stream_p stream, dsp_t val)
 Subtract each element of the input stream a value. More...
 
DLL_EXPORT void dsp_buffer_sum1 (dsp_stream_p stream, dsp_t val)
 Sum elements of the input stream to a value. More...
 
DLL_EXPORT void dsp_buffer_div1 (dsp_stream_p stream, double val)
 Divide elements of the input stream to a value. More...
 
DLL_EXPORT void dsp_buffer_1div (dsp_stream_p stream, double val)
 Divide a value to each element of the input stream. More...
 
DLL_EXPORT void dsp_buffer_mul1 (dsp_stream_p stream, double val)
 Multiply elements of the input stream to a value. More...
 
DLL_EXPORT void dsp_buffer_pow1 (dsp_stream_p stream, double val)
 Expose elements of the input stream to the given power. More...
 
DLL_EXPORT void dsp_buffer_log1 (dsp_stream_p stream, double val)
 Logarithm elements of the input stream using the given base. More...
 
DLL_EXPORT void dsp_buffer_median (dsp_stream_p stream, int size, int median)
 Median elements of the input stream. More...
 
DLL_EXPORT void dsp_buffer_sigma (dsp_stream_p stream, int size)
 Standard deviation of each element of the input stream within the given size. More...
 
DLL_EXPORT void dsp_buffer_deviate (dsp_stream_p stream, dsp_t *deviation, dsp_t mindeviation, dsp_t maxdeviation)
 Deviate forward the first input stream using the second stream as indexing reference. More...
 

Detailed Description

Macro Definition Documentation

◆ dsp_buffer_copy

#define dsp_buffer_copy (   in,
  out,
  len 
)
Value:
({ \
int k; \
for(k = 0; k < len; k++) { \
((__typeof (out[0])*)out)[k] = (__typeof (out[0]))((__typeof (in[0])*)in)[k]; \
} \
})

Fill the output buffer with the values of the elements of the input stream by casting them to the output buffer element type.

Parameters
inthe input stream.
outthe output stream.
lenthe length of the first input stream.

Definition at line 1038 of file dsp.h.

◆ dsp_buffer_copy_stepping

#define dsp_buffer_copy_stepping (   in,
  out,
  inlen,
  outlen,
  instep,
  outstep 
)
Value:
({ \
int k; \
int t; \
for(k = 0, t = 0; k < inlen && t < outlen; k+=instep, t+=outstep) { \
((__typeof (out[0])*)out)[t] = (__typeof (out[0]))((__typeof (in[0])*)in)[k]; \
} \
})

Fill the output buffer with the values of the elements of the input stream by casting them to the output buffer element type.

Parameters
inthe input stream.
outthe output stream.
inlenthe length of the input stream.
outlenthe length of the output stream.
instepcopy each instep elements of in into each outstep elements of out.
outstepcopy each instep elements of in into each outstep elements of out.

Definition at line 1059 of file dsp.h.

◆ dsp_buffer_normalize

#define dsp_buffer_normalize (   buf,
  len,
  mn,
  mx 
)
Value:
({\
int k;\
for(k = 0; k < len; k++) {\
buf[k] = Max(mn, Min(mx, buf[k]));\
}\
})
#define Max(a, b)
if max() is not present you can use this one
Definition: dsp.h:179
#define Min(a, b)
if min() is not present you can use this one
Definition: dsp.h:172

Normalize the input stream to the minimum and maximum values.

Parameters
bufthe input buffer
lenthe length in elements of the buffer.
mnthe clamping bottom value.
mxthe clamping upper value.

Definition at line 832 of file dsp.h.

◆ dsp_buffer_reverse

#define dsp_buffer_reverse (   buf,
  len 
)
Value:
({ \
int i = (len - 1) / 2; \
int j = i + 1; \
__typeof(buf[0]) _x; \
while(i >= 0) \
{ \
_x = buf[j]; \
buf[j] = buf[i]; \
buf[i] = _x; \
i--; \
j++; \
} \
})

Reverse the order of the buffer elements.

Parameters
bufthe inout stream.
lenthe length of the input stream.

Definition at line 991 of file dsp.h.

◆ dsp_buffer_set

#define dsp_buffer_set (   buf,
  len,
  _val 
)
Value:
({\
int k;\
for(k = 0; k < len; k++) {\
buf[k] = (__typeof(buf[0]))(_val);\
}\
})

Fill the buffer with the passed value.

Parameters
bufthe input buffer
lenthe length in elements of the buffer.
_valthe desired value.

Definition at line 815 of file dsp.h.

◆ dsp_buffer_stretch

#define dsp_buffer_stretch (   buf,
  len,
  _mn,
  _mx 
)
Value:
({\
int k;\
__typeof(buf[0]) __mn = dsp_stats_min(buf, len);\
__typeof(buf[0]) __mx = dsp_stats_max(buf, len);\
double oratio = (_mx - _mn);\
double iratio = (__mx - __mn);\
if(iratio == 0) iratio = 1;\
for(k = 0; k < len; k++) {\
buf[k] -= __mn;\
buf[k] = (__typeof(buf[0]))((double)buf[k] * oratio / iratio);\
buf[k] += _mn;\
}\
})
#define dsp_stats_min(buf, len)
Gets the minimum value of the input stream.
Definition: dsp.h:562
#define dsp_stats_max(buf, len)
Gets the maximum value of the input stream.
Definition: dsp.h:580

Stretch minimum and maximum values of the input stream.

Parameters
bufthe input buffer
lenthe length in elements of the buffer.
_mnthe desired minimum value.
_mxthe desired maximum value.

Definition at line 792 of file dsp.h.

◆ dsp_buffer_swap

#define dsp_buffer_swap (   in,
  len 
)
Value:
({ \
int k; \
switch(sizeof(((__typeof (in[0])*)in)[0])) { \
case 2: \
for(k = 0; k < len; k++) \
((__typeof (in[0])*)in)[k] = __bswap_16(((__typeof (in[0])*)in)[k]); \
break; \
case 3: \
for(k = 0; k < len; k++) \
((__typeof (in[0])*)in)[k] = __bswap_32(((__typeof (in[0])*)in)[k]); \
break; \
} \
})
#define __bswap_32(a)
Definition: dsp.h:34
#define __bswap_16(a)
Definition: dsp.h:33

Change the in buffer elements endianness.

Parameters
inthe inout stream.
lenthe length of the input stream.

Definition at line 1013 of file dsp.h.

Function Documentation

◆ dsp_buffer_1div()

DLL_EXPORT void dsp_buffer_1div ( dsp_stream_p  stream,
double  val 
)

Divide a value to each element of the input stream.

Parameters
streamthe stream on which execute
valthe nominator.

Definition at line 175 of file buffer.c.

◆ dsp_buffer_1sub()

DLL_EXPORT void dsp_buffer_1sub ( dsp_stream_p  stream,
dsp_t  val 
)

Subtract each element of the input stream a value.

Parameters
streamthe stream on which execute
valthe value to be subtracted.

Definition at line 145 of file buffer.c.

◆ dsp_buffer_deviate()

DLL_EXPORT void dsp_buffer_deviate ( dsp_stream_p  stream,
dsp_t deviation,
dsp_t  mindeviation,
dsp_t  maxdeviation 
)

Deviate forward the first input stream using the second stream as indexing reference.

Parameters
streamthe stream on which execute
deviationthe stream containing the deviation buffer
mindeviationthe deviation at 0.
maxdeviationthe deviation at 1.

Definition at line 391 of file buffer.c.

◆ dsp_buffer_div()

DLL_EXPORT void dsp_buffer_div ( dsp_stream_p  stream,
dsp_t in,
int  len 
)

Divide elements of one stream to another's.

Parameters
streamthe stream on which execute
inthe buffer operand.
lenthe length of the buffer

Definition at line 101 of file buffer.c.

◆ dsp_buffer_div1()

DLL_EXPORT void dsp_buffer_div1 ( dsp_stream_p  stream,
double  val 
)

Divide elements of the input stream to a value.

Parameters
streamthe stream on which execute
valthe denominator.

Definition at line 185 of file buffer.c.

◆ dsp_buffer_log()

DLL_EXPORT void dsp_buffer_log ( dsp_stream_p  stream,
dsp_t in,
int  len 
)

Logarithm elements of one stream using another's as base.

Parameters
streamthe stream on which execute
inthe buffer operand.
lenthe length of the buffer

Definition at line 134 of file buffer.c.

◆ dsp_buffer_log1()

DLL_EXPORT void dsp_buffer_log1 ( dsp_stream_p  stream,
double  val 
)

Logarithm elements of the input stream using the given base.

Parameters
streamthe stream on which execute
valthe logarithmic base.

Definition at line 215 of file buffer.c.

◆ dsp_buffer_max()

DLL_EXPORT void dsp_buffer_max ( dsp_stream_p  stream,
dsp_t in,
int  len 
)

Subtract elements of one stream from another's.

Parameters
streamthe stream on which execute
inthe buffer operand.
lenthe length of the buffer

Definition at line 79 of file buffer.c.

◆ dsp_buffer_median()

DLL_EXPORT void dsp_buffer_median ( dsp_stream_p  stream,
int  size,
int  median 
)

Median elements of the input stream.

Parameters
streamthe stream on which execute
sizethe length of the median.
medianthe location of the median value.

Definition at line 280 of file buffer.c.

◆ dsp_buffer_min()

DLL_EXPORT void dsp_buffer_min ( dsp_stream_p  stream,
dsp_t in,
int  len 
)

Sum elements of one stream to another's.

Parameters
streamthe stream on which execute
inthe buffer operand.
lenthe length of the buffer

Definition at line 90 of file buffer.c.

◆ dsp_buffer_mul()

DLL_EXPORT void dsp_buffer_mul ( dsp_stream_p  stream,
dsp_t in,
int  len 
)

Multiply elements of one stream to another's.

Parameters
streamthe stream on which execute
inthe buffer operand.
lenthe length of the buffer

Definition at line 112 of file buffer.c.

◆ dsp_buffer_mul1()

DLL_EXPORT void dsp_buffer_mul1 ( dsp_stream_p  stream,
double  val 
)

Multiply elements of the input stream to a value.

Parameters
streamthe stream on which execute
valthe value used for this operation.

Definition at line 195 of file buffer.c.

◆ dsp_buffer_pow()

DLL_EXPORT void dsp_buffer_pow ( dsp_stream_p  stream,
dsp_t in,
int  len 
)

Expose elements of one stream to another's.

Parameters
streamthe stream on which execute
inthe buffer operand.
lenthe length of the buffer

Definition at line 123 of file buffer.c.

◆ dsp_buffer_pow1()

DLL_EXPORT void dsp_buffer_pow1 ( dsp_stream_p  stream,
double  val 
)

Expose elements of the input stream to the given power.

Parameters
streamthe stream on which execute
valthe nth power to expose each element.

Definition at line 205 of file buffer.c.

◆ dsp_buffer_removemean()

DLL_EXPORT void dsp_buffer_removemean ( dsp_stream_p  stream)

Subtract mean from stream.

Parameters
streamthe stream on which execute

Definition at line 47 of file buffer.c.

◆ dsp_buffer_shift()

DLL_EXPORT void dsp_buffer_shift ( dsp_stream_p  stream)

Shift a stream on each dimension.

Parameters
streamthe input stream.

Definition at line 24 of file buffer.c.

◆ dsp_buffer_sigma()

DLL_EXPORT void dsp_buffer_sigma ( dsp_stream_p  stream,
int  size 
)

Standard deviation of each element of the input stream within the given size.

Parameters
streamthe stream on which execute
sizethe reference size.

Definition at line 358 of file buffer.c.

◆ dsp_buffer_sub()

DLL_EXPORT void dsp_buffer_sub ( dsp_stream_p  stream,
dsp_t in,
int  len 
)

Subtract elements of one stream from another's.

Parameters
streamthe stream on which execute
inthe buffer operand.
lenthe length of the buffer

Definition at line 57 of file buffer.c.

◆ dsp_buffer_sub1()

DLL_EXPORT void dsp_buffer_sub1 ( dsp_stream_p  stream,
dsp_t  val 
)

Subtract a value from elements of the input stream.

Parameters
streamthe stream on which execute
valthe value to be subtracted.

Definition at line 155 of file buffer.c.

◆ dsp_buffer_sum()

DLL_EXPORT void dsp_buffer_sum ( dsp_stream_p  stream,
dsp_t in,
int  len 
)

Sum elements of one stream to another's.

Parameters
streamthe stream on which execute
inthe buffer operand.
lenthe length of the buffer

Definition at line 68 of file buffer.c.

◆ dsp_buffer_sum1()

DLL_EXPORT void dsp_buffer_sum1 ( dsp_stream_p  stream,
dsp_t  val 
)

Sum elements of the input stream to a value.

Parameters
streamthe stream on which execute
valthe value used for this operation.

Definition at line 165 of file buffer.c.