Exemplo n.º 1
0
        /// <summary>
        /// Scan <paramref name="sndfile"/> file and return normalized peak value for each channel.
        /// </summary>
        /// <param name="sndfile">Audio file we want to scan.</param>
        /// <param name="channels">Number of audio channels in the audio file.</param>
        /// <returns>Normalized Peak values for each channel.</returns>
        public double[] CalcNormMaxAllChannels(IntPtr sndfile, int channels)
        {
            if (sndfile == IntPtr.Zero)
            {
                throw new ArgumentException("File handle is invalid/closed.");
            }
            if (channels <= 0)
            {
                throw new ArgumentOutOfRangeException("channels", channels, "Channels must be greater than zero.");
            }

            var max = m_Api.CalcNormMaxAllChannels(sndfile, channels);

            if (max == null || max.Length == 0)
            {
                throw new LibsndfileException("Unable to retrieve normalized signal max for all channels.");
            }

            return(max);
        }