示例#1
0
        public void MainWindow_OnSingerChanged(string path)
        {
            Log("Singer", "Singer changed...");
            Singer singer = new Singer(path);

            if (singer.IsEnabled)
            {
                SetSinger(singer); return;
            }
            string subpath = Directory.GetParent(path).FullName;

            singer = new Singer(subpath);
            if (singer.IsEnabled)
            {
                SetSinger(singer); return;
            }
            else
            {
                MessageBoxResult result = MessageBox.Show("Singer is not valid. Try again?", "Error on reading singer", MessageBoxButton.YesNo, MessageBoxImage.Error);
                if (result == MessageBoxResult.Yes)
                {
                    MainWindow.ShowSingerDialog();
                }
            }
        }
示例#2
0
 void AdjustLength(Ust ust)
 {
     Log("Adjusting length", "Starting...");
     foreach (UNote note in Ust.MainNotes)
     {
         note.Length = note.InitLength;
         foreach (UNote child in note.Children)
         {
             if (child is null)
             {
                 continue;
             }
             double length = TransLength;
             Oto    oto    = Singer.FindOto(child.Phonemes);
             if (oto != null)
             {
                 length = oto.Length;
             }
             else
             {
                 Log("Converting to aliases", $"No alias found for {child.Phonemes}");
             }
             child.Length = MusicMath.MillisecondToTick(length, ust.Tempo);
             if (note.Length - child.Length < 10)
             {
                 child.Length = note.Length / 2;
             }
             note.Length -= child.Length;
         }
     }
     Log("Adjusting length", "Completed");
 }
示例#3
0
 void SetSinger(Singer singer)
 {
     Log("Singer", "Set singer...");
     Singer = singer;
     MainWindow.ChangeSingerButton.ToolTip = Singer.Name;
     Refresh();
 }
示例#4
0
 public void SetWindow(MainWindow mainWindow)
 {
     Log("Core", "Initiating...");
     Log("Core", "Start reading files...");
     MainWindow      = mainWindow;
     mainWindow.Core = this;
     Log("Atlas", "Reading atlas...");
     try
     {
         Atlas = new Atlas(Dir);
     }
     catch (Exception ex)
     {
         Log("Atlas", $"{ex.Message }\r\n{ex.Source}\r\n{ex.TargetSite}\r\n{ex.StackTrace}", true);
         return;
     }
     Log("Atlas", "Reading complited.");
     Log("Dict", "Start reading...");
     try
     {
         Dict = new Dict();
     }
     catch (Exception ex)
     {
         Log("Dict", $"{ex.Message }\r\n{ex.Source}\r\n{ex.TargetSite}\r\n{ex.StackTrace}", true);
         return;
     }
     Log("Dict", "Reading complited.");
     Log("Ust", "Start reading...");
     try
     {
         Ust = new Ust(Dir);
     }
     catch (Exception ex)
     {
         Log("Ust", $"{ex.Message }\r\n{ex.Source}\r\n{ex.TargetSite}\r\n{ex.StackTrace}", true);
         return;
     }
     Log("Ust", "Reading complited.");
     Log("Singer", "Start reading...");
     try
     {
         Singer = new Singer(Ust.VoiceDir);
     }
     catch (Exception ex)
     {
         Log("Singer", $"{ex.Message }\r\n{ex.Source}\r\n{ex.TargetSite}\r\n{ex.StackTrace}", true);
         return;
     }
     Log("Singer", "Reading complited.");
     Log("Ust", "Reading complited.");
     Log("Core", "Reading files complited.");
     Log("Core", "Initiating values...");
     try
     {
         mainWindow.NewLengthDefault.Text      = TransLength.ToString();
         mainWindow.ChangeSingerButton.ToolTip = Singer.Name;
         InitUst = Ust.Clone();
         MainWindow.SetText(Ust.Notes);
         ConvertedUst = Process(Atlas, Ust);
         MainWindow.DrawNotes(Ust.Notes, ConvertedUst.Notes);
         MainWindow.OnNoteChanged   += OnNoteChanged_Core;
         MainWindow.OnTextChanged   += OnTextChanged_Core;
         MainWindow.OnSave          += Core_OnSave;
         mainWindow.OnLengthChanged += delegate(int length) { TransLength = length; };
         mainWindow.OnSingerChanged += MainWindow_OnSingerChanged;
         TransLength = (int)Ust.Tempo * 180 / 120;
         mainWindow.NewLengthDefault.Text = TransLength.ToString();
     }
     catch (Exception ex)
     {
         Log("Core", $"{ex.Message }\r\n{ex.Source}\r\n{ex.TargetSite}\r\n{ex.StackTrace}", true);
         return;
     }
     Log("Core", "Initiated.");
 }