Beispiel #1
0
        public static void InsertNote(string number, string lyric, Insert insert = Insert.Before)
        {
            string        newNumber   = UpgradeNumber(number, 0, 10, insert: insert);
            List <string> listNumbers = Numbers.ToList();
            int           newIndex    = listNumbers.IndexOf(number);

            listNumbers.Insert(newIndex + 1, newNumber);
            Ust.Numbers = listNumbers.ToArray();

            UNote notePrev = uNotes[number];
            UNote noteN    = notePrev.Copy();

            noteN.Lyric = lyric;
            int len = GetLength(lyric);

            if (len > notePrev.Length)
            {
                // note length is too small
                return;
            }
            noteN.Length     = len;
            notePrev.Length -= noteN.Length;

            uNotes[newNumber] = noteN;
        }
Beispiel #2
0
        public static void Merge(List <string> numbers)
        {
            // Merge all notes to 1

            UNote         NewNote   = uNotes[Numbers[0]].Copy();
            string        NewNumber = $"[#{Numbers.First().Substring(2,4)}-{Numbers.Last().Substring(2, 4)}]";
            List <string> lyrics    = new List <string> {
            };
            List <int> length       = new List <int> {
            };

            foreach (string number in numbers)
            {
                UNote note = uNotes[number];
                lyrics.Add(note.Lyric);
                length.Add(note.Length);
                uNotes[number] = new UNote();
            }
            string NewLyric  = String.Join(" ", lyrics);
            int    NewLength = length.Sum();

            NewNote.Length = NewLength;
            NewNote.Lyric  = NewLyric;

            uNotes[NewNumber] = NewNote;
            Numbers           = new string[] { NewNumber };
        }
Beispiel #3
0
        public static void Split(string number)
        {
            // Bisect all notes
            Dictionary <string, UNote> NewNotes = new Dictionary <string, UNote> {
            };
            List <string> NewNumbers            = new List <string> {
            };
            string initNumber = Ust.Numbers[0];
            int    i          = 0;
            string currentNumber;
            UNote  note       = uNotes[number];
            UNote  noteN      = note.Copy();
            int    initLength = note.Length;

            note.Length  = initLength * 2 / 3;
            noteN.Length = initLength - note.Length;
            noteN.SetDefaultNoteSettings();

            currentNumber = UpgradeNumber(initNumber, i);
            NewNumbers.Add(currentNumber);
            NewNotes[currentNumber] = note;

            currentNumber = UpgradeNumber(initNumber, i, 10);
            NewNumbers.Add(currentNumber);
            NewNotes[currentNumber] = noteN;
            Ust.Numbers             = NewNumbers.ToArray();
            Ust.uNotes = NewNotes;
        }
Beispiel #4
0
        private static UNote NoteRead(dynamic data, string which, ref long absoluteTime, out string number)
        {
            // May be #PREV, #0000 .... #NNNN, #NEXT
            if (int.TryParse(which, out int tempInt))
            {
                number = Number2NoteNumber(tempInt);
            }
            else
            {
                number = $"[#{which}]";
            }

            UNote note = new UNote();
            int   i    = 0;

            Console.WriteLine($"Setting values for note {number}");
            foreach (string parameter in data[number].Keys)
            {
                Console.WriteLine($"\tTrying set parameter  {parameter}");
                var value = data[number][parameter];
                note.Set(parameter, value);
                i++;
            }
            note.UNumber      = number;
            note.AbsoluteTime = absoluteTime;
            absoluteTime     += (long)note.Length;

            return(note);
        }
Beispiel #5
0
        public static void SetLyric(string[] lyric)
        {
            int i = 0;

            foreach (string number in Numbers)
            {
                UNote note = uNotes[number];
                note.SetLyric(lyric[i]);
                i++;
            }
        }
Beispiel #6
0
        public UNote CopyWhole()
        {
            // Copy all parameters
            UNote NewNote = new UNote();

            foreach (string parameter in GotParameters)
            {
                NewNote[parameter] = this[parameter];
            }
            NewNote.GotParameters = GotParameters;
            return(NewNote);
        }
Beispiel #7
0
        public UNote Copy()
        {
            // Copy only main parameters
            UNote         NewNote       = new UNote();
            List <string> NewParameters = new List <string> {
            };

            foreach (string parameter in GotParameters)
            {
                if (Parameters.Contains(parameter))
                {
                    NewNote[parameter] = this[parameter];
                    NewParameters.Add(parameter);
                }
                //else
                //{
                //    NewNote.SetDefault(parameter);
                //    NewParameters.Add(parameter);
                //}
            }
            NewNote.GotParameters = NewParameters;
            return(NewNote);
        }
Beispiel #8
0
 public static string BuildPitchData(UNote note)
 {
     // Nada napisat
     return("");
 }
Beispiel #9
0
        private void Read(dynamic data, string[] sections)
        {
            string stage = "Init";

            stage = "Version";
            // Reading string
            // uVersion = data["[#VERSION]"];
            // Reading settings
            stage = "Setting";
            data["[#SETTING]"].Keys.CopyTo(USettingsList, 0);
            foreach (string setting in USettingsList)
            {
                stage = $"Setting: {setting}";
                if (data["[#SETTING]"].ContainsKey(setting))
                {
                    uSettings[setting] = data["[#SETTING]"][setting];
                }
            }

            // Sections - Version, Settings;
            stage      = "Notes count";
            NotesCount = data["SectionsNumber"] - 3;
            if (data.ContainsKey("[#PREV]"))
            {
                NotesCount--;
            }
            if (data.ContainsKey("[#NEXT]"))
            {
                NotesCount--;
            }

            long absoluteTime = 0;

            // Reading prev
            stage   = "Prev";
            hasPrev = data.ContainsKey("[#PREV]");
            if (hasPrev)
            {
                uPrev = NoteRead(data, "PREV", ref absoluteTime, out string number);
            }

            // Reading notes
            stage   = "Notes";
            uNotes  = new Dictionary <string, UNote> {
            };
            Numbers = new string[NotesCount];
            stage   = "Searching first note number";
            int firstNote = -1;

            if (hasPrev)
            {
                firstNote = NoteNumber2Number(sections[4]);
            }
            else
            {
                firstNote = NoteNumber2Number(sections[3]);
            }
            NotesList = new UNote[NotesCount];

            for (int i = 0; i < NotesCount; i++)
            {
                stage = $"Note: {i}";
                UNote note = NoteRead(data, (i + firstNote).ToString(), ref absoluteTime, out string number);
                uNotes[number] = note;
                Numbers[i]     = number;
                NotesList[i]   = note;
            }

            // Reading next
            stage   = "Next";
            hasNext = data.ContainsKey("[#NEXT]");
            if (hasNext)
            {
                uNext = NoteRead(data, "NEXT", ref absoluteTime, out string number);
            }
            Console.WriteLine("Read UST successfully");
        }