Skip to content

Commit 606e2e9

Browse files
committed
finished sound/kick object
1 parent 6b1fb78 commit 606e2e9

File tree

1 file changed

+38
-10
lines changed

1 file changed

+38
-10
lines changed

src/objects/sound/pdspKick.cpp

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,17 @@
3737
//--------------------------------------------------------------
3838
pdspKick::pdspKick() : PatchObject("kick"){
3939

40-
this->numInlets = 1;
40+
this->numInlets = 4;
4141
this->numOutlets = 1;
4242

4343
_inletParams[0] = new float(); // bang
4444
*(float *)&_inletParams[0] = 0.0f;
45+
_inletParams[1] = new float(); // osc freq
46+
*(float *)&_inletParams[1] = 0.0f;
47+
_inletParams[2] = new float(); // filter freq
48+
*(float *)&_inletParams[2] = 0.0f;
49+
_inletParams[3] = new float(); // filter res
50+
*(float *)&_inletParams[3] = 0.0f;
4551

4652
_outletParams[0] = new ofSoundBuffer(); // audio output
4753

@@ -58,7 +64,6 @@ pdspKick::pdspKick() : PatchObject("kick"){
5864
filterRes = 0.168f;
5965

6066
this->width *= 2.0f;
61-
this->height *= 2.0f;
6267

6368
}
6469

@@ -67,8 +72,15 @@ void pdspKick::newObject(){
6772
PatchObject::setName( this->objectName );
6873

6974
this->addInlet(VP_LINK_NUMERIC,"bang");
75+
this->addInlet(VP_LINK_NUMERIC,"pitch");
76+
this->addInlet(VP_LINK_NUMERIC,"filter frequency");
77+
this->addInlet(VP_LINK_NUMERIC,"filter resonance");
7078

71-
this->addOutlet(VP_LINK_AUDIO,"envelopedSignal");
79+
this->addOutlet(VP_LINK_AUDIO,"kick");
80+
81+
this->setCustomVar(oscFreq,"OSC_FREQ");
82+
this->setCustomVar(filterFreq,"FILTER_FREQ");
83+
this->setCustomVar(filterRes,"FILTER_RES");
7284

7385

7486
}
@@ -118,9 +130,25 @@ void pdspKick::setupAudioOutObjectContent(pdsp::Engine &engine){
118130
//--------------------------------------------------------------
119131
void pdspKick::updateObjectContent(map<int,shared_ptr<PatchObject>> &patchObjects){
120132

133+
if(this->inletsConnected[1]){
134+
oscFreq = ofClamp(*(float *)&_inletParams[1],0.0f,100.0f);
135+
}
136+
137+
if(this->inletsConnected[2]){
138+
filterFreq = ofClamp(*(float *)&_inletParams[2],0.0f, 8260.0f);
139+
}
140+
141+
if(this->inletsConnected[3]){
142+
filterRes = ofClamp(*(float *)&_inletParams[3],0.0f,1.0f);
143+
}
144+
121145

122146
if(!loaded){
123147
loaded = true;
148+
149+
oscFreq = this->getCustomVar("OSC_FREQ");
150+
filterFreq = this->getCustomVar("FILTER_FREQ");
151+
filterRes = this->getCustomVar("FILTER_RES");
124152
}
125153
}
126154

@@ -151,19 +179,19 @@ void pdspKick::drawObjectNodeGui( ImGuiEx::NodeCanvas& _nodeCanvas ){
151179
// Visualize (Object main view)
152180
if( _nodeCanvas.BeginNodeContent(ImGuiExNodeView_Visualise) ){
153181

154-
ImGui::Dummy(ImVec2(-1,IMGUI_EX_NODE_CONTENT_PADDING*2*scaleFactor));
155-
156182
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)){
157183
osc_freq_ctrl.set(pdsp::f2p(oscFreq));
184+
this->setCustomVar(oscFreq,"OSC_FREQ");
158185
}
159-
ImGui::SameLine();
160-
186+
ImGui::SameLine();ImGui::Dummy(ImVec2(40*scaleFactor,-1));ImGui::SameLine();
161187
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)){
162188
filter_freq_ctrl.set(pdsp::f2p(filterFreq));
189+
this->setCustomVar(filterFreq,"FILTER_FREQ");
163190
}
164-
ImGui::SameLine();
191+
ImGui::SameLine();ImGui::Dummy(ImVec2(40*scaleFactor,-1));ImGui::SameLine();
165192
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)){
166193
filter_res_ctrl.set(filterRes);
194+
this->setCustomVar(filterRes,"FILTER_RES");
167195
}
168196

169197
ImGui::Dummy(ImVec2(-1,IMGUI_EX_NODE_CONTENT_PADDING*8*scaleFactor));
@@ -175,8 +203,8 @@ void pdspKick::drawObjectNodeGui( ImGuiEx::NodeCanvas& _nodeCanvas ){
175203
//--------------------------------------------------------------
176204
void pdspKick::drawObjectNodeConfig(){
177205
ImGuiEx::ObjectInfo(
178-
"Kick synth.",
179-
"https://mosaic.d3cod3.org/reference.php?r=ahr-envelop", scaleFactor);
206+
"A pretty simple kick synth.",
207+
"https://mosaic.d3cod3.org/reference.php?r=kick", scaleFactor);
180208
}
181209

182210
//--------------------------------------------------------------

0 commit comments

Comments
 (0)