Bypass equivalence

Status
Not open for further replies.

daspuru

Member
Hi dear Teensy friends,

When building audio components with the Teensy Audio Library, what would be the equivalent for bypassing some modules? for example, in this configuration, what would be the best way to bypass the reverb or the "noteFreq" module to reduce CPU usage? As far as I see, the only way I can see now is to "disconnect" the modules, but there is no "bypass" or "enable" property or method in the objects.

For example I want to draw two buttons in the touch display and by pressing them enable or disable the reverb or the noteFreq. What would be the best way to do it via software?

Here the config, thanks!

Screen Shot 2019-12-09 at 10.02.58 AM.png
 
Add a mixer to bypass each effect.
mixer_bypass_58647.gif
Set the gain of one input to one and the other input to zero.
Naming each one "switch", as I've done, instead of "mixer" will help to keep track of which are used as switches and which really are mixers.

Pete
 
"what would be the best way to bypass the reverb or the "noteFreq" module to reduce CPU usage? "

Does bypass using a mixer reduce CPU usage?
 
Ah. Good question. Not the way I've shown it.
I think another mixer between i2s1 and reverb1, which is turned on or off as well as switch1, should do the trick. The mixer won't output anything and reverb will use practically no cpu.
mixer_bypass_58647_1.gif

Pete
 
"what would be the best way to bypass the reverb or the "noteFreq" module to reduce CPU usage? "

Does bypass using a mixer reduce CPU usage?

I think this is not a good approach as the reverb or any module will still processing audio and consuming memory and CPU usage. As far as my research goes, all audio modules extend the AudioStream Class, located here.

A method that I can see that free some memory is AudioConnection::disconnect and that one could be an option.

Maybe AudioStream::update_stop?

I just want to know what would be the "Correct" way to disable and enable the modules dinamically to improve memory and CPU usage.

Thanks.
 
I haven’t looked at audio library source code, but I would be surprised if turning down a mixer before a reverb has any effect on the reverbs cpu utilization .
 
Ah. Good question. Not the way I've shown it.
I think another mixer between i2s1 and reverb1, which is turned on or off at the same time as switch1, should do the trick. The mixer won't output anything and reverb will use practically no cpu.
View attachment 18395

Pete
 
I don't expect that anything you can do with the level controls on a mixer object will affect CPU utilization of anything before or after. Maybe I'll test it to satisfy my curiosity.
 
I don't expect that anything you can do with the level controls on a mixer object will affect CPU utilization of anything before or after. Maybe I'll test it to satisfy my curiosity.

I think this thread gives an interesting approach, as I supposed, using disconnect in the audio connection, please check it out.

Best regards,
 
@daspuru
In order to have an audio object with an input to stop processing you need to stop the audiostream going to it's input.
There are 2 ways to achieve this:

use AudioConnection::disconnect

or

insert an AudioAmplifier object before the one you want to disable and set it's gain to zero. This will effectively stop the AudioAmplifier to output any data.
 
I've realized that what is needed using this method is an amplifier and a mixer - not two mixers. A mixer always outputs an audio buffer even when all inputs are zero gain.
mixer_bypass_58647_2.gif
When the amplifier is set to zero gain, it will not output an audio buffer, so the effect which follows won't do anything.

The connect/disconnect in the link given by @daspuru looks good too, especially since it wouldn't require any mixers/amps to be added which would simplify the design.

Pete
 
I don't expect that anything you can do with the level controls on a mixer object will affect CPU utilization of anything before or after.

That is a wrong assumption. The mixer and amp handle zero gain as a special case. They stop sending data, which does affect the CPU usage of most (but not all) objects connected to their outputs.

All objects in the audio library handle no data at their input as if it were silence. For many of them, the result is no CPU usage.

I believe the reverb (not freeverb) may currently have a bug where it immediately stops all processing when the input has no data. Obviously it should not do that that if it has previously had sound which should still create reverberation for quite some time after the input goes silent. I'm pretty sure freeverb handles this correctly.
 
I realized that after reading #10, then looking at the code.

Well, AudioAmplifier transmits nothing if mult==0.
But, AudioMixer4 will call transmit() if there is input on any channel, regardless of multiplier.
 
Last edited:
The mixer and amp handle zero gain as a special case. They stop sending data, which does affect the CPU usage of most (but not all) objects connected to their outputs.
Are you sure about that?
I was under impression(looking at the code but i might be wrong) that unity gain is handled as a special case in both the mixer and the amp, but that zero gain is only handled as a special case by the amp.
 
Thanks all!

Then I think I will code my control logic in a class that will encapsulate connections and disconnections of object instances of the audio library and that should solve the needs of freeing/allocating resources while activating or deactivating objects from the audio library. I just wanted to have a clear perspective before going into the wrong path with this delicate part of this particular audio application.

Best regards! :cool:
 
Status
Not open for further replies.
Back
Top