|
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_OBJECTFILTER_H 00024 #define PSYNTH_OBJECTFILTER_H 00025 00026 #include <vector> 00027 00028 #include <psynth/graph/node.hpp> 00029 #include <psynth/graph/node_factory.hpp> 00030 #include <psynth/synth/filter.hpp> 00031 00032 namespace psynth 00033 { 00034 namespace graph 00035 { 00036 00037 class node_filter : public node 00038 { 00039 public: 00040 enum in_audio_socket_id { 00041 IN_A_INPUT, 00042 N_IN_A_SOCKETS 00043 }; 00044 00045 enum in_control_socket_id { 00046 IN_C_CUTOFF, 00047 IN_C_EMPHASIS, 00048 N_IN_C_SOCKETS 00049 }; 00050 00051 enum out_audio_socket_id { 00052 OUT_A_OUTPUT, 00053 N_OUT_A_SOCKETS 00054 }; 00055 00056 enum out_control_socket_id { 00057 N_OUT_C_SOCKETS 00058 }; 00059 00060 enum filter_type { 00061 FILTER_LOWPASS = filter_values::LOWPASS, 00062 FILTER_HIGHPASS = filter_values::HIPASS, 00063 FILTER_BANDPASS_CSG = filter_values::BANDPASS_CSG, 00064 FILTER_BANDPASS_CZPG = filter_values::BANDPASS_CZPG, 00065 FILTER_NOTCH = filter_values::NOTCH, 00066 FILTER_MOOG = filter_values::MOOG, 00067 N_FILTER_TYPES, 00068 }; 00069 00070 enum param_id { 00071 PARAM_TYPE = node::N_COMMON_PARAMS, 00072 PARAM_CUTOFF, 00073 PARAM_RESONANCE, 00074 N_PARAM 00075 }; 00076 00077 static constexpr float DEFAULT_CUTOFF = 660.0f; 00078 static constexpr float DEFAULT_RESONANCE = 0.5f; 00079 00080 private: 00081 int m_param_type; 00082 float m_param_cutoff; 00083 float m_param_resonance; 00084 00085 filter_values m_filter_values; 00086 std::vector<filter> m_filter; 00087 00088 void do_update (const node* caller, int caller_port_type, int caller_port); 00089 void do_advance () {} 00090 void on_info_change () {} 00091 00092 public: 00093 node_filter (const audio_info& prop, int mode = FILTER_LOWPASS); 00094 ~node_filter (); 00095 }; 00096 00097 PSYNTH_DECLARE_NODE_FACTORY(node_filter, "filter"); 00098 00099 } /* namespace graph */ 00100 } /* namespace psynth */ 00101 00102 #endif /* PSYNTH_OBJECTFILTER_H */
1.7.4