[sdiy] Making a 2164 “linear” with a digital envelope generator
Benjamin Tremblay
btremblay at me.com
Sat Feb 10 16:27:49 CET 2024
Here is ChatGPT’s response to the above prompt. It misses the requirement to convert the logarithmic 2164 to a linear response.
Yes, you can use a Teensy PWM to control a VCA (Voltage Controlled Amplifier) with a digital envelope generator. In C++, you could create a function to process the digital envelope generator output to control the PWM signal. Here's a simple example of what that function might look like:
```cpp
// Function to map envelope value to PWM duty cycle
float mapEnvelopeToPWM(float envelopeValue) {
// Assuming envelopeValue ranges from 0 to 1
// Map the envelope value to PWM duty cycle (0 to 255 for 8-bit PWM)
float dutyCycle = envelopeValue * 255.0;
return dutyCycle;
}
// Example usage
float envelopeValue = calculateEnvelope(); // Calculate envelope value
float pwmDutyCycle = mapEnvelopeToPWM(envelopeValue); // Map envelope value to PWM duty cycle
```
In this example, the `mapEnvelopeToPWM` function takes the envelope value (ranging from 0 to 1) as input and maps it to the PWM duty cycle range (0 to 255 for an 8-bit PWM signal). You can adjust the scaling and mapping based on the specific requirements and characteristics of your VCA and PWM setup.
Benjamin Tremblay
> On Feb 10, 2024, at 10:17 AM, Benjamin Tremblay <btremblay at me.com> wrote:
>
> Hello, quick question.
> I have used Teensy PWM to control the 2164 as a programmable stereo mixer.
> Could I use a similar circuit to produce a conventional VCA response if I processed my Teensy digital envelope generator with a function? What would that function look like in C++?
>
> Thanks,
> Benjamin
> Benjamin Tremblay
More information about the Synth-diy
mailing list