CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2008
    Posts
    93

    Capture Speech with DirectX - Problems

    Hi @ all,

    I´m capturing speech with DirectSound.
    The special at this capturing is that I need frames of 20ms to send to network.
    Here I use the capture buffer from DirectSound.
    Sending a Notification message and getting data from offset of the buffer.
    The buffer himself has a size of 2560 bytes and the notify size is 640.
    The buffer has 4 segments.
    The way I do is not so correct I thought.
    I get noises and breaks by fragmenting the buffer.
    Here is the code of the Thread where Notification Message will be handled.
    Code:
    DWORD capturePos, readPos;
        m_captureBuffer->GetCurrentPosition(&capturePos, &readPos);
        DWORD diff;
        readPos >= m_NextOffset ?
            diff = readPos - m_NextOffset :
            diff = readPos + m_BufferSize - m_NextOffset;
            
        if(diff < m_NotifySize) return;
        
        //Lock the capture Buffer
        VOID* lockedBufferPointer = NULL;
        DWORD lockedBufferSize;
       
        m_captureBuffer->Lock(m_NextOffset, m_NotifySize, &lockedBufferPointer, &lockedBufferSize, NULL, NULL, 0L);
        //Put data to Output Sink
        const int SIZE = lockedBufferSize/2;
        //write to wave file
        write((BYTE*)lockedBufferPointer, lockedBufferSize);
       //edit the sample
        pSink->on_NewAudioDataCaptured((short*)lockedBufferPointer, SIZE);
        
        //Unlock the capture Buffer
        m_captureBuffer->Unlock(lockedBufferPointer, lockedBufferSize, NULL, 0);
           //Move the capture offset along
        m_NextOffset += lockedBufferSize;
        m_NextOffset %= m_BufferSize;
    What could I do wrong here?

  2. #2
    Join Date
    Sep 2008
    Posts
    93

    Re: Capture Speech with DirectX - Problems

    Ok I have it. The fragment was to small with 20ms. Now i do it with 60ms and it sounds good.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured