예제 #1
0
        /// <summary>
        ///   Copies this signal to a given array.
        /// </summary>
        ///
        public void CopyTo(double[] array)
        {
            if (format == Audio.SampleFormat.Format64BitIeeeFloat)
            {
                Buffer.BlockCopy(rawData, 0, array, 0, rawData.Length);
            }
            else if (format == Audio.SampleFormat.Format32BitIeeeFloat)
            {
                float[] source = new float[Samples];
                Buffer.BlockCopy(rawData, 0, source, 0, rawData.Length);
                for (int i = 0; i < source.Length; i++)
                {
                    array[i] = source[i];
                }
            }
            else if (format == Audio.SampleFormat.Format16Bit)
            {
                short[] source = new short[Samples];
                Buffer.BlockCopy(rawData, 0, source, 0, rawData.Length);
                SampleConverter.Convert(source, array);
            }

            else
            {
                throw new InvalidOperationException();
            }
        }
예제 #2
0
        /// <summary>
        ///   Copies this signal to a given array.
        /// </summary>
        ///
        public void CopyTo(float[] array)
        {
            if (format == Audio.SampleFormat.Format32BitIeeeFloat)
            {
                Buffer.BlockCopy(rawData, 0, array, 0, rawData.Length);
            }

            else if (format == Audio.SampleFormat.Format16Bit)
            {
                short[] source = new short[Samples];
                Buffer.BlockCopy(rawData, 0, source, 0, rawData.Length);
                SampleConverter.Convert(source, array);
            }

            else
            {
                throw new InvalidOperationException();
            }
        }