Annotation of src/usr.bin/aucat/aparams.h, Revision 1.1
1.1 ! ratchov 1: /* $OpenBSD$ */
! 2: /*
! 3: * Copyright (c) 2008 Alexandre Ratchov <alex@caoua.org>
! 4: *
! 5: * Permission to use, copy, modify, and distribute this software for any
! 6: * purpose with or without fee is hereby granted, provided that the above
! 7: * copyright notice and this permission notice appear in all copies.
! 8: *
! 9: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
! 10: * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
! 11: * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
! 12: * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
! 13: * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
! 14: * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
! 15: * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
! 16: */
! 17: #ifndef APARAMS_H
! 18: #define APARAMS_H
! 19:
! 20: #include <sys/param.h>
! 21:
! 22: #define CHAN_MAX 16 /* max number of channels */
! 23: #define RATE_MIN 1 /* min sample rate */
! 24: #define RATE_MAX (1 << 30) /* max sample rate */
! 25: #define BITS_MAX 32 /* max bits per sample */
! 26:
! 27: #if BYTE_ORDER == LITTLE_ENDIAN
! 28: #define NATIVE_LE 1
! 29: #elif BYTE_ORDER == BIG_ENDIAN
! 30: #define NATIVE_LE 0
! 31: #else
! 32: /* not defined */
! 33: #endif
! 34:
! 35: /*
! 36: * encoding specification
! 37: */
! 38: struct aparams {
! 39: unsigned bps; /* bytes per sample */
! 40: unsigned bits; /* actually used bits */
! 41: unsigned le; /* 1 if little endian, 0 if big endian */
! 42: unsigned sig; /* 1 if signed, 0 if unsigned */
! 43: unsigned msb; /* 1 if msb justified, 0 if lsb justified */
! 44: unsigned cmin, cmax; /* provided/consumed channels */
! 45: unsigned rate; /* frames per second */
! 46: };
! 47:
! 48: /*
! 49: * Samples are numbers in the interval [-1, 1[, note that 1, the upper
! 50: * boundary is excluded. We represent them in 16-bit signed fixed point
! 51: * numbers, so that we can do all multiplications and divisions in
! 52: * 32-bit precision without having to deal with overflows.
! 53: */
! 54:
! 55: #define ADATA_SHIFT (8 * sizeof(short) - 1)
! 56: #define ADATA_UNIT (1 << ADATA_SHIFT)
! 57: #define ADATA_MAX (ADATA_UNIT - 1)
! 58: #define ADATA_MUL(x,y) (((x) * (y)) >> ADATA_SHIFT)
! 59:
! 60: void aparams_init(struct aparams *, unsigned, unsigned, unsigned);
! 61: void aparams_print(struct aparams *);
! 62: void aparams_print2(struct aparams *, struct aparams *);
! 63: int aparams_eq(struct aparams *, struct aparams *);
! 64: unsigned aparams_bpf(struct aparams *);
! 65:
! 66: #endif /* !defined(APARAMS_H) */