audio/tests/PinResourceHelpers/HalfApp.cpp
HRESULT
CHalfApp::CreateSineToneDataBuffer
(
    WAVEFORMATEX* pWfx
)
{
    HRESULT hr = S_OK;

    if (!VERIFY_IS_NOT_NULL(pWfx)) {
        hr = E_FAIL;
        return hr;
    }

    m_dwSineToneDataBufferSize = (DWORD)(((ULONGLONG)BUF_LEN_IN_MS * pWfx->nSamplesPerSec / 1000) * pWfx->nBlockAlign);
    m_pbSineToneDataBuffer.reset((BYTE*)LocalAlloc(LPTR, m_dwSineToneDataBufferSize));
    if (!VERIFY_IS_NOT_NULL(m_pbSineToneDataBuffer)) {
        hr = E_OUTOFMEMORY;
        return hr;
    }

    if (m_DataFlow == render) // Sine tone for render
    {
        if (!VERIFY_SUCCEEDED(hr = FillBufferWithSineSignal(
            g_pBasicLog, XFAIL,
            pWfx,
            TEST_AMPLITUDE, // amplitude
            TEST_FREQUENCY, // frequency
            0.0, // initial phase,
            0.0, // dc
            Method_NoDithering,
            m_pbSineToneDataBuffer.get(),
            m_dwSineToneDataBufferSize / pWfx->nBlockAlign,
            m_dwSineToneDataBufferSize
        ))) {
            return hr;
        }

        m_dwSineToneDataBufferPosition = 0;
    }
    else // Silence for capture
    {
        memset(m_pbSineToneDataBuffer.get(), 0, m_dwSineToneDataBufferSize);
        m_dwSineToneDataBufferPosition = 0;
    }

    return hr;
}
////////////////////////////////////////////////////////////////////////////////////
//
// Creates a pre-load data buffer used by the stream render and capture routines.
//
// If the current endpoint is a render one, the data buffer consists of a sine tone
// wich gets loaded into a stream render routine.
//
// In the case of a capture endpoint, the pre-load data consists of silence.
//
////////////////////////////////////////////////////////////////////////////////////

Creates a pre-load data buffer used by the stream render and capture routines.
If the current endpoint is a render one, the data buffer consists of a sine tone
wich gets loaded into a stream render routine.

In the case of a capture endpoint, the pre-load data consists of silence.
Creates a pre - load data buffer used by the stream render and capture routines . If the current endpoint is a render one the data buffer consists of a sine tone wich gets loaded into a stream render routine . In the case of a capture endpoint the pre - load data consists of silence .
HRESULT
CHalfApp::CreateSineToneDataBuffer
(
    WAVEFORMATEX* pWfx
)
{
    HRESULT hr = S_OK;
    if (!VERIFY_IS_NOT_NULL(pWfx)) {
        hr = E_FAIL;
        return hr;
    }
    m_dwSineToneDataBufferSize = (DWORD)(((ULONGLONG)BUF_LEN_IN_MS * pWfx->nSamplesPerSec / 1000) * pWfx->nBlockAlign);
    m_pbSineToneDataBuffer.reset((BYTE*)LocalAlloc(LPTR, m_dwSineToneDataBufferSize));
    if (!VERIFY_IS_NOT_NULL(m_pbSineToneDataBuffer)) {
        hr = E_OUTOFMEMORY;
        return hr;
    }
    if (m_DataFlow == render) 
    {
        if (!VERIFY_SUCCEEDED(hr = FillBufferWithSineSignal(
            g_pBasicLog, XFAIL,
            pWfx,
            TEST_AMPLITUDE, 
            TEST_FREQUENCY, 
            0.0, 
            0.0, 
            Method_NoDithering,
            m_pbSineToneDataBuffer.get(),
            m_dwSineToneDataBufferSize / pWfx->nBlockAlign,
            m_dwSineToneDataBufferSize
        ))) {
            return hr;
        }
        m_dwSineToneDataBufferPosition = 0;
    }
    else 
    {
        memset(m_pbSineToneDataBuffer.get(), 0, m_dwSineToneDataBufferSize);
        m_dwSineToneDataBufferPosition = 0;
    }
    return hr;
}
HRESULT CHalfApp :: CreateSineToneDataBuffer ( WAVEFORMATEX * pWfx ) { HRESULT hr = S_OK ; if ( ! VERIFY_IS_NOT_NULL ( pWfx ) ) { hr = E_FAIL ; return hr ; } m_dwSineToneDataBufferSize = ( DWORD ) ( ( ( ULONGLONG ) BUF_LEN_IN_MS * pWfx -> nSamplesPerSec / 1000 ) * pWfx -> nBlockAlign ) ; m_pbSineToneDataBuffer . reset ( ( BYTE * ) LocalAlloc ( LPTR , m_dwSineToneDataBufferSize ) ) ; if ( ! VERIFY_IS_NOT_NULL ( m_pbSineToneDataBuffer ) ) { hr = E_OUTOFMEMORY ; return hr ; } if ( m_DataFlow == render ) { if ( ! VERIFY_SUCCEEDED ( hr = FillBufferWithSineSignal ( g_pBasicLog , XFAIL , pWfx , TEST_AMPLITUDE , TEST_FREQUENCY , 0.0 , 0.0 , Method_NoDithering , m_pbSineToneDataBuffer . get ( ) , m_dwSineToneDataBufferSize / pWfx -> nBlockAlign , m_dwSineToneDataBufferSize ) ) ) { return hr ; } m_dwSineToneDataBufferPosition = 0 ; } else { memset ( m_pbSineToneDataBuffer . get ( ) , 0 , m_dwSineToneDataBufferSize ) ; m_dwSineToneDataBufferPosition = 0 ; } return hr ; }
Creates a pre-load data buffer used by the stream render and capture routines.
Creates a pre - load data buffer used by the stream render and capture routines .
// Sine tone for render
 // amplitude
 // frequency
 // initial phase,
 // dc
 // Silence for capture
