Beispiel #1
0
        /// <summary>
        ///     Retrieves the level of a sample, stream, MOD music, or recording channel.
        /// </summary>
        /// <param name="config">Level configure.</param>
        /// <param name="length">
        ///     The amount of data to inspect to calculate the level, in seconds. The maximum is 1 second. Less
        ///     data than requested may be used if the full amount is not available, eg. if the channel's playback buffer is
        ///     shorter.
        /// </param>
        /// <returns>An array to receive the levels. </returns>
        public float[] GetLevelEx(LevelConfig config, float length)
        {
            CheckAvailable();

            float[] result = null;

            if (config.HasFlag(LevelConfig.Mono))
            {
                result = new float[1];
            }
            else if (config.HasFlag(LevelConfig.Stereo))
            {
                result = new float[2];
            }
            else
            {
                result = new float[Information.Channels];
            }

            GCHandle resultHandle = GCHandle.Alloc(result, GCHandleType.Pinned);

            ChannelModule.ChannelGetLevelExFunction.CheckResult(ChannelModule.ChannelGetLevelExFunction.Delegate(
                Handle, resultHandle.AddrOfPinnedObject(), length, config));

            resultHandle.Free();

            return result;
        }