3838pdspKick::pdspKick () : PatchObject(" kick" ){
3939
4040 this ->numInlets = 4 ;
41- this ->numOutlets = 1 ;
41+ this ->numOutlets = 3 ;
4242
4343 _inletParams[0 ] = new float (); // bang
4444 *(float *)&_inletParams[0 ] = 0 .0f ;
@@ -50,6 +50,10 @@ pdspKick::pdspKick() : PatchObject("kick"){
5050 *(float *)&_inletParams[3 ] = 0 .0f ;
5151
5252 _outletParams[0 ] = new ofSoundBuffer (); // audio output
53+ _outletParams[1 ] = new float (); // ADSR func
54+ *(float *)&_outletParams[1 ] = 0 .0f ;
55+ _outletParams[2 ] = new float (); // Freq. ADSR func
56+ *(float *)&_outletParams[2 ] = 0 .0f ;
5357
5458 this ->initInletsState ();
5559
@@ -59,11 +63,28 @@ pdspKick::pdspKick() : PatchObject("kick"){
5963
6064 loaded = false ;
6165
66+ attackDuration = 0 .0f ;
67+ decayDuration = 240 .0f ;
68+ sustainLevel = 0 .0f ;
69+ releaseDuration = 0 .0f ;
70+
71+ f_attackDuration = 0 .0f ;
72+ f_decayDuration = 15 .0f ;
73+ f_sustainLevel = 0 .0f ;
74+ f_releaseDuration = 0 .0f ;
75+
76+ drivePower = 4 .57f ;
77+
6278 oscFreq = 44 .0f ;
6379 filterFreq = 120 .0f ;
6480 filterRes = 0 .168f ;
6581
82+ compRatio = 8 .0f ;
83+ compAttack = 2 .0f ;
84+ compRelease = 2 .0f ;
85+
6686 this ->width *= 2 .0f ;
87+ this ->height *= 3 .7f ;
6788
6889}
6990
@@ -77,11 +98,26 @@ void pdspKick::newObject(){
7798 this ->addInlet (VP_LINK_NUMERIC," filter resonance" );
7899
79100 this ->addOutlet (VP_LINK_AUDIO," kick" );
101+ this ->addOutlet (VP_LINK_NUMERIC," envelope" );
102+ this ->addOutlet (VP_LINK_NUMERIC," frequency envelope" );
103+
104+ this ->setCustomVar (attackDuration," ATTACK" );
105+ this ->setCustomVar (decayDuration," DECAY" );
106+ this ->setCustomVar (sustainLevel," SUSTAIN" );
107+ this ->setCustomVar (releaseDuration," RELEASE" );
108+
109+ this ->setCustomVar (f_attackDuration," FREQ_ATTACK" );
110+ this ->setCustomVar (f_decayDuration," FREQ_DECAY" );
111+ this ->setCustomVar (f_sustainLevel," FREQ_SUSTAIN" );
112+ this ->setCustomVar (f_releaseDuration," FREQ_RELEASE" );
80113
81114 this ->setCustomVar (oscFreq," OSC_FREQ" );
82115 this ->setCustomVar (filterFreq," FILTER_FREQ" );
83116 this ->setCustomVar (filterRes," FILTER_RES" );
84117
118+ this ->setCustomVar (compRatio," COMP_RATIO" );
119+ this ->setCustomVar (compAttack," COMP_A" );
120+ this ->setCustomVar (compRelease," COMP_R" );
85121
86122}
87123
@@ -108,29 +144,39 @@ void pdspKick::setupAudioOutObjectContent(pdsp::Engine &engine){
108144 filter_res_ctrl.set (filterRes);
109145 filter_res_ctrl.enableSmoothing (50 .0f );
110146
111- pdsp::VAFilter::LowPass24 >> filter.in_mode ();
147+ comp_ratio_ctrl >> compressor.in_ratio ();
148+ comp_ratio_ctrl.set (compRatio);
149+ comp_ratio_ctrl.enableSmoothing (50 .0f );
150+
151+ comp_A_ctrl >> compressor.in_attack ();
152+ comp_A_ctrl.set (compAttack);
153+ comp_A_ctrl.enableSmoothing (50 .0f );
154+
155+ comp_R_ctrl >> compressor.in_release ();
156+ comp_R_ctrl.set (compRelease);
157+ comp_R_ctrl.enableSmoothing (50 .0f );
112158
113- 40 .0f >> eq.in_freq ();
114- 2 .0f >> eq.in_gain ();
115- 2 .0f >> eq.in_Q ();
159+ drive.set (drivePower);
116160
117- 8 .0f >> compressor.in_ratio ();
118- 4 .16f >> compressor.in_attack ();
119- 50 .0f >> compressor.in_release ();
161+ pdsp::VAFilter::LowPass24 >> filter.in_mode ();
120162
121- drive. set ( 4 . 57f );
163+ compressor. analog ( );
122164
123165 osc >> amp;
124- gate_ctrl.out_trig () >> ampEnv. set ( 0 . 0f , 240 . 0f , 0 . 0f , 0 . 0f ) >> amp.in_mod ();
125- gate_ctrl.out_trig () >> modEnv. set ( 0 . 0f , 15 . 0f , 0 . 0f , 0 . 0f ) * osc_freq_ctrl.get () >> osc.in_pitch ();
166+ gate_ctrl.out_trig () >> ampEnv >> amp.in_mod ();
167+ gate_ctrl.out_trig () >> modEnv * osc_freq_ctrl.get () >> osc.in_pitch ();
126168
127- amp >> filter >> compressor >> drive >> this ->pdspOut [0 ];
128- amp >> filter >> compressor >> drive >> scope >> engine.blackhole ();
169+ amp >> filter >> drive >> compressor >> this ->pdspOut [0 ];
170+ amp >> filter >> drive >> compressor >> scope >> engine.blackhole ();
129171
130172}
131173
132174// --------------------------------------------------------------
133175void pdspKick::updateObjectContent (map<int ,shared_ptr<PatchObject>> &patchObjects){
176+ unusedArgs (patchObjects);
177+
178+ ampEnv.set (attackDuration,decayDuration,sustainLevel,releaseDuration);
179+ modEnv.set (f_attackDuration,f_decayDuration,f_sustainLevel,f_releaseDuration);
134180
135181 // bang --> trigger envelope
136182 if (this ->inletsConnected [0 ]){
@@ -155,14 +201,30 @@ void pdspKick::updateObjectContent(map<int,shared_ptr<PatchObject>> &patchObject
155201 if (!loaded){
156202 loaded = true ;
157203
204+ attackDuration = this ->getCustomVar (" ATTACK" );
205+ decayDuration = this ->getCustomVar (" DECAY" );
206+ sustainLevel = this ->getCustomVar (" SUSTAIN" );
207+ releaseDuration = this ->getCustomVar (" RELEASE" );
208+
209+ f_attackDuration = this ->getCustomVar (" FREQ_ATTACK" );
210+ f_decayDuration = this ->getCustomVar (" FREQ_DECAY" );
211+ f_sustainLevel = this ->getCustomVar (" FREQ_SUSTAIN" );
212+ f_releaseDuration = this ->getCustomVar (" FREQ_RELEASE" );
213+
158214 oscFreq = this ->getCustomVar (" OSC_FREQ" );
159215 filterFreq = this ->getCustomVar (" FILTER_FREQ" );
160216 filterRes = this ->getCustomVar (" FILTER_RES" );
217+
218+ compRatio = this ->getCustomVar (" COMP_RATIO" );
219+ compAttack = this ->getCustomVar (" COMP_A" );
220+ compRelease = this ->getCustomVar (" COMP_R" );
161221 }
162222}
163223
164224// --------------------------------------------------------------
165225void pdspKick::drawObjectContent (ofTrueTypeFont *font, shared_ptr<ofBaseGLRenderer>& glRenderer){
226+ unusedArgs (font,glRenderer);
227+
166228 ofSetColor (255 );
167229
168230}
@@ -188,23 +250,74 @@ void pdspKick::drawObjectNodeGui( ImGuiEx::NodeCanvas& _nodeCanvas ){
188250 // Visualize (Object main view)
189251 if ( _nodeCanvas.BeginNodeContent (ImGuiExNodeView_Visualise) ){
190252
253+ if (ImGuiEx::KnobFloat (_nodeCanvas.getNodeDrawList (), (ImGui::GetWindowSize ().x -(46 *scaleFactor))/11 , IM_COL32 (255 ,255 ,120 ,255 ), " A" , &attackDuration, 0 .0f , 1000 .0f , 1000 .0f )){
254+ this ->setCustomVar (attackDuration," ATTACK" );
255+ }
256+ ImGui::SameLine ();ImGui::Dummy (ImVec2 (6 *scaleFactor,-1 ));ImGui::SameLine ();
257+ if (ImGuiEx::KnobFloat (_nodeCanvas.getNodeDrawList (), (ImGui::GetWindowSize ().x -(46 *scaleFactor))/11 , IM_COL32 (255 ,255 ,120 ,255 ), " D" , &decayDuration, 0 .0f , 1000 .0f , 1000 .0f )){
258+ this ->setCustomVar (decayDuration," DECAY" );
259+ }
260+ ImGui::SameLine ();ImGui::Dummy (ImVec2 (6 *scaleFactor,-1 ));ImGui::SameLine ();
261+ if (ImGuiEx::KnobFloat (_nodeCanvas.getNodeDrawList (), (ImGui::GetWindowSize ().x -(46 *scaleFactor))/11 , IM_COL32 (255 ,255 ,120 ,255 ), " S" , &sustainLevel, 0 .0f , 1 .0f , 100 .0f )){
262+ this ->setCustomVar (sustainLevel," SUSTAIN" );
263+ }
264+ ImGui::SameLine ();ImGui::Dummy (ImVec2 (6 *scaleFactor,-1 ));ImGui::SameLine ();
265+ if (ImGuiEx::KnobFloat (_nodeCanvas.getNodeDrawList (), (ImGui::GetWindowSize ().x -(46 *scaleFactor))/11 , IM_COL32 (255 ,255 ,120 ,255 ), " R" , &releaseDuration, 0 .0f , 1000 .0f , 1000 .0f )){
266+ this ->setCustomVar (releaseDuration," RELEASE" );
267+ }
268+
269+ ImGui::Dummy (ImVec2 (-1 ,IMGUI_EX_NODE_CONTENT_PADDING*8 *scaleFactor));
270+
271+ if (ImGuiEx::KnobFloat (_nodeCanvas.getNodeDrawList (), (ImGui::GetWindowSize ().x -(46 *scaleFactor))/11 , IM_COL32 (255 ,255 ,120 ,255 ), " FREQ A" , &f_attackDuration, 0 .0f , 1000 .0f , 1000 .0f )){
272+ this ->setCustomVar (f_attackDuration," FREQ_ATTACK" );
273+ }
274+ ImGui::SameLine ();ImGui::Dummy (ImVec2 (6 *scaleFactor,-1 ));ImGui::SameLine ();
275+ if (ImGuiEx::KnobFloat (_nodeCanvas.getNodeDrawList (), (ImGui::GetWindowSize ().x -(46 *scaleFactor))/11 , IM_COL32 (255 ,255 ,120 ,255 ), " FREQ D" , &f_decayDuration, 0 .0f , 1000 .0f , 1000 .0f )){
276+ this ->setCustomVar (f_decayDuration," FREQ_DECAY" );
277+ }
278+ ImGui::SameLine ();ImGui::Dummy (ImVec2 (6 *scaleFactor,-1 ));ImGui::SameLine ();
279+ if (ImGuiEx::KnobFloat (_nodeCanvas.getNodeDrawList (), (ImGui::GetWindowSize ().x -(46 *scaleFactor))/11 , IM_COL32 (255 ,255 ,120 ,255 ), " FREQ S" , &f_sustainLevel, 0 .0f , 1 .0f , 100 .0f )){
280+ this ->setCustomVar (f_sustainLevel," FREQ_SUSTAIN" );
281+ }
282+ ImGui::SameLine ();ImGui::Dummy (ImVec2 (6 *scaleFactor,-1 ));ImGui::SameLine ();
283+ if (ImGuiEx::KnobFloat (_nodeCanvas.getNodeDrawList (), (ImGui::GetWindowSize ().x -(46 *scaleFactor))/11 , IM_COL32 (255 ,255 ,120 ,255 ), " FREQ R" , &f_releaseDuration, 0 .0f , 1000 .0f , 1000 .0f )){
284+ this ->setCustomVar (f_releaseDuration," FREQ_RELEASE" );
285+ }
286+
287+ ImGui::Dummy (ImVec2 (-1 ,IMGUI_EX_NODE_CONTENT_PADDING*8 *scaleFactor));
288+
191289 if (ImGuiEx::KnobFloat (_nodeCanvas.getNodeDrawList (), (ImGui::GetWindowSize ().x -(46 *scaleFactor))/11 , IM_COL32 (255 ,255 ,120 ,255 ), " FREQ" , &oscFreq, 0 .0f , 100 .0f , 100 .0f )){
192290 osc_freq_ctrl.set (pdsp::f2p (oscFreq));
193291 this ->setCustomVar (oscFreq," OSC_FREQ" );
194292 }
195- ImGui::SameLine ();ImGui::Dummy (ImVec2 (40 *scaleFactor,-1 ));ImGui::SameLine ();
293+ ImGui::SameLine ();ImGui::Dummy (ImVec2 (6 *scaleFactor,-1 ));ImGui::SameLine ();
196294 if (ImGuiEx::KnobFloat (_nodeCanvas.getNodeDrawList (), (ImGui::GetWindowSize ().x -(46 *scaleFactor))/11 , IM_COL32 (255 ,255 ,120 ,255 ), " F. FREQ" , &filterFreq, 0 .0f , 8260 .0f , 2065 .0f )){
197295 filter_freq_ctrl.set (pdsp::f2p (filterFreq));
198296 this ->setCustomVar (filterFreq," FILTER_FREQ" );
199297 }
200- ImGui::SameLine ();ImGui::Dummy (ImVec2 (40 *scaleFactor,-1 ));ImGui::SameLine ();
298+ ImGui::SameLine ();ImGui::Dummy (ImVec2 (6 *scaleFactor,-1 ));ImGui::SameLine ();
201299 if (ImGuiEx::KnobFloat (_nodeCanvas.getNodeDrawList (), (ImGui::GetWindowSize ().x -(46 *scaleFactor))/11 , IM_COL32 (255 ,255 ,120 ,255 ), " F. RES" , &filterRes, 0 .0f , 1 .0f , 100 .0f )){
202300 filter_res_ctrl.set (filterRes);
203301 this ->setCustomVar (filterRes," FILTER_RES" );
204302 }
205303
206304 ImGui::Dummy (ImVec2 (-1 ,IMGUI_EX_NODE_CONTENT_PADDING*8 *scaleFactor));
207305
306+ if (ImGuiEx::KnobFloat (_nodeCanvas.getNodeDrawList (), (ImGui::GetWindowSize ().x -(46 *scaleFactor))/11 , IM_COL32 (255 ,255 ,120 ,255 ), " RATIO" , &compRatio, 1 .0f , 40 .0f , 400 .0f )){
307+ comp_ratio_ctrl.set (compRatio);
308+ this ->setCustomVar (compRatio," COMP_RATIO" );
309+ }
310+ ImGui::SameLine ();ImGui::Dummy (ImVec2 (6 *scaleFactor,-1 ));ImGui::SameLine ();
311+ if (ImGuiEx::KnobFloat (_nodeCanvas.getNodeDrawList (), (ImGui::GetWindowSize ().x -(46 *scaleFactor))/11 , IM_COL32 (255 ,255 ,120 ,255 ), " COMP A" , &compAttack, 0 .0f , 1000 .0f , 1000 .0f )){
312+ comp_A_ctrl.set (compAttack);
313+ this ->setCustomVar (compAttack," COMP_A" );
314+ }
315+ ImGui::SameLine ();ImGui::Dummy (ImVec2 (6 *scaleFactor,-1 ));ImGui::SameLine ();
316+ if (ImGuiEx::KnobFloat (_nodeCanvas.getNodeDrawList (), (ImGui::GetWindowSize ().x -(46 *scaleFactor))/11 , IM_COL32 (255 ,255 ,120 ,255 ), " COMP R" , &compRelease, 0 .0f , 1000 .0f , 1000 .0f )){
317+ comp_R_ctrl.set (compRelease);
318+ this ->setCustomVar (compRelease," COMP_R" );
319+ }
320+
208321 _nodeCanvas.EndNodeContent ();
209322
210323 }
@@ -220,6 +333,8 @@ void pdspKick::drawObjectNodeConfig(){
220333
221334// --------------------------------------------------------------
222335void pdspKick::removeObjectContent (bool removeFileFromData){
336+ unusedArgs (removeFileFromData);
337+
223338 for (map<int ,pdsp::PatchNode>::iterator it = this ->pdspOut .begin (); it != this ->pdspOut .end (); it++ ){
224339 it->second .disconnectAll ();
225340 }
@@ -241,6 +356,13 @@ void pdspKick::loadAudioSettings(){
241356
242357// --------------------------------------------------------------
243358void pdspKick::audioOutObject (ofSoundBuffer &outputBuffer){
359+ unusedArgs (outputBuffer);
360+
361+ // output envelope func
362+ *(float *)&_outletParams[1 ] = ampEnv.meter_output ();
363+ // output freq. envelope func
364+ *(float *)&_outletParams[2 ] = modEnv.meter_output ();
365+
244366 // SIGNAL BUFFER
245367 static_cast <ofSoundBuffer *>(_outletParams[0 ])->copyFrom (scope.getBuffer ().data (), bufferSize, 1 , sampleRate);
246368
0 commit comments