GNU Radio 3.7.1 C++ API
|
00001 /* -*- c++ -*- */ 00002 /* 00003 * Copyright 2008,2009,2013 Free Software Foundation, Inc. 00004 * 00005 * This file is part of GNU Radio 00006 * 00007 * GNU Radio is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 3, or (at your option) 00010 * any later version. 00011 * 00012 * GNU Radio is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with GNU Radio; see the file COPYING. If not, write to 00019 * the Free Software Foundation, Inc., 51 Franklin Street, 00020 * Boston, MA 02110-1301, USA. 00021 */ 00022 00023 #ifndef INCLUDED_GR_WAVFILE_SINK_H 00024 #define INCLUDED_GR_WAVFILE_SINK_H 00025 00026 #include <gnuradio/blocks/api.h> 00027 #include <gnuradio/sync_block.h> 00028 00029 namespace gr { 00030 namespace blocks { 00031 00032 /*! 00033 * \brief Write stream to a Microsoft PCM (.wav) file. 00034 * \ingroup audio_blk 00035 * 00036 * \details 00037 * Values must be floats within [-1;1]. 00038 * Check gr_make_wavfile_sink() for extra info. 00039 */ 00040 class BLOCKS_API wavfile_sink : virtual public sync_block 00041 { 00042 public: 00043 // gr::blocks::wavfile_sink::sptr 00044 typedef boost::shared_ptr<wavfile_sink> sptr; 00045 00046 /* 00047 * \param filename The .wav file to be opened 00048 * \param n_channels Number of channels (2 = stereo or I/Q output) 00049 * \param sample_rate Sample rate [S/s] 00050 * \param bits_per_sample 16 or 8 bit, default is 16 00051 */ 00052 static sptr make(const char *filename, 00053 int n_channels, 00054 unsigned int sample_rate, 00055 int bits_per_sample = 16); 00056 00057 /*! 00058 * \brief Opens a new file and writes a WAV header. Thread-safe. 00059 */ 00060 virtual bool open(const char* filename) = 0; 00061 00062 /*! 00063 * \brief Closes the currently active file and completes the WAV 00064 * header. Thread-safe. 00065 */ 00066 virtual void close() = 0; 00067 00068 /*! 00069 * \brief Set the sample rate. This will not affect the WAV file 00070 * currently opened. Any following open() calls will use this new 00071 * sample rate. 00072 */ 00073 virtual void set_sample_rate(unsigned int sample_rate) = 0; 00074 00075 /*! 00076 * \brief Set bits per sample. This will not affect the WAV file 00077 * currently opened (see set_sample_rate()). If the value is 00078 * neither 8 nor 16, the call is ignored and the current value 00079 * is kept. 00080 */ 00081 virtual void set_bits_per_sample(int bits_per_sample) = 0; 00082 }; 00083 00084 } /* namespace blocks */ 00085 } /* namespace gr */ 00086 00087 #endif /* INCLUDED_GR_WAVFILE_SINK_H */