Exemple #1
0
        /// <summary>
        /// Attempts to open and load the audio file at the given path as a new <see cref="Sound"/> instance.</br>
        /// Supported audio file types are WAVE (.wav), OGG/Vorbis (.ogg), and Flac (.flac).
        /// </summary>
        /// <param name="path">The path to the audio file.</param>
        /// <returns>The loaded audio data as a Sound.</returns>
        public static Sound LoadFile(string path)
        {
            using (var file = new AudioFile(path)) {
                // Load file data
                var buffer = new short[file.TotalSampleCount];
                var read   = file.ReadFrames(buffer);

                // Put data into sound
                return(new Sound(buffer, file.Stereo, file.SampleRate));
            }
        }