1998-08-13 17:43:39 +02:00
|
|
|
#ifndef FORMATS_H
|
|
|
|
#define FORMATS_H 1
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
2000-05-16 12:46:11 +02:00
|
|
|
#include <byteswap.h>
|
1998-08-13 17:43:39 +02:00
|
|
|
|
|
|
|
/* Definitions for .VOC files */
|
|
|
|
|
|
|
|
#define VOC_MAGIC_STRING "Creative Voice File\0x1A"
|
|
|
|
#define VOC_ACTUAL_VERSION 0x010A
|
|
|
|
#define VOC_SAMPLESIZE 8
|
|
|
|
|
|
|
|
#define VOC_MODE_MONO 0
|
|
|
|
#define VOC_MODE_STEREO 1
|
|
|
|
|
|
|
|
#define VOC_DATALEN(bp) ((u_long)(bp->datalen) | \
|
|
|
|
((u_long)(bp->datalen_m) << 8) | \
|
|
|
|
((u_long)(bp->datalen_h) << 16) )
|
|
|
|
|
|
|
|
typedef struct voc_header {
|
1998-11-27 16:17:45 +01:00
|
|
|
u_char magic[20]; /* must be MAGIC_STRING */
|
|
|
|
u_short headerlen; /* Headerlength, should be 0x1A */
|
|
|
|
u_short version; /* VOC-file version */
|
|
|
|
u_short coded_ver; /* 0x1233-version */
|
1998-08-13 17:43:39 +02:00
|
|
|
} VocHeader;
|
|
|
|
|
|
|
|
typedef struct voc_blocktype {
|
1998-11-27 16:17:45 +01:00
|
|
|
u_char type;
|
|
|
|
u_char datalen; /* low-byte */
|
|
|
|
u_char datalen_m; /* medium-byte */
|
|
|
|
u_char datalen_h; /* high-byte */
|
1998-08-13 17:43:39 +02:00
|
|
|
} VocBlockType;
|
|
|
|
|
|
|
|
typedef struct voc_voice_data {
|
1998-11-27 16:17:45 +01:00
|
|
|
u_char tc;
|
|
|
|
u_char pack;
|
1998-08-13 17:43:39 +02:00
|
|
|
} VocVoiceData;
|
|
|
|
|
|
|
|
typedef struct voc_ext_block {
|
1998-11-27 16:17:45 +01:00
|
|
|
u_short tc;
|
|
|
|
u_char pack;
|
|
|
|
u_char mode;
|
1998-08-13 17:43:39 +02:00
|
|
|
} VocExtBlock;
|
|
|
|
|
|
|
|
/* Definitions for Microsoft WAVE format */
|
|
|
|
|
2000-05-16 12:46:11 +02:00
|
|
|
#ifdef SND_LITTLE_ENDIAN
|
|
|
|
#define COMPOSE_ID(a,b,c,d) ((a) | ((b)<<8) | ((c)<<16) | ((d)<<24))
|
|
|
|
#define LE_SHORT(v) (v)
|
|
|
|
#define LE_INT(v) (v)
|
|
|
|
#else
|
|
|
|
#define COMPOSE_ID(a,b,c,d) ((d) | ((c)<<8) | ((b)<<16) | ((a)<<24))
|
|
|
|
#define LE_SHORT(v) bswap_16(v)
|
|
|
|
#define LE_INT(v) bswap_32(v)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define WAV_RIFF COMPOSE_ID('R','I','F','F')
|
|
|
|
#define WAV_WAVE COMPOSE_ID('W','A','V','E')
|
|
|
|
#define WAV_FMT COMPOSE_ID('f','m','t',' ')
|
|
|
|
#define WAV_DATA COMPOSE_ID('d','a','t','a')
|
1998-08-13 17:43:39 +02:00
|
|
|
#define WAV_PCM_CODE 1
|
|
|
|
|
|
|
|
/* it's in chunks like .voc and AMIGA iff, but my source say there
|
|
|
|
are in only in this combination, so I combined them in one header;
|
|
|
|
it works on all WAVE-file I have
|
1998-11-27 16:17:45 +01:00
|
|
|
*/
|
2000-05-29 20:54:23 +02:00
|
|
|
typedef struct {
|
|
|
|
u_int magic; /* 'RIFF' */
|
1998-11-27 16:17:45 +01:00
|
|
|
u_int length; /* filelen */
|
2000-05-29 20:54:23 +02:00
|
|
|
u_int type; /* 'WAVE' */
|
|
|
|
} WaveHeader;
|
1998-11-27 16:17:45 +01:00
|
|
|
|
2000-05-29 20:54:23 +02:00
|
|
|
typedef struct {
|
|
|
|
u_int type; /* 'fmt ' */
|
|
|
|
u_int length; /* length of chunk */
|
1998-11-27 16:17:45 +01:00
|
|
|
u_short format; /* should be 1 for PCM-code */
|
|
|
|
u_short modus; /* 1 Mono, 2 Stereo */
|
|
|
|
u_int sample_fq; /* frequence of sample */
|
|
|
|
u_int byte_p_sec;
|
|
|
|
u_short byte_p_spl; /* samplesize; 1 or 2 bytes */
|
|
|
|
u_short bit_p_spl; /* 8, 12 or 16 bit */
|
2000-05-29 20:54:23 +02:00
|
|
|
} WaveFmtHeader;
|
1998-11-27 16:17:45 +01:00
|
|
|
|
2000-05-29 20:54:23 +02:00
|
|
|
typedef struct {
|
|
|
|
u_int type; /* 'data' */
|
|
|
|
u_int length; /* samplecount */
|
|
|
|
} WaveChunkHeader;
|
1998-08-13 17:43:39 +02:00
|
|
|
|
|
|
|
/* Definitions for Sparc .au header */
|
|
|
|
|
|
|
|
#define AU_MAGIC 0x2e736e64
|
|
|
|
|
|
|
|
#define AU_FMT_ULAW 1
|
|
|
|
#define AU_FMT_LIN8 2
|
|
|
|
#define AU_FMT_LIN16 3
|
|
|
|
|
|
|
|
typedef struct au_header {
|
1998-11-27 16:17:45 +01:00
|
|
|
u_int magic; /* magic '.snd' */
|
|
|
|
u_int hdr_size; /* size of header (min 24) */
|
|
|
|
u_int data_size; /* size of data */
|
|
|
|
u_int encoding; /* see to AU_FMT_XXXX */
|
|
|
|
u_int sample_rate; /* sample rate */
|
|
|
|
u_int channels; /* number of channels (voices) */
|
1998-08-13 17:43:39 +02:00
|
|
|
} AuHeader;
|
|
|
|
|
1998-11-27 16:17:45 +01:00
|
|
|
#endif /* FORMATS */
|