3 * Copyright 2008 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
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)
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.
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.
23 // This file stores all the RIFF file type knowledge for the gr_wavfile_*
29 * \brief Read signal information from a given WAV file.
31 * \p fp File pointer to an opened, empty file.
32 * \p sample_rate Stores the sample rate [S/s]
33 * \p nchans Number of channels
34 * \p bytes_per_sample Bytes per sample, can either be 1 or 2 (corresponding to
35 * 8 or 16 bit samples, respectively)
36 * \p first_sample_pos Number of the first byte containing a sample. Use this
37 * with fseek() to jump from the end of the file to the first sample
38 * when in repeat mode.
39 * \p samples_per_chan Number of samples per channel
40 * \p normalize_fac The normalization factor with which you need to divide the
41 * integer values of the samples to get them within [-1;1]
42 * \p normalize_shift The value by which the sample values need to be shifted
43 * after normalization (reason being, 8-bit WAV files store samples as
44 * unsigned char and 16-bit as signed short int)
45 * \return True on a successful read, false if the file could not be read or is
46 * not a valid WAV file.
49 gri_wavheader_parse(FILE *fp,
50 unsigned int &sample_rate,
52 int &bytes_per_sample,
53 int &first_sample_pos,
54 unsigned int &samples_per_chan);
58 * \brief Read one sample from an open WAV file at the current position.
60 * Takes care of endianness.
63 gri_wav_read_sample(FILE *fp, int bytes_per_sample);
67 * \brief Write a valid RIFF file header
69 * Note: Some header values are kept blank because they're usually not known
70 * a-priori (file and chunk lengths). Use gri_wavheader_complete() to fill
74 gri_wavheader_write(FILE *fp,
75 unsigned int sample_rate,
77 int bytes_per_sample);
80 * \brief Write one sample to an open WAV file at the current position.
82 * Takes care of endianness.
85 gri_wav_write_sample(FILE *fp, short int sample, int bytes_per_sample);
89 * \brief Complete a WAV header
91 * Note: The stream position is changed during this function. If anything
92 * needs to be written to the WAV file after calling this function (which
93 * shouldn't happen), you need to fseek() to the end of the file (or
96 * \p fp File pointer to an open WAV file with a blank header
97 * \p byte_count Length of all samples written to the file in bytes.
100 gri_wavheader_complete(FILE *fp, unsigned int byte_count);