/// <summary>
        /// Resizes the specified <see cref="SampleCollection"/>. This frees the existing arrays after copying the
        /// values.
        /// </summary>
        /// <param name="samples">The <see cref="SampleCollection"/> to resize.</param>
        /// <param name="sampleCount">The new sample count.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="samples"/> is null.</exception>
        /// <exception cref="ArgumentOutOfRangeException">Thrown if <paramref name="sampleCount"/> is less than 1.</exception>
        public void Resize(SampleCollection samples, int sampleCount)
        {
            Contract.Requires <ArgumentNullException>(samples != null);
            Contract.Requires <ArgumentOutOfRangeException>(sampleCount > 0);
            Contract.Ensures(samples.SampleCount == sampleCount);

            for (var channel = 0; channel < samples.Channels; channel++)
            {
                float[] newArray = CreateOrGetCachedArray(sampleCount);
                Array.Copy(samples[channel], newArray, Math.Min(sampleCount, samples.SampleCount));
                samples[channel] = newArray;
                CacheArray(samples[channel]);
            }
        }
        /// <summary>
        /// Frees the internal arrays used by the specified <see cref="SampleCollection"/>, so they can be reallocated.
        /// </summary>
        /// <param name="samples">The <see cref="SampleCollection"/> to free.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="samples"/> is null.</exception>
        public void Free(SampleCollection samples)
        {
            Contract.Requires <ArgumentNullException>(samples != null);

            if (samples.SampleCount == 0)
            {
                return;
            }

            foreach (float[] channel in samples)
            {
                CacheArray(channel);
            }
        }
 public abstract void Submit(SampleCollection samples);
Example #4
0
 public void Submit(SampleCollection samples)
 {
     Contract.Requires <ArgumentNullException>(samples != null);
 }