aboutsummaryrefslogtreecommitdiffstats
path: root/src/common/sample.c
blob: 107c8e01c47562848a00d28e8c32d566808dffc6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <stdint.h>
#include "sample.h" 

void samples_to_int16(int16_t *spl, sample_t *samples, int length)
{
	while (length--) {
		if (*samples > 32767.0)
			*spl = 32767;
		else if (*samples < -32767.0)
			*spl = -32767;
		else
			*spl = (uint16_t)(*samples);
		samples++;
		spl++;
	}
}

void int16_to_samples(sample_t *samples, int16_t *spl, int length)
{
	while (length--) {
		*samples = (double)(*spl);
		samples++;
		spl++;
	}
}