コード例 #1
0
ファイル: XtAudio.cs プロジェクト: jameshball/xt-audio
        public static XtAttributes GetSampleAttributes(XtSample sample)
        {
            XtAttributes attributes = new XtAttributes();

            XtNative.XtAudioGetSampleAttributes(sample, attributes);
            return(attributes);
        }
コード例 #2
0
        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();
            }
        }
コード例 #3
0
        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();
            }
        }
コード例 #4
0
 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();
     }
 }
コード例 #5
0
 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();
     }
 }
コード例 #6
0
 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();
     }
 }
コード例 #7
0
 public static string SampleToString(XtSample sample)
 {
     return(XtNative.StringFromUtf8(XtNative.XtPrintSampleToString(sample)));
 }
コード例 #8
0
ファイル: XtMix.cs プロジェクト: jameshball/xt-audio
 public XtMix(int rate, XtSample sample)
 {
     this.rate   = rate;
     this.sample = sample;
 }
コード例 #9
0
        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();
            }
        }
コード例 #10
0
 public static XtAttributes GetSampleAttributes(XtSample sample)
 => HandleAssert(XtAudioGetSampleAttributes(sample));
コード例 #11
0
 static extern XtAttributes XtAudioGetSampleAttributes(XtSample sample);
コード例 #12
0
ファイル: XtNative.cs プロジェクト: jameshball/xt-audio
 internal static extern void XtAudioGetSampleAttributes(XtSample sample, [In, Out] XtAttributes attributes);
コード例 #13
0
ファイル: XtNative.cs プロジェクト: jameshball/xt-audio
 internal static extern IntPtr XtPrintSampleToString(XtSample sample);
コード例 #14
0
 public XtMix(int rate, XtSample sample)
 => (this.rate, this.sample) = (rate, sample);