Click here to Skip to main content
15,905,028 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
Does anyone can help me to know which this class allows to do please and thanks for you:
C#
public WaveInBuffer(IntPtr waveInHandle, int size)
{
    m_WaveIn = waveInHandle;
    m_HeaderHandle = GCHandle.Alloc(m_Header, GCHandleType.Pinned);
    m_Header.dwUser = (IntPtr)GCHandle.Alloc(this);
    m_HeaderData = new byte[size];
    m_HeaderDataHandle = GCHandle.Alloc(m_HeaderData, GCHandleType.Pinned);
    m_Header.lpData = m_HeaderDataHandle.AddrOfPinnedObject();
    m_Header.dwBufferLength = size;
    WaveInHelper.Try(WaveNative.waveInPrepareHeader(m_WaveIn, ref m_Header, Marshal.SizeOf(m_Header)));
}
~WaveInBuffer()
{
    Dispose();
}
public void Dispose()
{
    if (m_Header.lpData != IntPtr.Zero)
    {
        WaveNative.waveInUnprepareHeader(m_WaveIn, ref m_Header, Marshal.SizeOf(m_Header));
        m_HeaderHandle.Free();
        m_Header.lpData = IntPtr.Zero;
    }
    m_RecordEvent.Close();
    if (m_HeaderDataHandle.IsAllocated)
        m_HeaderDataHandle.Free();
    GC.SuppressFinalize(this);
}

public int Size
{
    get { return m_Header.dwBufferLength; }
}
public IntPtr Data
{
    get { return m_Header.lpData; }
}

public bool Record()
{
    lock (this)
    {
        m_RecordEvent.Reset();
        m_Recording = WaveNative.waveInAddBuffer(m_WaveIn, ref m_Header, Marshal.SizeOf(m_Header)) == WaveNative.MMSYSERR_NOERROR;
        return m_Recording;
    }
}
public void WaitFor()
{
    if (m_Recording)
        m_Recording = m_RecordEvent.WaitOne();
    else
        Thread.Sleep(0);
}
private void OnCompleted()
{
    m_RecordEvent.Set();
    m_Recording = false;
}

It is important for me to known the role of this class.
Posted
Updated 12-Jun-11 8:56am
v2
Comments
[no name] 12-Jun-11 10:46am    
This class manages a buffer while you are working with windows Waveform API. You can use it as a buffer i.e. for several of the WinAPI’s waveIn* methods. To be more specific, this class you can use in waveInProc (a call back method for waveIn devices), which will be used to record audio.
And by the way this class seems to control the recording thread, which in my opinion is not the job of a buffer ;)


The thing is that this is a superseded technique to program audio applications.

If you are going to write new audio applications, I suggest you to check MSDN for the latest techniques like directSound.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900