[JayDelay]

- added variable diffusor size, feedback delays and feedback gain
This commit is contained in:
2025-11-11 18:11:57 +01:00
parent a57e44f65f
commit b49404ec2c
3 changed files with 62 additions and 42 deletions
+57 -40
View File
@@ -9,7 +9,7 @@
#include <cstdlib> #include <cstdlib>
#include <cstdio> #include <cstdio>
#define NUM_PARMS 6 #define NUM_PARMS 8
#define MAX_ORDER 4 #define MAX_ORDER 4
const char * const pFTypeString[] = const char * const pFTypeString[] =
@@ -19,20 +19,24 @@ const char * const pFTypeString[] =
"Size 2", "Size 2",
"Size 3", "Size 3",
"Size 4", "Size 4",
"Feedback", "Feedback Delay Min",
"Feedback Delay Max",
"Feedback Gain",
}; };
const char * const pFUnitString[] = const char * const pFUnitString[] =
{ {
"Order", "",
"Size 1", "samples",
"Size 2", "samples",
"Size 3", "samples",
"Size 4", "samples",
"Feedback", "samples",
"samples",
"",
}; };
enum {ORDER, SIZE_1, SIZE_2, SIZE_3, SIZE_4, FEEDBACK}; enum {ORDER, SIZE_1, SIZE_2, SIZE_3, SIZE_4, FEEDBACK_DELAY_MIN, FEEDBACK_DELAY_XAX, FEEDBACK_GAIN};
AudioEffect* createEffectInstance (audioMasterCallback audioMaster) AudioEffect* createEffectInstance (audioMasterCallback audioMaster)
{ {
@@ -42,10 +46,8 @@ AudioEffect* createEffectInstance (audioMasterCallback audioMaster)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
Plugin::Plugin(audioMasterCallback audioMaster) Plugin::Plugin(audioMasterCallback audioMaster)
: AudioEffectX(audioMaster, 1, NUM_PARMS) // 1 program, 1 parameter only : AudioEffectX(audioMaster, 1, NUM_PARMS) // 1 program, 1 parameter only
//, m_reverb_1({(uint)(48000*0.02), (uint)(48000*0.04), (uint)(48000*0.08), (uint)(48000*0.16)}, (uint)(48000*0.1), (uint)(48000*0.2)) , m_reverb_1({DELAY_MAX, DELAY_MAX, DELAY_MAX, DELAY_MAX}, DELAY_MAX)
//, m_reverb_2({(uint)(48000*0.02), (uint)(48000*0.04), (uint)(48000*0.08), (uint)(48000*0.16)}, (uint)(48000*0.1), (uint)(48000*0.2)) , m_reverb_2({DELAY_MAX, DELAY_MAX, DELAY_MAX, DELAY_MAX}, DELAY_MAX)
, m_reverb_1({(uint)(48000*0.48)}, (uint)(48000*0.1), (uint)(48000*0.2))
, m_reverb_2({(uint)(48000*0.48)}, (uint)(48000*0.1), (uint)(48000*0.2))
{ {
sampleRate = 48000; sampleRate = 48000;
setNumInputs(2); // stereo in setNumInputs(2); // stereo in
@@ -54,6 +56,9 @@ Plugin::Plugin(audioMasterCallback audioMaster)
canMono(); // makes sense to feed both inputs with the same signal canMono(); // makes sense to feed both inputs with the same signal
canProcessReplacing(); // supports both accumulating and replacing output canProcessReplacing(); // supports both accumulating and replacing output
strcpy(programName, "Default"); // default program name strcpy(programName, "Default"); // default program name
m_feedback_delay[0] = 0;
m_feedback_delay[1] = 0;
} }
//----------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------
@@ -82,22 +87,29 @@ void Plugin::setParameter(VstInt32 index, float value)
case ORDER: case ORDER:
break; break;
case FEEDBACK: case SIZE_1:
case SIZE_2:
case SIZE_3:
case SIZE_4:
{
uint delay = (uint)(value*DELAY_MAX);
m_reverb_1.setDelay(delay, index - SIZE_1);
m_reverb_2.setDelay(delay, index - SIZE_1);
break;
}
case FEEDBACK_GAIN:
m_reverb_1.setFeedbackGain(value); m_reverb_1.setFeedbackGain(value);
m_reverb_2.setFeedbackGain(value); m_reverb_2.setFeedbackGain(value);
break; break;
case SIZE_1: case FEEDBACK_DELAY_MIN:
break; case FEEDBACK_DELAY_XAX:
m_feedback_delay[index-FEEDBACK_DELAY_MIN] = (uint)(value * DELAY_MAX);
case SIZE_2: m_reverb_1.setFeedbackDelay(m_feedback_delay[0], m_feedback_delay[0]);
break; m_reverb_2.setFeedbackDelay(m_feedback_delay[0], m_feedback_delay[0]);
case SIZE_3:
break;
case SIZE_4:
break; break;
} }
} }
@@ -114,25 +126,22 @@ float Plugin::getParameter(VstInt32 index)
break; break;
case SIZE_1: case SIZE_1:
value = 1;
break;
case SIZE_2: case SIZE_2:
value = 2;
break;
case SIZE_3: case SIZE_3:
value = 3;
break;
case SIZE_4: case SIZE_4:
value = 4; value = m_reverb_1.getDelay(index - SIZE_1);
break; break;
case FEEDBACK: case FEEDBACK_GAIN:
value = 0.707; value = m_reverb_1.getFeedbackGain();
break; break;
case FEEDBACK_DELAY_MIN:
case FEEDBACK_DELAY_XAX:
value = m_feedback_delay[index-FEEDBACK_DELAY_MIN];
break;
} }
return value; return value;
} }
@@ -147,7 +156,9 @@ void Plugin::getParameterName(VstInt32 index, char *label)
case SIZE_2: case SIZE_2:
case SIZE_3: case SIZE_3:
case SIZE_4: case SIZE_4:
case FEEDBACK: case FEEDBACK_DELAY_MIN:
case FEEDBACK_DELAY_XAX:
case FEEDBACK_GAIN:
strcpy(label,pFTypeString[index]); strcpy(label,pFTypeString[index]);
break; break;
default: default:
@@ -167,8 +178,12 @@ void Plugin::getParameterDisplay(VstInt32 index, char *text)
case SIZE_2: case SIZE_2:
case SIZE_3: case SIZE_3:
case SIZE_4: case SIZE_4:
case FEEDBACK: case FEEDBACK_DELAY_MIN:
strcpy(text, pFTypeString[index]); case FEEDBACK_DELAY_XAX:
sprintf(text, "%d", (int)getParameter(index));
break;
case FEEDBACK_GAIN:
sprintf(text, "%f", getParameter(index));
break; break;
} }
} }
@@ -183,7 +198,9 @@ void Plugin::getParameterLabel(VstInt32 index, char *label)
case SIZE_2: case SIZE_2:
case SIZE_3: case SIZE_3:
case SIZE_4: case SIZE_4:
case FEEDBACK: case FEEDBACK_DELAY_MIN:
case FEEDBACK_DELAY_XAX:
case FEEDBACK_GAIN:
strcpy(label, pFUnitString[index]); strcpy(label, pFUnitString[index]);
break; break;
} }
+4 -1
View File
@@ -11,7 +11,9 @@
class Plugin : public AudioEffectX class Plugin : public AudioEffectX
{ {
public: const uint DELAY_MAX = 48000;
public:
Plugin(audioMasterCallback audioMaster); Plugin(audioMasterCallback audioMaster);
~Plugin(); ~Plugin();
@@ -39,6 +41,7 @@ protected:
private: private:
Reverb<float, 8> m_reverb_1; Reverb<float, 8> m_reverb_1;
Reverb<float, 8> m_reverb_2; Reverb<float, 8> m_reverb_2;
uint m_feedback_delay[2];
}; };
#endif // __PLUGIN_H #endif // __PLUGIN_H