public static void Calculate32 (List<Node> result, Beat beat, int distance_from_start, Panel a, Panel b, Panel c, Panel d, Panel e) { if (!Panel.IsBracketable(a.index, b.index, c.index) || !Panel.IsBracketable(d.index, e.index)) { return; } bool is_force_tap = beat.notes[d.index_playable].tap == TapType.Force && beat.notes[e.index_playable].tap == TapType.Force; Panel front = LimbHelper.GetFrontPanel(a, b, c); Panel back = LimbHelper.GetBackPanel(a, b, c); Panel center = LimbHelper.GetCenterPanel(a, b, c); Iterate.Foot2((foot_a, foot_b) => { bool face_front = (back.index < d.index || back.index < e.index); if (foot_a == Node.INDEX_RIGHT_FOOT) { face_front = !face_front; } Iterate.Part2(foot_b, d.index, e.index, (b_0, b_1) => { if ( is_force_tap && ( b_0 == Limb.INDEX_EXTRA || b_1 == Limb.INDEX_EXTRA ) ) { return; } Node state = new Node(beat.second, distance_from_start); state.limbs[foot_a] = new Limb(); LimbHelper.Do3Bracket(state, foot_a, face_front, beat, a, b, c); state.limbs[foot_b] = new Limb(); state.limbs[foot_b][b_0] = new Part(beat, d); state.limbs[foot_b][b_1] = new Part(beat, e); state.sanityCheck(); result.Add(state); }); }); }
public static void Calculate31 (List<Node> result, Beat beat, int distance_from_start, Panel a, Panel b, Panel c, Panel d) { if (!Panel.IsBracketable(a.index, b.index, c.index)) { return; } Iterate.Foot2((foot_a, foot_b) => { Iterate.Part1(foot_b, (b_0) => { { Node state = new Node(beat.second, distance_from_start); state.limbs[foot_a] = new Limb(); LimbHelper.Do3Bracket(state, foot_a, true, beat, a, b, c); state.limbs[foot_b] = new Limb(); state.limbs[foot_b][b_0] = new Part(beat, d); state.sanityCheck(); result.Add(state); } { Node state = new Node(beat.second, distance_from_start); state.limbs[foot_a] = new Limb(); LimbHelper.Do3Bracket(state, foot_a, false, beat, a, b, c); state.limbs[foot_b] = new Limb(); state.limbs[foot_b][b_0] = new Part(beat, d); state.sanityCheck(); result.Add(state); } }); }); }
public static void Calculate22 (List<Node> result, Beat beat, int distance_from_start, Panel a, Panel b, Panel c, Panel d) { if (!Panel.IsBracketable(a.index, b.index) || !Panel.IsBracketable(c.index, d.index)) { return; } bool is_force_tap = beat.hasTapTypeOrNoneOnly(TapType.Force); Iterate.Foot2((foot_a, foot_b) => { Iterate.Part2(foot_a, a.index, b.index, (a_0, a_1) => { Iterate.Part2(foot_b, c.index, d.index, (b_0, b_1) => { if ( is_force_tap && ( a_0 == Limb.INDEX_EXTRA || a_1 == Limb.INDEX_EXTRA || b_0 == Limb.INDEX_EXTRA || b_1 == Limb.INDEX_EXTRA ) ) { return; } Node state = new Node(beat.second, distance_from_start); state.limbs[foot_a] = new Limb(); state.limbs[foot_a][a_0] = new Part(beat, a); state.limbs[foot_a][a_1] = new Part(beat, b); state.limbs[foot_b] = new Limb(); state.limbs[foot_b][b_0] = new Part(beat, c); state.limbs[foot_b][b_1] = new Part(beat, d); state.sanityCheck(); result.Add(state); }); }); }); }
public static void Do3Bracket (Node state, int limb_index, bool face_front, Beat beat, Panel a, Panel b, Panel c) { Limb limb = state.limbs[limb_index]; Panel front = GetFrontPanel(a, b, c); Panel back = GetBackPanel(a, b, c); Panel center = GetCenterPanel(a, b, c); if (limb_index == Node.INDEX_LEFT_FOOT) { if (face_front) { limb.setMain(beat, back); if (back.direction_x == PanelDirectionX.Left) { limb.setSub(beat, center); limb.setExtra(beat, front); } else { limb.setSub(beat, front); limb.setExtra(beat, center); } } else { limb.setMain(beat, front); if (front.direction_x == PanelDirectionX.Right) { limb.setSub(beat, center); limb.setExtra(beat, back); } else { limb.setSub(beat, back); limb.setExtra(beat, center); } } } else if (limb_index == Node.INDEX_RIGHT_FOOT) { if (face_front) { limb.setMain(beat, back); if (back.direction_x == PanelDirectionX.Right) { limb.setSub(beat, center); limb.setExtra(beat, front); } else { limb.setSub(beat, front); limb.setExtra(beat, center); } } else { limb.setMain(beat, front); if (front.direction_x == PanelDirectionX.Left) { limb.setSub(beat, center); limb.setExtra(beat, back); } else { limb.setSub(beat, back); limb.setExtra(beat, center); } } } else { throw new ArgumentException(); } }
public static void Calculate1 (List<Node> result, Beat beat, int distance_from_start, Panel a) { bool is_force_tap = beat.hasTapTypeOrNoneOnly(TapType.Force); Iterate.Foot1((foot) => { Iterate.Part1(foot, (_0) => { if (is_force_tap && _0 == Limb.INDEX_EXTRA) { return; } Node state = new Node(beat.second, distance_from_start); state.limbs[foot] = new Limb(); state.limbs[foot][_0] = new Part(beat, a); state.sanityCheck(); result.Add(state); }); }); }
// Use this for initialization void Start () { for (int i = 0; i < 4; i++) { blocks[i] = Instantiate(block); } initBlocks(); done = false; myBeat = this.GetComponent<Beat>(); timeToLive = 5; StartCoroutine(timeUntilDeath()); }
public static void Calculate2 (List<Node> result, Beat beat, int distance_from_start, Panel a, Panel b) { if (!Panel.IsBracketable(a.index, b.index)) { return; } bool is_force_tap = beat.hasTapTypeOrNoneOnly(TapType.Force); Iterate.Foot1((foot) => { Iterate.Part2(foot, a.index, b.index, (_0, _1) => { if (is_force_tap && (_0 == Limb.INDEX_EXTRA || _1 == Limb.INDEX_EXTRA)) { return; } Node state = new Node(beat.second, distance_from_start); state.limbs[foot] = new Limb(); state.limbs[foot][_0] = new Part(beat, a); state.limbs[foot][_1] = new Part(beat, b); state.sanityCheck(); result.Add(state); }); }); }
public static void Calculate11 (List<Node> result, Beat beat, int distance_from_start, Panel a, Panel b) { bool is_force_tap = beat.hasTapTypeOrNoneOnly(TapType.Force); Iterate.Foot2((foot_a, foot_b) => { Iterate.Part1(foot_a, (a_0) => { Iterate.Part1(foot_b, (b_0) => { if (is_force_tap && (a_0 == Limb.INDEX_EXTRA || b_0 == Limb.INDEX_EXTRA)) { return; } Node state = new Node(beat.second, distance_from_start); state.limbs[foot_a] = new Limb(); state.limbs[foot_a][a_0] = new Part(beat, a); state.limbs[foot_b] = new Limb(); state.limbs[foot_b][b_0] = new Part(beat, b); state.sanityCheck(); result.Add(state); }); }); }); }
public static void Calculate33 (List<Node> result, Beat beat, int distance_from_start, Panel a, Panel b, Panel c, Panel d, Panel e, Panel f) { if (!Panel.IsBracketable(a.index, b.index, c.index) || !Panel.IsBracketable(d.index, e.index, f.index)) { return; } Panel front_a = LimbHelper.GetFrontPanel(a, b, c); Panel back_a = LimbHelper.GetBackPanel(a, b, c); Panel center_a = LimbHelper.GetCenterPanel(a, b, c); Panel front_b = LimbHelper.GetFrontPanel(d, e, f); Panel back_b = LimbHelper.GetBackPanel(d, e, f); Panel center_b = LimbHelper.GetCenterPanel(d, e, f); Iterate.Foot2((foot_a, foot_b) => { bool face_front = (back_a.index < back_b.index); if (foot_a == Node.INDEX_RIGHT_FOOT) { face_front = !face_front; } Node state = new Node(beat.second, distance_from_start); state.limbs[foot_a] = new Limb(); LimbHelper.Do3Bracket(state, foot_a, face_front, beat, front_a, back_a, center_a); state.limbs[foot_b] = new Limb(); LimbHelper.Do3Bracket(state, foot_b, face_front, beat, front_b, back_b, center_b); state.sanityCheck(); result.Add(state); }); }
private static bool CanSkip (Beat cur, Beat prv) { if (cur.notes.Count != prv.notes.Count) { return false; } for (int i = 0; i < cur.notes.Count; ++i) { TapType cur_tap = cur.notes[i].tap; TapType prv_tap = prv.notes[i].tap; bool cur_is_body = (cur_tap == TapType.PassiveStay); bool prv_is_head_or_body = ( prv_tap == TapType.PassiveBegin || prv_tap == TapType.PassiveStay ); if (cur_is_body != prv_is_head_or_body) { return false; } } return true; }
public void ReadBeatEffects(Beat beat) { var flags = Data.ReadByte(); var flags2 = 0; if (_versionNumber >= 400) { flags2 = Data.ReadByte(); } beat.FadeIn = (flags & 0x10) != 0; if ((_versionNumber < 400 && (flags & 0x01) != 0) || (flags & 0x02) != 0) { beat.Vibrato = VibratoType.Slight; } beat.HasRasgueado = (flags2 & 0x01) != 0; if ((flags & 0x20) != 0 && _versionNumber >= 400) { var slapPop = Data.ReadSignedByte(); switch (slapPop) { case 1: beat.Tap = true; break; case 2: beat.Slap = true; break; case 3: beat.Pop = true; break; } } else if ((flags & 0x20) != 0) { var slapPop = Data.ReadSignedByte(); switch (slapPop) { case 1: beat.Tap = true; break; case 2: beat.Slap = true; break; case 3: beat.Pop = true; break; } Data.Skip(4); } if ((flags2 & 0x04) != 0) { ReadTremoloBarEffect(beat); } if ((flags & 0x40) != 0) { int strokeUp; int strokeDown; if (_versionNumber < 500) { strokeDown = Data.ReadByte(); strokeUp = Data.ReadByte(); } else { strokeUp = Data.ReadByte(); strokeDown = Data.ReadByte(); } if (strokeUp > 0) { beat.BrushType = BrushType.BrushUp; beat.BrushDuration = ToStrokeValue(strokeUp); } else if (strokeDown > 0) { beat.BrushType = BrushType.BrushDown; beat.BrushDuration = ToStrokeValue(strokeDown); } } if ((flags2 & 0x02) != 0) { switch (Data.ReadSignedByte()) { case 0: beat.PickStroke = PickStrokeType.None; break; case 1: beat.PickStroke = PickStrokeType.Up; break; case 2: beat.PickStroke = PickStrokeType.Down; break; } } }
public BeatGlyphBase GetOnNotesGlyphForBeat(Beat beat) { return(GetBeatContainer(beat).OnNotes); }
public void ReadMixTableChange(Beat beat) { var tableChange = new MixTableChange(); tableChange.Instrument = Data.ReadSignedByte(); if (_versionNumber >= 500) { Data.Skip(16); // Rse Info } tableChange.Volume = Data.ReadSignedByte(); tableChange.Balance = Data.ReadSignedByte(); var chorus = Data.ReadSignedByte(); var reverb = Data.ReadSignedByte(); var phaser = Data.ReadSignedByte(); var tremolo = Data.ReadSignedByte(); if (_versionNumber >= 500) { tableChange.TempoName = ReadStringIntByte(); } tableChange.Tempo = ReadInt32(); // durations if (tableChange.Volume >= 0) { Data.ReadByte(); } if (tableChange.Balance >= 0) { Data.ReadByte(); } if (chorus >= 0) { Data.ReadByte(); } if (reverb >= 0) { Data.ReadByte(); } if (phaser >= 0) { Data.ReadByte(); } if (tremolo >= 0) { Data.ReadByte(); } if (tableChange.Tempo >= 0) { tableChange.Duration = Data.ReadSignedByte(); if (_versionNumber >= 510) { Data.ReadByte(); // hideTempo (bool) } } if (_versionNumber >= 400) { Data.ReadByte(); // all tracks flag } // unknown if (_versionNumber >= 500) { Data.ReadByte(); } // unknown if (_versionNumber >= 510) { ReadStringIntByte(); ReadStringIntByte(); } if (tableChange.Volume >= 0) { var volumeAutomation = new Automation(); volumeAutomation.IsLinear = true; volumeAutomation.Type = AutomationType.Volume; volumeAutomation.Value = tableChange.Volume; beat.Automations.Add(volumeAutomation); } if (tableChange.Balance >= 0) { var balanceAutomation = new Automation(); balanceAutomation.IsLinear = true; balanceAutomation.Type = AutomationType.Balance; balanceAutomation.Value = tableChange.Balance; beat.Automations.Add(balanceAutomation); } if (tableChange.Instrument >= 0) { var instrumentAutomation = new Automation(); instrumentAutomation.IsLinear = true; instrumentAutomation.Type = AutomationType.Instrument; instrumentAutomation.Value = tableChange.Instrument; beat.Automations.Add(instrumentAutomation); } if (tableChange.Tempo >= 0) { var tempoAutomation = new Automation(); tempoAutomation.IsLinear = true; tempoAutomation.Type = AutomationType.Tempo; tempoAutomation.Value = tableChange.Tempo; beat.Automations.Add(tempoAutomation); beat.Voice.Bar.MasterBar.TempoAutomation = tempoAutomation; } }
private void beatListxmlToolStripMenuItem_Click(object sender, EventArgs e) { System.Windows.Forms.OpenFileDialog openDlg = new OpenFileDialog(); openDlg.Filter = "All Files(*.*)|*.*|XML Files(*.xml)|*.xml"; openDlg.FilterIndex = 2; // Set the default extension openDlg.DefaultExt = "xml"; //*****************OPENING DIALOG***********************// if (openDlg.ShowDialog() == DialogResult.OK) { XElement root = XElement.Load(openDlg.FileName); string associatedFilePath = ""; string associatedFileName = ""; //******************SETTING FILEPATH FROM SETTINGS *********************// if (Properties.Settings.Default.AssociatedFileDirectory != null) { // The Associated File Directory is saves in the programms settings // this is retreiving the directory from the programs settings and setting it up for use associatedFilePath = Properties.Settings.Default.AssociatedFileDirectory; } //******************GETTING SONG FILENAME*****************************// XAttribute fileName = root.Attribute("file"); if (fileName != null) { associatedFileName = Convert.ToString(fileName.Value); szSongFileName = associatedFileName; } XAttribute songName = root.Attribute("name"); if (songName != null) szSongName = Convert.ToString(songName.Value); //*****************LOADING MUSIC FILE***********************************// if (!System.IO.File.Exists(associatedFilePath + associatedFileName)) { // the file was not found so we must reaquire the associated file if (System.Windows.Forms.MessageBox.Show("\"" + associatedFileName + "\" can not be found in \"" + associatedFilePath + "\". Please relocate " + associatedFileName) == DialogResult.OK) { musicTrackToolStripMenuItem_Click(null, null); } } else { LoadMusic(associatedFilePath + associatedFileName); szSongFileName = associatedFileName; } // Loading Icon Images XElement xIcons = root.Element("icons"); XAttribute wIcon = xIcons.Attribute("wkey"); szWKeyImage = wIcon.Value; XAttribute aIcon = xIcons.Attribute("akey"); szAKeyImage = aIcon.Value; XAttribute sIcon = xIcons.Attribute("skey"); szSKeyImage = sIcon.Value; XAttribute dIcon = xIcons.Attribute("dkey"); szDKeyImage = dIcon.Value; //*******************LOADING ICONS***************************************// //**************W KEY****************************************// if (!System.IO.File.Exists(Properties.Settings.Default.IconFilePath + szWKeyImage)) { // the file was not found so we must reaquire the associated file if (System.Windows.Forms.MessageBox.Show("\"" + szWKeyImage + "\" can not be found in \"" + Properties.Settings.Default.IconFilePath + "\". Please relocate " + szWKeyImage) == DialogResult.OK) { loadWImageToolStripMenuItem_Click(null, null); } } else { KeyW = TEXMAN.LoadTexture(Properties.Settings.Default.IconFilePath + szWKeyImage, 0); WKeyPictureBox.BackgroundImage = new Bitmap(Properties.Settings.Default.IconFilePath + szWKeyImage); if (TEXMAN.GetTextureWidth(KeyW) >= 20) scaleX = 0.5f; if (TEXMAN.GetTextureHeight(KeyW) >= 20) scaleY = 0.5f; if (TEXMAN.GetTextureWidth(KeyW) >= 50) scaleX = 0.25f; if (TEXMAN.GetTextureHeight(KeyW) >= 50) scaleY = 0.25f; } //***************A KEY*****************************************// if (!System.IO.File.Exists(Properties.Settings.Default.IconFilePath + szAKeyImage)) { // the file was not found so we must reaquire the associated file if (System.Windows.Forms.MessageBox.Show("\"" + szAKeyImage + "\" can not be found in \"" + Properties.Settings.Default.IconFilePath + "\". Please relocate " + szAKeyImage) == DialogResult.OK) { loadAImageToolStripMenuItem_Click(null, null); } } else { KeyA = TEXMAN.LoadTexture(Properties.Settings.Default.IconFilePath + szAKeyImage, 0); AKeyPictureBox.BackgroundImage = new Bitmap(Properties.Settings.Default.IconFilePath + szAKeyImage); } //****************S KEY******************************************// if (!System.IO.File.Exists(Properties.Settings.Default.IconFilePath + szSKeyImage)) { // the file was not found so we must reaquire the associated file if (System.Windows.Forms.MessageBox.Show("\"" + szSKeyImage + "\" can not be found in \"" + Properties.Settings.Default.IconFilePath + "\". Please relocate " + szSKeyImage) == DialogResult.OK) { loadSImageToolStripMenuItem_Click(null, null); } } else { KeyS = TEXMAN.LoadTexture(Properties.Settings.Default.IconFilePath + szSKeyImage, 0); SKeyPictureBox.BackgroundImage = new Bitmap(Properties.Settings.Default.IconFilePath + szSKeyImage); } //*****************D KEY*******************************************// if (!System.IO.File.Exists(Properties.Settings.Default.IconFilePath + szDKeyImage)) { // the file was not found so we must reaquire the associated file if (System.Windows.Forms.MessageBox.Show("\"" + szDKeyImage + "\" can not be found in \"" + Properties.Settings.Default.IconFilePath + "\". Please relocate " + szDKeyImage) == DialogResult.OK) { loadDImageToolStripMenuItem_Click(null, null); } } else { KeyD = TEXMAN.LoadTexture(Properties.Settings.Default.IconFilePath + szDKeyImage, 0); DKeyPictureBox.BackgroundImage = new Bitmap(Properties.Settings.Default.IconFilePath + szDKeyImage); } //*****************LOAD BEATS******************************************// IEnumerable<XElement> xBeats = root.Elements("Beat"); if (xBeats != null) { foreach (XElement xBeat in xBeats) { Beat aBeat = new Beat(); // Getting and adding all beat stats XAttribute xTimeofbeat = xBeat.Attribute("timeofbeat"); aBeat.TimeOfBeat = Convert.ToUInt32(xTimeofbeat.Value); XAttribute xDirection = xBeat.Attribute("direction"); aBeat.Direction = xDirection.Value; XAttribute xKey = xBeat.Attribute("key"); aBeat.KeyPress = Convert.ToChar(xKey.Value); XAttribute xDifficulty = xBeat.Attribute("difficulty"); aBeat.Difficulty = xDifficulty.Value; XAttribute xWidth = xBeat.Attribute("width"); aBeat.Width = Convert.ToInt32(xWidth.Value); XAttribute xHeight = xBeat.Attribute("height"); aBeat.Height = Convert.ToInt32(xHeight.Value); XAttribute xBeatIs = xBeat.Attribute("beatis"); aBeat.Completion = (BEATIS)Convert.ToInt32(xBeatIs.Value); XAttribute xEvent = xBeat.Attribute("event"); aBeat.Event = xEvent.Value; if (BEATIS.ARROW == aBeat.Completion || BEATIS.COMPLETE == aBeat.Completion) { if (aBeat.Direction == "left") aBeat.ArrowTextureIndex = ArrowLeft; else if (aBeat.Direction == "right") aBeat.ArrowTextureIndex = ArrowRight; else if (aBeat.Direction == "up") aBeat.ArrowTextureIndex = ArrowUp; else if (aBeat.Direction == "down") aBeat.ArrowTextureIndex = ArrowDown; else if (aBeat.Direction == "leftdown") aBeat.ArrowTextureIndex = ArrowDownLeft; else if (aBeat.Direction == "rightdown") aBeat.ArrowTextureIndex = ArrowDownRight; else if (aBeat.Direction == "leftup") aBeat.ArrowTextureIndex = ArrowUpLeft; else if (aBeat.Direction == "rightup") aBeat.ArrowTextureIndex = ArrowUpRight; } if (BEATIS.KEY == aBeat.Completion || BEATIS.COMPLETE == aBeat.Completion) { switch (aBeat.KeyPress) { case 'w': aBeat.TextureIndex = KeyW; break; case 'a': aBeat.TextureIndex = KeyA; break; case 's': aBeat.TextureIndex = KeyS; break; case 'd': aBeat.TextureIndex = KeyD; break; } } // Adding beat to beatList listBeats.Add(aBeat); } } // Making sure the bListChanged = true; // Again..... being anal GC.Collect(); } }
public abstract EffectGlyph CreateNewGlyph(BarRendererBase renderer, Beat beat);
public bool CanExpand(EffectBarRenderer renderer, Beat @from, Beat to) { return(true); }
private void NotePasteButton_Click(object sender, EventArgs e) { if (CopiedBeats.Count > 0) { // Previous beat to get time splice from Beat lastBeat = new Beat(listBeats[CopiedBeats[0]]); // Adding first beat to list lastBeat.TimeOfBeat = nCurrentPositionMS; listBeats.Add(lastBeat); for (int i = 1; i < CopiedBeats.Count; ++i) { // Getting spread of last beat from original list and this beat, and adding current time to it Beat nextBeat = new Beat(listBeats[CopiedBeats[i]]); nextBeat.TimeOfBeat = (listBeats[CopiedBeats[i]].TimeOfBeat - listBeats[CopiedBeats[0]].TimeOfBeat) + nCurrentPositionMS; // Adding new beat listBeats.Add(nextBeat); } // Setting it so it gets sorted bListChanged = true; } }
public bool ShouldCreateGlyph(EffectBarRenderer renderer, Beat beat) { return(!beat.Text.IsNullOrWhiteSpace()); }
public EffectGlyph CreateNewGlyph(EffectBarRenderer renderer, Beat beat) { return(new TextGlyph(0, 0, beat.Text, renderer.Resources.EffectFont)); }
public bool ShouldCreateGlyph(Beat beat) { return(beat.Voice.Bar.Staff.Index == 0 && beat.Voice.Index == 0 && beat.Index == 0 && (beat.Voice.Bar.MasterBar.TempoAutomation != null || beat.Voice.Bar.Index == 0)); }
public bool ShouldCreateGlyph(Settings settings, Beat beat) { return(beat.Slap || beat.Pop || beat.Tap); }
public Spring AddBeatSpring(Beat beat, float beatSize, float preBeatSize) { return(AddSpring(beat.AbsoluteStart, beat.CalculateDuration(), beatSize, preBeatSize)); }
private float CalculateTooFast ( Limb cur, Limb prv, Beat cur_beat, Beat prv_beat ) { if (IsGallop(cur, prv, cur_beat, prv_beat)) { return 0.0f; } if ( cur_beat.beat_interval < GALLOP_BEAT_INTERVAL || prv_beat.beat_interval < GALLOP_BEAT_INTERVAL ) { return 0.0f; //Consider making it.. 24? } float delta_second = cur_beat.second - prv_beat.second; if ( delta_second > (cur_beat.seconds_per_beat / GALLOP_BEATS_PER_MEASURE + GALLOP_SECONDS_EPOCH) * 2.0f) { return 0.0f; //Unsure if this is correct.. } List<int> cur_indices = cur.JustMovedIndices(); List<int> prv_indices = prv.JustMovedIndices(); if (cur_indices.Count == 0 || prv_indices.Count == 0) { return 0.0f; } float cost = 0.0f; for (int c = 0; c < cur_indices.Count; ++c) { int cur_index = cur_indices[c]; Part cur_part = cur[cur_index]; for (int p = 0; p < prv_indices.Count; ++p) { int prv_index = prv_indices[p]; Part prv_part = prv[prv_index]; if (cur_part.IsUnknown() || prv_part.IsUnknown()) { continue; } if (cur_index == prv_index) { if (cur_part.panel == prv_part.panel) { //Do nothing? } else { cost += TOO_FAST_COST; } } else { if (cur_part.panel == prv_part.panel) { //Different parts but same panel, a.. part switch? cost += TOO_FAST_COST;//For now, treat it as too fast } else if (Panel.IsBracketable(cur_part.panel.index, prv_part.panel.index)) { //Do nothing, it's a gallop-ish thing } else { //Too fast, probably cost += TOO_FAST_COST; } } } } return cost; }
public ScoreBrushGlyph(Beat beat) : base(0, 0) { _beat = beat; }
public static bool Pump(Beat beat) { //lock (Lock) //{ String beattype = beat.GetType().Name; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri(beat.URL)); beat.Parameters = DefaultParameters; if (beat.Log) { beatlogger = new StreamWriter("heartbeat.log", true); } int totalTries = 0; int totalTriesStream = 0; retry: try { totalTries++; totalTriesStream = 0; beat.Prepare(); // Set all the request settings request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore); byte[] formData = Encoding.ASCII.GetBytes(beat.Parameters); request.ContentLength = formData.Length; request.Timeout = 15000; // 15 seconds retryStream: try { totalTriesStream++; using (Stream requestStream = request.GetRequestStream()) { requestStream.Write(formData, 0, formData.Length); if (Server.logbeat && beat.Log) { BeatLog(beat, beattype + " request sent at " + DateTime.Now.ToString()); } requestStream.Flush(); requestStream.Close(); } } catch (WebException e) { //Server.ErrorLog(e); if (e.Status == WebExceptionStatus.Timeout) { if (Server.logbeat && beat.Log) { #if DEBUG Server.s.Log(beattype + " timeout detected at " + DateTime.Now.ToString()); #endif BeatLog(beat, beattype + " timeout detected at " + DateTime.Now.ToString()); } if (totalTriesStream < max_retries) { goto retryStream; } else { if (Server.logbeat && beat.Log) BeatLog(beat, beattype + " timed out " + max_retries + " times. Aborting this request. " + DateTime.Now.ToString()); Server.s.Log(beattype + " timed out " + max_retries + " times. Aborting this request."); //throw new WebException("Failed during request.GetRequestStream()", e.InnerException, e.Status, e.Response); beatlogger.Close(); return false; } } else if (Server.logbeat && beat.Log) { #if DEBUG Server.s.Log(beattype + " non-timeout exception detected: " + e.Message); #endif BeatLog(beat, beattype + " non-timeout exception detected: " + e.Message); BeatLog(beat, "Stack Trace: " + e.StackTrace); } } //if (hash == null) //{ using (WebResponse response = request.GetResponse()) { using (StreamReader responseReader = new StreamReader(response.GetResponseStream())) { if (Server.logbeat && beat.Log) { #if DEBUG Server.s.Log(beattype + " response received at " + DateTime.Now.ToString()); #endif BeatLog(beat, beattype + " response received at " + DateTime.Now.ToString()); } if (String.IsNullOrEmpty(hash) && response.ContentLength > 0) { // Instead of getting a single line, get the whole damn thing and we'll strip stuff out string line = responseReader.ReadToEnd().Trim(); if (Server.logbeat && beat.Log) { BeatLog(beat, "Received: " + line); } beat.OnPump(line); } else { beat.OnPump(String.Empty); } } } } catch (WebException e) { if (e.Status == WebExceptionStatus.Timeout) { if (Server.logbeat && beat.Log) { #if DEBUG Server.s.Log(beattype + " timeout detected at " + DateTime.Now.ToString()); #endif BeatLog(beat, "Timeout detected at " + DateTime.Now.ToString()); } Pump(beat); } } catch (Exception e) { if (Server.logbeat && beat.Log) { BeatLog(beat, beattype + " failure #" + totalTries + " at " + DateTime.Now.ToString()); } if (totalTries < max_retries) goto retry; if (Server.logbeat && beat.Log) { #if DEBUG Server.s.Log(beattype + " failed " + max_retries + " times. Stopping."); #endif BeatLog(beat, "Failed " + max_retries + " times. Stopping."); beatlogger.Close(); } return false; } finally { request.Abort(); } if (beatlogger != null) { beatlogger.Close(); } //} return true; }
public static bool Pump(Beat type) { string postVars = staticVars; string url = "http://minecraft.net/heartbeat.jsp"; int totalTries = 0; retry : try { int hidden = 0; totalTries++; // append additional information as needed switch (type) { case Beat.Minecraft: if (Server.logbeat) { beatlogger = new StreamWriter("heartbeat.log", true); } postVars += "&salt=" + Server.salt; // For custom heartbeats, etc. File.WriteAllLines("hb.data", new string[] { "name = " + Server.name, "port = " + Server.port, "players = " + Player.players.Count, "maxplayers = " + Server.players, "salt = " + Server.salt, "description = " + Server.description, "flags = " + Server.flags }); goto default; // // //MCDawn Beat Coded by Gamemakergm. //and Jonneh (jonnyli1125) //Meep // // case Beat.MCDawn: if (hash == null) { throw new Exception("Hash not set"); } if (Server.logbeat) { beatlogger = new StreamWriter("heartbeat.log", true); } url = "http://servers.mcdawn.com/beat.php"; /*if (Player.number > 0) * { * players = ""; * foreach (Player p in Player.players) * { * if (p.hidden) * { * hidden++; * continue; * } * if (!Server.devs.Contains(p.name.ToLower()) && !Server.staff.Contains(p.name.ToLower())) * players += p.name + " (" + p.group.name + ")" + ","; * if (Server.devs.Contains(p.name.ToLower())) * players += p.name + " (Developer),"; * if (Server.staff.Contains(p.name.ToLower())) * players += p.name + " (MCDawn Staff),"; * } * if (Player.number - hidden > 0) * postVars += "&playernames=" + players.Substring(0, players.Length - 1); * }*/ postVars += "&players=" + Player.number.ToString(); worlds = ""; foreach (Level l in Server.levels) { worlds += l.name + ","; postVars += "&worlds=" + worlds.Substring(0, worlds.Length - 1); } postVars += "&motd=" + UrlEncode(Server.motd) + "&dawnversion=" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + "&hash=" + hash + "&name=" + Server.name + "&public=" + Server.pub + "&maxplayers=" + Server.players.ToString(); if (Server.useglobal) { postVars += "&gcname=" + Server.globalNick; } else { postVars += "&gcname=[Disabled]"; } //postVars += "&lastbeat=" + DateTime.UtcNow.ToString(); goto default; case Beat.TChalo: if (hash == null) { throw new Exception("Hash not set"); } url = "http://minecraft.tchalo.com/announce.php"; // build list of current players in server if (Player.number > 0) { players = ""; foreach (Player p in Player.players) { if (p.hidden) { hidden++; continue; } players += p.name + ","; } if (Player.number - hidden > 0) { postVars += "&players=" + players.Substring(0, players.Length - 1); } } worlds = ""; foreach (Level l in Server.levels) { worlds += l.name + ","; postVars += "&worlds=" + worlds.Substring(0, worlds.Length - 1); } postVars += "&motd=" + UrlEncode(Server.motd) + "&hash=" + hash + "&data=" + Server.Version + "," + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + "&server=MCDawn" + "&details=Running MCDawn version " + Server.Version; goto default; case Beat.WOM: url = "https://direct.worldofminecraft.com/server.php"; if (Server.logbeat) { beatlogger = new StreamWriter("heartbeat.log", true); } if (Player.number > 0) { players = ""; foreach (Player p in Player.players) { if (p.hidden) { hidden++; continue; } players += p.name + ","; } if (Player.number - hidden > 0) { postVars += "&users=" + players.Substring(0, players.Length - 1); } } postVars += "&salt=" + Server.salt + "&users=" + Player.number + "&alt=" + Server.name + "&desc=" + Server.description + "&flags=" + Server.flags + "&noforward=1"; goto default; default: postVars += "&users=" + (Player.number - hidden); break; } request = (HttpWebRequest)WebRequest.Create(new Uri(url)); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore); byte[] formData = Encoding.ASCII.GetBytes(postVars); request.ContentLength = formData.Length; request.Timeout = 15000; retryStream : try { using (Stream requestStream = request.GetRequestStream()) { requestStream.Write(formData, 0, formData.Length); if (type == Beat.Minecraft && Server.logbeat) { beatlogger.WriteLine("Request sent at " + DateTime.Now.ToString()); } requestStream.Close(); } } catch (WebException e) { //Server.ErrorLog(e); if (e.Status == WebExceptionStatus.Timeout) { if (type == Beat.Minecraft && Server.logbeat) { beatlogger.WriteLine("Timeout detected at " + DateTime.Now.ToString()); } goto retryStream; //throw new WebException("Failed during request.GetRequestStream()", e.InnerException, e.Status, e.Response); } else if (type == Beat.Minecraft && Server.logbeat) { beatlogger.WriteLine("Non-timeout exception detected: " + e.Message); beatlogger.Write("Stack Trace: " + e.StackTrace); } } //if (hash == null) //{ using (WebResponse response = request.GetResponse()) { using (StreamReader responseReader = new StreamReader(response.GetResponseStream())) { if (hash == null) { string line = responseReader.ReadLine(); if (type == Beat.Minecraft && Server.logbeat) { beatlogger.WriteLine("Response received at " + DateTime.Now.ToString()); beatlogger.WriteLine("Received: " + line); } if (type == Beat.MCDawn && Server.logbeat) { beatlogger.WriteLine("Received: " + line); Server.s.Log("MCDawn Recevied:" + line); } hash = line.Substring(line.LastIndexOf('=') + 1); serverURL = line; //serverURL = "http://" + serverURL.Substring(serverURL.IndexOf('.') + 1); Server.s.UpdateUrl(serverURL); File.WriteAllText("text/externalurl.txt", serverURL); Server.s.Log("URL found: " + serverURL); Server.URL = serverURL; } else if (type == Beat.Minecraft && Server.logbeat) { beatlogger.WriteLine("Response received at " + DateTime.Now.ToString()); } } } //} //Server.s.Log(string.Format("Heartbeat: {0}", type)); } catch (WebException e) { if (e.Status == WebExceptionStatus.Timeout) { if (type == Beat.Minecraft && Server.logbeat) { beatlogger.WriteLine("Timeout detected at " + DateTime.Now.ToString()); } Pump(type); } } catch { if (type == Beat.Minecraft && Server.logbeat) { beatlogger.WriteLine("Heartbeat failure #" + totalTries + " at " + DateTime.Now.ToString()); } if (totalTries < 3) { goto retry; } if (type == Beat.Minecraft && Server.logbeat) { beatlogger.WriteLine("Failed three times. Stopping."); beatlogger.Close(); } return(false); } finally { request.Abort(); } if (beatlogger != null) { beatlogger.Close(); } return(true); }
private void ResetEverything() { // Stopping Music if(fmodChannel != null) fmodChannel.stop(); fmodSystem = null; fmodChannel = null; theSong = null; szSongName = ""; nCurrentPositionMS = 0; nLengthMS = 0; bPlaying = false; bIsFastforwarding = false; bIsRewinding = false; bPaused = false; //bFreq = false; bRunning = true; bListChanged = false; listBeats = new List<Beat>(); MouseAddBeat = new Beat(); szClickedEventEdit = ""; nMouseScroll = 0; MouseSelectStartPoint = new Point(); MouseSelectRect = Rectangle.Empty; SelectedBeats.Clear(); CopiedBeats.Clear(); TimeCurrentLabel.Text = "0(s)"; TimeLengthLabel.Text = "0(s)"; BeatCountLabel.Text = "0"; BPMCurrentLabel.Text = "0"; // Clean shit up RIGHT NAO!!! GC.Collect(); }
public static bool Pump(Beat type) { string postVars = staticVars; string url = "http://www.minecraft.net/heartbeat.jsp"; int totalTries = 0; retry : try { int hidden = 0; totalTries++; // append additional information as needed switch (type) { case Beat.Minecraft: if (Server.logbeat) { beatlogger = new StreamWriter("heartbeat.log", true); } postVars += "&salt=" + Server.salt; goto default; case Beat.MCSong: if (hash == null) { throw new Exception("Hash not set"); } url = "http://mcsong.x10.mx/heartbeat.php"; if (Player.number > 0) { players = ""; foreach (Player p in Player.players) { if (p.hidden) { hidden++; continue; } players += p.name + " (" + p.group.name + ")" + ","; } if (Player.number - hidden > 0) { postVars += "&players=" + players.Substring(0, players.Length - 1); } postVars += "&pcount=" + (Player.number - hidden).ToString(); } worlds = ""; foreach (Level l in Server.levels) { worlds += l.name + ","; postVars += "&worlds=" + worlds.Substring(0, worlds.Length - 1); } postVars += "&motd=" + UrlEncode(Server.motd) + "&lvlcount=" + (byte)Server.levels.Count + "&hash=" + hash; goto default; case Beat.TChalo: if (hash == null) { throw new Exception("Hash not set"); } url = "http://minecraft.tchalo.com/announce.php"; // build list of current players in server if (Player.number > 0) { players = ""; foreach (Player p in Player.players) { if (p.hidden) { hidden++; continue; } players += p.name + ","; } if (Player.number - hidden > 0) { postVars += "&players=" + players.Substring(0, players.Length - 1); } } worlds = ""; foreach (Level l in Server.levels) { worlds += l.name + ","; postVars += "&worlds=" + worlds.Substring(0, worlds.Length - 1); } postVars += "&motd=" + UrlEncode(Server.motd) + "&hash=" + hash + "&data=" + Server.Version + "," + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + "&server=MCSong" + "&details=Running MCSong version " + Server.Version; goto default; default: postVars += "&users=" + (Player.number - hidden); break; } request = (HttpWebRequest)WebRequest.Create(new Uri(url)); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore); byte[] formData = Encoding.ASCII.GetBytes(postVars); request.ContentLength = formData.Length; request.Timeout = 15000; retryStream : try { using (Stream requestStream = request.GetRequestStream()) { requestStream.Write(formData, 0, formData.Length); if (type == Beat.Minecraft && Server.logbeat) { beatlogger.WriteLine("Request sent at " + DateTime.Now.ToString()); } requestStream.Close(); } } catch (WebException e) { //Server.ErrorLog(e); if (e.Status == WebExceptionStatus.Timeout) { if (type == Beat.Minecraft && Server.logbeat) { beatlogger.WriteLine("Timeout detected at " + DateTime.Now.ToString()); } goto retryStream; //throw new WebException("Failed during request.GetRequestStream()", e.InnerException, e.Status, e.Response); } else if (type == Beat.Minecraft && Server.logbeat) { beatlogger.WriteLine("Non-timeout exception detected: " + e.Message); beatlogger.Write("Stack Trace: " + e.StackTrace); } } //if (hash == null) //{ using (WebResponse response = request.GetResponse()) { using (StreamReader responseReader = new StreamReader(response.GetResponseStream())) { if (hash == null) { string line = responseReader.ReadLine(); if (type == Beat.Minecraft && Server.logbeat) { beatlogger.WriteLine("Response received at " + DateTime.Now.ToString()); beatlogger.WriteLine("Received: " + line); } hash = line.Substring(line.LastIndexOf('=') + 1); serverURL = line; //serverURL = "http://" + serverURL.Substring(serverURL.IndexOf('.') + 1); Server.s.UpdateUrl(serverURL); File.WriteAllText("text/externalurl.txt", serverURL); Server.s.Log("URL found: " + serverURL); } else if (type == Beat.Minecraft && Server.logbeat) { beatlogger.WriteLine("Response received at " + DateTime.Now.ToString()); } } } //} //Server.s.Log(string.Format("Heartbeat: {0}", type)); } catch (WebException e) { if (e.Status == WebExceptionStatus.Timeout) { if (type == Beat.Minecraft && Server.logbeat) { beatlogger.WriteLine("Timeout detected at " + DateTime.Now.ToString()); } Pump(type); } } catch { if (type == Beat.Minecraft && Server.logbeat) { beatlogger.WriteLine("Heartbeat failure #" + totalTries + " at " + DateTime.Now.ToString()); } if (totalTries < 3) { goto retry; } if (type == Beat.Minecraft && Server.logbeat) { beatlogger.WriteLine("Failed three times. Stopping."); beatlogger.Close(); } return(false); } finally { request.Abort(); } if (beatlogger != null) { beatlogger.Close(); } return(true); }
public static bool Pump(Beat type) { if (staticVars == null) Init(); // default information to send string postVars = staticVars; string url = "http://www.classicube.net/heartbeat.jsp"; try { int hidden = 0; // append additional information as needed switch (type) { case Beat.ClassiCube: postVars += "&salt=" + Server.salt2; goto default; case Beat.Minecraft: url = "https://minecraft.net/heartbeat.jsp"; postVars += "&salt=" + Server.salt; goto default; default: postVars += "&users=" + (Player.number - hidden); break; } request = (HttpWebRequest)WebRequest.Create(new Uri(url + "?" + postVars)); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore); byte[] formData = Encoding.ASCII.GetBytes(postVars); request.ContentLength = formData.Length; request.Timeout = 15000; try { using (Stream requestStream = request.GetRequestStream()) { requestStream.Write(formData, 0, formData.Length); requestStream.Close(); } } catch (WebException e) { if (e.Status == WebExceptionStatus.Timeout) { throw new WebException("Failed during request.GetRequestStream()", e.InnerException, e.Status, e.Response); } } if (hash == null) { using (WebResponse response = request.GetResponse()) { using (StreamReader responseReader = new StreamReader(response.GetResponseStream())) { string line = responseReader.ReadLine(); hash = line.Substring(line.LastIndexOf('=') + 1); serverURL = line; Server.s.UpdateUrl(serverURL); Server.s.Log("URL saved to text/externalurl.txt..."); File.WriteAllText("text/externalurl.txt", serverURL); } } } } catch (WebException e) { if (e.Status == WebExceptionStatus.Timeout) { Server.s.Log(string.Format("Timeout: {0}", type)); } Server.ErrorLog(e); } catch (Exception e) { Server.s.Log(string.Format("Error reporting to {0}", type)); Server.ErrorLog(e); return false; } finally { request.Abort(); } return true; }
public static VoicePart GetRenderTieVoicePart(this Beat beat) { return(beat.OwnerBar.HasSingularVoice() ? VoicePart.Treble : beat.VoicePart); }
public BeatContainerGlyph GetBeatContainer(Beat beat) { return(GetOrCreateVoiceContainer(beat.Voice).BeatGlyphs[beat.Index]); }
private void CreateOrResizeGlyph(EffectBarGlyphSizing sizing, Beat b) { switch (sizing) { case EffectBarGlyphSizing.SinglePreBeatOnly: case EffectBarGlyphSizing.SinglePreBeatToOnBeat: case EffectBarGlyphSizing.SinglePreBeatToPostBeat: case EffectBarGlyphSizing.SingleOnBeatOnly: case EffectBarGlyphSizing.SingleOnBeatToPostBeat: case EffectBarGlyphSizing.SinglePostBeatOnly: var g = _info.CreateNewGlyph(this, b); g.Renderer = this; g.DoLayout(); _effectGlyphs[b.Voice.Index][b.Index] = g; _uniqueEffectGlyphs[b.Voice.Index].Add(g); break; case EffectBarGlyphSizing.GroupedPreBeatOnly: case EffectBarGlyphSizing.GroupedPreBeatToOnBeat: case EffectBarGlyphSizing.GroupedPreBeatToPostBeat: case EffectBarGlyphSizing.GroupedOnBeatOnly: case EffectBarGlyphSizing.GroupedOnBeatToPostBeat: case EffectBarGlyphSizing.GroupedPostBeatOnly: if (b.Index > 0 || Index > 0) { // check if the previous beat also had this effect Beat prevBeat = b.PreviousBeat; if (_info.ShouldCreateGlyph(this, prevBeat)) { // expand the previous effect EffectGlyph prevEffect = null; if (b.Index > 0 && _effectGlyphs[b.Voice.Index].ContainsKey(prevBeat.Index)) { prevEffect = _effectGlyphs[b.Voice.Index][prevBeat.Index]; } else if (Index > 0) { var previousRenderer = ((EffectBarRenderer)(Stave.BarRenderers[Index - 1])); var voiceGlyphs = previousRenderer._effectGlyphs[b.Voice.Index]; if (voiceGlyphs.ContainsKey(prevBeat.Index)) { prevEffect = voiceGlyphs[prevBeat.Index]; } } if (prevEffect == null || !_info.CanExpand(this, prevBeat, b)) { CreateOrResizeGlyph(EffectBarGlyphSizing.SinglePreBeatOnly, b); } else { _effectGlyphs[b.Voice.Index][b.Index] = prevEffect; } } else { CreateOrResizeGlyph(EffectBarGlyphSizing.SinglePreBeatOnly, b); } } else { CreateOrResizeGlyph(EffectBarGlyphSizing.SinglePreBeatOnly, b); } break; } }
private bool IsFullBarJoin(Beat a, Beat b, int barIndex) { return((a.Duration.GetIndex() - 2 - barIndex > 0) && (b.Duration.GetIndex() - 2 - barIndex > 0)); }
private void OnBeat(Beat beat) { // lines.Add(CreateLine(beat.index, Color.white, 20, -40)); }
public NodeCollection (Beat beat) { this.beat = beat; }
public void ReadNoteEffects(Track track, Voice voice, Beat beat, Note note) { var flags = Data.ReadByte(); var flags2 = 0; if (_versionNumber >= 400) { flags2 = Data.ReadByte(); } if ((flags & 0x01) != 0) { ReadBend(note); } if ((flags & 0x10) != 0) { ReadGrace(voice, note); } if ((flags2 & 0x04) != 0) { ReadTremoloPicking(beat); } if ((flags2 & 0x08) != 0) { ReadSlide(note); } else if (_versionNumber < 400) { if ((flags & 0x04) != 0) { note.SlideType = SlideType.Shift; } } if ((flags2 & 0x10) != 0) { ReadArtificialHarmonic(note); } else if (_versionNumber < 400) { if ((flags & 0x04) != 0) { note.HarmonicType = HarmonicType.Natural; note.HarmonicValue = DeltaFretToHarmonicValue(note.Fret); } if ((flags & 0x08) != 0) { note.HarmonicType = HarmonicType.Artificial; } } if ((flags2 & 0x20) != 0) { ReadTrill(note); } note.IsLetRing = (flags & 0x08) != 0; note.IsHammerPullOrigin = (flags & 0x02) != 0; if ((flags2 & 0x40) != 0) { note.Vibrato = VibratoType.Slight; } note.IsPalmMute = (flags2 & 0x02) != 0; note.IsStaccato = (flags2 & 0x01) != 0; }
public static NodeCollection Calculate (Beat beat, int distance_from_start) { if (beat.isEmpty()) { throw new ArgumentException(); } NodeCollection result = new NodeCollection(beat); List<Node> items = result.items; int any_tap_count = beat.getAnyTapCount(); List<int> any_tap_indices = beat.getIndices(TapType.Force, TapType.PassiveBegin, TapType.PassiveStay, TapType.PassiveEnd); if (any_tap_count == 1) { Panel a = Panel.Panels_1D_Playable[any_tap_indices[0]]; Node1Calculator.Calculate1(items, beat, distance_from_start, a); } else if (any_tap_count == 2) { Panel a = Panel.Panels_1D_Playable[any_tap_indices[0]]; Panel b = Panel.Panels_1D_Playable[any_tap_indices[1]]; Node2Calculator.Calculate11(items, beat, distance_from_start, a, b); Node2Calculator.Calculate2(items, beat, distance_from_start, a, b); } else if (any_tap_count == 3) { Panel a = Panel.Panels_1D_Playable[any_tap_indices[0]]; Panel b = Panel.Panels_1D_Playable[any_tap_indices[1]]; Panel c = Panel.Panels_1D_Playable[any_tap_indices[2]]; //3 Node3Calculator.Calculate3(items, beat, distance_from_start, a, b, c); //21 Node3Calculator.Calculate21(items, beat, distance_from_start, a, b, c); Node3Calculator.Calculate21(items, beat, distance_from_start, a, c, b); Node3Calculator.Calculate21(items, beat, distance_from_start, b, c, a); if (items.Count == 0) { throw new NotImplementedException(); } } else if (any_tap_count == 4) { Panel a = Panel.Panels_1D_Playable[any_tap_indices[0]]; Panel b = Panel.Panels_1D_Playable[any_tap_indices[1]]; Panel c = Panel.Panels_1D_Playable[any_tap_indices[2]]; Panel d = Panel.Panels_1D_Playable[any_tap_indices[3]]; //31 Node4Calculator.Calculate31(items, beat, distance_from_start, a, b, c, d); Node4Calculator.Calculate31(items, beat, distance_from_start, b, c, d, a); Node4Calculator.Calculate31(items, beat, distance_from_start, c, d, a, b); Node4Calculator.Calculate31(items, beat, distance_from_start, d, a, b, c); //22 Node4Calculator.Calculate22(items, beat, distance_from_start, a, b, c, d); Node4Calculator.Calculate22(items, beat, distance_from_start, a, c, d, b); Node4Calculator.Calculate22(items, beat, distance_from_start, a, d, b, c); Node4Calculator.Calculate22(items, beat, distance_from_start, b, c, d, a); Node4Calculator.Calculate22(items, beat, distance_from_start, b, d, a, c); Node4Calculator.Calculate22(items, beat, distance_from_start, c, d, a, b); if (items.Count == 0) { throw new NotImplementedException(); } } else if (any_tap_count == 5) { Panel a = Panel.Panels_1D_Playable[any_tap_indices[0]]; Panel b = Panel.Panels_1D_Playable[any_tap_indices[1]]; Panel c = Panel.Panels_1D_Playable[any_tap_indices[2]]; Panel d = Panel.Panels_1D_Playable[any_tap_indices[3]]; Panel e = Panel.Panels_1D_Playable[any_tap_indices[4]]; Node5Calculator.Calculate32(items, beat, distance_from_start, a, b, c, d, e); Node5Calculator.Calculate32(items, beat, distance_from_start, a, b, d, e, c); Node5Calculator.Calculate32(items, beat, distance_from_start, a, b, e, c, d); Node5Calculator.Calculate32(items, beat, distance_from_start, a, c, d, e, b); Node5Calculator.Calculate32(items, beat, distance_from_start, a, c, e, b, d); Node5Calculator.Calculate32(items, beat, distance_from_start, a, d, e, b, c); Node5Calculator.Calculate32(items, beat, distance_from_start, b, c, d, e, a); Node5Calculator.Calculate32(items, beat, distance_from_start, b, c, e, a, d); Node5Calculator.Calculate32(items, beat, distance_from_start, b, d, e, a, c); Node5Calculator.Calculate32(items, beat, distance_from_start, c, d, e, a, b); if (items.Count == 0) { throw new NotImplementedException(); } } else if (any_tap_count == 6) { Panel a = Panel.Panels_1D_Playable[any_tap_indices[0]]; Panel b = Panel.Panels_1D_Playable[any_tap_indices[1]]; Panel c = Panel.Panels_1D_Playable[any_tap_indices[2]]; Panel d = Panel.Panels_1D_Playable[any_tap_indices[3]]; Panel e = Panel.Panels_1D_Playable[any_tap_indices[4]]; Panel f = Panel.Panels_1D_Playable[any_tap_indices[5]]; Node6Calculator.Calculate33(items, beat, distance_from_start, a, b, c, d, e, f); Node6Calculator.Calculate33(items, beat, distance_from_start, d, e, f, a, b, c); if (items.Count == 0) { throw new NotImplementedException(); } } else { throw new NotImplementedException(); } if (items.Count == 0) { throw new ExecutionEngineException(); } return result; }
protected virtual void OnBeat() { Beat?.Invoke(this, EventArgs.Empty); }
private bool IsGallop ( Limb cur, Limb prv, Beat cur_beat, Beat prv_beat ) { if ( cur_beat.beat_interval < GALLOP_BEAT_INTERVAL || prv_beat.beat_interval < GALLOP_BEAT_INTERVAL ) { return false; //Consider making it.. 24? } float delta_second = cur_beat.second - prv_beat.second; if (delta_second > cur_beat.seconds_per_beat / GALLOP_BEATS_PER_MEASURE + GALLOP_SECONDS_EPOCH) { return false; //Unsure if this is correct.. } if (cur.JustMovedCount() != 1 || prv.JustMovedCount() != 1) { return false; //For now, gallops are two taps.. } int cur_just_moved_index = cur.JustMovedIndex(); int prv_just_moved_index = prv.JustMovedIndex(); if (cur_just_moved_index == prv_just_moved_index) { return false; //.. by different parts of the same limb } Part cur_part = cur[cur_just_moved_index]; Part prv_part = prv[prv_just_moved_index]; if (cur_part.panel == null || prv_part.panel == null) { return false; //Must be hitting a note } if (cur_part.panel == prv_part.panel) { return false; //Must hit different notes } if (!Panel.IsBracketable( cur_part.panel.index, prv_part.panel.index )) { return false; //Must be bracketable } return true; }
/// <summary> /// Is called on each beat of the song /// </summary> /// <param name="beat">The current beat</param> private void OnBeat(Beat beat) { BeatPulseController(beat); }
public static State TransitionTo (State from, Limb[] to, float second, int distance_from_start, Beat beat, ICostFactory cost_factory) { State nxt = null; Vector facing = FacingCalculator.Calculate(to, from.facing); Vector facing_desired = FacingCalculator.CalculateDesiredFacing(facing, from.facing_desired); if (IsArcValidWithoutCrossing(to, facing_desired)) { nxt = new State(from, second, distance_from_start, false); } else if (IsArcValidWithCrossing(to, facing_desired)) { //nxt = new State(from, second, distance_from_start, true); return null; } else { return null; } //Transition for (int i = 0; i < from.limbs.Length; ++i) { nxt.limbs[i] = to[i]; } nxt.beat = beat; nxt.facing = facing; nxt.facing_desired = facing_desired; nxt.sanityCheck(); nxt.cost = cost_factory.Calculate(nxt); return nxt; }
public ScoreBeatContainerGlyph(Beat beat) : base(beat) { }
private static void BeatLog(Beat beat, string text) { if (Server.logbeat && beat.Log && beatlogger != null) { try { beatlogger.WriteLine(text); } catch { } } }
public Pattern(Beat b1, Beat b2, Beat b3, Beat b4) { beats = new Beat[] { b1, b2, b3, b4 }; }
private void PlaceBeatAtMousePosition() { if (MouseAddBeat.Completion != BEATIS.EMPTY) { //*********************DRAWING MATH********************************// // Cutting down on divide ops int Halfsies = TrackPanel.Bottom / 2; int XHalfsies = TrackPanel.Right / 2; // Mouse point Point mosPos; mosPos = TrackPanel.PointToClient(Cursor.Position); if (mosPos.X > XHalfsies) { // More coordinate magic to get the song position based off mouse X position MouseAddBeat.TimeOfBeat = nCurrentPositionMS + (uint)((mosPos.X * 1000 / 34 - (15000 + 118 * (mosPos.X / 34 - 15)))); } else { // More coordinate magic to get the song position based off mouse X position int nTime = (int)(nCurrentPositionMS + (mosPos.X * 1000 / 34 - (15000 - 57 * (15 - mosPos.X / 34)))); if (nTime > 0) MouseAddBeat.TimeOfBeat = (uint)nTime; } MouseAddBeat.Difficulty = szDifficulty; // Adding to list listBeats.Add(MouseAddBeat); bListChanged = true; Beat tBeat = MouseAddBeat; MouseAddBeat = new Beat(tBeat); } }
public void setMain (Beat beat, Panel panel) { main = new Part(beat, panel); }
private void AddBeat(Keys dir) { Beat tempBeat = new Beat(); bool isBeat = false; if(BothRadio.Checked || ArrowsRadio.Checked) switch (dir) { // Left Arrow case Keys.NumPad4: { LeftPictureBox.BackColor = Color.CornflowerBlue; tempBeat.Direction = "left"; tempBeat.Completion = BEATIS.ARROW; tempBeat.ArrowTextureIndex = ArrowLeft; isBeat = true; } break; // Right Arrow case Keys.NumPad6: { RightPictureBox.BackColor = Color.CornflowerBlue; tempBeat.Direction = "right"; tempBeat.Completion = BEATIS.ARROW; tempBeat.ArrowTextureIndex = ArrowRight; isBeat = true; } break; // Up Arrow case Keys.NumPad8: { UpPictureBox.BackColor = Color.CornflowerBlue; tempBeat.Direction = "up"; tempBeat.Completion = BEATIS.ARROW; tempBeat.ArrowTextureIndex = ArrowUp; isBeat = true; } break; // Down Arrow case Keys.NumPad2: { DownPictureBox.BackColor = Color.CornflowerBlue; tempBeat.Direction = "down"; tempBeat.Completion = BEATIS.ARROW; tempBeat.ArrowTextureIndex = ArrowDown; isBeat = true; } break; // Down Left Arrow case Keys.NumPad1: { DownLeftPictureBox.BackColor = Color.CornflowerBlue; tempBeat.Direction = "leftdown"; tempBeat.Completion = BEATIS.ARROW; tempBeat.ArrowTextureIndex = ArrowDownLeft; isBeat = true; } break; // Down Right Arrow case Keys.NumPad3: { DownRightPictureBox.BackColor = Color.CornflowerBlue; tempBeat.Direction = "rightdown"; tempBeat.Completion = BEATIS.ARROW; tempBeat.ArrowTextureIndex = ArrowDownRight; isBeat = true; } break; // Up Left Arrow case Keys.NumPad7: { UpLeftPictureBox.BackColor = Color.CornflowerBlue; tempBeat.Direction = "leftup"; tempBeat.Completion = BEATIS.ARROW; tempBeat.ArrowTextureIndex = ArrowUpLeft; isBeat = true; } break; // Up Right Arrow case Keys.NumPad9: { UpRightPictureBox.BackColor = Color.CornflowerBlue; tempBeat.Direction = "rightup"; tempBeat.Completion = BEATIS.ARROW; tempBeat.ArrowTextureIndex = ArrowUpRight; isBeat = true; } break; default: break; } if(BothRadio.Checked || NotesRadio.Checked) switch (dir) { // W Key case Keys.W: { WKeyPictureBox.BackColor = Color.Crimson; tempBeat.KeyPress = 'w'; tempBeat.Image = szWKeyImage; tempBeat.Completion = BEATIS.KEY; tempBeat.TextureIndex = KeyW; isBeat = true; } break; // A Key case Keys.A: { AKeyPictureBox.BackColor = Color.Crimson; tempBeat.KeyPress = 'a'; tempBeat.Image = szAKeyImage; tempBeat.Completion = BEATIS.KEY; tempBeat.TextureIndex = KeyA; isBeat = true; } break; // S Key case Keys.S: { SKeyPictureBox.BackColor = Color.Crimson; tempBeat.KeyPress = 's'; tempBeat.Image = szSKeyImage; tempBeat.Completion = BEATIS.KEY; tempBeat.TextureIndex = KeyS; isBeat = true; } break; // D Key case Keys.D: { DKeyPictureBox.BackColor = Color.Crimson; tempBeat.KeyPress = 'd'; tempBeat.Image = szDKeyImage; tempBeat.Completion = BEATIS.KEY; tempBeat.TextureIndex = KeyD; isBeat = true; } break; default: break; } if (!isBeat || fmodChannel == null) return; // Only setting beat time if it's not assigned yet fmodChannel.getPosition(ref tempBeat.nTimeOfBeat, FMOD.TIMEUNIT.MS); tempBeat.Width = 32; tempBeat.Height = 32; tempBeat.Difficulty = szDifficulty; listBeats.Add(tempBeat); bListChanged = true; }
public void setExtra (Beat beat, Panel panel) { extra = new Part(beat, panel); }
private void ClearSelectionButton_Click(object sender, EventArgs e) { ResetButtonBackgrounds(); SelectedBeats.Clear(); MouseAddBeat = new Beat(); }
public void ReadChord(Beat beat) { var chord = new Chord(); var chordId = Std.NewGuid(); if (_versionNumber >= 500) { Data.Skip(17); chord.Name = ReadStringByteLength(21); Data.Skip(4); chord.FirstFret = ReadInt32(); for (int i = 0; i < 7; i++) { var fret = ReadInt32(); if (i < beat.Voice.Bar.Staff.Track.Tuning.Length) { chord.Strings.Add(fret); } } var numberOfBarres = Data.ReadByte(); var barreFrets = new byte[5]; Data.Read(barreFrets, 0, barreFrets.Length); for (int i = 0; i < numberOfBarres; i++) { chord.BarreFrets.Add(barreFrets[i]); } Data.Skip(26); } else { if (Data.ReadByte() != 0) // mode1? { // gp4 if (_versionNumber >= 400) { // Sharp (1) // Unused (3) // Root (1) // Major/Minor (1) // Nin,Eleven or Thirteen (1) // Bass (4) // Diminished/Augmented (4) // Add (1) Data.Skip(16); chord.Name = (ReadStringByteLength(21)); // Unused (2) // Fifth (1) // Ninth (1) // Eleventh (1) Data.Skip(4); chord.FirstFret = (ReadInt32()); for (int i = 0; i < 7; i++) { var fret = ReadInt32(); if (i < beat.Voice.Bar.Staff.Track.Tuning.Length) { chord.Strings.Add(fret); } } var numberOfBarres = Data.ReadByte(); var barreFrets = new byte[5]; Data.Read(barreFrets, 0, barreFrets.Length); for (int i = 0; i < numberOfBarres; i++) { chord.BarreFrets.Add(barreFrets[i]); } // Barree end (5) // Omission1,3,5,7,9,11,13 (7) // Unused (1) // Fingering (7) // Show Diagram Fingering (1) // ?? Data.Skip(26); } else { // unknown Data.Skip(25); chord.Name = ReadStringByteLength(34); chord.FirstFret = ReadInt32(); for (int i = 0; i < 6; i++) { var fret = ReadInt32(); if (i < beat.Voice.Bar.Staff.Track.Tuning.Length) { chord.Strings.Add(fret); } } // unknown Data.Skip(36); } } else { int strings = _versionNumber >= 406 ? 7 : 6; chord.Name = ReadStringIntByte(); chord.FirstFret = ReadInt32(); if (chord.FirstFret > 0) { for (int i = 0; i < strings; i++) { var fret = ReadInt32(); if (i < beat.Voice.Bar.Staff.Track.Tuning.Length) { chord.Strings.Add(fret); } } } } } if (!string.IsNullOrEmpty(chord.Name)) { beat.ChordId = chordId; beat.Voice.Bar.Staff.Track.Chords[beat.ChordId] = chord; } }
public void ReadNote(Track track, Bar bar, Voice voice, Beat beat, int stringIndex) { var newNote = new Note(); newNote.String = track.Tuning.Length - stringIndex; var flags = Data.ReadByte(); if ((flags & 0x02) != 0) { newNote.Accentuated = AccentuationType.Heavy; } else if ((flags & 0x40) != 0) { newNote.Accentuated = AccentuationType.Normal; } newNote.IsGhost = ((flags & 0x04) != 0); if ((flags & 0x20) != 0) { var noteType = Data.ReadByte(); if (noteType == 3) { newNote.IsDead = true; } else if (noteType == 2) { newNote.IsTieDestination = true; } } if ((flags & 0x01) != 0 && _versionNumber < 500) { Data.ReadByte(); // duration Data.ReadByte(); // tuplet } if ((flags & 0x10) != 0) { var dynamicNumber = Data.ReadSignedByte(); newNote.Dynamic = ToDynamicValue(dynamicNumber); beat.Dynamic = newNote.Dynamic; } if ((flags & 0x20) != 0) { newNote.Fret = Data.ReadSignedByte(); } if ((flags & 0x80) != 0) { newNote.LeftHandFinger = (Fingers)Data.ReadSignedByte(); newNote.RightHandFinger = (Fingers)Data.ReadSignedByte(); newNote.IsFingering = true; } if (_versionNumber >= 500) { if ((flags & 0x01) != 0) { newNote.DurationPercent = ReadDouble(); } var flags2 = Data.ReadByte(); newNote.AccidentalMode = (flags2 & 0x02) != 0 ? NoteAccidentalMode.SwapAccidentals : NoteAccidentalMode.Default; } beat.AddNote(newNote); if ((flags & 0x08) != 0) { ReadNoteEffects(track, voice, beat, newNote); } }
private string FingerToString(Beat beat, Fingers finger, bool leftHand) { if (Settings.ForcePianoFingering || GeneralMidi.IsPiano(beat.Voice.Bar.Track.PlaybackInfo.Program)) { switch (finger) { case Fingers.Unknown: case Fingers.NoOrDead: return(null); case Fingers.Thumb: return("1"); case Fingers.IndexFinger: return("2"); case Fingers.MiddleFinger: return("3"); case Fingers.AnnularFinger: return("4"); case Fingers.LittleFinger: return("5"); default: return(null); } } else if (leftHand) { switch (finger) { case Fingers.Unknown: case Fingers.NoOrDead: return("0"); case Fingers.Thumb: return("T"); case Fingers.IndexFinger: return("1"); case Fingers.MiddleFinger: return("2"); case Fingers.AnnularFinger: return("3"); case Fingers.LittleFinger: return("4"); default: return(null); } } else { switch (finger) { case Fingers.Unknown: case Fingers.NoOrDead: return(null); case Fingers.Thumb: return("p"); case Fingers.IndexFinger: return("i"); case Fingers.MiddleFinger: return("m"); case Fingers.AnnularFinger: return("a"); case Fingers.LittleFinger: return("c"); default: return(null); } } }
public void setSub (Beat beat, Panel panel) { sub = new Part(beat, panel); }
/// <summary> /// Initializes a new instance of the <see cref="Bar"/> class. /// </summary> public Bar() { Index = 0; Beats = new Beat[0]; }
public bool ShouldCreateGlyph(Beat beat) { return(beat.Vibrato != VibratoType.None); }
public void ReadBeat(Track track, Bar bar, Voice voice) { var newBeat = new Beat(); var flags = Data.ReadByte(); if ((flags & 0x01) != 0) { newBeat.Dots = 1; } if ((flags & 0x40) != 0) { var type = Data.ReadByte(); newBeat.IsEmpty = (type & 0x02) == 0; } voice.AddBeat(newBeat); var duration = Data.ReadSignedByte(); switch (duration) { case -2: newBeat.Duration = Duration.Whole; break; case -1: newBeat.Duration = Duration.Half; break; case 0: newBeat.Duration = Duration.Quarter; break; case 1: newBeat.Duration = Duration.Eighth; break; case 2: newBeat.Duration = Duration.Sixteenth; break; case 3: newBeat.Duration = Duration.ThirtySecond; break; case 4: newBeat.Duration = Duration.SixtyFourth; break; default: newBeat.Duration = Duration.Quarter; break; } if ((flags & 0x20) != 0) { newBeat.TupletNumerator = ReadInt32(); switch (newBeat.TupletNumerator) { case 1: newBeat.TupletDenominator = 1; break; case 3: newBeat.TupletDenominator = 2; break; case 5: case 6: case 7: newBeat.TupletDenominator = 4; break; case 9: case 10: case 11: case 12: case 13: newBeat.TupletDenominator = 8; break; case 2: case 4: case 8: break; default: newBeat.TupletNumerator = 1; newBeat.TupletDenominator = 1; break; } } if ((flags & 0x02) != 0) { ReadChord(newBeat); } if ((flags & 0x04) != 0) { newBeat.Text = ReadStringIntUnused(); } if ((flags & 0x08) != 0) { ReadBeatEffects(newBeat); } if ((flags & 0x10) != 0) { ReadMixTableChange(newBeat); } var stringFlags = Data.ReadByte(); for (int i = 6; i >= 0; i--) { if ((stringFlags & (1 << i)) != 0 && (6 - i) < track.Tuning.Length) { ReadNote(track, bar, voice, newBeat, (6 - i)); } } if (_versionNumber >= 500) { Data.ReadByte(); var flag = Data.ReadByte(); if ((flag & 0x08) != 0) { Data.ReadByte(); } } }
int ExportOrFindBeat(Chord chord) { var beat = new Beat(); beat.Id = gpif.Beats.Count; foreach (var note in chord.Notes) { int id = ExportOrFindNote(note.Value); beat.Notes.Add(id); } // there seem to be a few accidental ties set in the Rocksmith XMLs // so unset the tie status on any strings that weren't in the current chord. for (int i = 0; i < 6; ++i) { if (!chord.Notes.ContainsKey(i)) link[i] = false; } // should we display a strum hint? if (chord.BrushDirection != Chord.BrushType.None) { var brushProp = new Property() { Name = "Brush" }; if (chord.BrushDirection == Chord.BrushType.Down) brushProp.Direction = "Down"; else brushProp.Direction = "Up"; if (beat.Properties == null) beat.Properties = new List<Property>(); beat.Properties.Add(brushProp); } // tremolo picking if (chord.Tremolo) { // 32nd notes tremolo picking (should be appropriate) beat.Tremolo = "1/8"; } // slap/pop notes if (chord.Slapped) { if (beat.Properties == null) beat.Properties = new List<Property>(); beat.Properties.Add(new Property() { Name = "Slapped", Enable = new Property.EnableType() }); } if (chord.Popped) { if (beat.Properties == null) beat.Properties = new List<Property>(); beat.Properties.Add(new Property() { Name = "Popped", Enable = new Property.EnableType() }); } // construct rhythm var rhythm = new Rhythm(); rhythm.Id = gpif.Rhythms.Count; switch (chord.Duration) { case 192: rhythm.NoteValue = "Whole"; break; case 168: // should avoid this, split note instead (TODO) rhythm.NoteValue = "Half"; rhythm.AugmentationDot = new Rhythm.Dot() { Count = 2 }; break; case 144: rhythm.NoteValue = "Half"; rhythm.AugmentationDot = new Rhythm.Dot() { Count = 1 }; break; case 96: rhythm.NoteValue = "Half"; break; case 84: // should avoid this, split note instead (TODO) rhythm.NoteValue = "Quarter"; rhythm.AugmentationDot = new Rhythm.Dot() { Count = 2 }; break; case 72: rhythm.NoteValue = "Quarter"; rhythm.AugmentationDot = new Rhythm.Dot() { Count = 1 }; break; case 48: rhythm.NoteValue = "Quarter"; break; case 36: rhythm.NoteValue = "Eighth"; rhythm.AugmentationDot = new Rhythm.Dot() { Count = 1 }; break; case 32: rhythm.NoteValue = "Quarter"; rhythm.PrimaryTuplet = new Rhythm.Tuplet() { Den = 2, Num = 3 }; break; case 24: rhythm.NoteValue = "Eighth"; break; case 18: rhythm.NoteValue = "16th"; rhythm.AugmentationDot = new Rhythm.Dot() { Count = 1 }; break; case 16: rhythm.NoteValue = "Eighth"; rhythm.PrimaryTuplet = new Rhythm.Tuplet() { Den = 2, Num = 3 }; break; case 12: rhythm.NoteValue = "16th"; break; case 9: rhythm.NoteValue = "32nd"; rhythm.AugmentationDot = new Rhythm.Dot() { Count = 1 }; break; case 8: rhythm.NoteValue = "16th"; rhythm.PrimaryTuplet = new Rhythm.Tuplet() { Den = 2, Num = 3 }; break; case 6: rhythm.NoteValue = "32nd"; break; case 4: rhythm.NoteValue = "32nd"; rhythm.PrimaryTuplet = new Rhythm.Tuplet() { Den = 2, Num = 3 }; break; case 3: rhythm.NoteValue = "64th"; break; case 2: rhythm.NoteValue = "64th"; rhythm.PrimaryTuplet = new Rhythm.Tuplet() { Den = 2, Num = 3 }; break; case 1: rhythm.NoteValue = "128th"; rhythm.PrimaryTuplet = new Rhythm.Tuplet() { Den = 2, Num = 3 }; break; default: Console.WriteLine(" Warning: Rhythm Duration {0} not handled, defaulting to quarter note.", chord.Duration); rhythm.NoteValue = "Quarter"; break; } // see if this rhythm already exists, otherwise add var searchRhythm = gpif.Rhythms.Find(x => x.Equals(rhythm)); if (searchRhythm != null) rhythm = searchRhythm; else gpif.Rhythms.Add(rhythm); beat.Rhythm.Ref = rhythm.Id; // should we display a chord name? if (chord.ChordId != -1 && chord.ChordId != prevChordId) { beat.Chord = chord.ChordId.ToString(); } prevChordId = chord.ChordId; if (chord.Section != null) beat.FreeText = chord.Section; // see if this beat already exists, otherwise add var searchBeat = gpif.Beats.Find(x => x.Equals(beat)); if (searchBeat != null) beat = searchBeat; else gpif.Beats.Add(beat); return beat.Id; }
public EffectGlyph CreateNewGlyph(BarRendererBase renderer, Beat beat) { return(new VibratoGlyph(0, 5 * renderer.Scale, 1.4f)); }
public static bool Pump(Beat type) { string postVars = staticVars; string url = "http://www.minecraft.net/heartbeat.jsp"; int totalTries = 0; retry: try { int hidden = 0; totalTries++; // append additional information as needed switch (type) { case Beat.Minecraft: if (Server.logbeat) { beatlogger = new StreamWriter("heartbeat.log", true); } postVars += "&salt=" + Server.salt; goto default; case Beat.MCPink: if (hash == null) { throw new Exception("Hash not set"); } url = "http://www.mclawl.tk/hbannounce.php"; if (Player.number > 0) { players = ""; foreach (Player p in Player.players) { if (p.hidden) { hidden++; continue; } players += p.name + " (" + p.group.name + ")" + ","; } if (Player.number - hidden > 0) postVars += "&players=" + players.Substring(0, players.Length - 1); } worlds = ""; foreach (Level l in Server.levels) { worlds += l.name + ","; postVars += "&worlds=" + worlds.Substring(0, worlds.Length - 1); } postVars += "&motd=" + UrlEncode(Server.motd) + "&lvlcount=" + (byte)Server.levels.Count + "&lawlversion=" + Server.Version.Replace(".0", "") + "&hash=" + hash; goto default; case Beat.TChalo: if (hash == null) throw new Exception("Hash not set"); url = "http://minecraft.tchalo.com/announce.php"; // build list of current players in server if (Player.number > 0) { players = ""; foreach (Player p in Player.players) { if (p.hidden) { hidden++; continue; } players += p.name + ","; } if (Player.number - hidden > 0) postVars += "&players=" + players.Substring(0, players.Length - 1); } worlds = ""; foreach (Level l in Server.levels) { worlds += l.name + ","; postVars += "&worlds=" + worlds.Substring(0, worlds.Length - 1); } postVars += "&motd=" + UrlEncode(Server.motd) + "&hash=" + hash + "&data=" + Server.Version + "," + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + "&server=MCPink" + "&details=Running MCPink version " + Server.Version; goto default; default: postVars += "&users=" + (Player.number - hidden); break; } request = (HttpWebRequest)WebRequest.Create(new Uri(url)); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore); byte[] formData = Encoding.ASCII.GetBytes(postVars); request.ContentLength = formData.Length; request.Timeout = 15000; retryStream: try { using (Stream requestStream = request.GetRequestStream()) { requestStream.Write(formData, 0, formData.Length); if (type == Beat.Minecraft && Server.logbeat) { beatlogger.WriteLine("Request sent at " + DateTime.Now.ToString()); } requestStream.Close(); } } catch (WebException e) { //Server.ErrorLog(e); if (e.Status == WebExceptionStatus.Timeout) { if (type == Beat.Minecraft && Server.logbeat) { beatlogger.WriteLine("Timeout detected at " + DateTime.Now.ToString()); } goto retryStream; //throw new WebException("Failed during request.GetRequestStream()", e.InnerException, e.Status, e.Response); } else if (type == Beat.Minecraft && Server.logbeat) { beatlogger.WriteLine("Non-timeout exception detected: " + e.Message); beatlogger.Write("Stack Trace: " + e.StackTrace); } } //if (hash == null) //{ using (WebResponse response = request.GetResponse()) { using (StreamReader responseReader = new StreamReader(response.GetResponseStream())) { if (hash == null) { string line = responseReader.ReadLine(); if (type == Beat.Minecraft && Server.logbeat) { beatlogger.WriteLine("Response received at " + DateTime.Now.ToString()); beatlogger.WriteLine("Received: " + line); } hash = line.Substring(line.LastIndexOf('=') + 1); serverURL = line; //serverURL = "http://" + serverURL.Substring(serverURL.IndexOf('.') + 1); Server.s.UpdateUrl(serverURL); File.WriteAllText("text/externalurl.txt", serverURL); Server.s.Log("URL found: " + serverURL); } else if (type == Beat.Minecraft && Server.logbeat) { beatlogger.WriteLine("Response received at " + DateTime.Now.ToString()); } } } //} //Server.s.Log(string.Format("Heartbeat: {0}", type)); } catch (WebException e) { if (e.Status == WebExceptionStatus.Timeout) { if (type == Beat.Minecraft && Server.logbeat) { beatlogger.WriteLine("Timeout detected at " + DateTime.Now.ToString()); } Pump(type); } } catch { if (type == Beat.Minecraft && Server.logbeat) { beatlogger.WriteLine("Heartbeat failure #" + totalTries + " at " + DateTime.Now.ToString()); } if (totalTries < 3) goto retry; if (type == Beat.Minecraft && Server.logbeat) { beatlogger.WriteLine("Failed three times. Stopping."); beatlogger.Close(); } return false; } finally { request.Abort(); } if (beatlogger != null) { beatlogger.Close(); } return true; }
public bool CanExpand(Beat @from, Beat to) { return(true); }