Exemple #1
0
        /// <summary>
        /// Initializes a new <see cref="OpusEncoder"/> instance, with the specified codec usage tuning, sample rate and channels.
        /// </summary>
        /// <param name="optimized">The codec usage tuning.</param>
        /// <param name="sampleRate">The sample rate in the input audio.</param>
        /// <param name="audioChannels">The channels in the input audio - mono or stereo.</param>
        public OpusEncoder(OpusOptimizer optimized, OpusSampleRate sampleRate, OpusAudioChannels audioChannels)
        {
            if (!Enum.IsDefined(typeof(OpusOptimizer), optimized))
            {
                throw new ArgumentException("Value is not defined in the enumeration.", nameof(optimized));
            }

            if (!Enum.IsDefined(typeof(OpusSampleRate), sampleRate))
            {
                throw new ArgumentException("Value is not defined in the enumeration.", nameof(sampleRate));
            }

            if (!Enum.IsDefined(typeof(OpusAudioCHannels), audioChannels))
            {
                throw new ArgumentException("Value is not defined in the enumeration.", nameof(audioChannels));
            }

            _handle = FFI.opus_encoder_create((int)sampleRate, (int)audioChannels, (int)optimized, out int error);

            ThrowIfError(error);

            Optimized     = optimized;
            SampleRate    = sampleRate;
            AudioChannels = audioChannels;
            Bitrate       = -1;
        }
Exemple #2
0
 /// <summary>
 /// Initializes a new <see cref="OpusEncoder"/> instance, with the specified codec usage tuning, sample rate and channels.
 /// </summary>
 /// <param name="sampleRate">The sample rate in the input audio.</param>
 /// <param name="audioChannels">The channels in the input audio - mono or stereo.</param>
 public OpusEncoder(OpusOptimizer optimized, int sampleRate, int audioChannels) : this(optimized, (OpusSampleRate)sampleRate, (OpusAudioChannels)audioChannels)
 {
 }
Exemple #3
0
 /// <summary>
 /// Initializes a new <see cref="OpusEncoder"/> instance as 48k stereo.
 /// </summary>
 /// <param name="optimized">The codec usage tuning.</param>
 public OpusEncoder(OpusOptimizer optimized) : this(optimized, OpusSampleRate._48k, OpusAudioChannels.Stereo)
 {
 }