public static XtAttributes GetSampleAttributes(XtSample sample) { XtAttributes attributes = new XtAttributes(); XtNative.XtAudioGetSampleAttributes(sample, attributes); return(attributes); }
private static void CopyInterleavedBufferFromNative(XtSample sample, IntPtr raw, Array managed, int channels, int frames) { switch (sample) { case XtSample.UInt8: Marshal.Copy(raw, (byte[])managed, 0, frames * channels); break; case XtSample.Int16: Marshal.Copy(raw, (short[])managed, 0, frames * channels); break; case XtSample.Int24: Marshal.Copy(raw, (byte[])managed, 0, frames * channels * 3); break; case XtSample.Int32: Marshal.Copy(raw, (int[])managed, 0, frames * channels); break; case XtSample.Float32: Marshal.Copy(raw, (float[])managed, 0, frames * channels); break; default: throw new ArgumentException(); } }
internal static void Copy(Array source, IntPtr target, XtSample sample, int channels, int frames) { switch (sample) { case XtSample.UInt8: Marshal.Copy((byte[])source, 0, target, channels * frames); break; case XtSample.Int16: Marshal.Copy((short[])source, 0, target, channels * frames); break; case XtSample.Int24: Marshal.Copy((byte[])source, 0, target, channels * frames * 3); break; case XtSample.Int32: Marshal.Copy((int[])source, 0, target, channels * frames); break; case XtSample.Float32: Marshal.Copy((float[])source, 0, target, channels * frames); break; default: throw new ArgumentOutOfRangeException(); } }
private static unsafe void CopyNonInterleavedBufferToNative(XtSample sample, Array managed, IntPtr raw, int channels, int frames) { void** data = (void**)raw.ToPointer(); switch (sample) { case XtSample.UInt8: for (int i = 0; i < channels; i++) Marshal.Copy(((byte[][])managed)[i], 0, new IntPtr(data[i]), frames); break; case XtSample.Int16: for (int i = 0; i < channels; i++) Marshal.Copy(((short[][])managed)[i], 0, new IntPtr(data[i]), frames); break; case XtSample.Int24: for (int i = 0; i < channels; i++) Marshal.Copy(((byte[][])managed)[i], 0, new IntPtr(data[i]), frames * 3); break; case XtSample.Int32: for (int i = 0; i < channels; i++) Marshal.Copy(((int[][])managed)[i], 0, new IntPtr(data[i]), frames); break; case XtSample.Float32: for (int i = 0; i < channels; i++) Marshal.Copy(((float[][])managed)[i], 0, new IntPtr(data[i]), frames); break; default: throw new ArgumentException(); } }
private static Array CreateInterleavedBuffer(XtSample sample, int channels, int frames) { switch (sample) { case XtSample.UInt8: return new byte[channels * frames]; case XtSample.Int16: return new short[channels * frames]; case XtSample.Int24: return new byte[channels * 3 * frames]; case XtSample.Int32: return new int[channels * frames]; case XtSample.Float32: return new float[channels * frames]; default: throw new ArgumentException(); } }
private static Array CreateNonInterleavedBuffer(XtSample sample, int channels, int frames) { switch (sample) { case XtSample.UInt8: return CreateNonInterleavedBuffer<byte>(channels, frames); case XtSample.Int16: return CreateNonInterleavedBuffer<short>(channels, frames); case XtSample.Int24: return CreateNonInterleavedBuffer<byte>(channels, frames * 3); case XtSample.Int32: return CreateNonInterleavedBuffer<int>(channels, frames); case XtSample.Float32: return CreateNonInterleavedBuffer<float>(channels, frames); default: throw new ArgumentException(); } }
public static string SampleToString(XtSample sample) { return(XtNative.StringFromUtf8(XtNative.XtPrintSampleToString(sample))); }
public XtMix(int rate, XtSample sample) { this.rate = rate; this.sample = sample; }
internal static void Interleave(Array source, Array target, XtSample sample, int channels, int frames) { switch (sample) { case XtSample.UInt8: for (int f = 0; f < frames; f++) { for (int c = 0; c < channels; c++) { ((byte[])target)[f * channels + c] = ((byte[][])source)[c][f]; } } break; case XtSample.Int16: for (int f = 0; f < frames; f++) { for (int c = 0; c < channels; c++) { ((short[])target)[f * channels + c] = ((short[][])source)[c][f]; } } break; case XtSample.Int24: for (int f = 0; f < frames; f++) { for (int c = 0; c < channels; c++) { for (int i = 0; i < 3; i++) { ((byte[])target)[(f * channels + c) * 3 + i] = ((byte[][])source)[c][f * 3 + i]; } } } break; case XtSample.Int32: for (int f = 0; f < frames; f++) { for (int c = 0; c < channels; c++) { ((int[])target)[f * channels + c] = ((int[][])source)[c][f]; } } break; case XtSample.Float32: for (int f = 0; f < frames; f++) { for (int c = 0; c < channels; c++) { ((float[])target)[f * channels + c] = ((float[][])source)[c][f]; } } break; default: throw new ArgumentOutOfRangeException(); } }
public static XtAttributes GetSampleAttributes(XtSample sample) => HandleAssert(XtAudioGetSampleAttributes(sample));
static extern XtAttributes XtAudioGetSampleAttributes(XtSample sample);
internal static extern void XtAudioGetSampleAttributes(XtSample sample, [In, Out] XtAttributes attributes);
internal static extern IntPtr XtPrintSampleToString(XtSample sample);
public XtMix(int rate, XtSample sample) => (this.rate, this.sample) = (rate, sample);