~ubuntu-branches/debian/squeeze/alsa-utils/squeeze

« back to all changes in this revision

Viewing changes to aplay/formats.h

  • Committer: Bazaar Package Importer
  • Author(s): Masato Taruishi
  • Date: 2002-04-03 14:58:38 UTC
  • Revision ID: james.westby@ubuntu.com-20020403145838-ylq6q55c9ifhpixw
Tags: upstream-0.9.0beta12
ImportĀ upstreamĀ versionĀ 0.9.0beta12

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef FORMATS_H
 
2
#define FORMATS_H               1
 
3
 
 
4
#include <endian.h>
 
5
#include <byteswap.h>
 
6
 
 
7
/* Definitions for .VOC files */
 
8
 
 
9
#define VOC_MAGIC_STRING        "Creative Voice File\0x1A"
 
10
#define VOC_ACTUAL_VERSION      0x010A
 
11
#define VOC_SAMPLESIZE          8
 
12
 
 
13
#define VOC_MODE_MONO           0
 
14
#define VOC_MODE_STEREO         1
 
15
 
 
16
#define VOC_DATALEN(bp)         ((u_long)(bp->datalen) | \
 
17
                                ((u_long)(bp->datalen_m) << 8) | \
 
18
                                ((u_long)(bp->datalen_h) << 16) )
 
19
 
 
20
typedef struct voc_header {
 
21
        u_char magic[20];       /* must be MAGIC_STRING */
 
22
        u_short headerlen;      /* Headerlength, should be 0x1A */
 
23
        u_short version;        /* VOC-file version */
 
24
        u_short coded_ver;      /* 0x1233-version */
 
25
} VocHeader;
 
26
 
 
27
typedef struct voc_blocktype {
 
28
        u_char type;
 
29
        u_char datalen;         /* low-byte    */
 
30
        u_char datalen_m;       /* medium-byte */
 
31
        u_char datalen_h;       /* high-byte   */
 
32
} VocBlockType;
 
33
 
 
34
typedef struct voc_voice_data {
 
35
        u_char tc;
 
36
        u_char pack;
 
37
} VocVoiceData;
 
38
 
 
39
typedef struct voc_ext_block {
 
40
        u_short tc;
 
41
        u_char pack;
 
42
        u_char mode;
 
43
} VocExtBlock;
 
44
 
 
45
/* Definitions for Microsoft WAVE format */
 
46
 
 
47
#if __BYTE_ORDER == __LITTLE_ENDIAN
 
48
#define COMPOSE_ID(a,b,c,d)     ((a) | ((b)<<8) | ((c)<<16) | ((d)<<24))
 
49
#define LE_SHORT(v)             (v)
 
50
#define LE_INT(v)               (v)
 
51
#define BE_SHORT(v)             bswap_16(v)
 
52
#define BE_INT(v)               bswap_32(v)
 
53
#elif __BYTE_ORDER == __BIG_ENDIAN
 
54
#define COMPOSE_ID(a,b,c,d)     ((d) | ((c)<<8) | ((b)<<16) | ((a)<<24))
 
55
#define LE_SHORT(v)             bswap_16(v)
 
56
#define LE_INT(v)               bswap_32(v)
 
57
#define BE_SHORT(v)             (v)
 
58
#define BE_INT(v)               (v)
 
59
#else
 
60
#error "Wrong endian"
 
61
#endif
 
62
 
 
63
#define WAV_RIFF                COMPOSE_ID('R','I','F','F')
 
64
#define WAV_WAVE                COMPOSE_ID('W','A','V','E')
 
65
#define WAV_FMT                 COMPOSE_ID('f','m','t',' ')
 
66
#define WAV_DATA                COMPOSE_ID('d','a','t','a')
 
67
#define WAV_PCM_CODE            1
 
68
 
 
69
/* it's in chunks like .voc and AMIGA iff, but my source say there
 
70
   are in only in this combination, so I combined them in one header;
 
71
   it works on all WAVE-file I have
 
72
 */
 
73
typedef struct {
 
74
        u_int magic;            /* 'RIFF' */
 
75
        u_int length;           /* filelen */
 
76
        u_int type;             /* 'WAVE' */
 
77
} WaveHeader;
 
78
 
 
79
typedef struct {
 
80
        u_short format;         /* should be 1 for PCM-code */
 
81
        u_short modus;          /* 1 Mono, 2 Stereo */
 
82
        u_int sample_fq;        /* frequence of sample */
 
83
        u_int byte_p_sec;
 
84
        u_short byte_p_spl;     /* samplesize; 1 or 2 bytes */
 
85
        u_short bit_p_spl;      /* 8, 12 or 16 bit */
 
86
} WaveFmtBody;
 
87
 
 
88
typedef struct {
 
89
        u_int type;             /* 'data' */
 
90
        u_int length;           /* samplecount */
 
91
} WaveChunkHeader;
 
92
 
 
93
/* Definitions for Sparc .au header */
 
94
 
 
95
#define AU_MAGIC                COMPOSE_ID('.','s','n','d')
 
96
 
 
97
#define AU_FMT_ULAW             1
 
98
#define AU_FMT_LIN8             2
 
99
#define AU_FMT_LIN16            3
 
100
 
 
101
typedef struct au_header {
 
102
        u_int magic;            /* '.snd' */
 
103
        u_int hdr_size;         /* size of header (min 24) */
 
104
        u_int data_size;        /* size of data */
 
105
        u_int encoding;         /* see to AU_FMT_XXXX */
 
106
        u_int sample_rate;      /* sample rate */
 
107
        u_int channels;         /* number of channels (voices) */
 
108
} AuHeader;
 
109
 
 
110
#endif                          /* FORMATS */