GNU Radio C++ API
gri_wavfile.h
Go to the documentation of this file.
1
/* -*- c++ -*- */
2
/*
3
* Copyright 2008 Free Software Foundation, Inc.
4
*
5
* This file is part of GNU Radio
6
*
7
* GNU Radio is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 3, or (at your option)
10
* any later version.
11
*
12
* GNU Radio is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with GNU Radio; see the file COPYING. If not, write to
19
* the Free Software Foundation, Inc., 51 Franklin Street,
20
* Boston, MA 02110-1301, USA.
21
*/
22
23
// This file stores all the RIFF file type knowledge for the gr_wavfile_*
24
// blocks.
25
26
#include <
gr_core_api.h
>
27
#include <cstdio>
28
29
/*!
30
* \brief Read signal information from a given WAV file.
31
*
32
* \p fp File pointer to an opened, empty file.
33
* \p sample_rate Stores the sample rate [S/s]
34
* \p nchans Number of channels
35
* \p bytes_per_sample Bytes per sample, can either be 1 or 2 (corresponding to
36
* 8 or 16 bit samples, respectively)
37
* \p first_sample_pos Number of the first byte containing a sample. Use this
38
* with fseek() to jump from the end of the file to the first sample
39
* when in repeat mode.
40
* \p samples_per_chan Number of samples per channel
41
* \p normalize_fac The normalization factor with which you need to divide the
42
* integer values of the samples to get them within [-1;1]
43
* \p normalize_shift The value by which the sample values need to be shifted
44
* after normalization (reason being, 8-bit WAV files store samples as
45
* unsigned char and 16-bit as signed short int)
46
* \return True on a successful read, false if the file could not be read or is
47
* not a valid WAV file.
48
*/
49
bool
50
gri_wavheader_parse(FILE *fp,
51
unsigned
int
&sample_rate,
52
int
&nchans,
53
int
&bytes_per_sample,
54
int
&first_sample_pos,
55
unsigned
int
&samples_per_chan);
56
57
58
/*!
59
* \brief Read one sample from an open WAV file at the current position.
60
*
61
* Takes care of endianness.
62
*/
63
short
int
64
gri_wav_read_sample
(FILE *fp,
int
bytes_per_sample);
65
66
67
/*!
68
* \brief Write a valid RIFF file header
69
*
70
* Note: Some header values are kept blank because they're usually not known
71
* a-priori (file and chunk lengths). Use gri_wavheader_complete() to fill
72
* these in.
73
*/
74
bool
75
gri_wavheader_write
(FILE *fp,
76
unsigned
int
sample_rate,
77
int
nchans,
78
int
bytes_per_sample);
79
80
/*!
81
* \brief Write one sample to an open WAV file at the current position.
82
*
83
* Takes care of endianness.
84
*/
85
void
86
gri_wav_write_sample
(FILE *fp,
short
int
sample,
int
bytes_per_sample);
87
88
89
/*!
90
* \brief Complete a WAV header
91
*
92
* Note: The stream position is changed during this function. If anything
93
* needs to be written to the WAV file after calling this function (which
94
* shouldn't happen), you need to fseek() to the end of the file (or
95
* whereever).
96
*
97
* \p fp File pointer to an open WAV file with a blank header
98
* \p byte_count Length of all samples written to the file in bytes.
99
*/
100
bool
101
gri_wavheader_complete
(FILE *fp,
unsigned
int
byte_count);
gnuradio-core
src
lib
io
gri_wavfile.h
Generated on Thu Jul 12 2012 00:06:24 for GNU Radio C++ API by
1.8.1.1