Filter with Envelope - how to continuously modulate?

Status
Not open for further replies.

mofuzz

New member
Hi folks,

I'm working through my first synth project with the awesome Teensy Audio Library.

My audio flow is shown in the screenshot below.

Screen shot 2017-05-24 at 9.39.14 PM.png

My problem is that once I trigger a sound, the filter will only update once the envelope is finished (I hope that makes sense). I'd like to be able to use the filter to modulate the sound even during the process of playing the envelope.

I'm using an analogRead from a potentiometer for the filter control.

Here's my code:

Code:
void playNote (int freq, int filt){
  synth_waveform.frequency(freq);
  filter.frequency(filt);
  envelope.noteOn();
}

I've also tried like this:

Code:
void playNote (int freq, int filt){
  synth_waveform.frequency(freq);
  envelope.noteOn();
  filter.frequency(filt);
}

Thanks. Hopefully I'm just missing something simple.

Mofuzz
 
I'd like to be able to use the filter to modulate the sound even during the process of playing the envelope.

The filter has a 2nd input which lets you alter the corner frequency with another signal. So all you need to do is create a signal that varies the way you want and connect it to that 2nd input.

Perhaps you could use a DC object. It does linear ramps if you specify a time to transition to a new DC level.

But that does require your sketch code to command it to new levels at the proper times. If you'd like things to be completely automatic, maybe feed a DC object into another envelope object. Then you could have your code just control the 2 envelopes the same way and they would work together. Or maybe DC and the fade object, or a sine or other waveform where you set it to a particular phase angle and let its waveform shape do the work. Or any number of other ways you might combine objects...
 
Here's a great Teensy project which uses filter envelope generators. (I think that's what you are getting at). I actually borrowed a lot of his code for a project I'm working on.


The sketch uses a DC "waveform" object to control an amplifier envelope (ramping up and down the volume of the sound) and to control a filter envelope (opening up the cutoff frequency of the filter). The play / stop note functions would look something like this:

Code:
void playNote() {
     voice1env.amplitude(1,attackTime); // This triggers the opening of the amp envelope generator
     voice1filterenv.amplitude(1,attackTimeFilter); // This opens the filter envelope
}
void stopNote() {
     voice1env.amplitude(1,releaseTime); // This closes the amp envelope generator
     voice1filterenv.amplitude(1,releaseTimeFilter); // This closes the filter envelope
}

Screen Shot 2017-06-01 at 12.27.29 AM.png

Here's the github that has his code: https://github.com/otem/teensypolysynth/blob/master/teensypolysynth.ino

Good luck!
 
It also occurs to me that you might just be trying to change the filter as you play a sound, not necessarily create a filter envelope.

If that's the case, I think I see your problem. You should probably pull the filter frequency line ( filter.frequency(filt) ) out of the playNote function and just put it in the loop function. The filter cutoff frequency should be updated as you turn that knob, whether or not you are playing a note at the time.

That is of course with me guessing without seeing the full sketch. :)
 
Last edited:
Status
Not open for further replies.
Back
Top