1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate #ifndef _AUDIO_AU_H 28*0Sstevel@tonic-gate #define _AUDIO_AU_H 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate #include <sys/isa_defs.h> 33*0Sstevel@tonic-gate #include <sys/types.h> 34*0Sstevel@tonic-gate 35*0Sstevel@tonic-gate #ifdef __cplusplus 36*0Sstevel@tonic-gate extern "C" { 37*0Sstevel@tonic-gate #endif 38*0Sstevel@tonic-gate 39*0Sstevel@tonic-gate /* 40*0Sstevel@tonic-gate * Define an on-disk audio file header for the AU file format. 41*0Sstevel@tonic-gate * 42*0Sstevel@tonic-gate * Note that there is an optional 'info' field that immediately follows this 43*0Sstevel@tonic-gate * structure in the file. It is an optional length field that is sometimes 44*0Sstevel@tonic-gate * used to store additional information. At the minimum, it is at 45*0Sstevel@tonic-gate * least 4 bytes. 46*0Sstevel@tonic-gate * 47*0Sstevel@tonic-gate * The offset field is problematic in the general case because the 48*0Sstevel@tonic-gate * field is really "data location", which does not ensure that all 49*0Sstevel@tonic-gate * the bytes between the header and the data are really 'info'. 50*0Sstevel@tonic-gate * Further, there are no absolute guarantees that the info is ASCII text. 51*0Sstevel@tonic-gate * 52*0Sstevel@tonic-gate * When audio files are passed through pipes, the au_data_size field may 53*0Sstevel@tonic-gate * not be known in advance. In such cases, au_data_size should be 54*0Sstevel@tonic-gate * set to AUDIO_AU_UNKNOWN_SIZE. 55*0Sstevel@tonic-gate */ 56*0Sstevel@tonic-gate 57*0Sstevel@tonic-gate struct au_filehdr { 58*0Sstevel@tonic-gate uint32_t au_magic; /* magic number */ 59*0Sstevel@tonic-gate uint32_t au_offset; /* size of this header */ 60*0Sstevel@tonic-gate uint32_t au_data_size; /* length of data */ 61*0Sstevel@tonic-gate uint32_t au_encoding; /* data encoding format */ 62*0Sstevel@tonic-gate uint32_t au_sample_rate; /* samples per second */ 63*0Sstevel@tonic-gate uint32_t au_channels; /* number of interleaved channels */ 64*0Sstevel@tonic-gate }; 65*0Sstevel@tonic-gate typedef struct au_filehdr au_filehdr_t; 66*0Sstevel@tonic-gate 67*0Sstevel@tonic-gate /* 68*0Sstevel@tonic-gate * This is the appearance of a typical AU audio file as described 69*0Sstevel@tonic-gate * by this structure. 70*0Sstevel@tonic-gate * 71*0Sstevel@tonic-gate * ------------------------------------------------------------ 72*0Sstevel@tonic-gate * | | | | 73*0Sstevel@tonic-gate * | AU Audio Header | Info | Audio Data | 74*0Sstevel@tonic-gate * | | (optional) | | 75*0Sstevel@tonic-gate * | | | | 76*0Sstevel@tonic-gate * | 24 bytes | 4 bytes (min) | n bytes | 77*0Sstevel@tonic-gate * | | | | 78*0Sstevel@tonic-gate * ------------------------------------------------------------ 79*0Sstevel@tonic-gate */ 80*0Sstevel@tonic-gate 81*0Sstevel@tonic-gate /* Define the magic number */ 82*0Sstevel@tonic-gate #define AUDIO_AU_FILE_MAGIC ((uint32_t)0x2e736e64) /* ".snd" */ 83*0Sstevel@tonic-gate 84*0Sstevel@tonic-gate /* Unknown header size */ 85*0Sstevel@tonic-gate #define AUDIO_AU_UNKNOWN_SIZE ((unsigned)(~0)) /* (unsigned) -1 */ 86*0Sstevel@tonic-gate 87*0Sstevel@tonic-gate /* Define the AU encoding fields */ 88*0Sstevel@tonic-gate #define AUDIO_AU_ENCODING_ULAW (1) /* 8-bit u-law */ 89*0Sstevel@tonic-gate #define AUDIO_AU_ENCODING_LINEAR_8 (2) /* 8-bit linear PCM */ 90*0Sstevel@tonic-gate #define AUDIO_AU_ENCODING_LINEAR_16 (3) /* 16-bit linear PCM */ 91*0Sstevel@tonic-gate #define AUDIO_AU_ENCODING_LINEAR_24 (4) /* 24-bit linear PCM */ 92*0Sstevel@tonic-gate #define AUDIO_AU_ENCODING_LINEAR_32 (5) /* 32-bit linear PCM */ 93*0Sstevel@tonic-gate #define AUDIO_AU_ENCODING_FLOAT (6) /* 32-bit IEEE floating point */ 94*0Sstevel@tonic-gate #define AUDIO_AU_ENCODING_DOUBLE (7) /* 64-bit IEEE double */ 95*0Sstevel@tonic-gate /* precision float */ 96*0Sstevel@tonic-gate #define AUDIO_AU_ENCODING_FRAGMENTED (8) /* Fragmented sample data */ 97*0Sstevel@tonic-gate #define AUDIO_AU_ENCODING_DSP (10) /* DSP program */ 98*0Sstevel@tonic-gate #define AUDIO_AU_ENCODING_FIXED_8 (11) /* 8-bit fixed point */ 99*0Sstevel@tonic-gate #define AUDIO_AU_ENCODING_FIXED_16 (12) /* 16-bit fixed point */ 100*0Sstevel@tonic-gate #define AUDIO_AU_ENCODING_FIXED_24 (13) /* 24-bit fixed point */ 101*0Sstevel@tonic-gate #define AUDIO_AU_ENCODING_FIXED_32 (14) /* 32-bit fixed point */ 102*0Sstevel@tonic-gate #define AUDIO_AU_ENCODING_EMPHASIS (18) /* 16-bit linear with */ 103*0Sstevel@tonic-gate /* emphasis */ 104*0Sstevel@tonic-gate #define AUDIO_AU_ENCODING_COMPRESSED (19) /* 16-bit linear compressed */ 105*0Sstevel@tonic-gate #define AUDIO_AU_ENCODING_EMP_COMP (20) /* 16-bit linear with */ 106*0Sstevel@tonic-gate /* emphasis and compression */ 107*0Sstevel@tonic-gate #define AUDIO_AU_ENCODING_MUSIC_KIT (21) /* Music kit DSP commands */ 108*0Sstevel@tonic-gate #define AUDIO_AU_ENCODING_ADPCM_G721 (23) /* 4-bit CCITT G.721 ADPCM */ 109*0Sstevel@tonic-gate #define AUDIO_AU_ENCODING_ADPCM_G722 (24) /* CCITT G.722 ADPCM */ 110*0Sstevel@tonic-gate #define AUDIO_AU_ENCODING_ADPCM_G723_3 (25) /* CCITT G.723.3 ADPCM */ 111*0Sstevel@tonic-gate #define AUDIO_AU_ENCODING_ADPCM_G723_5 (26) /* CCITT G.723.5 ADPCM */ 112*0Sstevel@tonic-gate #define AUDIO_AU_ENCODING_ALAW (27) /* 8-bit A-law G.711 */ 113*0Sstevel@tonic-gate 114*0Sstevel@tonic-gate 115*0Sstevel@tonic-gate /* Byte swapping routines */ 116*0Sstevel@tonic-gate #if defined(_BIG_ENDIAN) 117*0Sstevel@tonic-gate #define AUDIO_AU_FILE2HOST(from, to) *((long *)(to)) = *((long *)(from)) 118*0Sstevel@tonic-gate #else 119*0Sstevel@tonic-gate #define AUDIO_AU_FILE2HOST(from, to) \ 120*0Sstevel@tonic-gate ((char *)(to))[0] = ((char *)(from))[3]; \ 121*0Sstevel@tonic-gate ((char *)(to))[1] = ((char *)(from))[2]; \ 122*0Sstevel@tonic-gate ((char *)(to))[2] = ((char *)(from))[1]; \ 123*0Sstevel@tonic-gate ((char *)(to))[3] = ((char *)(from))[0]; 124*0Sstevel@tonic-gate #endif /* byte swapping */ 125*0Sstevel@tonic-gate 126*0Sstevel@tonic-gate #if defined(__sparc) || defined(__i386) || defined(__amd64) 127*0Sstevel@tonic-gate #define AUDIO_AU_HOST2FILE(from, to) AUDIO_AU_FILE2HOST((from), (to)) 128*0Sstevel@tonic-gate #else 129*0Sstevel@tonic-gate #error unknown machine type; 130*0Sstevel@tonic-gate #endif /* encode */ 131*0Sstevel@tonic-gate 132*0Sstevel@tonic-gate #ifdef __cplusplus 133*0Sstevel@tonic-gate } 134*0Sstevel@tonic-gate #endif 135*0Sstevel@tonic-gate 136*0Sstevel@tonic-gate #endif /* _AUDIO_AU_H */ 137