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

Thread: Multiple audio effects

  1. #1

    Multiple audio effects

    Can the Teensy 3.2 run multiple audio effects such as reverb, chorus and delay all at the same time?

    If so, what is the maximum delay that can be achieved while running the Freeverb and Chorus?

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,734
    You'll probably want Teensy 3.5 or 3.6 for this. Teensy 3.2 has only 64K RAM. That's not enough to run reverb, chorus and meaningful delay at the same time.

    For a more specific answer to your question, the best info is the memory usage summary the Arduino IDE prints when you Verify or Upload. You can do Verify without buying a Teensy, if you merely want to get an idea of how much of the memory a design will use.

  3. #3
    The 3.5 is doable.
    Is it too much to expect that the 3.5 also handle user interface (3 quad encoders, I2C display)?

    Also interested in sampling or looping (maybe 30 - 60 seconds of mono audio)

  4. #4
    Paul

    If you have time for a 15 minute phone conversation, I would like to discuss all the requirements for this project.
    It would mean a large quantity of devices per month if the product works.

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,734
    I hope you can understand I don't do phone consultations for projects.

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,734
    Quote Originally Posted by bdoan View Post
    Is it too much to expect that the 3.5 also handle user interface (3 quad encoders, I2C display)?
    Yes, Teensy 3.5 can pretty easily do this. On the display, I2C is generally useful for smaller displays, since the speed is limited to 400 kHz or 1 MHz. For a larger display, you'll probably want SPI.

    I highly recommend starting with the audio tutorial, to get a strong idea of how the audio stuff works and what it can do.

    https://www.pjrc.com/store/audio_tutorial_kit.html

    The last part of the tutorial involves using a ILI9341 display (SPI interface) to show a peak level meter while playing a WAV file (also accessed over the same SPI bus). If you scroll down at that page, you can see the walkthrough video where Alysia and I quickly demo every part of the tutorial. Of course it's best to actually do the tutorial, but that video can also serve to give you a quick look at the hardware capability.

  7. #7
    I have a 3.2 with the audio board and have experimented with the SD read and write applications as well as USB audio.

    I will build an app with the Teensy Audio Library and see how the memory holds up.

    One unrelated issue,

    do you have any recommendations for very low latency wireless audio?

  8. #8
    Re: "Teensy 3.2 has only 64K RAM. That's not enough to run reverb, chorus and meaningful delay at the same time."

    Would it work to add RAM to the "MEM" location on the audio board?

  9. #9
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,734
    Quote Originally Posted by bdoan View Post
    Would it work to add RAM to the "MEM" location on the audio board?
    For simple delay, yes. Details here:

    https://www.pjrc.com/teensy/gui/?inf...tDelayExternal

    For anything else, no, or at least not without writing (very difficult) custom code. Currently delayExt is the only effect using the external memory. It's unlikely anyone will ever write more complex effects using the external memory, partly because we have enough memory in the newer model Teensy boards, and partly because the SPI communication overhead is prohibitive for more complex effects than simple delay.

  10. #10
    So with the T3.5 or T3.6, you are saying that there is enough RAM for reverb and (0.5sec) delay?

  11. #11
    On the T3.2, is it possible to use delayExt for the delay effect and the internal RAM for reverb and chorus?

  12. #12
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,734
    Quote Originally Posted by bdoan View Post
    So with the T3.5 or T3.6, you are saying that there is enough RAM for reverb and (0.5sec) delay?
    Look, all these answers involve some amount of "it depends".

    So, to talk of something specific, here's a quick test I did just now (and I'm hoping will inspire you to do such tests yourself) by merely putting I2S input & outout and these 2 effects onto the design tool, wiring them together, then export to Arduino and add 1 line for AudioMemory with enough to hold 1/2 second.

    Code:
    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>
    
    // GUItool: begin automatically generated code
    AudioSynthWaveformDc     dc1;            //xy=213,95
    AudioEffectEnvelope      envelope1;      //xy=360,91
    AudioEffectFreeverb      freeverb1;      //xy=463,270
    AudioSynthWaveformModulated waveformMod1;   //xy=475,177
    AudioOutputI2S           i2s1;           //xy=657,178
    AudioConnection          patchCord1(dc1, envelope1);
    AudioConnection          patchCord2(dc1, freeverb1);
    AudioConnection          patchCord3(envelope1, 0, waveformMod1, 0);
    AudioConnection          patchCord4(waveformMod1, 0, i2s1, 0);
    AudioConnection          patchCord5(waveformMod1, 0, i2s1, 1);
    // GUItool: end automatically generated code
    
    void setup() {
      AudioMemory(200);
    
    }
    
    void loop() {
    
    }
    When I click Verify in Arduino (no Teensy needed to merely Verify) with Teensy 3.5 selected in Tools > Boards, the result is:

    Code:
    Sketch uses 26960 bytes (5%) of program storage space. Maximum is 524288 bytes.
    Global variables use 84952 bytes (32%) of dynamic memory, leaving 177184 bytes for local variables. Maximum is 262136 bytes.
    So, there is the result, 32% of Teensy 3.5's RAM is used for this test with both delay and reverb.

  13. #13
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,734
    Here's another very quick test, this time uses the stereo version of freeverb.

    Code:
    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>
    
    // GUItool: begin automatically generated code
    AudioInputI2S            i2s2;           //xy=196,136
    AudioEffectDelay         delay1;         //xy=383,82
    AudioEffectFreeverbStereo freeverbs1;     //xy=388,220
    AudioMixer4              mixer1;         //xy=595,76
    AudioMixer4              mixer2;         //xy=601,172
    AudioOutputI2S           i2s1;           //xy=781,100
    AudioConnection          patchCord1(i2s2, 0, delay1, 0);
    AudioConnection          patchCord2(i2s2, 1, freeverbs1, 0);
    AudioConnection          patchCord3(delay1, 0, mixer1, 1);
    AudioConnection          patchCord4(delay1, 1, mixer2, 1);
    AudioConnection          patchCord5(freeverbs1, 0, mixer1, 0);
    AudioConnection          patchCord6(freeverbs1, 1, mixer2, 0);
    AudioConnection          patchCord7(mixer1, 0, i2s1, 0);
    AudioConnection          patchCord8(mixer2, 0, i2s1, 1);
    // GUItool: end automatically generated code
    
    
    void setup() {
      AudioMemory(200);
    
    }
    
    void loop() {
    
    }
    With this, the RAM usage climbs to 43%.

    Code:
    Sketch uses 27552 bytes (5%) of program storage space. Maximum is 524288 bytes.
    Global variables use 113140 bytes (43%) of dynamic memory, leaving 148996 bytes for local variables. Maximum is 262136 bytes.
    If I edit this example to increase AudioMemory to 400, which would give enough for 1 second, the memory usage climbs even more, to 63%.

    Code:
    Sketch uses 27556 bytes (5%) of program storage space. Maximum is 524288 bytes.
    Global variables use 165364 bytes (63%) of dynamic memory, leaving 96772 bytes for local variables. Maximum is 262136 bytes.
    As you add more stuff, or allocate more buffers (used by delay & some other objects - read the details in the design tool docs) the memory usage changes.

    These are all well over 64K, which is why I said Teensy 3.2 does not have enough RAM to do all these memory hungry effects simultaneously.

  14. #14
    Thanks for the quick response.
    I am not asking you to design a product for me but I need to know if I can use the Teensy as a DSP substitute for an existing product.
    Just trying to get a sense of what the limitations are.
    Also, is it even reasonable to consider using this in a product (for sale) ?

  15. #15
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,734
    Quote Originally Posted by bdoan View Post
    Just trying to get a sense of what the limitations are.
    You really need to do some experimentation with the design tool and running some tests on the hardware. I've tried to make this as easy as possible. But because things vary so much depending on your design, I'm rather reluctant to give "one size fits all" answers. It really does depend on what you do.


    Also, is it even reasonable to consider using this in a product (for sale) ?
    Yes. In fact, many people do this. One successful example in the Radio Music product from Music Thing Modular, which is sold both as a completed product and a DIY-soldering kit.

    We also sell a bootloader chip, if you wish to design a fully custom board. Whether to go fully custom or just use a Teensy in a socket can be a tricky decision. Unless you have something like a government contract or an already-successful crowdfunding campaign where you know for sure you'll make a large quantity on your first run, putting a regular Teensy in a socket often ends up being a wise business move, because you can keep your inventory cost (and financial risk) lower as you get started, buying the Teensy part only as needed when you actually ship products.

  16. #16
    Senior Member Blackaddr's Avatar
    Join Date
    Mar 2017
    Location
    Canada
    Posts
    193
    Quote Originally Posted by PaulStoffregen View Post
    For simple delay, yes. Details here:

    https://www.pjrc.com/teensy/gui/?inf...tDelayExternal

    For anything else, no, or at least not without writing (very difficult) custom code. Currently delayExt is the only effect using the external memory. It's unlikely anyone will ever write more complex effects using the external memory, partly because we have enough memory in the newer model Teensy boards, and partly because the SPI communication overhead is prohibitive for more complex effects than simple delay.
    I've found use for the external memory for some more complex effects, particularly for Sound-On-Sound which is admittedly still delay based though. All the effects in BALibrary use DMA SPI for external memory usage so there is very little overhead on the CPU.

    The thread about it is https://forum.pjrc.com/threads/53145...AudioEffectSOS

    I've also been considering using SPI memory for some large waveshaper tables but haven't got too far down that road yet. Either way, the SPI DMA memory will be essential.

Posting Permissions

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