Ejemplo n.º 1
0
        /// <summary>
        /// Open MP3 file
        /// </summary>
        /// <param name="filePath">Path to file to open</param>
        /// <returns>true if successful</returns>
        public bool OpenMp3File(string filePath)
        {
            try
            {
                mp3File = new Mp3FileReader(filePath);
                WaveChannel32 inputStream = new WaveChannel32(mp3File);
                inputStream.PadWithZeroes = false;  // don't pad, otherwise the stream never ends
                streamProcessor           = new WaveStreamProcessor(inputStream);

                waveOut = new WaveOut()
                {
                    DesiredLatency = 100
                };

                waveOut.Init(streamProcessor);  // inputStream);
                waveOut.PlaybackStopped += EventHandler_stopped;

                StatusMessage.Write("Opened file " + filePath);
                return(true);
            }
            catch (Exception exp)
            {
                // Error in opening file
                waveOut = null;
                StatusMessage.Write("Can't open file: " + exp.Message);
                return(false);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Open Wav file
        /// </summary>
        /// <param name="filePath">Path to file to open</param>
        /// <returns>true if successful</returns>
        public void OpenWaveFile(string filePath)
        {
            try
            {
                Stop();
                waveFile = new WaveFileReader(filePath);
                WaveChannel32 inputStream = new WaveChannel32(waveFile);
                inputStream.PadWithZeroes = false;  // don't pad, otherwise the stream never ends

                equaliser.CreateFilters(inputStream.WaveFormat);
                streamProcessor = new WaveStreamProcessor(inputStream, equaliser);

                directSoundOut = new DirectSoundOut();

                directSoundOut.Init(streamProcessor);  // inputStream);
                directSoundOut.PlaybackStopped += EventHandler_stopped;

                StatusMessage.Write("Opened file " + filePath);
            }
            catch (Exception exp)
            {
                // Error in opening file
                directSoundOut = null;
                StatusMessage.Write("Can't open file: " + exp.Message);
            }
        }