公開方法#region 公開方法
public void Stop()
{
isRunning = false;
if (m_Buffer != null)
{
m_Buffer.Stop();
}
}
public void Write(byte[] data)
{
try
{
Console.WriteLine("播放聲音:{0}", data.Length);
circularBuffer.Write(data);
}
catch (Exception)
{
}
}
#endregion
}
用戶錄制聲音
public class CaptureSound
{
私有成員#region 私有成員
private const int NumberRecordNotifications = 4;
private readonly BufferPositionNotify[] positionNotify;
private Capture selectedDevice;
private CaptureBuffer buffer;
private int captureBufferSize;
private string fileName;
private bool isRecording;
private int nextCaptureOffset;
private AutoResetEvent notificationEvent;
private Notify notify;
private int notifySize;
private Thread notifyThread;
private long sampleCount;
private WaveFormat selectedFormat;
private FileStream waveFile;
private BinaryWriter writer;
#endregion