Example #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="fileName">File to open using Game Music Emu.</param>
        /// <param name="sampleRate">Desired sample rate. Defaults to 44100Hz if not specified.</param>
        /// <param name="channels">Number of channels to use. Defaults to two if not specified.</param>
        public GmeReader(string fileName, int sampleRate = 44100, int channels = 2)
        {
            // Open the file.
            this.emuHandle = GmeNative.OpenFile(fileName, sampleRate);

            // Enable accurate sound emulation.
            GmeNative.gme_enable_accuracy(emuHandle, true);

            // Get track info
            this.TrackInfo  = GmeNative.GetTrackInfo(emuHandle, track);
            this.TrackCount = GmeNative.gme_track_count(emuHandle);
            this.VoiceCount = GmeNative.gme_voice_count(emuHandle);
            this.Equalizer  = GmeNative.GetEqualizer(emuHandle);
            this.Type       = GmeNative.GetType(emuHandle);

            GmeType tempType = this.Type; // Since properties can't be used in ref arguments.

            this.SupportsMultipleTracks = GmeNative.gme_type_multitrack(ref tempType);

            // Init the wave format.
            this.waveFormat = new WaveFormat(sampleRate, 16, channels);
        }