Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 7 of 7

Thread: Filter Modulation

  1. #1
    Junior Member
    Join Date
    May 2022
    Posts
    11

    Filter Modulation

    I am trying to put together synth that will have a filter modulated by an envelope and an lfo. I'd like to attenuate the filter frequency manually as well. Basic stuff. I have an envelope between the oscillators and the filter input and that envelope works great. I can't for the life of me figure how to do the same with the filter frequency. I'm also not getting my mind around how I can control the frequency from multiple sources like lfo, envelope etc. Attached a screenshot of my current connections. Keep in mind, I'm a beginner with this library. Click image for larger version. 

Name:	Capture.jpg 
Views:	42 
Size:	33.4 KB 
ID:	28544

  2. #2
    Senior Member
    Join Date
    Apr 2020
    Location
    DFW area in Texas
    Posts
    586
    Quote Originally Posted by Pkore View Post
    I am trying to put together synth that will have a filter modulated by an envelope and an lfo. I'd like to attenuate the filter frequency manually as well. Basic stuff. I have an envelope between the oscillators and the filter input and that envelope works great. I can't for the life of me figure how to do the same with the filter frequency. I'm also not getting my mind around how I can control the frequency from multiple sources like lfo, envelope etc.Click image for larger version. 

Name:	Capture.jpg 
Views:	42 
Size:	33.4 KB 
ID:	28544
    @Pkore: Welcome to using Teensy's fantastic audio library !! I'll take a best guess at what you are trying to accomplish. Import the following into the design tool (NOTE: in the future, when posting audio design details, I would suggest that you use the "export" capability in the audio design tool & include the details of this export between code tags (using the "#" tool icon in the reply window) as shown below. . . including only a screen capture loses the details of the "types" of audio object that you are interconnecting):

    Code:
    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>
    
    // GUItool: begin automatically generated code
    AudioSynthWaveform       osc1;      //xy=75,80
    AudioSynthWaveform       osc2;      //xy=75,120
    AudioSynthWaveform       osc3;      //xy=75,160
    AudioSynthNoiseWhite     noise;         //xy=75,200
    AudioSynthWaveform       fltOsc;      //xy=75,300
    AudioSynthWaveformDc     fltDC;            //xy=75,380
    AudioEffectEnvelope      fltDCEnv;      //xy=226,420
    AudioEffectEnvelope      fltOscEnv;      //xy=226.5,340
    AudioMixer4              oscMx;         //xy=255,140
    AudioEffectEnvelope      ampEnv;      //xy=366,220
    AudioMixer4              fltMx;         //xy=438,340
    AudioMixer4              ampMx;         //xy=479,140
    AudioFilterLadder        ladder;        //xy=622,140
    AudioOutputI2S           audioOut;           //xy=793,141
    AudioConnection          patchCord1(osc1, 0, oscMx, 0);
    AudioConnection          patchCord2(osc2, 0, oscMx, 1);
    AudioConnection          patchCord3(osc3, 0, oscMx, 2);
    AudioConnection          patchCord4(noise, 0, oscMx, 3);
    AudioConnection          patchCord5(fltOsc, 0, fltMx, 0);
    AudioConnection          patchCord6(fltOsc, fltOscEnv);
    AudioConnection          patchCord7(fltDC, fltDCEnv);
    AudioConnection          patchCord8(fltDC, 0, fltMx, 2);
    AudioConnection          patchCord9(fltDCEnv, 0, fltMx, 3);
    AudioConnection          patchCord10(fltOscEnv, 0, fltMx, 1);
    AudioConnection          patchCord11(oscMx, 0, ampMx, 0);
    AudioConnection          patchCord12(oscMx, ampEnv);
    AudioConnection          patchCord13(ampEnv, 0, ampMx, 1);
    AudioConnection          patchCord14(fltMx, 0, ladder, 1);
    AudioConnection          patchCord15(ampMx, 0, ladder, 0);
    AudioConnection          patchCord16(ladder, 0, audioOut, 0);
    AudioConnection          patchCord17(ladder, 0, audioOut, 1);
    // GUItool: end automatically generated code
    Take particular note of the following: everywhere that an envelope is included, a mixer follows. These mixers allow you to select the "non-enveloped" signal (bypass the envelope) or the "enveloped" signal (apply the envelope). Using my best guess, you should be able to do any of the following: apply an envelope to the "fltOSC", apply a separate envelope to "fltDC", and use a mix of any of them, per your choosing.

    Hope that helps & feel free to ask any other questions !!

    Good luck & have fun !!

    Mark J Culross
    KD5RXT

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    27,998
    As a quick test, try using File > Examples > Audio > Synthesis > LadderFilter. It has a fixed 3 oscillator input and then 2 LFOs modulate the filter frequency and the resonance. You'll hear the sound get louder and filled with detail as the frequency goes higher, allowing more of the original oscillator wavefors to pass, and get quieter and only lower deep base sound as the filter cuts off most of the higher frequencies. The resonance LFO is slower, so some of the times the filter allows more sound through, you'll hear a sort of whistling sound as the resonance is driven so high the filter starts to self oscillate.

    That may or may not actually help you achieve the effects you want, but at least it's a quick way to hear the filter modulation in action.

  4. #4
    Junior Member
    Join Date
    May 2022
    Posts
    11
    Quote Originally Posted by kd5rxt-mark View Post
    @Pkore: Welcome to using Teensy's fantastic audio library !! I'll take a best guess at what you are trying to accomplish. Import the following into the design tool (NOTE: in the future, when posting audio design details, I would suggest that you use the "export" capability in the audio design tool & include the details of this export between code tags (using the "#" tool icon in the reply window) as shown below. . . including only a screen capture loses the details of the "types" of audio object that you are interconnecting):

    Code:
    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>
    
    // GUItool: begin automatically generated code
    AudioSynthWaveform       osc1;      //xy=75,80
    AudioSynthWaveform       osc2;      //xy=75,120
    AudioSynthWaveform       osc3;      //xy=75,160
    AudioSynthNoiseWhite     noise;         //xy=75,200
    AudioSynthWaveform       fltOsc;      //xy=75,300
    AudioSynthWaveformDc     fltDC;            //xy=75,380
    AudioEffectEnvelope      fltDCEnv;      //xy=226,420
    AudioEffectEnvelope      fltOscEnv;      //xy=226.5,340
    AudioMixer4              oscMx;         //xy=255,140
    AudioEffectEnvelope      ampEnv;      //xy=366,220
    AudioMixer4              fltMx;         //xy=438,340
    AudioMixer4              ampMx;         //xy=479,140
    AudioFilterLadder        ladder;        //xy=622,140
    AudioOutputI2S           audioOut;           //xy=793,141
    AudioConnection          patchCord1(osc1, 0, oscMx, 0);
    AudioConnection          patchCord2(osc2, 0, oscMx, 1);
    AudioConnection          patchCord3(osc3, 0, oscMx, 2);
    AudioConnection          patchCord4(noise, 0, oscMx, 3);
    AudioConnection          patchCord5(fltOsc, 0, fltMx, 0);
    AudioConnection          patchCord6(fltOsc, fltOscEnv);
    AudioConnection          patchCord7(fltDC, fltDCEnv);
    AudioConnection          patchCord8(fltDC, 0, fltMx, 2);
    AudioConnection          patchCord9(fltDCEnv, 0, fltMx, 3);
    AudioConnection          patchCord10(fltOscEnv, 0, fltMx, 1);
    AudioConnection          patchCord11(oscMx, 0, ampMx, 0);
    AudioConnection          patchCord12(oscMx, ampEnv);
    AudioConnection          patchCord13(ampEnv, 0, ampMx, 1);
    AudioConnection          patchCord14(fltMx, 0, ladder, 1);
    AudioConnection          patchCord15(ampMx, 0, ladder, 0);
    AudioConnection          patchCord16(ladder, 0, audioOut, 0);
    AudioConnection          patchCord17(ladder, 0, audioOut, 1);
    // GUItool: end automatically generated code
    Take particular note of the following: everywhere that an envelope is included, a mixer follows. These mixers allow you to select the "non-enveloped" signal (bypass the envelope) or the "enveloped" signal (apply the envelope). Using my best guess, you should be able to do any of the following: apply an envelope to the "fltOSC", apply a separate envelope to "fltDC", and use a mix of any of them, per your choosing.

    Hope that helps & feel free to ask any other questions !!

    Good luck & have fun !!

    Mark J Culross
    KD5RXT
    Thanks! That makes sense. The only thing I'm wondering is why there would need to be two envelopes for the filter frequency, one with an oscillator and one with a DC. Is that just so I have multiple options for modulation? What's the difference between using an oscillator for a signal and a DC? Is the oscillator in your example being used as an LFO? If so why does the LFO need an envelope? A lot of questions I guess.

  5. #5
    Senior Member
    Join Date
    Apr 2020
    Location
    DFW area in Texas
    Posts
    586
    Quote Originally Posted by Pkore View Post
    Thanks! That makes sense. The only thing I'm wondering is why there would need to be two envelopes for the filter frequency, one with an oscillator and one with a DC. Is that just so I have multiple options for modulation? What's the difference between using an oscillator for a signal and a DC? Is the oscillator in your example being used as an LFO? If so why does the LFO need an envelope? A lot of questions I guess.
    @Pkore:

    Nothing in the example that I gave is absolutely required. I simply intended to give you some possibilities to play with (my best guess as to what you were looking for).

    More details:

    Using a DC source followed by an envelope will allow you to have the ladder filter's frequency change as the envelope opens (raising the DC level) & closes (lowering the DC level). As the DC level increases, the cutoff frequency also increases. And likewise, as the DC level decreases, the cutoff frequency also decreases. The absolute level of the DC source (combined with your use of the "octaveControl()" function) will determine how for the corner frequency of the ladder filter varies. Using an oscillator source will allow you to vary the corner frequency of the ladder filter in a repetitive way (sine = corner frequency swings in a periodic manner; square = corner frequency alternates between two values; triangle = corner frequancy ramps up & down in a periodic manner; etc.). Adding an envelope to the oscillator further allows you to vary the intensity of the corner frequency change as the envelope opens & closes.

    If you haven't already done so, per Paul's advice, the best thing for you to do is load up the examples & play around with the capabilities. This will allow you to quickly get a feel for the effect that each input & each function call have on the operation of the ladder filter (& anything else that you hook to it).

    Good luck & have fun !!

    Mark J Culross
    KD5RXT

  6. #6
    Junior Member
    Join Date
    May 2022
    Posts
    11
    Thanks that's very helpful! I'll try that out ASAP. Yes I took a look at the ladder example before posting here. That demo only shows how to modulate the frequency and resonance directly from one source each. What I was having an issue with is modulating one parameter from multiple sources. I couldn't find an example that went over that scenario exactly. The midi examples were very helpful though.

  7. #7
    Member
    Join Date
    Jun 2019
    Location
    Sydney, Australia
    Posts
    44
    I have a very simple example here LFO Modulation that might help.

    It has an LFO modulating both an oscillator and a filter with an independent amount control as well. It doesn't use an envelope, but inserting one follows exactly the same pattern.
    Last edited by kallikak; 06-03-2022 at 10:55 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •