summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjmcneill <jmcneill@NetBSD.org>2010-09-01 21:54:00 +0000
committerjmcneill <jmcneill@NetBSD.org>2010-09-01 21:54:00 +0000
commit014a1e1b18cdb42e5af429db6c8b2f5ee12edaf2 (patch)
treea3fc4782cb49c1a88828a682f1853ebf35135557
parentfb721bf812f199b422c910c0c0013480f2691f80 (diff)
use htole16 to ensure that the pcm stream is slinear16_le on big endian hosts
-rw-r--r--usr.bin/audiocfg/dtmf.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/usr.bin/audiocfg/dtmf.c b/usr.bin/audiocfg/dtmf.c
index db81939ac5c..4c5f94f2c0c 100644
--- a/usr.bin/audiocfg/dtmf.c
+++ b/usr.bin/audiocfg/dtmf.c
@@ -1,4 +1,4 @@
-/* $NetBSD: dtmf.c,v 1.1 2010/09/01 09:04:16 jmcneill Exp $ */
+/* $NetBSD: dtmf.c,v 1.2 2010/09/01 21:54:00 jmcneill Exp $ */
/*
* Copyright (c) 2010 Jared D. McNeill <jmcneill@invisible.ca>
@@ -26,6 +26,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include <sys/endian.h>
+
#include <fcntl.h>
#include <math.h>
#include <stdio.h>
@@ -50,9 +52,10 @@ dtmf_create(int16_t *buf, unsigned int sample_rate,
for (c = 0; c < channels; c++) {
if ((chanmask & (1 << c)) == 0)
continue;
- buf[c] =
+ buf[c] = htole16(
(sin(i * PI2 * (freq1 / sample_rate)) +
- sin(i * PI2 * (freq2 / sample_rate))) * 16383;
+ sin(i * PI2 * (freq2 / sample_rate))) * 16383
+ );
}
buf += channels;
}