GNU Radio Manual and C++ API Reference  3.7.9.2
The Free & Open Software Radio Ecosystem
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
wavfile_sink.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2008,2009,2013 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 #ifndef INCLUDED_GR_WAVFILE_SINK_H
24 #define INCLUDED_GR_WAVFILE_SINK_H
25 
26 #include <gnuradio/blocks/api.h>
27 #include <gnuradio/sync_block.h>
28 
29 namespace gr {
30  namespace blocks {
31 
32  /*!
33  * \brief Write stream to a Microsoft PCM (.wav) file.
34  * \ingroup audio_blk
35  *
36  * \details
37  * Values must be floats within [-1;1].
38  * Check gr_make_wavfile_sink() for extra info.
39  */
40  class BLOCKS_API wavfile_sink : virtual public sync_block
41  {
42  public:
43  // gr::blocks::wavfile_sink::sptr
44  typedef boost::shared_ptr<wavfile_sink> sptr;
45 
46  /*
47  * \param filename The .wav file to be opened
48  * \param n_channels Number of channels (2 = stereo or I/Q output)
49  * \param sample_rate Sample rate [S/s]
50  * \param bits_per_sample 16 or 8 bit, default is 16
51  */
52  static sptr make(const char *filename,
53  int n_channels,
54  unsigned int sample_rate,
55  int bits_per_sample = 16);
56 
57  /*!
58  * \brief Opens a new file and writes a WAV header. Thread-safe.
59  */
60  virtual bool open(const char* filename) = 0;
61 
62  /*!
63  * \brief Closes the currently active file and completes the WAV
64  * header. Thread-safe.
65  */
66  virtual void close() = 0;
67 
68  /*!
69  * \brief Set the sample rate. This will not affect the WAV file
70  * currently opened. Any following open() calls will use this new
71  * sample rate.
72  */
73  virtual void set_sample_rate(unsigned int sample_rate) = 0;
74 
75  /*!
76  * \brief Set bits per sample. This will not affect the WAV file
77  * currently opened (see set_sample_rate()). If the value is
78  * neither 8 nor 16, the call is ignored and the current value
79  * is kept.
80  */
81  virtual void set_bits_per_sample(int bits_per_sample) = 0;
82  };
83 
84  } /* namespace blocks */
85 } /* namespace gr */
86 
87 #endif /* INCLUDED_GR_WAVFILE_SINK_H */
boost::shared_ptr< wavfile_sink > sptr
Definition: wavfile_sink.h:44
Include this header to use the message passing features.
Definition: logger.h:131
#define BLOCKS_API
Definition: gr-blocks/include/gnuradio/blocks/api.h:30
synchronous 1:1 input to output with historyOverride work to provide the signal processing implementa...
Definition: sync_block.h:37
Write stream to a Microsoft PCM (.wav) file.
Definition: wavfile_sink.h:40