public Track(Singer singer) { Singer = singer; if (!Singer.IsEnabled) { throw new Exception("dsdasdf"); } }
public SingerManager() { InitSingers(); if (!Singers.ContainsKey(Settings.Current.DefaultVoicebank)) { throw new Exception("нет такого"); } DefaultSinger = Singers[Settings.Current.DefaultVoicebank]; DefaultSinger.Load(); }
public void ResolveLengths(Singer singer) { for (var i = 0; i < Heads.Count; i++) { var head = Heads[i]; var next = (RenderNote)Heads.ElementAtOrDefault(i + 1) ?? this; head.RenderLength = (int)(FREE_CONSONANT_LENGTH + next.SafeOto.Preutter); if (head.RenderLength <= 0) { throw new Exception(); } } ChildrenLength = 0; for (var index = 0; index < Children.Count; index++) { var child = Children[index]; var next = Children.ElementAtOrDefault(index + 1); if (next != null) { child.RenderLength = (int)(FREE_CONSONANT_LENGTH + next.SafeOto.Preutter); if (child.RenderLength <= 0) { throw new Exception(); } } else { child.RenderLength = (int)singer.GetRestLength(child.SafeOto.Alias); } ChildrenLength += child.RenderLength; } RenderPosition = AbsoluteTime; RenderLength = Length; var headsOffset = 0; for (int i = Heads.Count; i > 0; i--) { var head = Heads[i - 1]; headsOffset += head.RenderLength; head.RenderPosition = RenderPosition - headsOffset; if (head.RenderPosition <= 0) { throw new Exception(); } } ResolvePositions(); }
public void LoadSinger(string dir) { if (dir.StartsWith("%VOICE%")) { var name = dir.Replace("%VOICE%", ""); dir = Path.Combine(Settings.Current.VoicebankDirectory, name); } var singer = new Singer(dir); if (Singers.ContainsKey(singer.Name)) { return; } SingerNames.Add(singer.Name); Singers[singer.Name] = singer; }
public SingerDictionary(Singer singer) { if (!singer.IsEnabled) { return; } if (singer.VoicebankType == null) { return; } var dir = Path.Combine(Settings.Current.Local, "Dict", singer.VoicebankType + ".dict"); if (!File.Exists(dir)) { return; } Open(dir); }
//public int UnitPerBar => BeatPerBar * BeatUnit; public Project(Singer defaultSinger) { DefaultSinger = defaultSinger; }
public void BuildRenderPart(Part part) { SourcePart = part; Singer = SourcePart.Track.Singer; if (Singer == null) { throw new Exception(); } RenderPart = new Part { Track = new Track(Singer), IsRender = true }; SourcePart.RenderPart = RenderPart; var notes = RenderPart.Notes; var consonantsQueue = new List <string>(); Note prevNote = null; RenderNote prevRenderNote = null; RenderNoteParent prevVowel = null; foreach (var note in SourcePart.Notes) { prevRenderNote = ProcessRestNotesForRenderBuild(prevNote, note, consonantsQueue, notes, prevVowel, prevRenderNote); if (prevNote == null || prevNote.AbsoluteTime + prevNote.Length < note.AbsoluteTime) { prevVowel = null; } var phonemes = note.Phonemes.Split(' '); var vowelIndex = -1; for (var i = 0; i < phonemes.Length; i++) { if (Singer.IsVowel(phonemes[i])) { vowelIndex = i; break; } } if (vowelIndex == -1) { consonantsQueue.AddRange(phonemes); continue; } var fromPrevCount = consonantsQueue.Count; for (var i = 0; i < vowelIndex; i++) { consonantsQueue.Add(phonemes[i]); } RenderNoteParent vowel = new RenderNoteParent(RenderPart, note); vowel.Length = note.Length; vowel.AbsoluteTime = note.AbsoluteTime; FillRenderNote(vowel, phonemes[vowelIndex], note); var lengthParent = prevVowel ?? vowel; var newNotes = new List <RenderNote>(); for (var i = consonantsQueue.Count - 1; i >= 0; i--) { var phoneme = consonantsQueue[i]; var length = (int)Singer.GetConsonantLength(phoneme); var pitchParent = i < consonantsQueue.Count - fromPrevCount && prevRenderNote != null ? prevRenderNote : note; var newNote = new RenderNoteChild(RenderPart, lengthParent); FillRenderNote(newNote, phoneme, pitchParent); newNotes.Add(newNote); if (prevVowel != null) { prevVowel.AddChildAsFirst(newNote); } else { vowel.AddHeadAsFirst(newNote); } } consonantsQueue.Clear(); newNotes.Reverse(); notes.AddRange(newNotes); notes.Add(vowel); for (int i = vowelIndex + 1; i < phonemes.Length; i++) { consonantsQueue.Add(phonemes[i]); } prevRenderNote = vowel; prevVowel = vowel; prevNote = note; } ProcessRestNotesForRenderBuild(prevNote, null, consonantsQueue, notes, prevVowel, prevRenderNote); ProcessOto(notes); ResolveLength(notes); ProcessEnvelope(notes); }