録再

録音して再生してみた。動いているっぽい。途中、Array cdataにキャプチャ結果が入っているから、foreach(Int16 d in cdata)みたいにして、加工できるのではなかろうか。

WaveFormat wfx = new WaveFormat();
wfx.Channels = 2;
wfx.FormatTag = WaveFormatTag.Pcm;
wfx.BitsPerSample = 16;
wfx.SamplesPerSecond = 44100;
wfx.BlockAlign = (short)(wfx.Channels * (wfx.BitsPerSample / 8));
wfx.AverageBytesPerSecond = wfx.BlockAlign * wfx.SamplesPerSecond;

Device device = new Device();
device.SetCooperativeLevel(this, CooperativeLevel.Normal);

Capture capture = new Capture();
CaptureBufferDescription desc = new CaptureBufferDescription();
desc.BufferBytes = wfx.AverageBytesPerSecond;
desc.Format = wfx;
CaptureBuffer cb = new CaptureBuffer(desc, capture);
cb.Start(false);
while(cb.Capturing){
    System.Threading.Thread.Sleep(10);
}
Array cdata = cb.Read(0, Type.GetType("System.Int16"), LockFlag.None, wfx.AverageBytesPerSecond/2);

BufferDescription bdesc = new BufferDescription();
bdesc.Format = wfx;
bdesc.BufferBytes = wfx.AverageBytesPerSecond;

SecondaryBuffer sb = new SecondaryBuffer(bdesc, device);
sb.Write(0, cdata, LockFlag.None);
sb.Play(0, BufferPlayFlags.Default);