disabling audio filters

greyman

Member
I'm working on a synth project using the Teensy4.1, which is going really well so far.

However I have a question about the ladder filter.

Given that it is very processor intensive, is it possible to disable the filter when not in use in order to free up resources?

if so how would I go about doing that?

Many Thanks
G
 
You could maybe try using the dynamic patch cord capability in recent Teensyduino releases to disconnect() the audio input, combined with setting resonance to zero so it’s not trying to self-oscillate. Use connect() to re-connect when you want to use the filter again.

This is based on a brief inspection of the source code - I’ve not tried it!
 
You could maybe try using the dynamic patch cord capability in recent Teensyduino releases to disconnect() the audio input, combined with setting resonance to zero so it’s not trying to self-oscillate. Use connect() to re-connect when you want to use the filter again.

This is based on a brief inspection of the source code - I’ve not tried it!

ooh, I was not aware of the dynamic patch cord feature - must have missed that one :)

not sure if it would kill the processor usage of the filter though?
 
ooh, I was not aware of the dynamic patch cord feature - must have missed that one :)

not sure if it would kill the processor usage of the filter though?
Dynamic patch cords are fairly new.

From my reading of the code for the ladder filter the update() does an early exit with minimal execution time if there’s no audio to process and it’s not self-oscillating… but as I said, I’ve not tried it. It’s a simple thing to try out, though, just I don’t have time to try it for you!
 
Dynamic patch cords are fairly new.

From my reading of the code for the ladder filter the update() does an early exit with minimal execution time if there’s no audio to process and it’s not self-oscillating… but as I said, I’ve not tried it. It’s a simple thing to try out, though, just I don’t have time to try it for you!

No Worries :)

I'm sure I can work out some processor usage tests to see what happens!
 
OK ... I found some time ... it had slipped down behind the sofa cushions :D. Looks like disconnection works:
Code:
#include <Audio.h>

// GUItool: begin automatically generated code
AudioSynthWaveform       wav1;           //xy=313,83
AudioFilterLadder        ladder1;        //xy=468,97
AudioOutputTDM           tdm;            //xy=641,194

AudioConnection          patchCord1(wav1, 0, ladder1, 0);
AudioConnection          patchCord2(ladder1, 0, tdm, 0);

AudioControlCS42448      cs42448;        //xy=636,345

// GUItool: end automatically generated code
void setup() {
  AudioMemory(10);
  
  cs42448.enable();
  cs42448.volume(1.0f);

  wav1.begin(0.7f,440.0f,WAVEFORM_BANDLIMIT_SAWTOOTH);
}

uint32_t lastt;
enum {en,dis} state;

void loop() {

  if (millis() - lastt > 1000)
  {
    lastt = millis();
    
    switch (state)
    {
      case en:
        ladder1.resonance(0.0f);
        patchCord1.disconnect();
        state = dis;
        break;

      case dis:
        ladder1.resonance(1.5f);
        patchCord1.connect(wav1, ladder1);
        state = en;
        break;    
    }

    delay(5); // allow audio engine to update
    ladder1.processorUsageMaxReset();
    delay(5); // allow audio engine to update
    Serial.printf("State %d; CPU %.3f\n",state,ladder1.processorUsageMax());
  }
}
 
OK ... I found some time ... it had slipped down behind the sofa cushions :D. Looks like disconnection works:
Code:
#include <Audio.h>

// GUItool: begin automatically generated code
AudioSynthWaveform       wav1;           //xy=313,83
AudioFilterLadder        ladder1;        //xy=468,97
AudioOutputTDM           tdm;            //xy=641,194

AudioConnection          patchCord1(wav1, 0, ladder1, 0);
AudioConnection          patchCord2(ladder1, 0, tdm, 0);

AudioControlCS42448      cs42448;        //xy=636,345

// GUItool: end automatically generated code
void setup() {
  AudioMemory(10);
  
  cs42448.enable();
  cs42448.volume(1.0f);

  wav1.begin(0.7f,440.0f,WAVEFORM_BANDLIMIT_SAWTOOTH);
}

uint32_t lastt;
enum {en,dis} state;

void loop() {

  if (millis() - lastt > 1000)
  {
    lastt = millis();
    
    switch (state)
    {
      case en:
        ladder1.resonance(0.0f);
        patchCord1.disconnect();
        state = dis;
        break;

      case dis:
        ladder1.resonance(1.5f);
        patchCord1.connect(wav1, ladder1);
        state = en;
        break;    
    }

    delay(5); // allow audio engine to update
    ladder1.processorUsageMaxReset();
    delay(5); // allow audio engine to update
    Serial.printf("State %d; CPU %.3f\n",state,ladder1.processorUsageMax());
  }
}


cool!

Thank you so much for taking the time to do this, your a gentleman :)

I really do need to look into the dynamic patch cords in more depth, maybe create a virtual modular synth :)

G
 
Back
Top