1 #ifndef _FMTHEADERS_H
2 #define _FMTHEADERS_H	1
3 
4 #include <sys/types.h>
5 
6 #ifdef __GNUC__
7 # define PACKED(x)      __attribute__((packed)) x
8 #else
9 # define PACKED(x)	x
10 #endif
11 
12 /* Definitions for .VOC files */
13 
14 #define VOC_MAGIC	"Creative Voice File\032"
15 
16 #define DATALEN(bp)	((u_int32_t)(bp.BlockLen[0]) | \
17                          ((u_int32_t)(bp.BlockLen[1]) << 8) | \
18                          ((u_int32_t)(bp.BlockLen[2]) << 16) )
19 
20 typedef struct vochead {
21   u_int8_t  Magic[20];	/* must be VOC_MAGIC */
22   u_int16_t BlockOffset;	/* Offset to first block from top of file */
23   u_int16_t Version;	/* VOC-file version */
24   u_int16_t IDCode;	/* complement of version + 0x1234 */
25 } PACKED(vochead);
26 
27 typedef struct blockTC {
28   u_int8_t  BlockID;
29   u_int8_t  BlockLen[3];	/* low, mid, high byte of length of rest of block */
30 } PACKED(blockTC);
31 
32 typedef struct blockT1 {
33   u_int8_t  TimeConstant;
34   u_int8_t  PackMethod;
35 } PACKED(blockT1);
36 
37 typedef struct blockT8 {
38   u_int16_t TimeConstant;
39   u_int8_t  PackMethod;
40   u_int8_t  VoiceMode;
41 } PACKED(blockT8);
42 
43 typedef struct blockT9 {
44   u_int32_t SamplesPerSec;
45   u_int8_t  BitsPerSample;
46   u_int8_t  Channels;
47   u_int16_t Format;
48   u_int8_t  reserved[4];
49 } PACKED(blockT9);
50 
51 
52 
53 /* Definitions for Microsoft WAVE format */
54 
55 /* it's in chunks like .voc and AMIGA iff, but my source say there
56    are in only in this combination, so I combined them in one header;
57    it works on all WAVE-file I have
58 */
59 typedef struct wavhead {
60   u_int32_t	main_chunk;	/* 'RIFF' */
61   u_int32_t	length;		/* Length of rest of file */
62   u_int32_t	chunk_type;	/* 'WAVE' */
63 
64   u_int32_t	sub_chunk;	/* 'fmt ' */
65   u_int32_t	sc_len;		/* length of sub_chunk, =16 (rest of chunk) */
66   u_int16_t	format;		/* should be 1 for PCM-code */
67   u_int16_t	modus;		/* 1 Mono, 2 Stereo */
68   u_int32_t	sample_fq;	/* frequence of sample */
69   u_int32_t	byte_p_sec;
70   u_int16_t	byte_p_spl;	/* samplesize; 1 or 2 bytes */
71   u_int16_t	bit_p_spl;	/* 8, 12 or 16 bit */
72 
73   u_int32_t	data_chunk;	/* 'data' */
74   u_int32_t	data_length;	/* samplecount (lenth of rest of block?)*/
75 } PACKED(wavhead);
76 
77 #endif
78