|
libpsynth 0.2.1
|
00001 /*************************************************************************** 00002 * * 00003 * PSYCHOSYNTH * 00004 * =========== * 00005 * * 00006 * Copyright (C) Juan Pedro Bolivar Puente 2007 * 00007 * * 00008 * This program is free software: you can redistribute it and/or modify * 00009 * it under the terms of the GNU General Public License as published by * 00010 * the Free Software Foundation, either version 3 of the License, or * 00011 * (at your option) any later version. * 00012 * * 00013 * This program is distributed in the hope that it will be useful, * 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00016 * GNU General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU General Public License * 00019 * along with this program. If not, see <http://www.gnu.org/licenses/>. * 00020 * * 00021 ***************************************************************************/ 00022 00023 #ifndef PSYNTH_NODE_DOUBLE_SAMPLER_H 00024 #define PSYNTH_NODE_DOUBLE_SAMPLER_H 00025 00026 #include <psynth/graph/node.hpp> 00027 #include <psynth/io/file_input.hpp> 00028 #include <psynth/io/caching_file_input.hpp> 00029 #include <psynth/graph/node_factory.hpp> 00030 #include <psynth/synth/scaler.hpp> 00031 00032 namespace psynth 00033 { 00034 namespace graph 00035 { 00036 00037 class node_double_sampler : public node 00038 { 00039 public: 00040 enum in_audio_socket_id { 00041 N_IN_A_SOCKETS 00042 }; 00043 00044 enum in_control_socket_id { 00045 IN_C_BLEND, 00046 IN_C_TRIGGER, 00047 N_IN_C_SOCKETS 00048 }; 00049 00050 enum param_id { 00051 PARAM_FILE_ONE = node::N_COMMON_PARAMS, 00052 PARAM_FILE_TWO, 00053 PARAM_AMPLITUDE, 00054 PARAM_BLEND, 00055 N_PARAM 00056 }; 00057 00058 enum out_audio_socket_id { 00059 OUT_A_OUTPUT, 00060 N_OUT_A_SOCKETS 00061 }; 00062 00063 enum out_control_socket_id { 00064 N_OUT_C_SOCKETS 00065 }; 00066 00067 private: 00068 typedef sound::stereo32sf_range interleaved_range; 00069 typedef sound::stereo32sf_buffer interleaved_buffer; 00070 00071 io::file_input_ptr<interleaved_range> m_reader_one; 00072 io::caching_file_input_adapter<interleaved_range, 00073 decltype (m_reader_one)> 00074 m_fetcher_one; 00075 io::file_input_ptr<interleaved_range> m_reader_two; 00076 io::caching_file_input_adapter<interleaved_range, decltype (m_reader_two)> 00077 m_fetcher_two; 00078 00079 interleaved_buffer m_inbuf_one; 00080 interleaved_buffer m_inbuf_two; 00081 00082 float m_param_ampl; 00083 float m_param_blend; 00084 00085 bool m_restart; 00086 00087 std::string m_param_file_one; 00088 std::string m_param_file_two; 00089 00090 std::mutex m_update_mutex; 00091 00092 void on_file_one_change (node_param& par); 00093 void on_file_two_change (node_param& par); 00094 void read (audio_buffer& buf, int start, int end); 00095 void restart(); 00096 00097 void do_update (const node* caller, int caller_port_type, int caller_port); 00098 void do_advance (); 00099 void on_info_change (); 00100 00101 public: 00102 node_double_sampler (const audio_info& info); 00103 ~node_double_sampler (); 00104 }; 00105 00106 PSYNTH_DECLARE_NODE_FACTORY (node_double_sampler, "double_sampler"); 00107 00108 } /* namespace graph */ 00109 } /* namespace psynth */ 00110 00111 #endif /* PSYNTH_OBJECTSAMPLER_H */
1.7.4