예제 #1
0
        public byte[] Save()
        {
            int length = 6;

            foreach (SEQ seq in seqs)
            {
                length += 13;
                length += seq.Data.Length;
            }
            byte[] data = new byte [length];
            BEBitConv.ToInt32(data, 0, Magic);
            BEBitConv.ToInt16(data, 4, Version);
            int offset = 6;

            for (int i = 0; i < seqs.Count; i++)
            {
                SEQ seq = seqs[i];
                BEBitConv.ToInt16(data, offset, (short)i);
                BEBitConv.ToInt16(data, offset + 2, seq.Resolution);
                MIDIConv.To3BE(data, offset + 4, seq.Tempo);
                BEBitConv.ToInt16(data, offset + 7, seq.Rhythm);
                BEBitConv.ToInt32(data, offset + 9, seq.Data.Length);
                offset += 13;
                seq.Data.CopyTo(data, offset);
                offset += seq.Data.Length;
            }
            return(data);
        }
예제 #2
0
 public byte[] Save()
 {
     byte[] result = new byte [15 + data.Length];
     BEBitConv.ToInt32(result, 0, Magic);
     BEBitConv.ToInt32(result, 4, Version);
     BEBitConv.ToInt16(result, 8, resolution);
     MIDIConv.To3BE(result, 10, tempo);
     BEBitConv.ToInt16(result, 13, rhythm);
     data.CopyTo(result, 15);
     return(result);
 }
예제 #3
0
        public static void ToInt32(Endianness endianness, byte[] str, int offset, int value)
        {
            switch (endianness)
            {
            case Endianness.LittleEndian:
                BitConv.ToInt32(str, offset, value);
                break;

            case Endianness.BigEndian:
                BEBitConv.ToInt32(str, offset, value);
                break;

            default:
                throw new ArgumentException("Endianness is invalid.");
            }
        }