IEnumerator SN(D_Note note) { if (note._time > 2.102343f) { yield return(new WaitForSeconds((float)(note._time - 2.1388116f))); //GameObject note_ = Object.Instantiate (SlideNote_prefab, new Vector3 ((float)note.pos, (2.128756f*SPEED), -3.556f), Quaternion.Euler (0, 0, 0)); GameObject note_ = ObjectPooler.SharedInstance.GetPooledObject("slideynote"); if (note_ != null) { note_.name = "Slide Note ID: " + note.id_; note_.transform.localScale = new Vector3((float)note.size / 2, 0.6275f, 0.2f); note_.transform.position = new Vector3((float)note.pos, (2.128756f * SPEED), -3.556f); note_.transform.SetParent(transform); note_.SetActive(true); } } else { GameObject note_ = Object.Instantiate(SlideNote_prefab, new Vector3((float)note.pos, (float)(note._time * SPEED), -3.556f), Quaternion.Euler(0, 0, 0)); note_.name = "Slide Note ID: " + note.id_; note_.transform.localScale = new Vector3((float)note.size / 2, 0.6275f, 0.2f); note_.transform.SetParent(transform); } }
private static string getOctaveMod(D_Note note, D_Note previous_note, ref int current_scope_octave) { int difference, notes_octave_difference; string sign = ""; if (previous_note != null) { notes_octave_difference = getOctaveDifference(note, previous_note); current_scope_octave += notes_octave_difference; } difference = (note.octave - current_scope_octave); if (current_scope_octave > note.octave) { sign = ","; } else if (current_scope_octave < note.octave) { sign = "'"; } else { return(""); } current_scope_octave += difference; return(StringUtil.duplicateString(sign, Math.Abs(difference))); }
private void composeBars(List <D_Bar> bars, ref string lilypondString, ref int current_scope_octave) { D_Note previous_note = null; D_Measure current_measure = bars[0].measure; foreach (D_Bar bar in bars) { lilypondString += " "; if (bar.measure != current_measure) { current_measure = bar.measure; composeMeasureInformation(current_measure, ref lilypondString); lilypondString += " "; } foreach (D_Note note in bar.notes) { lilypondString += LilypondNoteComposer.placeNoteInLilypondString(note, previous_note, ref current_scope_octave); lilypondString += " "; if (!note.is_rest) { previous_note = note; } } lilypondString += "|\r\n"; } }
public static string placeNoteInLilypondString(D_Note note, D_Note previous_note, ref int current_scope_octave) { string lilypondString = ""; string note_alteration = ""; string octave_mod = ""; char note_level = getNoteLevel(note); if (!note.is_rest) { note_alteration = getNoteAlteration(note); octave_mod = getOctaveMod(note, previous_note, ref current_scope_octave); } string note_length = getNoteLength(note); string length_mod = getNoteModifier(note); lilypondString += String.Format("{0}{1}{2}{3}{4}", note_level, note_alteration, octave_mod, note_length, length_mod); if (note.note_tie == NoteTie.start) { lilypondString += " ~"; } return(lilypondString); }
private static string getNoteLength(D_Note note) { int note_length_int = (note.length_modifier) ? (int)((double)note.length / 1.5) : note.length; note_length_int = (int)(16 / (double)note_length_int); return(String.Format("{0}", note_length_int)); }
public void TestSplitNote() { D_Note original_note = new D_Note(NoteLevel.C, 12, NoteTie.none); Tuple <D_Note, D_Note> returned = D_Note.splitNote(original_note, 8); Assert.AreEqual(8, returned.Item1.length); Assert.AreEqual(4, returned.Item2.length); Assert.AreEqual(NoteLevel.C, returned.Item1.level); Assert.AreEqual(NoteLevel.C, returned.Item2.level); Assert.AreEqual(NoteTie.start, returned.Item1.note_tie); Assert.AreEqual(NoteTie.stop, returned.Item2.note_tie); }
private static string getNoteAlteration(D_Note note) { if (note.alteration == NoteAlteration.none) { return(""); } else if (note.alteration == NoteAlteration.sharp) { return("is"); } else { return("es"); } }
private void composeRelativeInformation(D_Note first_note, ref string lilypondString, ref int current_scope_octave) { int first_note_octave = first_note.octave; string octave_modifiers = ""; if (first_note_octave > central_c_ocatave) { octave_modifiers = StringUtil.duplicateString("'", first_note_octave - central_c_ocatave); } else if (first_note_octave < central_c_ocatave) { octave_modifiers = StringUtil.duplicateString(",", central_c_ocatave - first_note_octave); } current_scope_octave = first_note_octave; lilypondString += String.Format("\\relative c{0}{{\r\n", octave_modifiers); }
private static int getOctaveDifference(D_Note note, D_Note previous_note) { int steps = LilypondUtil.getClosestNotePositionInSteps(previous_note, note); if (LilypondUtil.newNoteOctaveChange(previous_note, steps)) { if (steps < 0) { return(-1); } else if (steps > 0) { return(1); } throw new Exception("Octave changes with 0 steps"); } return(0); }
private static string getNoteModifier(D_Note note) { return((note.length_modifier) ? "." : ""); }
private static char getNoteLevel(D_Note note) { return(noteLeveltoChar[note.level]); }
static D_Chart DeserializeManual(string json) { D_Chart ch = new D_Chart(); Dictionary <string, object> dictionary = json.dictionaryFromJson(); foreach (var kp in dictionary) { if (kp.Key == "speed") { ch.speed = Convert.ToDouble(kp.Value); } else if (kp.Key == "notes") { List <D_Note> lnotes = new List <D_Note> (); List <object> notes = (kp.Value.ToString()).listFromJson(); foreach (var n in notes) { Dictionary <string, object> main_props = n.ToString().dictionaryFromJson(); D_Note n_ = new D_Note(); foreach (var props in main_props) { if (props.Key == "$id") { n_.id_ = props.Value.ToString(); } else if (main_props.ContainsKey("type") && props.Key == "type") { n_.type = Convert.ToInt32(props.Value); } else if (main_props.ContainsKey("sounds") && props.Key == "sounds") { List <D_Sound> s = new List <D_Sound> (); List <object> soundss = props.Value.ToString().listFromJson(); foreach (var sound in soundss) { D_Sound ss = new D_Sound(); Dictionary <string, object> so = sound.ToString().dictionaryFromJson(); foreach (var s_va in so) { if (s_va.Key == "w") { ss.w = Convert.ToDouble(s_va.Value); } else if (s_va.Key == "d") { ss.d = Convert.ToDouble(s_va.Value); } else if (s_va.Key == "p") { ss.p = Convert.ToInt32(s_va.Value); } else if (s_va.Key == "v") { ss.v = Convert.ToInt32(s_va.Value); } } s.Add(ss); } n_.sounds = s; } else if (props.Key == "pos") { n_.pos = Convert.ToDouble(props.Value); } else if (props.Key == "size") { n_.size = Convert.ToDouble(props.Value); } else if (props.Key == "_time") { n_._time = Convert.ToDouble(props.Value); } else if (props.Key == "shift") { n_.shift = Convert.ToDouble(props.Value); } else if (props.Key == "time") { n_.time = Convert.ToDouble(props.Value); } } lnotes.Add(n_); } ch.notes = lnotes; } else if (kp.Key == "links") { List <D_Link> llinks = new List <D_Link> (); List <object> l1 = kp.Value.ToString().listFromJson(); foreach (var sama in l1) { D_Link lll = new D_Link(); Dictionary <string, object> dl = sama.ToString().dictionaryFromJson(); List <object> ref_d = dl ["notes"].ToString().listFromJson(); List <D_Note2> l2 = new List <D_Note2> (); foreach (var ref_dd in ref_d) { D_Note2 note2 = new D_Note2(); Dictionary <string, object> only1ref = ref_dd.ToString().dictionaryFromJson(); note2.ref_ = only1ref ["$ref"].ToString(); l2.Add(note2); } lll.notes = l2; llinks.Add(lll); } ch.links = llinks; } } if (ch != null) { Debug.Log("Success"); //Debug.Log (JsonConvert.SerializeObject (ch)); } return(ch); }