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

Thread: Amplitude latency?

  1. #1
    Junior Member
    Join Date
    Oct 2018
    Posts
    10

    Amplitude latency?

    Hi all,

    I mentioned this down in a buried thread about a month back, but the question has re-arisen. I wrote a script that periodically changes the amplitude of a sine wave generated through the Audio library ("AudioSynthWaveformSine"). I output digital pulses at approximately the same time (a line of code later) that I change the amplitude, so I measured both outputs with an RZ5D TDT system. It appears that changing the amplitude only occurs after, on average, like a 7.5 ms delay. I'm assuming that it's coming from 2 audio blocks (~5.8 seconds), plus the remainder of the current audio block (assuming 1.5 ms average, that puts it us at 7.3 ms). Does this sound right? Here is the output from the digital pulse and the audio pin:
    Click image for larger version. 

Name:	Screenshot from 2018-10-26 14-08-27.png 
Views:	26 
Size:	15.4 KB 
ID:	15238

    And here is a plot showing the delays over 50 trials:
    Name:  Screenshot from 2018-10-26 14-30-20.png
Views: 160
Size:  7.9 KB

    Thanks for any and all help!

    Best,
    Mike
    Attached Files Attached Files

  2. #2
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,567
    Yes, sounds right.
    You can try to use shorter audio-blocks (64 or 32), either by editing AudioStream.h, or by using -DAUDIO_BLOCK_SAMPLES=64 if you use a makefile or this. The downside is, it adds some overhead for processing.

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,942
    Most of the output objects have 2 buffers. In hindsight, really only 1 is needed. Eventually I'm going to update them all to avoid buffering a 2nd packet, which should gut 2.9 ms from the latency.

  4. #4
    Junior Member
    Join Date
    Oct 2018
    Posts
    10
    Ah thank you both! Very helpful! That was my understanding from running through the code a little bit, but I'm new to C++, so I wasn't confident that was correct.

  5. #5
    Junior Member
    Join Date
    Mar 2019
    Posts
    2
    Yes 2nd packet buffers alot.2nd packet is never needed here,it is just creating glitches.So pls update them.

  6. #6
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,567
    You can do that and make a pull request at github.

  7. #7
    Junior Member
    Join Date
    Mar 2019
    Posts
    2
    Quote Originally Posted by Dean700 View Post
    Yes 2nd packet buffers alot.2nd packet is never needed here,it is just creating glitches.So pls update them.
    Thank you very much,i will definitely make a request at github.Thanks for the reply..I hope it will work.If it doesn't than will report u back soon.Thanks mykfcexperience

Posting Permissions

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