|
libpsynth 0.2.1
|
00001 /*************************************************************************** 00002 * * 00003 * PSYCHOSYNTH * 00004 * =========== * 00005 * * 00006 * Copyright (C) Juan Pedro Bolivar Puente 2008 * 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_OBJECTSTEPSEQ_H 00024 #define PSYNTH_OBJECTSTEPSEQ_H 00025 00026 #include <psynth/graph/node.hpp> 00027 #include <psynth/graph/node_factory.hpp> 00028 #include <psynth/synth/multi_point_envelope.hpp> 00029 00030 namespace psynth 00031 { 00032 namespace graph 00033 { 00034 00035 class node_step_seq : public node 00036 { 00037 public: 00038 static constexpr int MAX_STEPS = 32; 00039 static constexpr float DEFAULT_BPM = 260.0; 00040 static constexpr int DEFAULT_NUM_STEPS = 12; 00041 static constexpr int DEFAULT_STEP = true; 00042 static constexpr float DEFAULT_HIGH = 0.8f; 00043 static constexpr float DEFAULT_SLOPE = 0.1f; 00044 00045 enum shape { 00046 SHAPE_SQUARE, 00047 SHAPE_TRIANGLE, 00048 SHAPE_FWSAWTOOTH, 00049 SHAPE_BWSAWTOOTH, 00050 N_SHAPES 00051 }; 00052 00053 enum in_audio_socket_id { 00054 N_IN_A_SOCKETS 00055 }; 00056 00057 enum in_control_socket_id { 00058 IN_C_BPM, 00059 N_IN_C_SOCKETS 00060 }; 00061 00062 enum param_id { 00063 PARAM_BPM = node::N_COMMON_PARAMS, 00064 PARAM_SHAPE, 00065 PARAM_HIGH, 00066 PARAM_SLOPE, 00067 PARAM_CURRENT_STEP, 00068 PARAM_NUM_STEPS, 00069 PARAM_STEP_0, 00070 PARAM_STEP_1, 00071 PARAM_STEP_2, 00072 PARAM_STEP_3, 00073 PARAM_STEP_4, 00074 PARAM_STEP_5, 00075 PARAM_STEP_6, 00076 PARAM_STEP_7, 00077 PARAM_STEP_8, 00078 PARAM_STEP_9, 00079 PARAM_STEP_10, 00080 PARAM_STEP_11, 00081 PARAM_STEP_12, 00082 PARAM_STEP_13, 00083 PARAM_STEP_14, 00084 PARAM_STEP_15, 00085 PARAM_STEP_16, 00086 PARAM_STEP_17, 00087 PARAM_STEP_18, 00088 PARAM_STEP_19, 00089 PARAM_STEP_20, 00090 PARAM_STEP_21, 00091 PARAM_STEP_22, 00092 PARAM_STEP_23, 00093 PARAM_STEP_24, 00094 PARAM_STEP_25, 00095 PARAM_STEP_26, 00096 PARAM_STEP_27, 00097 PARAM_STEP_28, 00098 PARAM_STEP_29, 00099 PARAM_STEP_30, 00100 PARAM_STEP_31, 00101 N_PARAM, 00102 }; 00103 00104 enum out_audio_socket_id { 00105 N_OUT_A_SOCKETS 00106 }; 00107 00108 enum out_constrol_socket_id { 00109 OUT_C_OUTPUT, 00110 N_OUT_C_SOCKETS 00111 }; 00112 00113 private: 00114 void do_update (const node* caller, int caller_port_type, int caller_port); 00115 void do_advance (); 00116 void on_info_change (); 00117 void create_shape (); 00118 void update_shape (); 00119 00120 float m_param_bpm; 00121 int m_param_shape; 00122 float m_param_high; 00123 float m_param_slope; 00124 int m_param_num_steps; 00125 int m_param_step[MAX_STEPS]; 00126 00127 float m_old_param_high; 00128 int m_old_param_shape; 00129 00130 synth::envelope_values<sound::bits32sf> m_hi_env_vals; 00131 synth::envelope_values<sound::bits32sf> m_lo_env_vals; 00132 synth::multi_point_envelope<sample_range> m_env; 00133 int m_cur_step; 00134 00135 void init_envelope_values (); 00136 void update_envelope_values (); 00137 void update_envelope_factor (float mod); 00138 00139 public: 00140 node_step_seq(const audio_info& info); 00141 }; 00142 00143 PSYNTH_DECLARE_NODE_FACTORY(node_step_seq, "stepseq"); 00144 00145 } /* namespace graph */ 00146 } /* namespace psynth */ 00147 00148 #endif /* PSYNTH_OBJECTSTEPSEQ_H */
1.7.4