3 * Copyright 2004,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 #ifndef INCLUDED_GR_WAVFILE_SOURCE_H
24 #define INCLUDED_GR_WAVFILE_SOURCE_H
26 #include <gr_sync_block.h>
28 class gr_wavfile_source;
29 typedef boost::shared_ptr<gr_wavfile_source> gr_wavfile_source_sptr;
31 gr_wavfile_source_sptr
32 gr_make_wavfile_source (const char *filename, bool repeat = false);
35 * \brief Read stream from a Microsoft PCM (.wav) file, output floats
37 * Unless otherwise called, values are within [-1;1].
38 * Check gr_make_wavfile_source() for extra info.
43 class gr_wavfile_source : public gr_sync_block
46 friend gr_wavfile_source_sptr gr_make_wavfile_source (const char *filename,
48 gr_wavfile_source(const char *filename, bool repeat);
53 unsigned d_sample_rate;
55 int d_bytes_per_sample;
56 int d_first_sample_pos;
57 unsigned d_samples_per_chan;
58 unsigned d_sample_idx;
59 int d_normalize_shift;
63 * \brief Convert an integer sample value to a float value within [-1;1]
65 float convert_to_float(short int sample);
68 ~gr_wavfile_source ();
70 int work(int noutput_items,
71 gr_vector_const_void_star &input_items,
72 gr_vector_void_star &output_items);
75 * \brief Read the sample rate as specified in the wav file header
77 unsigned int sample_rate() const { return d_sample_rate; };
80 * \brief Return the number of bits per sample as specified in the wav
81 * file header. Only 8 or 16 bit are supported here.
83 int bits_per_sample() const { return d_bytes_per_sample * 8; };
86 * \brief Return the number of channels in the wav file as specified in
87 * the wav file header. This is also the max number of outputs you can
90 int channels() const { return d_nchans; };
93 #endif /* INCLUDED_GR_WAVFILE_SOURCE_H */