Beispiel #1
0
        private void InitializeStream(string filePath, bool normalizeVolume)
        {
            if (!File.Exists(filePath))
            {
                throw new FileNotFoundException($"FilePath {filePath} does not exist at the specified location.", nameof(filePath));
            }

            Stream = new AudioFileReader(filePath);
            if (!normalizeVolume)
            {
                return;
            }

            float maxVolume = Stream.GetMaxVolume();

            if (maxVolume is 0 or >= 1.0f)
            {
                return;                            // normalization is not possible outside these bounds
            }
            Stream.Volume = 1 / maxVolume;
        }