Exemplo n.º 1
0
        public SonicArrangerFile(Stream stream)
        {
            var reader = new BinaryReader(stream, Encoding.ASCII);
            string soar = new string(reader.ReadChars(4));
            if(soar != "SOAR")
            {
                stream.Position = 0;
                long start = ReadTo(reader, pcstart);
                int songptr = 0x28;
                int ovtbptr = reader.ReadInt32BE();
                int notbptr = reader.ReadInt32BE();
                int intbptr = reader.ReadInt32BE();
                int syntptr = reader.ReadInt32BE();

                stream.Position = start+songptr;
                int songs = (ovtbptr-songptr)/12;
                Songs = new Song[songs];
                for(int i = 0; i < songs; i++)
                {
                    Songs[i] = new Song(reader);
                }

                stream.Position = start+ovtbptr;
                int voices = (notbptr-ovtbptr)/4;
                Voices = new Voice[voices];
                for(int i = 0; i < voices; i++)
                {
                    Voices[i] = new Voice(reader);
                }

                stream.Position = start+notbptr;
                int notes = (intbptr-notbptr)/4;
                Notes = new Note[notes];
                for(int i = 0; i < notes; i++)
                {
                    Notes[i] = new Note(reader);
                }

                stream.Position = start+intbptr;
                int instrs = (syntptr-intbptr)/152;
                Instruments = new Instrument[instrs];
                for(int i = 0; i < instrs; i++)
                {
                    Instruments[i] = new Instrument(reader);
                }
            }else{
                Version = new string(reader.ReadChars(4));

                string tag;
                while(true)
                {
                    tag = new string(reader.ReadChars(4));
                    switch(tag)
                    {
                        case "STBL":
                            Songs = new SongTable(reader).Songs;
                            break;
                        case "OVTB":
                            Voices = new OverTable(reader).Voices;
                            break;
                        case "NTBL":
                            Notes = new NoteTable(reader).Notes;
                            break;
                        case "INST":
                            Instruments = new InstrumentTable(reader).Instruments;
                            break;
                        default:
                            return;
                    }
                }
            }
        }
Exemplo n.º 2
0
        public SonicArrangerFile(Stream stream)
        {
            var    reader = new BinaryReader(stream, Encoding.ASCII);
            string soar   = new string(reader.ReadChars(4));

            if (soar != "SOAR")
            {
                stream.Position = 0;
                long start   = ReadTo(reader, pcstart);
                int  songptr = 0x28;
                int  ovtbptr = reader.ReadInt32BE();
                int  notbptr = reader.ReadInt32BE();
                int  intbptr = reader.ReadInt32BE();
                int  syntptr = reader.ReadInt32BE();

                stream.Position = start + songptr;
                int songs = (ovtbptr - songptr) / 12;
                Songs = new Song[songs];
                for (int i = 0; i < songs; i++)
                {
                    Songs[i] = new Song(reader);
                }

                stream.Position = start + ovtbptr;
                int voices = (notbptr - ovtbptr) / 4;
                Voices = new Voice[voices];
                for (int i = 0; i < voices; i++)
                {
                    Voices[i] = new Voice(reader);
                }

                stream.Position = start + notbptr;
                int notes = (intbptr - notbptr) / 4;
                Notes = new Note[notes];
                for (int i = 0; i < notes; i++)
                {
                    Notes[i] = new Note(reader);
                }

                stream.Position = start + intbptr;
                int instrs = (syntptr - intbptr) / 152;
                Instruments = new Instrument[instrs];
                for (int i = 0; i < instrs; i++)
                {
                    Instruments[i] = new Instrument(reader);
                }
            }
            else
            {
                Version = new string(reader.ReadChars(4));

                string tag;
                while (true)
                {
                    tag = new string(reader.ReadChars(4));
                    switch (tag)
                    {
                    case "STBL":
                        Songs = new SongTable(reader).Songs;
                        break;

                    case "OVTB":
                        Voices = new OverTable(reader).Voices;
                        break;

                    case "NTBL":
                        Notes = new NoteTable(reader).Notes;
                        break;

                    case "INST":
                        Instruments = new InstrumentTable(reader).Instruments;
                        break;

                    default:
                        return;
                    }
                }
            }
        }