Run in Linux

- Define Pi to avoid running into too many feature test macros
- Define _DEFAULT_SOURCE if not in OpenBSD
- Add a play target that works in Linux
master
Lucas 3 years ago
parent afbe512452
commit 06f6a4881c

@ -31,9 +31,15 @@ arngment: ${OBJ}
${OBJ}: ${HDR}
play: all
play:
@${MAKE} _play_$$(uname)
_play_OpenBSD: all
./arngment ${ARNGMENT_ARGS} | aucat -e s16 -h raw -i -
_play_Linux: all
./arngment ${ARNGMENT_ARGS} | aplay -f dat -t raw -
clean:
rm -f arngment ${OBJ} ${P}-${V}.tgz

@ -30,6 +30,11 @@
* <http://creativecommons.org/publicdomain/zero/1.0/>.
*/
/* lrand48, visibility for glibc */
#if !defined(__OpenBSD__)
#define _DEFAULT_SOURCE
#endif
#include <stdint.h>
#include <stdlib.h>

@ -13,6 +13,11 @@
* <http://creativecommons.org/publicdomain/zero/1.0/>.
*/
/* getopt, srand48, visibility for glibc */
#if !defined(__OpenBSD__)
#define _DEFAULT_SOURCE
#endif
#include <limits.h>
#include <stdio.h>
#include <stdint.h>

@ -15,6 +15,13 @@
#include <math.h>
/*
* Apparently, it's too hard for OSes to expose M_PI in a portable way.
* Definition taken from
* $OpenBSD: math.h,v 1.36 2018/03/10 20:52:58 kettenis Exp $
*/
#define JUST_PI ((double)3.14159265358979323846)
#define CLAMP(x, a, b) ((x) < (a) ? (a) : (x) > (b) ? (b) : (x))
double
@ -27,7 +34,7 @@ synth_distortion(double gain, double x)
double
synth_sinewave(double t, double a)
{
return sin(2.0 * M_PI * t * a);
return sin(2.0 * JUST_PI * t * a);
}
double

Loading…
Cancel
Save