Input to Output Inversion Madness (C++)

Pleased to have cracked this one.
I’m working on my midi to CV converter. Having had it pointed out that Lich was a lot of HP to waste for this I added some an
ADSR … my own code from scratch, didn’t see anything in the libraries but this one sounds great.
…and a couple of other tweaks
Having got this going I got Lich to pass audio from Right input to right output and made it into a VCA using an ADSR (has to be updated at sample level, or there’s 2kHz breakthrough)

This left the Left audio input with nothing to do, so I had the idea to create a MAX function with the ADSR.
(so VCA could be used from CV in Right input as an alternate…or …)

Anyway, the MAX function wouldn’t work, …until I inverted the left audio input.

Thought I’d better report this…may save someone some headaches.

FloatArray left = buffer.getSamples(LEFT_CHANNEL);
FloatArray right = buffer.getSamples(RIGHT_CHANNEL);

	for( int j=0; j<blockSize ; j++ ){
		left[j] = -left[j];// this is left audio input as a float array NEEDS INVERSION
                    envVCA[j] = adsrVCA.GetLevel();//envVCA is a floatarray
		if(left[j]>envVCA[j]){	envVCA[j] = left[j];}// took ages to find why this wouldn't work


Yeah, it’s a know issue. IIRC, outputs are inverted by the analog amplifier, so we can’t avoid this in software. I guess eventually we will invert them in firmware builds for devices have this problem to restore correct orientation.

Btw, OWL library has an envelope template that supports linear or exponetial ADSRs. It can be used as an envelope generartor or applied to other audio signal (hence inherits from both SignalProcessor and SignalGenerator base classes).

Thanks for confirming.
I made a few tweaks to my adsr which I don’t know would have worked using library code.
The Attack is a nice sounding math hack, the Decay is expontial drop towards the Sustain, so very smooth transition, Release is linear. Starting to get a grip on the api though.

Yeah, if you want to have different shapes at different envelope stages, that’s not something that the builtin ADSR supports. It only covers 2 of the most common envelope types (which is almost always good enough).

Maybe adding a more generic multi-segment envelope generator could be a nice addition, supporting both different shapes and number of stages if necessary. Another nice feature to have is morphing between linear and exponential shapes (maybe logarithmic too).