Convert() public static method

Converts a matrix of signed 16-bit integer samples into a matrix of 32-bit signed integer samples.
public static Convert ( Int16 from, Int32 to ) : void
from System.Int16 The original sample.
to System.Int32 The resulting sample.
return void
Esempio n. 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();
            }
        }
Esempio n. 2
0
 /// <summary>
 ///   Copies this signal to a given array.
 /// </summary>
 ///
 public void CopyTo(double[] array)
 {
     if (format == Audio.SampleFormat.Format64BitIeeeFloat)
     {
         if (array.Length < NumberOfSamples)
         {
             throw new Exception("The provided array is not large enough to contain the signal.");
         }
         Buffer.BlockCopy(rawData, 0, array, 0, Math.Min(NumberOfBytes, array.GetNumberOfBytes()));
     }
     else if (format == Audio.SampleFormat.Format32BitIeeeFloat)
     {
         float[] source = new float[NumberOfSamples];
         Buffer.BlockCopy(rawData, 0, source, 0, Math.Min(NumberOfBytes, source.GetNumberOfBytes()));
         SampleConverter.Convert(source, array);
     }
     else if (format == Audio.SampleFormat.Format16Bit)
     {
         short[] source = new short[NumberOfSamples];
         Buffer.BlockCopy(rawData, 0, source, 0, Math.Min(NumberOfBytes, source.GetNumberOfBytes()));
         SampleConverter.Convert(source, array);
     }
     else
     {
         throw new InvalidOperationException();
     }
 }
Esempio n. 3
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();
            }
        }