/// <summary> /// Update the file. /// </summary> public void update() { magic = "CISP".ToCharArray(); stream.magic = "STRM".ToCharArray(); stream.numberOfChannels = (byte)channelData.Count; stream.numberOfTracks = (UInt32)tracks.Count; if (stream.numberOfChannels == 0) { stream.sampleSize = 0; } else { stream.sampleSize = (UInt32)(channelData[0].Count() * 2); } seekBlock = new byte[0]; seekSize = (UInt32)seekBlock.Length; channelMagic = "CHAN".ToCharArray(); for (int i = 0; i < tracks.Count; i++) { trackInfo t = tracks[i]; t.channelCount = (UInt32)tracks[i].channels.Count; t.magic = "TRAC".ToCharArray(); tracks[i] = t; } }
/// <summary> /// Read a file. /// </summary> /// <param name="b"></param> public void load(byte[] b) { MemoryStream src = new MemoryStream(b); BinaryDataReader br = new BinaryDataReader(src); br.ByteOrder = ByteOrder.LittleEndian; //Magic. magic = br.ReadChars(4); //Stream. stream.magic = br.ReadChars(4); stream.loop = br.ReadByte(); stream.numberOfChannels = br.ReadByte(); stream.sampleRate = br.ReadUInt32(); stream.loopStart = br.ReadUInt32(); stream.loopEnd = br.ReadUInt32(); stream.numberOfTracks = br.ReadUInt32(); stream.sampleSize = br.ReadUInt32(); //Tracks. tracks = new List <trackInfo>(); for (int i = 0; i < (int)stream.numberOfTracks; i++) { trackInfo t = new trackInfo(); t.magic = br.ReadChars(4); t.volume = br.ReadByte(); t.pan = br.ReadByte(); t.flags = br.ReadUInt16(); t.channelCount = br.ReadUInt32(); t.channels = new List <byte>(); for (int j = 0; j < t.channelCount; j++) { t.channels.Add(br.ReadByte()); } tracks.Add(t); } //Seek. seekSize = br.ReadUInt32(); seekBlock = br.ReadBytes((int)seekSize); //Channels. channelMagic = br.ReadChars(4); channelData = new List <UInt16[]>(); for (int i = 0; i < stream.numberOfChannels; i++) { List <UInt16> channel = new List <UInt16>(); for (int j = 0; j < (int)(stream.sampleSize / 2); j++) { channel.Add(br.ReadUInt16()); } channelData.Add(channel.ToArray()); } }
public static wrInfo getWR(string track, string CName) { wrInfo wi; try { trackInfo tt = (trackTable[track] as trackInfo); wi = (wrInfo)tt.carTable[CName]; return(wi); } catch { return(null); } }
public static bool load(string user, string pass, string idk) { string readLine; long split1 = 0; long split2 = 0; long split3 = 0; long lastSplit = 0; long sectorSplit1 = 0; long sectorSplit2 = 0; long sectorSplit3 = 0; long sectorSplitLast = 0; long WRTime = 0; // using (System.IO.StreamReader sr = new System.IO.StreamReader("./lfswr.txt")) string url; if (idk == "" && user == "" && pass == "") { return(false); } if (idk != null) { url = "http://www.lfsworld.net/pubstat/get_stat2.php?version=1.3&idk=" + idk + "&action=wr"; } else { url = "http://www.lfsworld.net/pubstat/get_stat2.php?version=1.3&user="******"&pass="******"&action=wr"; } WebRequest req = WebRequest.Create(url); WebResponse result = req.GetResponse(); Stream receiveStream = result.GetResponseStream(); using (StreamReader sr = new StreamReader(receiveStream)) { while (true) { readLine = sr.ReadLine(); if (readLine == null) { break; } if (readLine.IndexOf("Identification") != -1) { return(false); } if (readLine.IndexOf("can't") != -1) { return(false); } string[] mline = readLine.Split(' '); string track = convTrack(mline[1]); string car = mline[2]; lastSplit = 0; sectorSplit1 = 0; sectorSplit2 = 0; sectorSplit3 = 0; sectorSplitLast = 0; split1 = long.Parse(mline[3]); sectorSplit1 = split1 - lastSplit; lastSplit = split1; split2 = long.Parse(mline[4]); if (split2 != 0) { sectorSplit2 = split2 - lastSplit; lastSplit = split2; } split3 = long.Parse(mline[5]); if (split3 != 0) { sectorSplit3 = split3 - lastSplit; lastSplit = split3; } WRTime = long.Parse(mline[6]); sectorSplitLast = WRTime - lastSplit; if (!trackTable.ContainsKey(track)) { trackTable[track] = new trackInfo(track); } trackInfo tt = (trackTable[track] as trackInfo); if (!tt.carTable.ContainsKey(car)) { tt.carTable[car] = new wrInfo(track, car, WRTime, split1, split2, split3, sectorSplit1, sectorSplit2, sectorSplit3, sectorSplitLast); } } } return(true); }
public static bool load(string user, string pass, string idk) { string readLine; long split1 = 0; long split2 = 0; long split3 = 0; long lastSplit = 0; long sectorSplit1 = 0; long sectorSplit2 = 0; long sectorSplit3 = 0; long sectorSplitLast = 0; long WRTime = 0; // using (System.IO.StreamReader sr = new System.IO.StreamReader("./lfswr.txt")) string url; if (idk == "" && user == "" && pass == "") { return false; } if (idk != null) url = "http://www.lfsworld.net/pubstat/get_stat2.php?version=1.3&idk=" + idk + "&action=wr"; else url = "http://www.lfsworld.net/pubstat/get_stat2.php?version=1.3&user="******"&pass="******"&action=wr"; WebRequest req = WebRequest.Create(url); WebResponse result = req.GetResponse(); Stream receiveStream = result.GetResponseStream(); using (StreamReader sr = new StreamReader(receiveStream)) { while (true) { readLine = sr.ReadLine(); if (readLine == null) break; if (readLine.IndexOf("Identification") != -1) return false; if (readLine.IndexOf("can't") != -1) return false; string[] mline = readLine.Split(' '); string track = convTrack( mline[1] ); string car = mline[2]; lastSplit = 0; sectorSplit1 = 0; sectorSplit2 = 0; sectorSplit3 = 0; sectorSplitLast = 0; split1 = long.Parse(mline[3]); sectorSplit1 = split1 - lastSplit; lastSplit = split1; split2 = long.Parse(mline[4]); if( split2 != 0 ){ sectorSplit2 = split2 - lastSplit; lastSplit = split2; } split3 = long.Parse(mline[5]); if( split3 != 0 ){ sectorSplit3 = split3 - lastSplit; lastSplit = split3; } WRTime = long.Parse(mline[6]); sectorSplitLast = WRTime - lastSplit; if (!trackTable.ContainsKey(track)) { trackTable[track] = new trackInfo(track); } trackInfo tt = (trackTable[track] as trackInfo); if (!tt.carTable.ContainsKey(car)) { tt.carTable[car] = new wrInfo(track, car, WRTime, split1, split2, split3, sectorSplit1, sectorSplit2, sectorSplit3, sectorSplitLast ); } } } return true; }