Simulating a capacitor in gen~

damu's icon

Hi there,

I'm trying to simulate a capacitor in gen for an envelope design i'm working on.

The basic idea is that you send a number to some sort of counter, as a 1 sample impulse.

The counter should then count down from whatever number that is until it reaches zero, where it will rest until it receives another number input.

The kicker is that if the counter receives the input of additional numbers before it has finished counting down to zero, it should add those numbers to the remaining total and proceed to count down from the new total, until it reaches zero.

I hope that makes sense, if anyone could help me, it would be much appreciated. My patch it getting messy as i'm getting frustrated.

Thank you!

Max Patch
Copy patch and select New From Clipboard in Max.

damu's icon

I did it!

The lesson is to have a break whenever i'm getting frustrated.

Max Patch
Copy patch and select New From Clipboard in Max.

Django Pither's icon

I know this is pretty old but I'm new to gen~. How would you create the inverse of the discharge cycle? For example using a toggle. Toggle on charges the capacitor and toggle off discharges?

Your solution seems really slick and if I could just wrap my head around gen~ I think it'd solve a specific use case I'm having.