Esempio n. 1
0
        public RenderItem(UPhoneme phoneme, UVoicePart part, UProject project)
        {
            var singer = project.Tracks[part.TrackNo].Singer;

            SourceFile = phoneme.Oto.File;
            SourceFile = Path.Combine(PathManager.Inst.InstalledSingersPath, SourceFile);

            var strechRatio      = Math.Pow(2, 1.0 - (double)(int)phoneme.Parent.Expressions["velocity"].Data / 100);
            var length           = phoneme.Oto.Preutter * strechRatio + phoneme.Envelope.Points[4].X;
            var requiredLength   = Math.Ceiling(length / 50 + 1) * 50;
            var lengthAdjustment = phoneme.TailIntrude == 0 ? phoneme.Preutter : phoneme.Preutter - phoneme.TailIntrude + phoneme.TailOverlap;

            NoteNum        = phoneme.Parent.NoteNum;
            Velocity       = (int)phoneme.Parent.Expressions["velocity"].Data;
            Volume         = (int)phoneme.Parent.Expressions["volume"].Data;
            StrFlags       = phoneme.Parent.GetResamplerFlags();
            PitchData      = BuildPitchData(phoneme, part, project);
            RequiredLength = (int)requiredLength;
            Oto            = phoneme.Oto;
            Tempo          = project.BPM;

            SkipOver = phoneme.Oto.Preutter * strechRatio - phoneme.Preutter;
            PosMs    = project.TickToMillisecond(part.PosTick + phoneme.Parent.PosTick + phoneme.PosTick) - phoneme.Preutter;
            DurMs    = project.TickToMillisecond(phoneme.DurTick) + lengthAdjustment;
            Envelope = phoneme.Envelope.Points;

            phonemeName = phoneme.Phoneme;
        }
Esempio n. 2
0
        public RenderItem(UPhoneme phoneme, UVoicePart part, UTrack track, UProject project, string resamplerName)
        {
            SourceFile    = phoneme.oto.File;
            SourceFile    = Path.Combine(PathManager.Inst.InstalledSingersPath, SourceFile);
            ResamplerName = resamplerName;
            if (project.expressions.TryGetValue("eng", out var descriptor))
            {
                int    index     = (int)phoneme.GetExpression(project, "eng").Item1;
                string resampler = descriptor.options[index];
                if (!string.IsNullOrEmpty(resampler))
                {
                    ResamplerName = resampler;
                }
            }
            string ext = Path.GetExtension(SourceFile);

            SourceTemp = Path.Combine(PathManager.Inst.GetCachePath(null),
                                      $"{HashHex(track.Singer.Id)}-{HashHex(phoneme.oto.Set)}-{HashHex(SourceFile)}{ext}");

            Velocity   = (int)phoneme.GetExpression(project, "vel").Item1;
            Volume     = (int)phoneme.GetExpression(project, "vol").Item1;
            Modulation = (int)phoneme.GetExpression(project, "mod").Item1;
            var strechRatio      = Math.Pow(2, 1.0 - Velocity / 100.0);
            var length           = phoneme.oto.Preutter * strechRatio + phoneme.envelope.data[4].X;
            var requiredLength   = Math.Ceiling(length / 50 + 1) * 50;
            var lengthAdjustment = phoneme.tailIntrude == 0 ? phoneme.preutter : phoneme.preutter - phoneme.tailIntrude + phoneme.tailOverlap;

            NoteNum        = phoneme.Parent.tone;
            StrFlags       = phoneme.GetResamplerFlags(project);
            PitchData      = BuildPitchData(phoneme, part, project);
            RequiredLength = (int)requiredLength;
            Oto            = phoneme.oto;
            Tempo          = project.bpm;

            SkipOver = phoneme.oto.Preutter * strechRatio - phoneme.preutter;
            PosMs    = project.TickToMillisecond(part.position + phoneme.Parent.position + phoneme.position) - phoneme.preutter;
            DurMs    = project.TickToMillisecond(phoneme.Duration) + lengthAdjustment;
            Envelope = phoneme.envelope.data;

            phonemeName = phoneme.phoneme;
        }