예제 #1
0
 private void CreateDecodingChannel(string audioFilePath)
 {
     _decodingChannel = Channel.CreateFileStreamForDecoding(audioFilePath, _useFloatingPoint);
     _currentFilePath = audioFilePath;
     _channelLength = _decodingChannel.GetLength();
     _decodePosition = 0;
     lock (_locker)
     {
         Monitor.Pulse(_locker);
     }
 }
예제 #2
0
        /// <summary>
        /// Loads the current channel and audio file metadata.
        /// </summary>
        public void Load(bool useFloatingPoint)
        {
            // Load audio file metadata
            _audioFile.RefreshMetadata();

            #if !PCL && !WINDOWSSTORE && !WINDOWS_PHONE

            // Check if a channel already exists
            if(_channel != null)
                Dispose();

            // Load channel
            _channel = Channel.CreateFileStreamForDecoding(_audioFile.FilePath, useFloatingPoint);
            _lengthBytes = _channel.GetLength();

            // Divide length by 2 if using floating point
            if (_channel.IsFloatingPoint)
                _lengthBytes /= 2;

            // Check if this is a FLAC file over 44100Hz
            if (_audioFile.FileType == AudioFileFormat.FLAC && _audioFile.SampleRate > 44100)
                _lengthBytes = (long)((float)_lengthBytes * 1.5f);

            _lengthSamples = ConvertAudio.ToPCM(_lengthBytes, (uint)_audioFile.BitsPerSample, 2);
            _lengthMilliseconds = (int)ConvertAudio.ToMS(_lengthSamples, (uint)_audioFile.SampleRate);
            _lengthString = Conversion.MillisecondsToTimeString((ulong)_lengthMilliseconds);

            #endif

            _isLoaded = true;
        }