Esempio n. 1
0
        /// <summary>
        /// Reads PCM data from this MP3.
        /// </summary>
        /// <returns>Returns exactly BufferSize (default: 16384 * 4) bytes of data.
        /// If less data is returned, it means the end of the file was reached.</returns>
        public byte[] DecompressedWav()
        {
            /*byte[] Buffer = new byte[BufferSize];
             * int BytesRead = m_Stream.Read(Buffer, 0, BufferSize);
             *
             * if (BytesRead != 0)
             * {
             *  if (BytesRead < BufferSize)
             *      Array.Resize(ref Buffer, BytesRead);
             *
             *  return Buffer;
             * }
             *
             * return null;*/

            if (FileManager.IsLinux)
            {
                m_Stream.DecodeFrames(1);
                byte[] Buffer    = new byte[m_Stream.Length];
                int    BytesRead = 1;

                while (BytesRead > 0)
                {
                    BytesRead = m_Stream.Read(Buffer, 0, BufferSize);
                }

                return(Buffer);
            }
            else
            {
                throw new MP3Exception("Attempted to play MP3 directly on Windows! Use SoundPlayer.cs to do this!");
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Reads PCM data from this MP3.
        /// </summary>
        /// <returns>Returns exactly BufferSize (default: 4096) bytes of data.
        /// If less data is returned, it means the end of the file was reached.</returns>
        public byte[] DecompressedWav()
        {
            /*byte[] Buffer = new byte[BufferSize];
             * int BytesRead = m_Stream.Read(Buffer, 0, BufferSize);
             *
             * if (BytesRead != 0)
             * {
             *  if (BytesRead < BufferSize)
             *      Array.Resize(ref Buffer, BytesRead);
             *
             *  return Buffer;
             * }
             *
             * return null;*/

            m_Stream.DecodeFrames(1);
            byte[] Buffer    = new byte[m_Stream.Length];
            int    BytesRead = 1;

            while (BytesRead > 0)
            {
                BytesRead = m_Stream.Read(Buffer, 0, BufferSize);
            }

            return(Buffer);
        }