diff options
author | Tom Rondeau <trondeau@vt.edu> | 2013-03-09 09:35:43 -0500 |
---|---|---|
committer | Tom Rondeau <trondeau@vt.edu> | 2013-03-09 09:35:43 -0500 |
commit | b359d899af0771f3b3d66180af46df38d1c141f6 (patch) | |
tree | 9970d6cb0fe1b101d5e5163a9bb005f746ddd752 /gr-blocks/include/blocks/wavfile_sink.h | |
parent | fe70fa72ea22a133874337da2d03d30611e5ab1c (diff) | |
parent | 21c95a82a495f0cf9dfe511f9ef370bae9ac0eeb (diff) |
Merge branch 'master' into next
Diffstat (limited to 'gr-blocks/include/blocks/wavfile_sink.h')
-rw-r--r-- | gr-blocks/include/blocks/wavfile_sink.h | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/gr-blocks/include/blocks/wavfile_sink.h b/gr-blocks/include/blocks/wavfile_sink.h new file mode 100644 index 0000000000..b095191d07 --- /dev/null +++ b/gr-blocks/include/blocks/wavfile_sink.h @@ -0,0 +1,87 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2009,2013 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_WAVFILE_SINK_H +#define INCLUDED_GR_WAVFILE_SINK_H + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Write stream to a Microsoft PCM (.wav) file. + * + * Values must be floats within [-1;1]. + * Check gr_make_wavfile_sink() for extra info. + * + * \ingroup sink_blk + */ + class BLOCKS_API wavfile_sink : virtual public gr_sync_block + { + public: + // gr::blocks::wavfile_sink::sptr + typedef boost::shared_ptr<wavfile_sink> sptr; + + /* + * \p filename The .wav file to be opened + * \p n_channels Number of channels (2 = stereo or I/Q output) + * \p sample_rate Sample rate [S/s] + * \p bits_per_sample 16 or 8 bit, default is 16 + */ + static sptr make(const char *filename, + int n_channels, + unsigned int sample_rate, + int bits_per_sample = 16); + + /*! + * \brief Opens a new file and writes a WAV header. Thread-safe. + */ + virtual bool open(const char* filename) = 0; + + /*! + * \brief Closes the currently active file and completes the WAV + * header. Thread-safe. + */ + virtual void close() = 0; + + /*! + * \brief Set the sample rate. This will not affect the WAV file + * currently opened. Any following open() calls will use this new + * sample rate. + */ + virtual void set_sample_rate(unsigned int sample_rate) = 0; + + /*! + * \brief Set bits per sample. This will not affect the WAV file + * currently opened (see set_sample_rate()). If the value is + * neither 8 nor 16, the call is ignored and the current value + * is kept. + */ + virtual void set_bits_per_sample(int bits_per_sample) = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_WAVFILE_SINK_H */ |