Пример #1
0
        /// <summary>
        ///     Send Note to AppendTool
        /// </summary>
        public void SendToAppendTool(RenderNote note, RenderNote next, string filename)
        {
            var offset = note.Pre;

            if (next != null)
            {
                offset -= next.StraightPre;
            }

            var    envelope = note.Envelope;
            var    sign     = offset >= 0 ? "+" : "-";
            var    length   = $"{note.RenderLength}@{Settings.Current.Tempo}{sign}{Math.Abs(offset).ToString("f0")}";
            string ops      = string.Format("{0} {1} {2} {3} {4} {5} {6} {7} {8} {9} {10} {11} {12}",
                                            note.Stp, // STP,
                                            length,   //note.RequiredLength,
                                            envelope.p1,
                                            envelope.p2,
                                            envelope.p3,
                                            envelope.v1,
                                            envelope.v2,
                                            envelope.v3,
                                            envelope.v4,
                                            note.Ovl, //note.Oto.Overlap,
                                            envelope.p4,
                                            envelope.p5,
                                            envelope.v5);
            var request = $"\"{Settings.Current.AppendTool}\" \"{Settings.Current.Output}\" \"{filename}\" {ops} \r\n";

            File.AppendAllText(Settings.Current.Bat, request);
        }
Пример #2
0
        private void FillRenderNote(RenderNote note, string phoneme, Note pitchParent)
        {
            note.Lyric      = phoneme;
            note.Phonemes   = phoneme;
            note.Intensity  = pitchParent.Intensity;
            note.NoteNum    = pitchParent.NoteNum;
            note.Modulation = pitchParent.Modulation;

            ReportRenderBuild($"{note.AbsoluteTime}\t{note.Length}\t{note}");
        }
Пример #3
0
        private int GetRequiredLength(RenderNote note, RenderNote next)
        {
            var    len            = note.FinalLength;
            double requiredLength = len + note.Pre;

            //if (next != null)
            //    requiredLength -= next.StraightPre;

            requiredLength = Math.Ceiling((requiredLength + note.Stp + 25) / 50) * 50;
            return((int)requiredLength);
        }
Пример #4
0
        public void SendToResampler(RenderNote note, RenderNote next, string tempFilename)
        {
            var    pitchBase64 = Base64.Current.Base64EncodeInt12(TakeEach(note.PitchBend.Array, Settings.Current.SkipOnRender));
            var    oto         = note.SafeOto;
            string request     = string.Format(
                "\"{0}\" \"{1}\" \"{2}\" {3} {4:D} \"{5}\" {6} {7:D} {8} {9} {10:D} {11:D} !{12} {13}\r\n\r\n",
                Settings.Current.Resampler,
                Path.Combine(Part.Track.Singer.Dir, oto.File),
                tempFilename,
                MusicMath.Current.NoteNum2String(note.NoteNum - 12),
                note.Velocity,
                Part.Flags + note.Flags,
                oto.Offset,
                (int)GetRequiredLength(note, next),
                oto.Consonant,
                oto.Cutoff,
                note.Intensity,
                note.Modulation,
                note.NoteNum,
                pitchBase64);

            File.AppendAllText(Settings.Current.Bat, request);
        }
Пример #5
0
        private RenderNote ProcessRestNotesForRenderBuild(Note prevNote, Note note, List <string> consonantsQueue, List <Note> notes, RenderNoteParent prevVowel, RenderNote prevRenderNote)
        {
            if (RenderPart.Notes.Count == 0)
            {
                return(null);
            }
            if (prevNote != null && (note == null || prevNote.AbsoluteTime + prevNote.Length < note.AbsoluteTime))
            {
                var last = (RenderNote)RenderPart.Notes[RenderPart.Notes.Count - 1];
                foreach (var phoneme in consonantsQueue)
                {
                    var addedNote = new RenderNoteChild(RenderPart, prevVowel);
                    FillRenderNote(addedNote, phoneme, prevVowel);
                    notes.Add(addedNote);
                    prevVowel.AddChild(addedNote);
                    last = addedNote;
                }
                consonantsQueue.Clear();
                var exhaleNote = new RenderNoteChild(RenderPart, prevVowel);
                FillRenderNote(exhaleNote, TransitionTool.Current.GetExhaleLength(last.Phonemes), prevVowel);
                exhaleNote.IsExhale = true;
                notes.Add(exhaleNote);
                prevVowel.AddChild(exhaleNote);

                if (!last.IsRender)
                {
                    throw new Exception();
                }
                return(last);
            }

            return(prevRenderNote);
        }
Пример #6
0
        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);
        }