/// <summary>
        ///     Creates a new Opus decoder.
        /// </summary>
        /// <param name="outputSampleRate">Sample rate to decode at (Hz). This must be one of 8000, 12000, 16000, 24000, or 48000.</param>
        /// <param name="outputChannels">Number of channels to decode.</param>
        /// <returns>A new <c>OpusDecoder</c>.</returns>
        public static OpusDecoder Create(int outputSampleRate, int outputChannels)
        {
            if (outputSampleRate != 8000 &&
                outputSampleRate != 12000 &&
                outputSampleRate != 16000 &&
                outputSampleRate != 24000 &&
                outputSampleRate != 48000)
            {
                throw new ArgumentOutOfRangeException(nameof(outputSampleRate));
            }
            if (outputChannels != 1 && outputChannels != 2)
            {
                throw new ArgumentOutOfRangeException(nameof(outputChannels));
            }

            OpusLoader.LoadOpus();

            IntPtr error;
            IntPtr decoder = OpusApi.opus_decoder_create(outputSampleRate, outputChannels, out error);

            if ((Errors)error != Errors.OK)
            {
                throw new Exception("Exception occurred while creating decoder");
            }
            return(new OpusDecoder(decoder, outputSampleRate, outputChannels));
        }
        /// <summary>
        ///     Creates a new Opus encoder.
        /// </summary>
        /// <param name="inputSamplingRate">
        ///     Sampling rate of the input signal (Hz). This must be one of 8000, 12000, 16000, 24000,
        ///     or 48000.
        /// </param>
        /// <param name="inputChannels">Number of channels (1 or 2) in input signal.</param>
        /// <param name="application">Coding mode.</param>
        /// <returns>A new <c>OpusEncoder</c></returns>
        public static OpusEncoder Create(int inputSamplingRate, int inputChannels, Application application)
        {
            if (inputSamplingRate != 8000 &&
                inputSamplingRate != 12000 &&
                inputSamplingRate != 16000 &&
                inputSamplingRate != 24000 &&
                inputSamplingRate != 48000)
            {
                throw new ArgumentOutOfRangeException(nameof(inputSamplingRate));
            }
            if (inputChannels != 1 && inputChannels != 2)
            {
                throw new ArgumentOutOfRangeException(nameof(inputChannels));
            }

            OpusLoader.LoadOpus();

            IntPtr error;
            IntPtr encoder = OpusApi.opus_encoder_create(inputSamplingRate, inputChannels, (int)application, out error);

            if ((Errors)error != Errors.OK)
            {
                throw new Exception("Exception occurred while creating encoder");
            }
            return(new OpusEncoder(encoder, inputSamplingRate, inputChannels, application));
        }