示例#1
0
        /// <summary>
        /// Decodes the mp3 file
        /// </summary>
        public WaveFile Decode(Stream input)
        {
            //TODO: Still AWFUL playback quality

            Mp3Stream mp3 = new Mp3Stream(input);

            mp3.Seek(0, SeekOrigin.Begin);
            mp3.DecodeFrames(1);

            WaveFile wf = new WaveFile();
            wf.Bits = 16;
            wf.Channels = mp3.ChannelCount;
            wf.Frequency = mp3.Frequency;
            System.Console.WriteLine(mp3.Length);
            MemoryStream data = new MemoryStream();
            int buffersize = 4*4096;
            byte[] buffer = new byte[buffersize];
            int result = 1;
            while(true)
            {
                result = mp3.Read(buffer, 0, buffersize);
                data.Write(buffer, 0, result);
                if(result != buffersize)
                {
                    break;
                }
            }

            data.Seek(0, SeekOrigin.Begin);
            wf.Data = data;

            Axiom.Core.LogManager.Instance.Write("SoundSystem: File is MPEG Layer III "+wf.Frequency+"Hz, "+wf.Channels+" channels");

            return wf;
        }
示例#2
0
 /// <summary>
 /// Decodes the Wave file
 /// </summary>
 /// <param name="input">The incoming stream</param>
 /// <returns>The outgoing stream</returns>
 public WaveFile Decode(Stream input)
 {
     WaveFile wf = new WaveFile();
     wf.WavFile = input;
     return wf;
 }