UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
wav_reader.h
Go to the documentation of this file.
1
5/*
6 * Copyright (c) 2013-2021 CESNET, z. s. p. o.
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, is permitted provided that the following conditions
11 * are met:
12 *
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 *
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 *
20 * 3. Neither the name of CESNET nor the names of its contributors may be
21 * used to endorse or promote products derived from this software without
22 * specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
26 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
27 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
28 * EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
29 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
35 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 */
37
38#include <stdio.h> // FILE *
39
40#ifdef __cplusplus
41#include <cstdint>
42#else
43#include <stdint.h>
44#endif
45
47 unsigned int ch_count;
48 unsigned int sample_rate;
49 unsigned int bits_per_sample;
50 uint16_t valid_bits;
51 uint32_t channel_mask;
52
53 long long data_offset;
54 long long data_size;
55};
56
57#define WAV_HDR_PARSE_OK 0
58#define WAV_HDR_PARSE_READ_ERROR 1
59#define WAV_HDR_PARSE_WRONG_FORMAT 2
60#define WAV_HDR_PARSE_NOT_PCM 3
61#define WAV_HDR_PARSE_INVALID_PARAM 4
62
63#ifdef __cplusplus
64extern "C" {
65#endif
66
78int read_wav_header(FILE *wav_file, struct wav_metadata *metadata);
79
86size_t wav_read(void *buffer, size_t sample_count, FILE *wav_file, struct wav_metadata *metadata);
88int wav_seek(FILE *wav_file, long offset, int whence, struct wav_metadata *metadata);
89
90const char *get_wav_error(int errcode);
91
92#ifdef __cplusplus
93}
94#endif
95
static __device__ const float offset
Definition cuda_dxt.cu:139
unsigned int ch_count
Definition wav_reader.h:47
unsigned int sample_rate
Definition wav_reader.h:48
long long data_offset
offset from beginning, -1 if unknown (typically unseekable)
Definition wav_reader.h:53
uint32_t channel_mask
Definition wav_reader.h:51
unsigned int bits_per_sample
Definition wav_reader.h:49
long long data_size
size of data, -1 if unknown
Definition wav_reader.h:54
uint16_t valid_bits
Definition wav_reader.h:50
int wav_seek(FILE *wav_file, long offset, int whence, struct wav_metadata *metadata)
same as fseek but WAV header presence is respected (for SEEK SET)
Definition wav_reader.c:319
const char * get_wav_error(int errcode)
Definition wav_reader.c:300
size_t wav_read(void *buffer, size_t sample_count, FILE *wav_file, struct wav_metadata *metadata)
Definition wav_reader.c:291
int read_wav_header(FILE *wav_file, struct wav_metadata *metadata)
Definition wav_reader.c:215