gr_wavfile_sink.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef INCLUDED_GR_WAVFILE_SINK_H
00024 #define INCLUDED_GR_WAVFILE_SINK_H
00025
00026 #include <gr_sync_block.h>
00027 #include <gr_file_sink_base.h>
00028 #include <omnithread.h>
00029
00030 class gr_wavfile_sink;
00031 typedef boost::shared_ptr<gr_wavfile_sink> gr_wavfile_sink_sptr;
00032
00033
00034
00035
00036
00037
00038
00039 gr_wavfile_sink_sptr
00040 gr_make_wavfile_sink (const char *filename,
00041 int n_channels,
00042 unsigned int sample_rate,
00043 int bits_per_sample = 16);
00044
00053 class gr_wavfile_sink : public gr_sync_block
00054 {
00055 private:
00056 friend gr_wavfile_sink_sptr gr_make_wavfile_sink (const char *filename,
00057 int n_channels,
00058 unsigned int sample_rate,
00059 int bits_per_sample);
00060
00061 gr_wavfile_sink(const char *filename,
00062 int n_channels,
00063 unsigned int sample_rate,
00064 int bits_per_sample);
00065
00066 unsigned d_sample_rate;
00067 int d_nchans;
00068 unsigned d_sample_count;
00069 int d_bytes_per_sample;
00070 int d_bytes_per_sample_new;
00071 int d_max_sample_val;
00072 int d_min_sample_val;
00073 int d_normalize_shift;
00074 int d_normalize_fac;
00075
00076 FILE *d_fp;
00077 FILE *d_new_fp;
00078 bool d_updated;
00079 omni_mutex d_mutex;
00080
00085 short convert_to_short(float sample);
00086
00093 void close_wav();
00094
00095 public:
00096 ~gr_wavfile_sink ();
00097
00101 bool open(const char* filename);
00102
00107 void close();
00108
00114 void do_update();
00115
00121 void set_sample_rate(unsigned int sample_rate);
00122
00128 void set_bits_per_sample(int bits_per_sample);
00129
00130
00131 int work(int noutput_items,
00132 gr_vector_const_void_star &input_items,
00133 gr_vector_void_star &output_items);
00134
00135 };
00136
00137 #endif