2021-03-31 12:16:38 +02:00
|
|
|
#include "utils.h"
|
|
|
|
|
#include <cmath>
|
2021-06-28 02:07:42 +02:00
|
|
|
#include <sstream>
|
2021-03-31 12:16:38 +02:00
|
|
|
|
2021-05-14 20:14:13 +02:00
|
|
|
void char_array_to_uchar(int8_t *in, uint8_t *out, int nsamples)
|
2021-03-31 12:16:38 +02:00
|
|
|
{
|
|
|
|
|
for (int i = 0; i < nsamples; i++)
|
|
|
|
|
{
|
2021-05-12 21:16:53 +02:00
|
|
|
double r = in[i] * 127.0;
|
2021-03-31 12:16:38 +02:00
|
|
|
if (r < 0)
|
|
|
|
|
r = 0;
|
|
|
|
|
else if (r > 255)
|
|
|
|
|
r = 255;
|
2021-05-12 21:16:53 +02:00
|
|
|
out[i] = floor(r);
|
2021-03-31 12:16:38 +02:00
|
|
|
}
|
2021-06-28 02:07:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::vector<std::string> splitString(std::string input, char del)
|
|
|
|
|
{
|
|
|
|
|
std::stringstream stcStream(input);
|
|
|
|
|
std::string seg;
|
|
|
|
|
std::vector<std::string> segs;
|
|
|
|
|
|
|
|
|
|
while (std::getline(stcStream, seg, del))
|
|
|
|
|
segs.push_back(seg);
|
|
|
|
|
|
|
|
|
|
return segs;
|
2021-03-31 12:16:38 +02:00
|
|
|
}
|