/// <summary> /// Copies from buffer array to ChannelArea. /// </summary> /// <param name="buffer">Buffer.</param> /// <param name="bufferPos">Buffer position.</param> /// <param name="area">ChannelArea</param> /// <param name="bufferCount">Number of buffer samples</param> public void CopyTo(float[] buffer, int bufferPos, SoundIOChannelAreas areas, int bufferCount) { foreach (var item in areas) { Marshal.Copy(buffer, bufferPos, item.Pointer, bufferCount); } }
/// <summary> /// Call this function when you are ready to begin reading from the device buffer. /// </summary> /// <param name="areas">The memory area data can be read from.</param> /// <param name="frameCount">Positive number of frames to read, returns the number of frames that will be actually read.</param> /// <returns>Value indicating operation success.</returns> /// <remarks> /// Call this function only from the OnReadCallback thread context. When done reading from areas, call EndRead. /// </remarks> public SoundIoError BeginRead(out SoundIOChannelAreas areas, ref int frameCount) { IntPtr head; SoundIoError result = NativeMethods.SoundIoInstreamBeginRead(handle, out head, ref frameCount); if (head == IntPtr.Zero) { areas = null; } else { areas = new SoundIOChannelAreas(head, Layout.ChannelCount, frameCount); } return(result); }