1717 ParameterRamper attackRamp{0.1 };
1818 ParameterRamper releaseRamp{0.1 };
1919 ParameterRamper bwRatioRamp{0.5 };
20-
21- float attackTimeL = 0.1 ;
22- float releaseTimeL = 0.1 ;
23- float bwRatioL = 0.5 ;
24- float attackTimeR = 0.1 ;
25- float releaseTimeR = 0.1 ;
26- float bwRatioR = 0.5 ;
2720
2821public:
2922 VocoderDSP () {
3528
3629 void init (int channelCount, double sampleRate) override {
3730 SoundpipeDSPBase::init (channelCount, sampleRate);
31+
32+ // Create and initialize vocoders first
3833 sp_vocoder_create (&vocoderL);
39- sp_vocoder_init (sp, vocoderL);
4034 sp_vocoder_create (&vocoderR);
35+
36+ // Initialize vocoders after setting parameters
37+ sp_vocoder_init (sp, vocoderL);
4138 sp_vocoder_init (sp, vocoderR);
4239 }
4340
@@ -50,6 +47,7 @@ void deinit() override {
5047 void reset () override {
5148 SoundpipeDSPBase::reset ();
5249 if (!isInitialized) return ;
50+
5351 sp_vocoder_init (sp, vocoderL);
5452 sp_vocoder_init (sp, vocoderR);
5553 }
@@ -62,22 +60,11 @@ void process(FrameRange range) override {
6260 float excitationInR = input2Sample (1 , i); // modulator input right
6361 float outSampleL;
6462 float outSampleR;
65-
66- attackTimeL = attackRamp.getAndStep ();
67- releaseTimeL = releaseRamp.getAndStep ();
68- bwRatioL = bwRatioRamp.getAndStep ();
6963
70- attackTimeR = attackTimeL;
71- releaseTimeR = releaseTimeL;
72- bwRatioR = bwRatioL;
73-
74- vocoderL->atk = &attackTimeL;
75- vocoderL->rel = &releaseTimeL;
76- vocoderL->bwratio = &bwRatioL;
77- vocoderR->atk = &attackTimeR;
78- vocoderR->rel = &releaseTimeR;
79- vocoderR->bwratio = &bwRatioR;
80-
64+ *vocoderL->atk = *vocoderR->atk = attackRamp.getAndStep ();
65+ *vocoderL->rel = *vocoderR->rel = releaseRamp.getAndStep ();
66+ *vocoderL->bwratio = *vocoderR->bwratio = bwRatioRamp.getAndStep ();
67+
8168 sp_vocoder_compute (sp, vocoderL, &sourceInL, &excitationInL, &outSampleL);
8269 sp_vocoder_compute (sp, vocoderR, &sourceInR, &excitationInR, &outSampleR);
8370
0 commit comments