source: mainline/uspace/app/wavplay/wave.h@ fa91c0f

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since fa91c0f was ea6c838, checked in by Jan Vesely <jano.vesely@…>, 13 years ago

Create libpcm.

Move pcm related functions and definitions there.
Make other stuff use this library.
Rename most of it on the way.

  • Property mode set to 100644
File size: 3.1 KB
Line 
1/*
2 * Copyright (c) 2011 Jan Vesely
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28/** @addtogroup dplay
29 * @{
30 */
31/** @file
32 * @brief .wav file format.
33 */
34#ifndef WAVE_H
35#define WAVE_H
36
37#include <stdint.h>
38#include <pcm/sample_format.h>
39
40/** Wave file header format.
41 *
42 * https://ccrma.stanford.edu/courses/422/projects/WaveFormat/
43 * @note: 8-bit samples are stored as unsigned bytes,
44 * 16-bit samples are stored as signed integers.
45 * @note: The default byte ordering assumed for WAVE data files is
46 * little-endian. Files written using the big-endian byte ordering scheme have
47 * the identifier RIFX instead of RIFF.
48 */
49typedef struct wave_header {
50 /** Should be 'R', 'I', 'F', 'F'. */
51 char chunk_id[4];
52#define CHUNK_ID "RIFF"
53
54 /** Total size minus the first 8 bytes */
55 uint32_t chunk_size;
56 /** Should be 'W', 'A', 'V', 'E'. */
57 char format[4];
58#define FORMAT_STR "WAVE"
59
60 /** Should be 'f', 'm', 't', ' '. */
61 char subchunk1_id[4];
62#define SUBCHUNK1_ID "fmt "
63
64 /** Size of the ret of this subchunk. 16 for PCM file. */
65 uint32_t subchunk1_size;
66#define PCM_SUBCHUNK1_SIZE 16
67 /** Format. 1 for Linear PCM */
68 uint16_t audio_format;
69#define FORMAT_LINEAR_PCM 1
70 /** Number of channels. */
71 uint16_t channels;
72 /** Sampling rate. */
73 uint32_t sampling_rate;
74 /** Byte rate. */
75 uint32_t byte_rate;
76 /** Block align. Bytes in one block (samples for all channels). */
77 uint16_t block_align;
78 /** Bits per sample (one channel). */
79 uint16_t sample_size;
80
81 /** Should be 'd', 'a', 't', 'a'. */
82 char subchunk2_id[4];
83#define SUBCHUNK2_ID "data"
84 /** Audio data size. */
85 uint32_t subchunk2_size;
86 /** Audio data. */
87 uint8_t data[];
88
89} wave_header_t;
90
91int wav_parse_header(void *, const void**, size_t *, unsigned *, unsigned *,
92 pcm_sample_format_t *, const char **);
93
94#endif
95/**
96 * @}
97 */
Note: See TracBrowser for help on using the repository browser.