コード例 #1
0
        protected override void OnRender(DrawingContext drawingContext)
        {
            int    note = UIConstants.MaxNoteNum - 1 - (int)(OffsetY / TrackHeight);
            double top  = TrackHeight * (UIConstants.MaxNoteNum - note - 1) - OffsetY;

            while (top < _size.Height)
            {
                drawingContext.DrawRectangle(
                    MusicMath.IsBlackKey(note) ? ThemeManager.BlackKeyBrushNormal :
                    MusicMath.IsCenterKey(note) ? ThemeManager.CenterKeyBrushNormal : ThemeManager.WhiteKeyBrushNormal,
                    null,
                    new Rect(0, (int)top, _size.Width, TrackHeight));

                if (TrackHeight >= 12)
                {
                    FormattedText text = new FormattedText(
                        MusicMath.GetToneName(note),
                        System.Threading.Thread.CurrentThread.CurrentUICulture,
                        FlowDirection.LeftToRight,
                        SystemFonts.CaptionFontFamily.GetTypefaces().First(),
                        12,
                        MusicMath.IsBlackKey(note) ? ThemeManager.BlackKeyNameBrushNormal :
                        MusicMath.IsCenterKey(note) ? ThemeManager.CenterKeyNameBrushNormal : ThemeManager.WhiteKeyNameBrushNormal,
                        VisualTreeHelper.GetDpi(this).PixelsPerDip
                        );
                    drawingContext.DrawText(text, new Point(42 - text.Width, (int)(top + (TrackHeight - text.Height) / 2)));
                }
                top += TrackHeight;
                note--;
            }
        }
コード例 #2
0
        /// <summary>
        /// Utility method to map a phoneme alias to proper pitch using prefixmap.
        /// For example, MapPhoneme("あ", 72, singer) may return "あC5".
        /// </summary>
        /// <param name="phoneme">Alias before pitch mapping.</param>
        /// <param name="tone">Music tone of note. C4 = 60.</param>
        /// <param name="singer">The singer.</param>
        /// <returns>Mapped alias.</returns>
        public static string MapPhoneme(string phoneme, int tone, USinger singer)
        {
            var toneName = MusicMath.GetToneName(tone);

            if (singer.PrefixMap.TryGetValue(toneName, out var prefix))
            {
                var phonemeMapped = prefix.Item1 + phoneme + prefix.Item2;
                if (singer.FindOto(phonemeMapped) != null)
                {
                    phoneme = phonemeMapped;
                }
            }
            return(phoneme);
        }
コード例 #3
0
ファイル: USinger.cs プロジェクト: SeleDreams/OpenUtau
        public bool TryGetMappedOto(string phoneme, int tone, out UOto oto)
        {
            oto = default;
            string toneName = MusicMath.GetToneName(tone);

            if (PrefixMap.TryGetValue(toneName, out var mapped))
            {
                string phonemeMapped = mapped.Item1 + phoneme + mapped.Item2;
                if (TryGetOto(phonemeMapped, out oto))
                {
                    return(true);
                }
            }
            if (TryGetOto(phoneme, out oto))
            {
                return(true);
            }
            return(false);
        }
コード例 #4
0
ファイル: DriverModels.cs プロジェクト: SeleDreams/OpenUtau
        /// <summary>
        /// 从RenderItem初始化过程
        /// </summary>
        /// <returns></returns>
        internal static EngineInput CreateInputModel(RenderItem renderItem, double Modulation)
        {
            EngineInput Ret = new EngineInput
            {
                inputWaveFile  = renderItem.SourceTemp,
                NoteString     = MusicMath.GetToneName(renderItem.NoteNum),
                Velocity       = renderItem.Velocity,
                StrFlags       = renderItem.StrFlags,
                Offset         = renderItem.Oto.Offset,
                RequiredLength = renderItem.RequiredLength,
                Consonant      = renderItem.Oto.Consonant,
                Cutoff         = renderItem.Oto.Cutoff,
                Volume         = renderItem.Volume,
                Modulation     = Modulation,
                pitchBend      = renderItem.PitchData.ToArray(),
                nPitchBend     = renderItem.PitchData.Count,
                Tempo          = renderItem.Tempo
            };

            return(Ret);
        }
コード例 #5
0
ファイル: RenderItem.cs プロジェクト: SeleDreams/OpenUtau
 public string GetResamplerExeArgs()
 {
     // fresamp.exe <infile> <outfile> <tone> <velocity> <flags> <offset> <length_req>
     // <fixed_length> <endblank> <volume> <modulation> <pitch>
     return(FormattableString.Invariant($"{MusicMath.GetToneName(NoteNum)} {Velocity:D} \"{StrFlags}\" {Oto.Offset} {RequiredLength:D} {Oto.Consonant} {Oto.Cutoff} {Volume:D} {Modulation:D} T{Tempo} {Base64.Base64EncodeInt12(PitchData.ToArray())}"));
 }