|
libpsynth 0.2.1
|
00001 00011 /* 00012 * Copyright (C) 2010 Juan Pedro Bolivar 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_SOUND_OUTPUT_H_ 00032 #define PSYNTH_SOUND_OUTPUT_H_ 00033 00034 #include <ostream> 00035 #include <psynth/sound/channel_base.hpp> 00036 00037 namespace psynth 00038 { 00039 namespace sound 00040 { 00041 00042 template<typename S, typename L> struct frame; 00043 template<typename S, typename L> struct planar_frame_reference; 00044 template<typename S, typename L> struct planar_frame_iterator; 00045 template<typename P, typename C, typename L> 00046 struct packed_frame; 00047 template<typename P, bool C, typename L> 00048 struct buffer; 00049 template<typename P> 00050 struct buffer_range; 00051 template <typename B, typename C, typename L, bool M> 00052 struct bit_aligned_frame_reference; 00053 template <typename Ref> 00054 struct bit_aligned_frame_iterator; 00055 00056 namespace detail 00057 { 00058 00059 struct item_output_fn 00060 { 00061 item_output_fn (std::ostream& os) : _os (os) {} 00062 00063 template <class T> 00064 void operator () (const T& x) 00065 { _os << x << " ";} 00066 00067 private: 00068 std::ostream& _os; 00069 }; 00070 00071 template <class Frame> 00072 std::ostream& output_frame (std::ostream& os, const Frame& f) 00073 { 00074 os << "< "; 00075 static_for_each (f, item_output_fn (os)); 00076 return os << ">"; 00077 } 00078 00079 } /* namespace detail */ 00080 00081 template <typename S, typename L> 00082 std::ostream& operator<< (std::ostream& os, const frame<S, L>& f) 00083 { 00084 return detail::output_frame (os, f); 00085 } 00086 00087 template <typename P, typename C, typename L, bool M> 00088 std::ostream& operator<< (std::ostream& os, 00089 const bit_aligned_frame_reference<P, C, L, M>& f) 00090 { 00091 return detail::output_frame (os, f); 00092 } 00093 00094 template <typename Ref> 00095 std::ostream& operator<< (std::ostream& os, 00096 const bit_aligned_frame_iterator<Ref>& f) 00097 { 00098 os << "*"; 00099 return detail::output_frame (os, *f); 00100 } 00101 00102 template <typename P, typename C, typename L> 00103 std::ostream& operator<< (std::ostream& os, 00104 const packed_frame<P, C, L>& f) 00105 { 00106 return os; 00107 } 00108 00109 template <typename S, typename L> 00110 std::ostream& operator<< (std::ostream& os, 00111 const planar_frame_reference<S, L>& f) 00112 { 00113 return detail::output_frame (os, f); 00114 } 00115 00116 00117 template <typename S, typename L> 00118 std::ostream& operator<< (std::ostream& os, 00119 const planar_frame_iterator<S, L>& f) 00120 { 00121 os << "*"; 00122 return detail::output_frame (os, *f); 00123 } 00124 00125 template <typename F, bool P, typename A> 00126 std::ostream& operator<< (std::ostream& os, const buffer<F, P, A>& f) 00127 { 00128 os << "["; 00129 for (auto it = f.begin (); it != f.end (); ++it) 00130 { 00131 os << " "; 00132 detail::output_frame (os, *it); 00133 } 00134 return os << " ]"; 00135 } 00136 00137 template <typename I> 00138 std::ostream& operator<< (std::ostream& os, const buffer_range<I>& f) 00139 { 00140 os << "["; 00141 for (auto it = f.begin (); it != f.end (); ++it) 00142 { 00143 os << " "; 00144 detail::output_frame (os, *it); 00145 } 00146 return os << " ]"; 00147 } 00148 00149 } /* namespace sound */ 00150 } /* namespace psynth */ 00151 00152 #endif /* PSYNTH_SOUND_OUTPUT_H_ */
1.7.4