192 lines
3.9 KiB
C
192 lines
3.9 KiB
C
// --------------------------------------------------------------
|
|
// --------------------------------------------------------------
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
#include <math.h>
|
|
|
|
#include "synth_defs.h"
|
|
#include "vector_utils.h"
|
|
|
|
// --------------------------------------------------------------
|
|
// Exported functions
|
|
// --------------------------------------------------------------
|
|
void Add_inplace_VS(synth_float_t *pSrcDst1, synth_float_t gain1, synth_float_t src2, UINT32 len)
|
|
{
|
|
if (gain1 == 0)
|
|
{
|
|
while(len--)
|
|
{
|
|
*(pSrcDst1) = src2;
|
|
pSrcDst1++;
|
|
}
|
|
return;
|
|
}
|
|
|
|
while(len--)
|
|
{
|
|
*(pSrcDst1) = *(pSrcDst1)*gain1 + src2;
|
|
pSrcDst1++;
|
|
}
|
|
}
|
|
|
|
void Add_inplace_VV(synth_float_t *pSrcDst1, synth_float_t gain1, synth_float_t *pSrc2, synth_float_t gain2, UINT32 len)
|
|
{
|
|
if (gain1 == 0)
|
|
{
|
|
while(len--)
|
|
{
|
|
*(pSrcDst1++) = *(pSrc2++)*gain2;
|
|
}
|
|
return;
|
|
}
|
|
|
|
if ((gain1 == 1.0) && (gain2 == 1.0))
|
|
{
|
|
while(len--)
|
|
{
|
|
*(pSrcDst1++) += *(pSrc2++);
|
|
}
|
|
return;
|
|
}
|
|
|
|
while(len--)
|
|
{
|
|
*(pSrcDst1) = *(pSrcDst1)*gain1 + *(pSrc2++)*gain2;
|
|
pSrcDst1++;
|
|
}
|
|
|
|
}
|
|
|
|
void Add_VS(synth_float_t *pDst, synth_float_t *pSrc1, synth_float_t gain1, synth_float_t src2, UINT32 len)
|
|
{
|
|
while(len--)
|
|
{
|
|
*(pDst++) = *(pSrc1++)*gain1 + src2;
|
|
}
|
|
}
|
|
|
|
void Add_VV(synth_float_t *pDst, synth_float_t *pSrc1, synth_float_t gain1, synth_float_t *pSrc2, synth_float_t gain2, UINT32 len)
|
|
{
|
|
while(len--)
|
|
{
|
|
*(pDst++) = *(pSrc1++)*gain1 + *(pSrc2++)*gain2;
|
|
}
|
|
}
|
|
|
|
void Sub_inplace_VS(synth_float_t *pSrcDst1, synth_float_t gain1, synth_float_t src2, UINT32 len)
|
|
{
|
|
while(len--)
|
|
{
|
|
*(pSrcDst1) = *(pSrcDst1)*gain1 - src2;
|
|
pSrcDst1++;
|
|
}
|
|
}
|
|
|
|
void Sub_inplace_VV(synth_float_t *pSrcDst1, synth_float_t gain1, synth_float_t *pSrc2, synth_float_t gain2, UINT32 len)
|
|
{
|
|
while(len--)
|
|
{
|
|
*(pSrcDst1) = *(pSrcDst1)*gain1 - *(pSrc2++)*gain2;
|
|
pSrcDst1++;
|
|
}
|
|
}
|
|
|
|
void Sub_VS(synth_float_t *pDst, synth_float_t *pSrc1, synth_float_t gain1, synth_float_t src2, UINT32 len)
|
|
{
|
|
while(len--)
|
|
{
|
|
*(pDst++) = *(pSrc1++)*gain1 - src2;
|
|
}
|
|
}
|
|
|
|
void Sub_VV(synth_float_t *pDst, synth_float_t *pSrc1, synth_float_t gain1, synth_float_t *pSrc2, synth_float_t gain2, UINT32 len)
|
|
{
|
|
while(len--)
|
|
{
|
|
*(pDst++) = *(pSrc1++)*gain1 - *(pSrc2++)*gain2;
|
|
}
|
|
}
|
|
|
|
void Mul_inplace_VS(synth_float_t *pSrcDst, synth_float_t src, UINT32 len)
|
|
{
|
|
while(len--)
|
|
{
|
|
*(pSrcDst++) *= src;
|
|
}
|
|
}
|
|
|
|
void Mul_inplace_VV(synth_float_t *pSrcDst, synth_float_t *pSrc, UINT32 len)
|
|
{
|
|
while(len--)
|
|
{
|
|
*(pSrcDst++) *= *(pSrc++);
|
|
}
|
|
}
|
|
|
|
|
|
void Mul_VS(synth_float_t *pDst, synth_float_t *pSrc1, synth_float_t src2, UINT32 len)
|
|
{
|
|
while(len--)
|
|
{
|
|
*(pDst++) = *(pSrc1++) * src2;
|
|
}
|
|
}
|
|
|
|
void Mul_VV(synth_float_t *pDst, synth_float_t *pSrc1, synth_float_t *pSrc2, UINT32 len)
|
|
{
|
|
while(len--)
|
|
{
|
|
*(pDst++) = *(pSrc1++) * *(pSrc2++);
|
|
}
|
|
}
|
|
|
|
|
|
void Clamp_inplace_V(synth_float_t *pSrcDst, synth_float_t minimum, synth_float_t maximum, UINT32 len)
|
|
{
|
|
while(len--)
|
|
{
|
|
*(pSrcDst) = jsy_max(minimum, jsy_min(maximum, *(pSrcDst)));
|
|
pSrcDst++;
|
|
}
|
|
}
|
|
|
|
void Clamp_V(synth_float_t *pDst, synth_float_t *pSrc, synth_float_t minimum, synth_float_t maximum, UINT32 len)
|
|
{
|
|
while(len--)
|
|
{
|
|
*(pDst++) = jsy_max(minimum, jsy_min(maximum, *(pSrc++)));
|
|
}
|
|
}
|
|
|
|
void uMax_VS(synth_float_t *pDst, synth_float_t *pSrc1, synth_float_t src2, UINT32 len)
|
|
{
|
|
while(len--)
|
|
{
|
|
*(pDst++) = jsy_max(fabs(*(pSrc1++)), src2);
|
|
}
|
|
}
|
|
|
|
void uMax_VV(synth_float_t *pDst, synth_float_t *pSrc1, synth_float_t *pSrc2, UINT32 len)
|
|
{
|
|
while(len--)
|
|
{
|
|
*(pDst++) = jsy_max(fabs(*(pSrc1++)), *(pSrc2++));
|
|
}
|
|
}
|
|
|
|
void uMin_VS(synth_float_t *pDst, synth_float_t *pSrc1, synth_float_t src2, UINT32 len)
|
|
{
|
|
while(len--)
|
|
{
|
|
*(pDst++) = jsy_min(fabs(*(pSrc1++)), src2);
|
|
}
|
|
}
|
|
|
|
void uMin_VV(synth_float_t *pDst, synth_float_t *pSrc1, synth_float_t *pSrc2, UINT32 len)
|
|
{
|
|
while(len--)
|
|
{
|
|
*(pDst++) = jsy_min(fabs(*(pSrc1++)), *(pSrc2++));
|
|
}
|
|
}
|