https://reviews.freebsd.org/D47638
test.c
#include <stdio.h>
#include <string.h>
#define _AMD64_INCLUDE_PARAM_H_
#include "src/sys/sys/param.h"
#define __assert_unreachable() __unreachable()
#include "src/sys/sys/soundcard.h"
#include "src/sys/dev/sound/pcm/sound.h"
#include "src/sys/dev/sound/pcm/pcm.h"
int
main(int argc, char **argv)
{
for (int i = -100; i < 100; i++) {
float x = (float)((double)i * (1.41421 / (1l << 34)));
intpcm_t v = pcm_sample_read(&x, AFMT_FLOAT);
double y = (double)v / PCM_S32_MAX;
printf("%16.9e %10d %16.9e %16.9e\n", x, v, y, y - x);
}
return 0;
}plot.py
import numpy as np
import matplotlib.pyplot as plt
[x,v,y,err] = np.loadtxt("res.txt").T
plt.plot(x,err)
plt.savefig("error.png")
plt.show()
