libpsynth 0.2.1
/home/raskolnikov/dev/psynth/trunk/src/psynth/io/file_output.hpp
Go to the documentation of this file.
00001 
00011 /*
00012  *  Copyright (C) 2011 Juan Pedro BolĂ­var Puente
00013  *
00014  *  This file is part of Psychosynth.
00015  *   
00016  *  Psychosynth is free software: you can redistribute it and/or modify
00017  *  it under the terms of the GNU General Public License as published by
00018  *  the Free Software Foundation, either version 3 of the License, or
00019  *  (at your option) any later version.
00020  *
00021  *  Psychosynth is distributed in the hope that it will be useful,
00022  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00023  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00024  *  GNU General Public License for more details.
00025  *
00026  *  You should have received a copy of the GNU General Public License
00027  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00028  *
00029  */
00030 
00031 #ifndef PSYNTH_IO_FILE_OUTPUT_H_
00032 #define PSYNTH_IO_FILE_OUTPUT_H_
00033 
00034 #include <string>
00035 #include <sndfile.h>
00036 
00037 #include <psynth/io/file_common.hpp>
00038 
00039 namespace psynth
00040 {
00041 namespace io
00042 {
00043 
00044 template <class Range>
00045 class file_output : public file_output_base<Range>
00046 {
00047     typedef file_output_base<Range> base;
00048 public:
00049     typedef typename base::range range;
00050     typedef typename base::const_range const_range;
00051     
00052     static_assert (file_support<Range>::is_supported::value,
00053                    "Audio file format not supported.");
00054     
00055     file_output (const std::string& fname,
00056                  file_fmt           format,
00057                  std::size_t        rate);
00058 
00059     ~file_output ();
00060 
00061     std::size_t put (const const_range& data);
00062 
00063     std::size_t seek (std::ptrdiff_t offset, seek_dir dir);
00064     
00065 private:
00066     SNDFILE* _file;
00067     SF_INFO  _info;
00068 };
00069 
00070 } /* namespace io */
00071 } /* namespace psynth */
00072 
00073 #include <psynth/io/file_output.tpp>
00074 
00075 #endif /* PSYNTH_IO_FILE_OUTPUT_H_ */
00076