public static Convert ( |
||
from | The original sample. | |
to | The resulting sample. | |
return | void |
/// <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(); } }
/// <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(); } }
/// <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(); } }