turning on and off different effect chains?

steeley

Well-known member
Just wondering - if I use the disconnect command to disable a chain of modules, does it
that chain stop processing? (I.E free up memory/CPU)

I was thinking of some way to make an effects unit that has a delay, reverb, filter bank. etc that you could
switch between each one of them, with only one running at a time.

Many thanks.
 
Just wondering - if I use the disconnect command to disable a chain of modules, does it
that chain stop processing? (I.E free up memory/CPU)

I was thinking of some way to make an effects unit that has a delay, reverb, filter bank. etc that you could
switch between each one of them, with only one running at a time.

Many thanks.

I don't know the direct answer to your question, but one typical way to implement a multi-option capability like you describe is to make use of the 4-input mixer audio object. Set the mixer level of the input for the desired effect to "1" & set the mixer level of all other inputs to "0". You could even do a "partial-mix" for each of them by allowing levels between full OFF ("0") & full ON ("1") simultaneously. Each of the capabilities would always be processing, but the audio processing system is written to be very efficient.

As an example in point, my TeensyMIDIPolySynth (TMPS) includes over 600 different audio objects (modulated waveform generators, filters, modulators, strings, white & pink noise, envelope generators, ladder filter, etc.) which are all routed thru a series of mixers, providing a completely independent/configurable sound processing system that implements a 14-poly 3-voice synthesizer.

Hope that helps . . .

Mark J Culross
KD5RXT
 
You really need to experiment or look at the source to see if any CPU cycles will be saved, and whether audio objects will behave well when disconnected. There are at least a couple of examples (fader and envelope) where their processing stalls if supplied with silence in the form of NULL block pointers, so e.g. the envelope cycle doesn't complete until audio re-starts. I have PRs in place for those, but they're not merged yet, and there may well be other examples.

I also just took a quick look at the mixer code. It's optimised for unity gain channels, but not for zero gain, so disconnection will save more CPU than setting channels to zero gain.

There won't be any saving in memory by disconnecting patchcords. Probably not a major issue until you get to the scale of Mark's magnum opus ... the memory footprint of most objects is tiny. You'll run out of CPU first.
 
interesting... thanks for the info. Maybe the way forward is to use a load of mixers and just disconnect inputs from each processing chain(saving CPU) when not in use?
 
I also just took a quick look at the mixer code. It's optimised for unity gain channels, but not for zero gain, so disconnection will save more CPU than setting channels to zero gain.

I recall Paul Stoffregen addressing the mixer optimization for both gain=0 & gain =1 in a previous post, but I can't seem to find it now that I need it !!

However, the code (mixer.cpp) does show the following, which seems to indicate that both gain=0 & gain=1 do not incur any processing burden with each block update:

Code:
void AudioAmplifier::update(void)
{
	audio_block_t *block;
	int32_t mult = multiplier;

	if (mult == 0) {
		// zero gain, discard any input and transmit nothing
		block = receiveReadOnly(0);
		if (block) release(block);
	} else if (mult == MULTI_UNITYGAIN) {
		// unity gain, pass input to output without any change
		block = receiveReadOnly(0);
		if (block) {
			transmit(block);
			release(block);
		}
	} else {
		// apply gain to signal
		block = receiveWritable(0);
		if (block) {
			applyGain(block->data, mult);
			transmit(block);
			release(block);
		}
	}
}

Hope that helps . . .

Mark J Culross
KD5RXT
 
Thanks Mark - thats one solution for sure. You synth must be an amazing piece of work!

All of the credit for the functionality built into my TMPS goes to Paul Stoffregen & the folks that contributed to the Audio Adapter & supporting library !! I simply gathered & loosely organized the appropriate function calls...LOL. With that said, I am quite impressed & still very much pleased with the amazing & flexible capabilities that the audio library allowed me to put together to create my idea of a multi-voice, multi-poly, digital synth !!

I keep saying that I'll publish the project results some day, but up to now, it is still very much a work-in-progress. I did publish its predecessor (at that time, it used hardware knobs, LEDs, buttons, and switches, was 16-poly, but only 2-voice) in <this thread> from a couple of years ago. This latest fully digital version (now using touchscreen sliders, buttons, indicators, etc.) is much easier to add to / modify / expand.

Mark J Culross
KD5RXT
 
I recall Paul Stoffregen addressing the mixer optimization for both gain=0 & gain =1 in a previous post, but I can't seem to find it now that I need it !!

However, the code (mixer.cpp) does show the following, which seems to indicate that both gain=0 & gain=1 do not incur any processing burden with each block update:

Code:
void [COLOR="#FF0000"]AudioAmplifier[/COLOR]::update(void)
{
	audio_block_t *block;
	int32_t mult = multiplier;

	if (mult == 0) {
		// zero gain, discard any input and transmit nothing
		block = receiveReadOnly(0);
		if (block) release(block);
	} else if (mult == MULTI_UNITYGAIN) {
		// unity gain, pass input to output without any change
		block = receiveReadOnly(0);
		if (block) {
			transmit(block);
			release(block);
		}
	} else {
		// apply gain to signal
		block = receiveWritable(0);
		if (block) {
			applyGain(block->data, mult);
			transmit(block);
			release(block);
		}
	}
}

Hope that helps . . .

Mark J Culross
KD5RXT
That’s the AudioAmplifier object, just the one input. The existing AudioMixer4 (same file, further up) only optimises for gain=1.0, but I just put in a PR which optimises for gain=0.0. Interestingly, my testing seemed to show that the 1.0 optimisation doesn’t make any difference, even though it executes fewer lines of code. I think the DSP instructions etc. must be super-effective!
 
If you are looking for the audio infrastructure to support any number of effects, in any order, individually control all their parameters and save all that as multiple presets, you should take a look at the Teensy based Multiverse by Aviate Audio. You build up your effects as virtual pedal boards and save them as presets. Only the effects that are currently active (not bypassed) consume CPU.

It also provides a DAW like interface for the audio effects you write yourself using Teensy Audio, in addition to using the effects published by others.

In particular, my delay and tremolo effects, and HexeFX's reverb and phaser all started in these forums.

Check out this link, and the most recent Teensy Audio effect added to the platform is a clone of the Klon Centaur overdrive (See here.

Source code for the delay, tremolo and klon is here.
 
Back
Top