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

Thread: Read Functions for Audio Waveform and Envelope Objects

  1. #1

    Read Functions for Audio Waveform and Envelope Objects

    Hi,

    I'm working on a synth build, and would love to add some LED indication for the envelopes and LFO. Would it be feasible to add some kind of read function to the waveform and envelope objects in the audio library? (Something similar to the read function on the DC object.)

    Click image for larger version. 

Name:	screen2.jpg 
Views:	3 
Size:	92.7 KB 
ID:	24624

    Thanks as always, Paul, for all the work you do on the Teensy hardware/software.

  2. #2
    Senior Member
    Join Date
    Jul 2020
    Posts
    977
    It would indeed be feasible for the envelope - the "mult_hires" variable in AudioEffectEnvelope is a fixed point 2.30
    value you could sample with an extra method.

    For the waveform itself the AudioAnalyzeRMS class might be useful as is.

  3. #3
    Member
    Join Date
    Apr 2021
    Location
    Cambridgeshire, UK
    Posts
    50
    Quote Originally Posted by toutant View Post
    Hi,
    Would it be feasible to add some kind of read function to the waveform and envelope objects in the audio library? (Something similar to the read function on the DC object.)
    I've just implemented a float getGain() function on my variant of an exponential envelope generator - grab the latest code from https://github.com/h4yn0nnym0u5e/Aud...es/expEnvelope. As suggested by @MarkT, it just reads out the mult_hires value, scaled to a float between 0.0 and 1.0 for consistency with the rest of the access functions. Obviously this only updates every 2.9ms, but that should be more than enough for front panel LEDs.

    The result might be a bit like this: magenta plot is the actual envelope, red plot is the result of reading getGain() every audio engine update cycle. (In reality the red will trail the magenta, but my test code reads the previous envelope and the current gain level. And the weird decay is because I changed it just after it started...)
    Click image for larger version. 

Name:	2021-04-28 19_30_08-COM20 (Teensy) Serial+MIDI+Audio.png 
Views:	3 
Size:	44.0 KB 
ID:	24633

    Cheers

    Jonathan

  4. #4
    Thanks, Mark and Jonathan!

    I went ahead and added a read function (same as your getGain function) to the envelope.

    Now the question is, can I get a value from a waveform object that I could update an LFO indicator with?

    BTW, I should add that the AudioAnalyzeRMS class only gives RMS peaks, and not a continuous reading of the wave amplitude needed for an LED indicator.

    What I'm trying to do is something like this, where the LFO LED indicator flashes in time with the LFO waveform.
    https://www.youtube.com/watch?v=wlYbjkd3VTk
    Last edited by toutant; 04-28-2021 at 07:51 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
  •