protected void Button1_Click(object sender, EventArgs e) { //byte[] buffer = new Buffer[512]; using (FileStream fs = File.Open(@"Z:\20121204.SVD", FileMode.Open, FileAccess.Read)) { using (BinaryReader br = new BinaryReader(fs)) { FileHead fh = new FileHead(); fh.Name = br.ReadSByte().ToChar().ToString() + br.ReadSByte().ToChar().ToString() + br.ReadSByte().ToChar().ToString(); fh.Ver = br.ReadSByte().ToString(); fh.Size = br.ReadInt16().ToString(); byte[] temp = new byte[8]; br.Read(temp, 0, 8); //fh.MachineSN = br.ReadSByte().ToString() + br.ReadSByte().ToString() + br.ReadSByte().ToString() + br.ReadSByte().ToString() + br.ReadSByte().ToString() + br.ReadSByte().ToString() + br.ReadSByte().ToString() + br.ReadSByte().ToString(); fh.MachineSN = temp.ToHexString(); fh.BootVer = br.ReadSByte().ToString() + br.ReadSByte().ToString() + br.ReadSByte().ToString(); fh.SoftVer = br.ReadSByte().ToString() + br.ReadSByte().ToString() + br.ReadSByte().ToString(); fh.SumRecord = br.ReadInt32().ToString(); fh.UploadRecord = br.ReadInt32().ToString(); fh.NextUploadFPtr = br.ReadInt32().ToString(); Response.Write(fh.ToString()); } } }
public static FacetSector readSector(BinaryReader r) { FacetSector fs = new FacetSector(); fs.facetID = r.ReadByte(); fs.sectorID = r.ReadUInt16(); for (int x = 0; x < 64; ++x) { fs.tiles[x] = new facetTile_t[64]; for (int y = 0; y < 64; ++y) { fs.tiles[x][y].z = r.ReadSByte(); fs.tiles[x][y].landtileGraphic = r.ReadUInt16(); fs.tiles[x][y].delimitersCount = r.ReadByte(); if (fs.tiles[x][y].delimitersCount > 0) { fs.tiles[x][y].delimiters = new facetDelimiter_t[fs.tiles[x][y].delimitersCount]; for (int i = 0; i < fs.tiles[x][y].delimitersCount; ++i) { fs.tiles[x][y].delimiters[i].direction = r.ReadByte(); if (fs.tiles[x][y].delimiters[i].direction < 8) { fs.tiles[x][y].delimiters[i].z = r.ReadSByte(); fs.tiles[x][y].delimiters[i].graphic = r.ReadUInt32(); } } } fs.tiles[x][y].staticsCount = r.ReadByte(); if (fs.tiles[x][y].staticsCount > 0) { fs.tiles[x][y].statics = new facetStatic_t[fs.tiles[x][y].staticsCount]; for (int i = 0; i < fs.tiles[x][y].staticsCount; ++i) { fs.tiles[x][y].statics[i].graphic = r.ReadUInt32(); fs.tiles[x][y].statics[i].z = r.ReadSByte(); fs.tiles[x][y].statics[i].color = r.ReadUInt32(); } } } } return fs; }
//--Methods public InstrumentChunk(string id, int size, BinaryReader reader) : base(id, size) { instNote = reader.ReadByte(); instFineTune = reader.ReadSByte(); instGain = reader.ReadSByte(); instLowNote = reader.ReadByte(); instHighNote = reader.ReadByte(); instLowVelocity = reader.ReadByte(); instHighVelocity = reader.ReadByte(); reader.ReadByte(); //always read pad }
private void ClientData(BinaryReader source) { var mask = source.ReadUInt16(); var view_ofs_z = (0!=(mask & 0x0001))?source.ReadSByte():22; var ang_ofs_1 = (0 != (mask & 0x0002)) ? (float)source.ReadSByte() : 0.0; var angles_0 = (0 != (mask & 0x0004)) ? source.ReadSByte() : 0; var vel_0 = (0 != (mask & 0x0020)) ? (source.ReadSByte()) : 0; var angles_1 = (0 != (mask & 0x0008)) ? (source.ReadSByte()) : 0; var vel_1 = (0 != (mask & 0x0040)) ? source.ReadSByte() : 0; var angles_2 = (0 != (mask & 0x0010)) ? source.ReadSByte() : 0; var vel_2 = (0 != (mask & 0x0080)) ? source.ReadSByte() : 0; var items = (0 != (mask & 0x0200)) ? source.ReadInt32() : 0x4001; var uk_bit_b10 = (0 != (mask & 0x0400)) ? 1 : 0; // bit 10 var uk_bit_b11 = (0 != (mask & 0x0800)) ? 1 : 0; // bit 11 var weaponframe = (0 != (mask & 0x1000)) ? source.ReadByte() : 0; var armorvalue = (0 != (mask & 0x2000)) ? source.ReadByte() : 0; var weaponmodel = (0 != (mask & 0x4000)) ? source.ReadByte() : 0; var health = source.ReadInt16(); var currentammo = source.ReadByte(); var ammo_shells = source.ReadByte(); var ammo_nails = source.ReadByte(); var ammo_rockets = source.ReadByte(); var ammo_cells = source.ReadByte(); var weapon = source.ReadByte(); }
public Metric(BinaryReader br) { advance = br.ReadSingle(); u = br.ReadInt16(); v = br.ReadInt16(); bearingX = br.ReadSByte(); bearingY = br.ReadSByte(); width = br.ReadByte(); height = br.ReadByte(); first = br.ReadByte(); second = br.ReadByte(); prevNum = br.ReadByte(); nextNum = br.ReadByte(); }
public static string DeserializeToString(byte[] data) { MemoryStream stream = new MemoryStream(data); BinaryReader reader = new BinaryReader(stream); reader.ReadSByte(); //取出第一个null字符 StringBuilder builder = new StringBuilder(); int count = reader.ReadInt32(); for (int i = 0; i < count; ++i) { sbyte flag = reader.ReadSByte(); if (flag == LineFlag) { int line = reader.ReadInt32(); flag = reader.ReadSByte(); int sourceLine = builder.ToString().Split('\n').Length; for (int j = sourceLine; j < line; ++j) builder.Append('\n'); } TokenType type = (TokenType)flag; object value = null; switch (type) { case TokenType.Boolean: value = (reader.ReadSByte() == 1); break; case TokenType.String: value = "\"" + Util.ReadString(reader).Replace("\n", "\\n") + "\""; break; case TokenType.SimpleString: value = "@\"" + Util.ReadString(reader) + "\""; break; case TokenType.Identifier: value = Util.ReadString(reader); break; case TokenType.Number: if (reader.ReadSByte() == 1) value = reader.ReadDouble(); else value = reader.ReadInt64() + "L"; break; default: value = GetTokenString(type); break; } builder.Append(value + " "); } return builder.ToString(); }
public void Read(BinaryReader reader, MDStream stream) { offs = reader.ReadUInt32 (); size = reader.ReadUInt32 (); StringBuilder name_builder = new StringBuilder (); while (true) { sbyte c = reader.ReadSByte(); if (c == 0) break; name_builder.Append ((char) c); } name = name_builder.ToString (); if (name.Length == 0) throw new BadImageException("Invalid stream name."); // Round up to dword boundary. long pos = reader.BaseStream.Position; if (stream != null) pos -= stream.Root.filePos; pos += 3; pos &= ~3; if (stream != null) pos += stream.Root.filePos; // Advance file pointer. reader.BaseStream.Position = pos; }
public static HighEnumLiteral Read(CatalogReader catalog, BinaryReader reader, uint literalSize, bool isSigned) { string name = catalog.GetString(reader.ReadUInt32()); long value; switch (literalSize) { case 8: value = reader.ReadInt64(); break; case 4: if (isSigned) value = reader.ReadInt32(); else value = reader.ReadUInt32(); break; case 2: if (isSigned) value = reader.ReadInt16(); else value = reader.ReadUInt16(); break; case 1: if (isSigned) value = reader.ReadSByte(); else value = reader.ReadByte(); break; default: throw new ArgumentException(); } return new HighEnumLiteral(name, value); }
public override object Read(BinaryReader buffer, Type resultType, TypeDescription typeDescriptor, byte code, BinaryJSONReader binaryJsonReader) { switch (code) { case BinaryValue.BYTE: return Convert.ChangeType(buffer.ReadByte(), resultType); case BinaryValue.SBYTE: return Convert.ChangeType(buffer.ReadSByte(), resultType); case BinaryValue.INT16: return Convert.ChangeType(buffer.ReadInt16(), resultType); case BinaryValue.UINT16: return Convert.ChangeType(buffer.ReadUInt16(), resultType); case BinaryValue.INT32: return Convert.ChangeType(buffer.ReadInt32(), resultType); case BinaryValue.UINT32: return Convert.ChangeType(buffer.ReadUInt32(), resultType); case BinaryValue.INT64: return Convert.ChangeType(buffer.ReadInt64(), resultType); case BinaryValue.UINT64: return Convert.ChangeType(buffer.ReadUInt64(), resultType); case BinaryValue.FLOAT: return Convert.ChangeType(buffer.ReadSingle(), resultType); case BinaryValue.BOOLEAN: return Convert.ChangeType(buffer.ReadBoolean(), resultType); case BinaryValue.DOUBLE: return Convert.ChangeType(buffer.ReadDouble(), resultType); case BinaryValue.DECIMAL: return Convert.ChangeType(buffer.ReadDecimal(), resultType); case BinaryValue.CHAR: return Convert.ChangeType(buffer.ReadChar(), resultType); } return null; }
public HeightData(System.IO.BinaryReader reader) { ReferenceHeight = reader.ReadSingle(); HeightPoints = reader.ReadSByteArray(65 * 65); reader.ReadInt16(); // always -22801, or (239, 166)? reader.ReadSByte(); // always 0, deleted? }
public static void DecodePackedFile(BinaryReader reader) { reader.ReadSByte(); List<string> dictionary = PS.readDictionary(reader); XmlNode xmlroot = xDoc.CreateNode(XmlNodeType.Element, FileName, ""); PS.readElement(reader, xmlroot, xDoc, dictionary); xDoc.AppendChild(xmlroot); }
public override void Deserialize(BinaryReader reader) { GUID = reader.ReadUInt32(); x = reader.ReadInt16(); y = reader.ReadInt16(); level = reader.ReadSByte(); dir = (Direction)reader.ReadByte(); }
public override void Deserialize(BinaryReader reader) { Interaction = reader.ReadUInt16(); CallerID = reader.ReadInt16(); x = reader.ReadInt16(); y = reader.ReadInt16(); level = reader.ReadSByte(); }
public override void Deserialize(BinaryReader reader) { base.Deserialize(reader); Interaction = reader.ReadUInt16(); x = reader.ReadInt16(); y = reader.ReadInt16(); level = reader.ReadSByte(); }
static int ReadSByte(IntPtr L) { LuaScriptMgr.CheckArgsCount(L, 1); System.IO.BinaryReader obj = (System.IO.BinaryReader)LuaScriptMgr.GetNetObjectSelf(L, 1, "System.IO.BinaryReader"); sbyte o = obj.ReadSByte(); LuaScriptMgr.Push(L, o); return(1); }
public static int ReadInt32FromSbytes(BinaryReader br) { sbyte[] b = new sbyte[4]; for (int i = 0; i < 4; i++) { b[i] = br.ReadSByte(); } return (((b[0] & 0xff) << 24) | ((b[1] & 0xff) << 16) | ((b[2] & 0xff) << 8) | (b[3] & 0xff)); }
public string readBase64(BinaryReader reader, int lengthInBytes) { sbyte[] bytes = new sbyte[lengthInBytes]; for (int i = 0; i < lengthInBytes; i++) { bytes[i] = reader.ReadSByte(); } return byteArrayToBase64(bytes); }
public override void Deserialize(BinaryReader reader) { base.Deserialize(reader); ObjectID = reader.ReadInt16(); x = reader.ReadInt16(); y = reader.ReadInt16(); level = reader.ReadSByte(); dir = (Direction)reader.ReadByte(); }
public static uint ReadUInt16FromSbytes(BinaryReader br) { sbyte[] b = new sbyte[2]; for (int i = 0; i < 2; i++) { b[i] = br.ReadSByte(); } return (ushort)(((b[0] & 0xff) << 8) | (b[1] & 0xff)); }
public static List<Token> Deserialize(byte[] data) { MemoryStream stream = new MemoryStream(data); BinaryReader reader = new BinaryReader(stream); reader.ReadSByte(); //取出第一个null字符 List<Token> tokens = new List<Token>(); int count = reader.ReadInt32(); int sourceLine = 0; for (int i = 0; i < count; ++i) { sbyte flag = reader.ReadSByte(); if (flag == LineFlag) { sourceLine = reader.ReadInt32(); flag = reader.ReadSByte(); } TokenType type = (TokenType)flag; object value = null; switch (type) { case TokenType.Boolean: value = (reader.ReadSByte() == 1); break; case TokenType.String: case TokenType.SimpleString: value = Util.ReadString(reader); break; case TokenType.Identifier: value = Util.ReadString(reader); break; case TokenType.Number: if (reader.ReadSByte() == 1) value = reader.ReadDouble(); else value = reader.ReadInt64(); break; default: value = type.ToString(); break; } tokens.Add(new Token(type, value, sourceLine - 1, 0)); } return tokens; }
public void Deserialize(BinaryReader reader) { Operand = new VMSetBalloonHeadlineOperand(); Operand.Read(reader.ReadBytes(8)); Target = reader.ReadInt16(); IconTarget = reader.ReadInt16(); Index = reader.ReadSByte(); Duration = reader.ReadInt32(); Anim = reader.ReadInt32(); }
private static void ReadChild(BinaryReader reader, INode parent, ICollection<INode> container) { var type = (Type)reader.ReadSByte(); if (type == Type.Folder) { ReadFolder(reader, parent, container); } else { ReadImageData(reader, parent, container); } }
public ItemState(BinaryReader reader, short type) : this() { Type = type; reader.ReadByte(); Class = (ItemClass)reader.ReadByte(); Slot = (ItemSlot)reader.ReadByte(); BreakRate = reader.ReadByte(); Gender = (Gender)reader.ReadByte(); FreeHands = reader.ReadByte(); LifePointsBonus = reader.ReadByte(); SpellPointsBonus = reader.ReadByte(); AttributeType = (AttributeType)reader.ReadByte(); AttributeBonus = reader.ReadByte(); SkillTypeBonus = (SkillType)reader.ReadByte(); SkillBonus = reader.ReadByte(); PhysicalDamageProtection = reader.ReadByte(); PhysicalDamageCaused = reader.ReadByte(); AmmunitionType = reader.ReadByte(); SkillType1Tax = (SkillType)reader.ReadByte(); SkillType2Tax = (SkillType)reader.ReadByte(); Skill1Tax = reader.ReadSByte(); Skill2Tax = reader.ReadSByte(); TorchIntensity = reader.ReadByte(); AmmoAnimation = reader.ReadByte(); Spell = (ItemSpellType)reader.ReadByte(); SpellID = reader.ReadByte(); Charges = reader.ReadByte(); NumRecharged = reader.ReadByte(); MaxNumRecharged = reader.ReadByte(); MaxCharges = reader.ReadByte(); Count1 = reader.ReadByte(); Count2 = reader.ReadByte(); IconAnim = reader.ReadByte(); Weight = reader.ReadInt16(); Value = reader.ReadInt16()/10f; Icon = reader.ReadInt16(); UsingClass = reader.ReadInt16(); UsingRace = reader.ReadInt16(); }
public void Deserialize(BinaryReader reader) { Type = (VMArchitectureCommandType)reader.ReadByte(); x = reader.ReadInt32(); y = reader.ReadInt32(); level = reader.ReadSByte(); x2 = reader.ReadInt32(); y2 = reader.ReadInt32(); pattern = reader.ReadUInt16(); style = reader.ReadUInt16(); }
static public int ReadSByte(IntPtr l) { try { System.IO.BinaryReader self = (System.IO.BinaryReader)checkSelf(l); var ret = self.ReadSByte(); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } }
public bool readBoolean(BinaryReader reader, int lengthInBytes) { bool @bool = lengthInBytes == 1; if (@bool) { if (reader.ReadSByte() != 1) { throw new System.ArgumentException("Boolean error"); } } return @bool; }
public SampleHeader(BinaryReader reader) { sampleName = IOHelper.Read8BitString(reader, 20); start = reader.ReadUInt32(); end = reader.ReadUInt32(); startLoop = reader.ReadUInt32(); endLoop = reader.ReadUInt32(); sampleRate = reader.ReadUInt32(); originalPitch = reader.ReadByte(); pitchCorrection = reader.ReadSByte(); sampleLink = reader.ReadUInt16(); soundFontSampleLink = (SFSampleLink)reader.ReadUInt16(); }
public Material(BinaryReader r) { name = ASCIIEncoding.ASCII.GetString(r.ReadBytes(32)).Split((char)0)[0]; ambient = ReadColor(r); diffuse = ReadColor(r); specular = ReadColor(r); emissive = ReadColor(r); shininess = r.ReadSingle(); transparency = r.ReadSingle(); mode = r.ReadSByte(); textureFile = ASCIIEncoding.ASCII.GetString(r.ReadBytes(128)).Split((char)0)[0]; alphaMapFile = ASCIIEncoding.ASCII.GetString(r.ReadBytes(128)).Split((char)0)[0]; }
static object Read(World world, BinaryReader r, Type t, ref bool result) { if (t == typeof(byte)) return r.ReadByte(); if (t == typeof(sbyte)) return r.ReadSByte(); if (t == typeof(char)) return r.ReadChar(); if (t == typeof(int)) return r.ReadInt32(); if (t == typeof(uint)) return r.ReadUInt32(); if (t == typeof(bool)) return r.ReadBoolean(); if (t == typeof(string)) return r.ReadString(true); if (t == typeof(int2)) return r.ReadInt2(); if (t == typeof(long)) return r.ReadInt64(); if (t == typeof(ulong)) return r.ReadUInt64(); if (t == typeof(short)) return r.ReadInt16(); if (t == typeof(ushort)) return r.ReadUInt16(); if (t == typeof(Actor)) { Actor ret; if (result) result = TryGetActorFromUInt(world, r.ReadUInt32(), out ret); else TryGetActorFromUInt(world, r.ReadUInt32(), out ret); return ret; } throw new Exception("Tried to deserialize unhandled type."); }
public EncounterGift6(byte[] data, bool oras) { Data = data; ORAS = oras; using (BinaryReader br = new BinaryReader(new MemoryStream(Data))) { Species = br.ReadUInt16(); u2 = br.ReadUInt16(); Form = br.ReadByte(); Level = br.ReadByte(); Shiny = br.ReadByte(); Ability = br.ReadSByte(); Nature = br.ReadSByte(); u9 = br.ReadByte(); uA = br.ReadByte(); uB = br.ReadByte(); HeldItem = br.ReadInt32(); Gender = br.ReadSByte(); if (ORAS) { u11 = br.ReadByte(); MetLocation = br.ReadInt16(); Move = br.ReadUInt16(); } for (int i = 0; i < 6; i++) IVs[i] = br.ReadSByte(); if (ORAS) { ContestStats = br.ReadBytes(6); u22 = br.ReadByte(); } uLast = br.ReadByte(); } }
public Group(BinaryReader r) { flags = (Flags)r.ReadByte(); name = ASCIIEncoding.ASCII.GetString(r.ReadBytes(32)).Split((char)0)[0]; numTriangles = r.ReadUInt16(); triangleIndices = new ushort[numTriangles]; for (int i = 0; i < numTriangles; i++) { triangleIndices[i] = r.ReadUInt16(); } materialIndex = r.ReadSByte(); }
static private sbyte[] streamToSbyte(BinaryReader stream, int length) { List<sbyte> list = new List<sbyte>(); { sbyte ch; var i = 0; while ((ch = stream.ReadSByte()) != -1 && i < length) { list.Add(ch); i++; } } return list.ToArray(); }
public static PmdMaterial Parse(BinaryReader br) { return new PmdMaterial { Diffuse = new[] { br.ReadSingle(), br.ReadSingle(), br.ReadSingle(), br.ReadSingle() }, Power = br.ReadSingle(), Specular = new[] { br.ReadSingle(), br.ReadSingle(), br.ReadSingle() }, Ambient = new[] { br.ReadSingle(), br.ReadSingle(), br.ReadSingle() }, ToonIndex = br.ReadSByte(), NoEdge = br.ReadBoolean(), IndexCount = br.ReadInt32(), Texture = PmdDocument.ReadPmdString(br, 20), }; }
public override IEnumerable <Tone> ImportToneFile(string fileName) { string ext = System.IO.Path.GetExtension(fileName); var Option = new Option(); List <Tone> tones = new List <Tone>(); try { switch (ext.ToUpper(CultureInfo.InvariantCulture)) { case ".WOPL": { using (var file = new System.IO.BinaryReader(new System.IO.FileStream(fileName, System.IO.FileMode.Open))) { file.BaseStream.Seek(0x11, System.IO.SeekOrigin.Begin); { var val = file.ReadByte(); //if ((val & 1) != 0) // tone.AMD = 1; //if ((val & 2) != 0) // tone.VIB = 1; } file.BaseStream.Seek(0x57, System.IO.SeekOrigin.Begin); for (int i = 0; i < 128; i++) { Tone tone1 = new Tone(); Tone tone2 = new Tone(); tone1.Number = i * 2; tone2.Number = i * 2 + 1; //32 var name = Encoding.ASCII.GetString(file.ReadBytes(32)); var nidx = name.IndexOf('\0'); if (nidx >= 0) { name = name.Substring(0, nidx); } if (name != null && name.Length != 0) { tone1.Name = name; tone2.Name = name + "(2nd)"; } //2 tone1.KeyShift = YMF262.ReadInt16Big(file); //2 tone2.KeyShift = YMF262.ReadInt16Big(file); //1 file.ReadByte(); //MIDI Velocity offset //1 tone2.PitchShift = file.ReadSByte(); //1 //DrumTimbres[i].BaseNote = (NoteNames)file.ReadByte(); file.ReadByte(); //1 var opmode = file.ReadByte(); if (opmode == 0) //2OP { setRegisters(file, tone1, null); tones.Add(tone1); } else if (opmode == 1) //4OP { setRegisters(file, tone1, tone2); tone1.CNT = (tone1.CNT << 1 | tone2.CNT) + 2; tone1.FB2 = tone2.FB; tone1.aOp[2] = tone2.aOp[0]; tone1.aOp[3] = tone2.aOp[1]; tones.Add(tone1); } else if (opmode == 3) { setRegisters(file, tone1, tone2); tones.Add(tone1); tones.Add(tone2); } else if ((opmode & 4) == 4) { //empty } else { // System.Windows.Forms.MessageBox.Show("Unsupported op mode " + opmode); } } for (int i = 0; i < 128; i++) { Tone tone1 = new Tone(); Tone tone2 = new Tone(); tone1.Number = i * 2 + 256; tone2.Number = i * 2 + 256 + 1; //32 var name = Encoding.ASCII.GetString(file.ReadBytes(32)); var nidx = name.IndexOf('\0'); if (nidx >= 0) { name = name.Substring(0, nidx); } if (name != null && name.Length != 0) { tone1.Name = name; tone2.Name = name + "(2nd)"; } else { tone1.Name = tone1.Number.ToString(); tone2.Name = tone2.Number.ToString(); } //2 tone1.KeyShift = ReadInt16Big(file); //2 tone2.KeyShift = ReadInt16Big(file); //1 file.ReadByte(); //MIDI Velocity offset //1 tone2.PitchShift = file.ReadSByte(); //1 //TODO: Drum //DrumTimbres[i].BaseNote = (NoteNames)file.ReadByte(); file.ReadByte(); //1 var opmode = file.ReadByte(); if (opmode == 0) //2OP { setRegisters(file, tone1, null); tones.Add(tone1); } else if (opmode == 1) //4OP { setRegisters(file, tone1, tone2); tone1.CNT = (tone1.CNT << 1 | tone2.CNT) + 2; tone1.aOp[2] = tone2.aOp[0]; tone1.aOp[3] = tone2.aOp[1]; tones.Add(tone1); } else if (opmode == 3) { setRegisters(file, tone1, tone2); tones.Add(tone1); tones.Add(tone2); } else if ((opmode & 4) == 4) { //empty } else { // System.Windows.Forms.MessageBox.Show("Unsupported op mode " + opmode); } } } } break; case ".OPL": { List <Head> list = new List <Head>(); byte maxBankNumber = 0; using (var file = new System.IO.BinaryReader(new System.IO.FileStream(fileName, System.IO.FileMode.Open))) { while (true) { //read head Head p = new Head(); p.Patch = file.ReadByte(); p.Bank = file.ReadByte(); p.Offset = file.ReadUInt32(); if (p.Patch == 0xff && p.Bank == 0xff) { break; } if ((p.Bank != 0x7F) && (p.Bank > maxBankNumber)) { maxBankNumber = p.Bank; } list.Add(p); } ; for (int i = 0; i < list.Count; i++) { var p = list[i]; file.BaseStream.Seek(p.Offset, System.IO.SeekOrigin.Begin); bool isPerc = (p.Bank == 0x7F); int gmPatchId = isPerc ? p.Patch : (p.Patch + (p.Bank * 128)); ushort insLen = file.ReadUInt16(); insLen -= 2; byte[] idata = new byte[24]; if (insLen < 24) { idata = file.ReadBytes(insLen); } else { idata = file.ReadBytes(24); file.BaseStream.Seek(insLen - 24, System.IO.SeekOrigin.Current); } //var tim = Timbres[p.Patch + (isPerc ? 128 : 0)]; Tone tone = new Tone(); tone.Number = i; tone.Name = i.ToString(); //ins.percNoteNum = (isPerc) ? idata[0] : 0; //ins.note_offset1 = (isPerc) ? 0 : idata[0]; //if (isPerc) //{ // var t = DrumTimbres[p.Patch]; // t.BaseNote = (NoteNames)idata[0]; // t.TimbreNumber = (ProgramAssignmentNumber)(p.Patch + 128); //} tone.aOp[0].AM = (byte)((idata[1] >> 7) & 0x1); tone.aOp[0].VIB = (byte)((idata[1] >> 6) & 0x1); tone.aOp[0].EG = (byte)((idata[1] >> 5) & 0x1); tone.aOp[0].KSR = (byte)((idata[1] >> 4) & 0x1); tone.aOp[0].ML = (byte)((idata[1]) & 0xf); tone.aOp[0].KS = (byte)((idata[2] >> 6) & 0x03); tone.aOp[0].TL = (byte)((idata[2]) & 0x3f); tone.aOp[0].AR = (byte)((idata[3] >> 4) & 0x0f); tone.aOp[0].DR = (byte)((idata[3]) & 0x0f); tone.aOp[0].SL = (byte)((idata[4] >> 4) & 0x0f); tone.aOp[0].SR = -1; tone.aOp[0].RR = (byte)((idata[4]) & 0x0f); tone.aOp[0].WS = (byte)((idata[5]) & 0x07); tone.aOp[1].AM = (byte)((idata[7] >> 7) & 0x1); tone.aOp[1].VIB = (byte)((idata[7] >> 6) & 0x1); tone.aOp[1].EG = (byte)((idata[7] >> 5) & 0x1); tone.aOp[1].KSR = (byte)((idata[7] >> 4) & 0x1); tone.aOp[1].ML = (byte)((idata[7]) & 0xf); tone.aOp[1].KS = (byte)((idata[8] >> 6) & 0x03); tone.aOp[1].TL = (byte)((idata[8]) & 0x3f); tone.aOp[1].AR = (byte)((idata[9] >> 4) & 0x0f); tone.aOp[1].DR = (byte)((idata[9]) & 0x0f); tone.aOp[1].SL = (byte)((idata[10] >> 4) & 0x0f); tone.aOp[1].SR = -1; tone.aOp[1].RR = (byte)((idata[10]) & 0x0f); tone.aOp[1].WS = (byte)((idata[11]) & 0x07); tone.CNT = (byte)((idata[6]) & 0x01); tone.FB = (byte)((idata[6] >> 1) & 0x07); tones.Add(tone); } } } break; default: return(base.ImportToneFile(fileName)); } } catch (Exception ex) { if (ex.GetType() == typeof(Exception)) { throw; } else if (ex.GetType() == typeof(SystemException)) { throw; } MessageBox.Show(Resources.FailedLoadFile + "\r\n" + ex.Message); } return(tones); }
public override sbyte ReadScalarValue(System.IO.BinaryReader br) { var r = br.ReadSByte(); return(r); }