Skip to content

Commit 0f91be0

Browse files
committed
added numeric envelope outlet to ADSR and AHR envelope generators
1 parent bd81332 commit 0f91be0

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

src/objects/sound/pdspADSR.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
pdspADSR::pdspADSR() : PatchObject("ADSR envelope"){
3939

4040
this->numInlets = 6;
41-
this->numOutlets = 1;
41+
this->numOutlets = 2;
4242

4343
_inletParams[0] = new ofSoundBuffer(); // audio input
4444

@@ -54,6 +54,8 @@ pdspADSR::pdspADSR() : PatchObject("ADSR envelope"){
5454
*(float *)&_inletParams[5] = 0.0f;
5555

5656
_outletParams[0] = new ofSoundBuffer(); // audio output
57+
_outletParams[1] = new float(); // ADSR func
58+
*(float *)&_outletParams[1] = 0.0f;
5759

5860
this->initInletsState();
5961

@@ -88,6 +90,7 @@ void pdspADSR::newObject(){
8890
this->addInlet(VP_LINK_NUMERIC,"S");
8991
this->addInlet(VP_LINK_NUMERIC,"R");
9092
this->addOutlet(VP_LINK_AUDIO,"envelopedSignal");
93+
this->addOutlet(VP_LINK_NUMERIC,"envelope");
9194

9295
this->setCustomVar(attackHardness,"ATTACK_CURVE");
9396
this->setCustomVar(releaseHardness,"RELEASE_CURVE");
@@ -119,6 +122,7 @@ void pdspADSR::setupAudioOutObjectContent(pdsp::Engine &engine){
119122

120123
//--------------------------------------------------------------
121124
void pdspADSR::updateObjectContent(map<int,shared_ptr<PatchObject>> &patchObjects){
125+
unusedArgs(patchObjects);
122126

123127
env.set(attackDuration,decayDuration,sustainLevel,releaseDuration);
124128
env.setAttackCurve(attackHardness);
@@ -172,6 +176,8 @@ void pdspADSR::updateObjectContent(map<int,shared_ptr<PatchObject>> &patchObject
172176

173177
//--------------------------------------------------------------
174178
void pdspADSR::drawObjectContent(ofTrueTypeFont *font, shared_ptr<ofBaseGLRenderer>& glRenderer){
179+
unusedArgs(font,glRenderer);
180+
175181
ofSetColor(255);
176182

177183
}
@@ -240,6 +246,8 @@ void pdspADSR::drawObjectNodeConfig(){
240246

241247
//--------------------------------------------------------------
242248
void pdspADSR::removeObjectContent(bool removeFileFromData){
249+
unusedArgs(removeFileFromData);
250+
243251
for(map<int,pdsp::PatchNode>::iterator it = this->pdspIn.begin(); it != this->pdspIn.end(); it++ ){
244252
it->second.disconnectAll();
245253
}
@@ -264,6 +272,11 @@ void pdspADSR::loadAudioSettings(){
264272

265273
//--------------------------------------------------------------
266274
void pdspADSR::audioOutObject(ofSoundBuffer &outputBuffer){
275+
unusedArgs(outputBuffer);
276+
277+
// output envelope func
278+
*(float *)&_outletParams[1] = env.meter_output();
279+
267280
// SIGNAL BUFFER
268281
static_cast<ofSoundBuffer *>(_outletParams[0])->copyFrom(scope.getBuffer().data(), bufferSize, 1, sampleRate);
269282
}

src/objects/sound/pdspAHR.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
pdspAHR::pdspAHR() : PatchObject("AHR envelope"){
3939

4040
this->numInlets = 5;
41-
this->numOutlets = 1;
41+
this->numOutlets = 2;
4242

4343
_inletParams[0] = new ofSoundBuffer(); // audio input
4444

@@ -52,6 +52,8 @@ pdspAHR::pdspAHR() : PatchObject("AHR envelope"){
5252
*(float *)&_inletParams[4] = 0.0f;
5353

5454
_outletParams[0] = new ofSoundBuffer(); // audio output
55+
_outletParams[1] = new float(); // AHR func
56+
*(float *)&_outletParams[1] = 0.0f;
5557

5658
this->initInletsState();
5759

@@ -83,6 +85,7 @@ void pdspAHR::newObject(){
8385
this->addInlet(VP_LINK_NUMERIC,"H");
8486
this->addInlet(VP_LINK_NUMERIC,"R");
8587
this->addOutlet(VP_LINK_AUDIO,"envelopedSignal");
88+
this->addOutlet(VP_LINK_NUMERIC,"envelope");
8689

8790
this->setCustomVar(attackHardness,"ATTACK_CURVE");
8891
this->setCustomVar(releaseHardness,"RELEASE_CURVE");
@@ -113,6 +116,7 @@ void pdspAHR::setupAudioOutObjectContent(pdsp::Engine &engine){
113116

114117
//--------------------------------------------------------------
115118
void pdspAHR::updateObjectContent(map<int,shared_ptr<PatchObject>> &patchObjects){
119+
unusedArgs(patchObjects);
116120

117121
env.set(attackDuration,holdDuration,releaseDuration);
118122
env.setAttackCurve(attackHardness);
@@ -156,6 +160,8 @@ void pdspAHR::updateObjectContent(map<int,shared_ptr<PatchObject>> &patchObjects
156160

157161
//--------------------------------------------------------------
158162
void pdspAHR::drawObjectContent(ofTrueTypeFont *font, shared_ptr<ofBaseGLRenderer>& glRenderer){
163+
unusedArgs(font,glRenderer);
164+
159165
ofSetColor(255);
160166

161167
}
@@ -221,6 +227,8 @@ void pdspAHR::drawObjectNodeConfig(){
221227

222228
//--------------------------------------------------------------
223229
void pdspAHR::removeObjectContent(bool removeFileFromData){
230+
unusedArgs(removeFileFromData);
231+
224232
for(map<int,pdsp::PatchNode>::iterator it = this->pdspIn.begin(); it != this->pdspIn.end(); it++ ){
225233
it->second.disconnectAll();
226234
}
@@ -245,6 +253,11 @@ void pdspAHR::loadAudioSettings(){
245253

246254
//--------------------------------------------------------------
247255
void pdspAHR::audioOutObject(ofSoundBuffer &outputBuffer){
256+
unusedArgs(outputBuffer);
257+
258+
// output envelope func
259+
*(float *)&_outletParams[1] = env.meter_output();
260+
248261
// SIGNAL BUFFER
249262
static_cast<ofSoundBuffer *>(_outletParams[0])->copyFrom(scope.getBuffer().data(), bufferSize, 1, sampleRate);
250263
}

0 commit comments

Comments
 (0)