1 /* $OpenBSD: afile.h,v 1.1 2015/01/21 08:43:55 ratchov Exp $ */ 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 WAV_H 18 #define WAV_H 19 20 #include <sys/types.h> 21 #include "dsp.h" 22 23 struct afile { 24 struct aparams par; /* file params */ 25 #define AFILE_FMT_PCM 0 /* integers (fixed point) */ 26 #define AFILE_FMT_ULAW 1 /* 8-bit mu-law */ 27 #define AFILE_FMT_ALAW 2 /* 8-bit a-law */ 28 #define AFILE_FMT_FLOAT 3 /* IEEE 754 32-bit floats */ 29 int fmt; /* one of above */ 30 int rate; /* file sample rate */ 31 int nch; /* file channel count */ 32 #define AFILE_HDR_AUTO 0 /* guess from file name */ 33 #define AFILE_HDR_RAW 1 /* headerless aka "raw" file */ 34 #define AFILE_HDR_WAV 2 /* microsoft .wav */ 35 #define AFILE_HDR_AIFF 3 /* apple .aiff */ 36 #define AFILE_HDR_AU 4 /* sun/next .au */ 37 int hdr; /* header type */ 38 int fd; /* file descriptor */ 39 #define AFILE_FREAD 1 /* open for reading */ 40 #define AFILE_FWRITE 2 /* open for writing */ 41 int flags; /* bitmap of above */ 42 off_t curpos; /* read/write position (bytes) */ 43 off_t startpos; /* where payload starts */ 44 off_t endpos; /* where payload ends */ 45 off_t maxpos; /* max allowed pos (.wav limitation) */ 46 char *path; /* file name (debug only) */ 47 }; 48 49 int afile_open(struct afile *, char *, int, int, struct aparams *, int, int); 50 size_t afile_read(struct afile *, void *, size_t); 51 size_t afile_write(struct afile *, void *, size_t); 52 int afile_seek(struct afile *, off_t); 53 void afile_close(struct afile *); 54 55 #endif /* !defined(WAV_H) */ 56