Latency Teensy 4

Status
Not open for further replies.

yentz

Member
Hi,
I just bought a Teensy 4.1 to try some stuff for eurorack. I am also havin some DSP's around which are ok to control with a esp32 over i2c.
The DSP's have a latency of around 3 ms. How about the teensy? I want to do stuff in direction envelope follower and don't know whether this is too much already
 
Hi Jens,

I take it you are referring to audio digital signal processing?
If so, have a look at this page [and subpages]: [url]https://www.pjrc.com/teensy/td_libs_Audio.html[/URL].
On the "Creating New Audio Objects" page, there is a statement "The heart of your object is it's update() function. The library will call your update function every 128 samples, or approximately every 2.9 milliseconds".
That leads me to believe that the minimum latency you can achieve is 2.9 ms. I can imagine that more chained audio functions blocks will multiply that number of milliseconds [but I'm not an expert on that matter].

Paul
 
It's easy to change the number of samples in a block. I run my effects with AUDIO_BLOCK_SAMPLES set to 16 (one block = 0.36ms long).

Smaller block sizes work with with most but not all of the objects and work fine with custom effects, the trade off is increased processing but with a Teensy 4 you have lots of processor power.

In practice you will have latency of longer than one block size unless it is a very simple effect as you pass the data from one block to another plus some time for the codec to process things.

Some practical feedback, a recent project with around 20 objects (effects, filters, mixers etc) resulted in overall latency of 1.7ms with a block size of 16.

Cheers, Paul
 
Thanks for your answers, this helps a lot. So if I find a way to do the same thing I can do in Sigma Studio I am much better off using the teensy and don't have to mess with the uncomfortable i2c controlling of the ADAU 1701 using an esp32.
So would it be possible to do something like an envelope follower / peak detector using the objects in teensyuino?
I am an absolute beginner so bare with me if those might be stupid questions but for extracting gate signals I should be fine using the digital outputs of the teensy which if turned on should be 3,3 V right? So if this is the case I just need to amplify to 5 / switchable to 10 V which I dont know how to do yet but I am sure I will find out. Thanks for helping so fast :)
 
If you edit AUDIO_BLOCK_SAMPLES in AudioStream.h for a smaller block size, almost everything still works. The things that are known to break are WAV file playing, FFT analysis, and USB input & output.
 
That leads me to believe that the minimum latency you can achieve is 2.9 ms. I can imagine that more chained audio functions blocks will multiply that number of milliseconds [but I'm not an expert on that matter].
In fact the whole audio flow graph is processed at once, so that the overall latency depends on the processing load plus
the buffering overhead. The processing overhead has to be less than 1 block's time overhead or it won't keep up... Buffering might
add a around a couple of block delays (input, output). Smaller block size will increase processor load due to setup overheads.
 
Thanks a lot for that great support.
I am still very new to programming so to understand the given example of an envelope follower I still have a lot of work to do as I want it to have a couple of different functions which I suppose will be possible using Teensy, as long as I understand how.
I am a bit confused as compared to the graphical environment of Sigma Studio for DSP's there are objects that do not have any connection at all and there aren't any outputs I could route onto GPIO's if I am right. I suppose this is defined within the sketch.
Do you think a simple level shifter based on TXS0108E will be fine to make my digital output going from 3,3 to 5 V and create gate signals for Eurorack?
It would be quite easy to do on the DSP but I don't know if 3ms latency wont be too much.
Ohh and then I have another probably stupid question. Is it possible to include the libraries into the file so that I don't have to look for them when on different computers (I am a dentist and do stuff like this if a patient doesn't show up as well as when I am at home) and that I don't have to remember what changes I made if anything doesn't work because I suppose if I make changes within the library it affects all sketches using this library.
 
I think using github might be the way to go for working from several sites. It also records your change history. You'd clone the library repo and
create your own branch(s) to work on.
 
Github (or similar) is definitely the way to go. If you've never used a version control system before, it's not a trivial thing to get into, but it is totally totally totally a skill worth having.

Alternatively, one of the more generic cloud storage solutions would allow you to keep your code synchronized across multiple computers: dropbox, Google drive, microsoft live, apple whatever. Or you can keep your code on a USB drive on your keychain. Not a copy that you have to keep backing up, but your live code that you edit every day...it can live on a USB drive just as easily as your computer's harddrive. If the live copoy is on your keychain, it'll always move with you!

I recommend GitHub.

Chip
 
Thanks a lot for your help.
I am not sure if I can go that route as it wouldn't leave any time for making music.
I think I am going to try the dsp first and see how this is going.
Havent got into the whole idea of github yet.
Thanks for your help :)

Edit: I just see that there is a peak detection example. I might try to get myself into that. I suppose there isn't a way to put the code into the graphic editor and go backwards?
I don't really want an envelope follower. What I want to do is get a mono signal in, split into three parts, each part with a bandpass filter controlled by poti freq and q, then into a peak detection circuit with threshold and maybe some hold or release parameter which are controlled by poti and each time peak is on get a signal out of the pwm outputs, amplify to 5V and hopefully trigger eurorack modules with it. the background is that I used to produce and release breakbeat / jungle which is completely sampler made unti 2005 and then got into tech house which is a bit of both samples and synths
Now I would like to go back to jungle but thought it would be awesome to have a device which allows selecting the frequency of a signal (either the single chopped breaks tracks or the breaks subgroup) and generate triggers out of it that I can use to trigger my modular. I am not interested in stuff like 4/4 or 2/4 etc but more stuff like the shuffles etc and was / am hoping to get a nice way of augmenting the supergroovy rhythm with some percussive elements that stand a bit out and give like a melody. You surely could do that with kick and snare and hats but then we are talking drum & bass which I used to make but don't want to anymore. That is why I was asking about the latency of the teensy as the triggers cant be too delayed.
I think I might look into the examples and just try to copy code from a few sources (that is the way I did it when controlling the dsp with esp32 - but I am sure that it could have been done way more nice than I did) or alternatively build in hardware which I suppose shouldn't be too difficult. I just ordered some cheap level shifters to hopefully get 3,3 V up to 5 To be able to trigger. Not giving up yet I think.
 
Last edited:
Status
Not open for further replies.
Back
Top