Пример #1
0
        const uint MAGIC_OGG  = 0x5367674F;        //Future reference

        public static StreamingSound Open(Stream stream)
        {
            var  reader = new BinaryReader(stream);
            uint magic  = reader.ReadUInt32();

            reader.BaseStream.Seek(-4, SeekOrigin.Current);
            switch (magic)
            {
            case MAGIC_RIFF:
                return(RiffLoader.GetSound(stream));

            case MAGIC_OGG:
                //TODO: Opus
                return(VorbisLoader.GetSound(stream));

            default:
                return(Mp3Utils.GetSound(stream, null));
            }
        }
Пример #2
0
        public static StreamingSound GetSound(Stream stream)
        {
            RiffLoader file = new RiffLoader(stream);

            if (file.Format == WaveFormat.PCM)
            {
                var snd = new StreamingSound();
                snd.Format    = ALUtils.GetFormat(file.m_Channels, file.Bits);
                snd.Frequency = file.Frequency;
                snd.Size      = file.dataLength;
                snd.Data      = file.GetDataStream();
                return(snd);
            }
            else if (file.Format == WaveFormat.MP3)
            {
                return(Mp3Utils.GetSound(file.GetDataStream(), file));
            }
            throw new NotSupportedException();
        }