Forum Rule: Always post complete source code & details to reproduce any issue!
Page 2 of 2 FirstFirst 1 2
Results 26 to 44 of 44

Thread: Envelope detector and VCA with Teensy's Audio library

  1. #26
    sounds good, thanks so much!!

  2. #27
    So I think I understand how it works, the Absolute value acts like an effect, it take the input of an audio stream and outputs the absolute value aka the envelope? So I take the output of the ABS and send that into the control input of a state variable filter?

  3. #28
    Well, not exactly. After you obtain the absolute value of the signal, which is called a rectified signal, you need to low pass filter it out in order to make it a signal that evolves following the envelope of the original signal. Then you can use the signal as a control signal as you pointed out.
    https://en.wikipedia.org/wiki/Envelope_detector <- this is the equivalent in the analog domain, diode rectifies and capacitor lowpassfilters.

    effectAbsExample.ino
    Here's the arduino sketch that you can use as a test. It uses de signal you will input in the analog input of the teensy, gets its envelope and uses it to modulate the amplitude of a sine wave. What you should listen is the volume of the sine wave to increase as the signal volume of the breathe detector increases.

    Hope it helps, and get back to me for any doubts or help you need.

    Salut!

  4. #29
    wow, I got it working!! Now I have a sweeet envelope controlled filter, and it sounds good! I appreciate you taking the time to help me out. Now my mind is exploding with all the possibilities of envelope control...

  5. #30
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,366
    Quote Originally Posted by RTPNaskers View Post
    Well, not exactly. After you obtain the absolute value of the signal, which is called a rectified signal, you need to low pass filter it out in order to make it a signal that evolves following the envelope of the original signal. Then you can use the signal as a control signal as you pointed out.
    https://en.wikipedia.org/wiki/Envelope_detector <- this is the equivalent in the analog domain, diode rectifies and capacitor lowpassfilters.
    which gives you not the envelope, but an approximation to the rms value.
    Wikipedia is not completely correct!
    See figure where the link is to analytic signal.

  6. #31
    Glad to hear that it helped you! Which breathe sensor are you using? I've always wanted to create a trumpet-like instrument but never known of suitable sensors... You think yours can serve that purpose?
    WMXZ, dunno buddy, I call that envelope an it works for me to generate the envelope of another signal... I just linked to wikipedia for a quick-dirty illustration of the concept!

  7. #32
    Senior Member
    Join Date
    Feb 2017
    Posts
    317
    I'm thinking you may want to add the '#include "effect_abs.h"' statement explicitly to your application code rather than putting it in Audio.h. If PRJC updates the library and creates a new Audio.h, then your modification will be lost.
    Last edited by gfvalvo; 04-18-2017 at 05:20 PM.

  8. #33
    Quote Originally Posted by RTPNaskers View Post
    Glad to hear that it helped you! Which breathe sensor are you using? I've always wanted to create a trumpet-like instrument but never known of suitable sensors... You think yours can serve that purpose?
    WMXZ, dunno buddy, I call that envelope an it works for me to generate the envelope of another signal... I just linked to wikipedia for a quick-dirty illustration of the concept!
    Hey! I'm using the envelope to control the bandpass frequency of the state variable filter. So it's like an auto wah. I use the effect on the synth sounds generated using the library.

  9. #34
    Quote Originally Posted by sam View Post
    Hey! I'm using the envelope to control the bandpass frequency of the state variable filter. So it's like an auto wah. I use the effect on the synth sounds generated using the library.
    Nice! And which is the sensor you are using to detect the breathe?

  10. #35
    Quote Originally Posted by gfvalvo View Post
    I'm thinking you may want to add the '#include "effect_abs.h"' statement explicitly to your application code rather than putting it in Audio.h. If PRJC updates the library and creates a new Audio.h, then your modification will be lost.
    Good point, it actually happened to me once, but losing the Audio.h wasn't the most annoying thing but losing the .h and .cpp of the new class code which can be erased when you update the teensyduino. Can those be placed in another folder or they need to be placed in the Audio folder in order to fetch properly the dependencies like AudioStream?

  11. #36
    Senior Member
    Join Date
    Feb 2017
    Posts
    317
    You can put your .cpp and .h files for your custom audio classes in a separate folder in your 'libraries' folder or in the same folder as your application .ino file. The former makes more sense as it allows you to use your custom classes in multiple applications.

    Delete your custom Audio.h file. In your custom .cpp and/or .h files files, include the classes you need from the Audio library. For example:

    Code:
    #include "AudioStream.h"

  12. #37
    Quote Originally Posted by RTPNaskers View Post
    Nice! And which is the sensor you are using to detect the breathe?
    Hey! Not totally sure what you mean. I'm not using any sensors or any external signals. The synth sound are generated inernally by the Teensy, and I'm using that to create the envelope and then using the envelope to control the state variable filter applied to the same signal I extracted the envelope from. Hopen that makes sense!

  13. #38
    Nevermind, I just thought that as long as you wanted to monitor human breath patterns you were using some sort of sensor to do so.

  14. #39
    Quote Originally Posted by RTPNaskers View Post
    Nevermind, I just thought that as long as you wanted to monitor human breath patterns you were using some sort of sensor to do so.
    I understand! There are two Sams!! You are referring to username skwelker, whose real name is Sam, who wants to monitor human breath patterns.
    I am username Sam, my real name is Sam, and I want to use the envelope filter to make funky synth sounds. Now it all makes sense!!

  15. #40
    True that, okay!

  16. #41
    Banned
    Join Date
    May 2018
    Posts
    16
    Quote Originally Posted by RTPNaskers View Post
    Well, not exactly. After you obtain the absolute value of the signal, which is called a rectified signal, you need to low pass filter it out in order to make it a signal that evolves following the envelope of the original signal. Then you can use the signal as a control signal as you pointed out.
    https://en.wikipedia.org/wiki/Envelope_detector <- this is the equivalent in the analog domain, diode rectifies and capacitor lowpassfilters.

    effectAbsExample.ino
    Here's the arduino sketch that you can use as a test. It uses de signal you will input in the analog input of the teensy, gets its envelope and uses it to modulate the amplitude of a sine wave. What you should listen is the volume of the sine wave to increase as the signal volume of the breathe detector increases.

    Hope it helps, and get back to me for any doubts or help you need.

    Salut!
    RTPNaskers can you help me use your Envelope with midi cc? I thinking do it in steps like that: adc1(A2) go to abs go to filter1 go to usbMIDI CC1. But I'm not sure how to get output from filter, and use it to generating CC, and what I need else to connect to the input 1 filter? can I connect real potentiometer to the input 1 for setting freq filter?

  17. #42
    Hi Kirazvora!

    I think that what you want to do is definitely possible. Your guess is right: you need to get the envelope with the abs and then the filter and then output this from the audio system to the sketch so you can put these values into a variable that is sent with usbMDI CC1. To do so input and output data from the sketch to the audio system and back again to the sketch I'm pretty sure you need to use AudioPlayQueue and AudioRecordQueue respectively. I haven't done so yet and it looks you have to deal with buffers and other stuff that might be tricky but I think that's the way to go. If needed I can try to implement and sketch with these so I learn myself how to use them!

    Salut!

  18. #43
    Banned
    Join Date
    May 2018
    Posts
    16
    Quote Originally Posted by RTPNaskers View Post
    Hi Kirazvora!

    I think that what you want to do is definitely possible. Your guess is right: you need to get the envelope with the abs and then the filter and then output this from the audio system to the sketch so you can put these values into a variable that is sent with usbMDI CC1. To do so input and output data from the sketch to the audio system and back again to the sketch I'm pretty sure you need to use AudioPlayQueue and AudioRecordQueue respectively. I haven't done so yet and it looks you have to deal with buffers and other stuff that might be tricky but I think that's the way to go. If needed I can try to implement and sketch with these so I learn myself how to use them!

    Salut!
    Yeah itís possible, I downloaded abs and I will try it. Abs in the working, is similarly to RMS object from Audio library? I guess that is. Will be great to see examples from you if you can. I trying get envelope follower with RMS object and I get some success, close to my needs. Still have some minor problems, when finishing up, I put my code on forum.

  19. #44
    Take in account that abs by itself won't do the envelope following, actually by itself does some sort of double-pitching to the signal as it rectifies it: kinda funny, but not what you're looking for. It has to work along with an LPF with a low cutoff frequency around 15Hz or less. I'm attaching the same example I uploaded for you to test the envelope following. When I get a little more of free time I'll try to do an example that can output the envelope from the audio system to the sketch.
    Attached Files Attached Files

Posting Permissions

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