How to eliminate 1 second delay in DirectShow filter chain? (Using Delphi and DSPACK)

I have a Delphi 6 Pro application that uses the DSPACK component library to send audio to Skype from the system's preferred audio input device. I use the TSampleGrabber component to connect to the Filter Graph chain, and then send the audio buffers to Skype. The problem is that I only receive once a second. In other words, the OnBuffer () event for the TSampleGrabber instance is fired only once per second with the full second data value in the Buffer parameter. I need to know how to change the Filter Graph chain so that it captures data from the input device faster than once per second. If possible, I would like to do it as fast as every 50 ms, or at least every 100 ms.

The My Filter Graph chain consists of a TFilter that is displayed on the preferred audio input device at the top. I connect the output terminals of this filter to the “WAV Dest” input pins assigned by TFilter, so I can get samples in WMA format in PCM format. Then I connect the output pins of the WAV Dest filter to the input pins of the TSampleGrabber instance. What do I need to change to fire the TSampleGrabber OnBuffer () event for a faster transition?


UPDATE . Based on Roman R's answer, I was able to implement a solution, which I will show below. One record. His link led me to the following blog post, which was helpful in solving:

http://sid6581.wordpress.com/2006/10/09/minimizing-audio-capture-latency-in-directshow/

// Variable declaration for output pin to manipulate.
var
    intfCapturePin: IPin;

...............


    // Put this code after you have initialized your audio capture device
    //  TFilter instance *and* set it wave audio format.  My variable for
    //  this is FFiltAudCap.  I believe you need to set the buffer size before
    //  connecting up the pins of the Filters.  The media type was
    //  retrieved earlier (theMediaType) when I initialized the audio
    //  input device Filter so you will need to do similarly.

    // Get a reference to the desired output pin for the audio capture device.
    with FFiltAudCap as IBaseFilter do
        CheckDSError(findPin(StringToOleStr('Capture'), intfCapturePin));

    if not Assigned(intfCapturePin) then
        raise Exception.Create('Unable to find the audio input device' Capture output pin.');

    // Set the capture device buffer to 50 ms worth of audio data to
    //  reduce latency.  NOTE: This will fail if the device does not
    //  support the latency you desire so make sure you watch out for that.
    setBufferLatency(intfCapturePin as IAMBufferNegotiation, 50, theMediaType);

..................

// The setBufferLatency() procedure.
procedure setBufferLatency(
                // A buffer negotiation interface pointer.
                intfBufNegotiate: IAMBufferNegotiation;
                // The desired latency in milliseconds.
                bufLatencyMS: WORD;
                // The media type the audio stream is set to.
                theMediaType: TMediaType);
var
    allocProp: _AllocatorProperties;
    wfex: TWaveFormatEx;
begin
    if not Assigned(intfBufNegotiate) then
        raise Exception.Create('The buffer negotiation interface object is unassigned.');

    // Calculate the number of bytes per second using the wave
    // format belonging to the given Media Type.
    wfex := getWaveFormat(theMediaType);

    if wfex.nAvgBytesPerSec = 0 then
        raise Exception.Create('The average bytes per second value for the given Media Type is 0.');

    allocProp.cbAlign := -1;  // -1 means "no preference".
    // Calculate the size of the buffer needed to get the desired
    //  latency in milliseconds given the average bytes per second
    //  of the Media Type audio format.
    allocProp.cbBuffer := Trunc(wfex.nAvgBytesPerSec * (bufLatencyMS / 1000));
    allocProp.cbPrefix := -1;
    allocProp.cBuffers := -1;

    // Try to set the buffer size to the desired.
    CheckDSError(intfBufNegotiate.SuggestAllocatorProperties(allocProp));
end;
+5
1

, Audio Capture , , .

IAMBufferNegotiation , SuggestAllocatorProperties .

. : DMO Windows Media Audio Encoder .

+6

All Articles