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

Thread: Amplitude latency?

  1. #1
    Junior Member
    Join Date
    Oct 2018

    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:	5 
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: 75
Size:  7.9 KB

    Thanks for any and all help!

    Attached Files Attached Files

  2. #2
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Germany NRW
    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
    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
    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.

Posting Permissions

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