17
17
ParameterRamper attackRamp{0.1 };
18
18
ParameterRamper releaseRamp{0.1 };
19
19
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 ;
27
20
28
21
public:
29
22
VocoderDSP () {
35
28
36
29
void init (int channelCount, double sampleRate) override {
37
30
SoundpipeDSPBase::init (channelCount, sampleRate);
31
+
32
+ // Create and initialize vocoders first
38
33
sp_vocoder_create (&vocoderL);
39
- sp_vocoder_init (sp, vocoderL);
40
34
sp_vocoder_create (&vocoderR);
35
+
36
+ // Initialize vocoders after setting parameters
37
+ sp_vocoder_init (sp, vocoderL);
41
38
sp_vocoder_init (sp, vocoderR);
42
39
}
43
40
@@ -50,6 +47,7 @@ void deinit() override {
50
47
void reset () override {
51
48
SoundpipeDSPBase::reset ();
52
49
if (!isInitialized) return ;
50
+
53
51
sp_vocoder_init (sp, vocoderL);
54
52
sp_vocoder_init (sp, vocoderR);
55
53
}
@@ -62,22 +60,11 @@ void process(FrameRange range) override {
62
60
float excitationInR = input2Sample (1 , i); // modulator input right
63
61
float outSampleL;
64
62
float outSampleR;
65
-
66
- attackTimeL = attackRamp.getAndStep ();
67
- releaseTimeL = releaseRamp.getAndStep ();
68
- bwRatioL = bwRatioRamp.getAndStep ();
69
63
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
+
81
68
sp_vocoder_compute (sp, vocoderL, &sourceInL, &excitationInL, &outSampleL);
82
69
sp_vocoder_compute (sp, vocoderR, &sourceInR, &excitationInR, &outSampleR);
83
70
0 commit comments