The K4W2 Audio enginelatency of Microphone array is constant? RRS feed

  • Question

  • Hello, I try to render sound of K4W2 input captured by 4 microphone array using WASAPI.

    But I think there is some unflexibility of latency of resampler of example.

    In AudioCaptureRaw of Example of KinectBrowser,

    When the TargetLatency is 20ms, 50ms and 100ms... ,

    hr = _CaptureClient->GetBuffer(&pData, &framesAvailable, &flags, NULL, NULL);
    //framesAvailable is always 160 although the Latency is changed.
    //lockedLength is always 3840 although the Latency is changed.
    What does that mean?

    Is there a solution change latency of CaptureClient?

    • Edited by Haeyong Wednesday, September 17, 2014 12:00 PM
    Wednesday, September 17, 2014 11:40 AM


All replies

  • I found the code

    DWORD waitResult = WaitForSingleObject(_ShutdownEvent, _EngineLatencyInMS / 2);

    When the _EngineLatencyInMS is not 20ms, sounds are discontinued.

    The _EngineLatency is variable, but I think it is constant.

    Wednesday, September 17, 2014 11:59 AM
  • Keep in mind if you want time slices less that 50ms (or 100ms) can't remember, that you need to use the Multimedia Class Scheduler to get a "real-time" priority on the thread function. Keep in mind it is very strict and if you do not keep the function timing in line with the time slice amount, you will be demoted to a regular priority.

    If you are polling, you can disregard, but you have to ensure the loop is fast enough and runs time lock for consistent results. If you are running arbitrary time slices, you will have to take that into account when looking at the capture buffer amount.

    Carmine Sirignano - MSFT

    Wednesday, September 17, 2014 5:16 PM
  • Thank you for your reply!

    But I have a question... still

    In _AudioClient->Initialize,

    When I set the bufferDuration 20ms,

    captureClient Buffer Frame Size: 320

    captureClient FramesAvailable: 160

    InputBuffer maxLength: 5120

    dataToCopy: 2560

    And When I set the bufferDuration 40ms,

    captureClient Buffer Frame Size: 640

    captureClient FramesAvailable: 160

    InputBuffer maxLength: 10240

    dataToCopy: 2560

    I want to know why the number of FramesAvailable in captureClient is always 160.

    I guess kinect machine only send data of 20ms. right?

    The bufferSize is bigger, but available frame size is same.

    Thursday, September 18, 2014 9:52 AM
  • if you have questions about WASAPI, you are best to ask over on the audio forums. If you are accessing the sensor audio as an IAudioEndPoint then it will work like a regular microphone exposed to the operating system. The minimum latency you will get with WASAPI is ~100ms as far as I know. You might be able to get to 50ms if using exclusive.

    From the sample provided in the SDK Browser, we are polling at 50ms and pulling the data from the exposed IStream interface from our SDK API's.

    Carmine Sirignano - MSFT

    • Marked as answer by Haeyong Saturday, September 27, 2014 9:45 AM
    Thursday, September 18, 2014 4:33 PM