コード例 #1
0
ファイル: ExpCommands.cs プロジェクト: SeleDreams/OpenUtau
 public SetPhonemeExpressionCommand(UProject project, UPhoneme phoneme, string abbr, float value)
 {
     this.project = project;
     this.phoneme = phoneme;
     Key          = abbr;
     newValue     = value;
     oldValue     = phoneme.GetExpression(project, abbr).Item1;
 }
コード例 #2
0
ファイル: RenderItem.cs プロジェクト: SeleDreams/OpenUtau
        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;
        }