コード例 #1
0
ファイル: Music.cs プロジェクト: Iandika/Cgen.Audio
 /// <summary>
 /// Initializes a new instance of the <see cref="Music"/> class.
 /// </summary>
 public Music()
     : base()
 {
     _reader      = null;
     _sampleCount = 0;
     _duration    = TimeSpan.Zero;
 }
コード例 #2
0
ファイル: Music.cs プロジェクト: SirusDoma/Cgen.Audio
        /// <summary>
        /// Initializes a new instance of the <see cref="Music"/> class.
        /// </summary>
        public Music()
            : base()
        {
            _reader      = null;
            _sampleCount = 0;
            _duration    = TimeSpan.Zero;

        }
コード例 #3
0
ファイル: Music.cs プロジェクト: Iandika/Cgen.Audio
        /// <summary>
        /// Initializes a new instance of the <see cref="Music"/> class
        /// from specified <see cref="Stream"/> containing sound data.
        /// </summary>
        /// <param name="stream">A <see cref="Stream"/> contains sound data to load.</param>
        public Music(Stream stream)
            : this()
        {
            _reader = Decoders.CreateReader(stream);
            if (_reader == null)
            {
                throw new NotSupportedException("The specified sound is not supported.");
            }

            _info = _reader.Open(stream);
            Initialize(_info.ChannelCount, _info.SampleRate);
        }
コード例 #4
0
ファイル: Music.cs プロジェクト: SirusDoma/Cgen.Audio
        /// <summary>
        /// Initializes a new instance of the <see cref="Music"/> class
        /// from specified <see cref="Stream"/> containing sound data.
        /// </summary>
        /// <param name="stream">A <see cref="Stream"/> contains sound data to load.</param>
        public Music(Stream stream)
            : this()
        {
            _reader = Decoders.CreateReader(stream);
            if (_reader == null)
            {
                throw new NotSupportedException("The specified sound is not supported.");
            }

            _info = _reader.Open(stream);
            Initialize(_info.ChannelCount, _info.SampleRate);
        }
コード例 #5
0
ファイル: SoundBuffer.cs プロジェクト: Iandika/Cgen.Audio
        private void Initialize(SoundReader reader, SampleInfo info)
        {
            // Retrieve the sound parameters
            long sampleCount  = info.SampleCount;
            int  channelCount = info.ChannelCount;
            int  sampleRate   = info.SampleRate;

            // Read the samples from the provided file
            using (reader)
            {
                _samples = new short[sampleCount];
                if (reader.Read(_samples, sampleCount) == sampleCount)
                {
                    // Update the internal buffer with the new samples
                    Update(channelCount, sampleRate);
                }
                else
                {
                    throw new Exception("Failed to decode the sound data.");
                }
            }
        }
コード例 #6
0
ファイル: SoundBuffer.cs プロジェクト: SirusDoma/Cgen.Audio
        private void Initialize(SoundReader reader, SampleInfo info)
        {
            // Retrieve the sound parameters
            long sampleCount  = info.SampleCount;
            int  channelCount = info.ChannelCount;
            int  sampleRate   = info.SampleRate;

            // Read the samples from the provided file
            using (reader)
            {
                _samples = new short[sampleCount];
                if (reader.Read(_samples, sampleCount) == sampleCount)
                {
                    // Update the internal buffer with the new samples
                    Update(channelCount, sampleRate);
                }
                else
                {
                    throw new Exception("Failed to decode the sound data.");
                }
            }
        }