Annotation of src/usr.bin/aucat/aparams.h, Revision 1.4
1.4 ! ratchov 1: /* $OpenBSD: aparams.h,v 1.3 2008/11/03 22:25:13 ratchov Exp $ */
1.1 ratchov 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:
1.2 ratchov 22: #define NCHAN_MAX 16 /* max channel in a stream */
23: #define RATE_MIN 4000 /* min sample rate */
24: #define RATE_MAX 192000 /* max sample rate */
25: #define BITS_MIN 1 /* min bits per sample */
1.1 ratchov 26: #define BITS_MAX 32 /* max bits per sample */
27:
1.2 ratchov 28: /*
29: * maximum size of the encording string (the longest possible
30: * encoding is ``s24le3msb'')
31: */
32: #define ENCMAX 10
33:
1.1 ratchov 34: #if BYTE_ORDER == LITTLE_ENDIAN
35: #define NATIVE_LE 1
36: #elif BYTE_ORDER == BIG_ENDIAN
37: #define NATIVE_LE 0
38: #else
39: /* not defined */
40: #endif
41:
42: /*
1.2 ratchov 43: * default bytes per sample for the given bits per sample
44: */
45: #define APARAMS_BPS(bits) (((bits) <= 8) ? 1 : (((bits) <= 16) ? 2 : 4))
46:
47: /*
1.1 ratchov 48: * encoding specification
49: */
50: struct aparams {
51: unsigned bps; /* bytes per sample */
52: unsigned bits; /* actually used bits */
53: unsigned le; /* 1 if little endian, 0 if big endian */
54: unsigned sig; /* 1 if signed, 0 if unsigned */
55: unsigned msb; /* 1 if msb justified, 0 if lsb justified */
56: unsigned cmin, cmax; /* provided/consumed channels */
57: unsigned rate; /* frames per second */
58: };
59:
60: /*
61: * Samples are numbers in the interval [-1, 1[, note that 1, the upper
62: * boundary is excluded. We represent them in 16-bit signed fixed point
63: * numbers, so that we can do all multiplications and divisions in
64: * 32-bit precision without having to deal with overflows.
65: */
66:
67: #define ADATA_SHIFT (8 * sizeof(short) - 1)
68: #define ADATA_UNIT (1 << ADATA_SHIFT)
69: #define ADATA_MAX (ADATA_UNIT - 1)
70: #define ADATA_MUL(x,y) (((x) * (y)) >> ADATA_SHIFT)
1.4 ! ratchov 71:
! 72: #define MIDI_MAXCTL 127
! 73: #define MIDI_TO_ADATA(m) (aparams_ctltovol[m])
! 74:
! 75: extern int aparams_ctltovol[128];
1.1 ratchov 76:
77: void aparams_init(struct aparams *, unsigned, unsigned, unsigned);
78: void aparams_print(struct aparams *);
79: void aparams_print2(struct aparams *, struct aparams *);
1.3 ratchov 80: int aparams_eqrate(struct aparams *, struct aparams *);
81: int aparams_eqenc(struct aparams *, struct aparams *);
1.1 ratchov 82: int aparams_eq(struct aparams *, struct aparams *);
1.3 ratchov 83: int aparams_subset(struct aparams *, struct aparams *);
1.1 ratchov 84: unsigned aparams_bpf(struct aparams *);
1.2 ratchov 85: int aparams_strtoenc(struct aparams *, char *);
86: int aparams_enctostr(struct aparams *, char *);
87: void aparams_copyenc(struct aparams *, struct aparams *);
1.1 ratchov 88:
89: #endif /* !defined(APARAMS_H) */