Пример #1
0
    /// <summary>
    /// スクリプトの本体
    /// </summary>
    /// <param name="vsq"></param>
    /// <returns></returns>
    public static ScriptReturnStatus Edit(VsqFileEx vsq)
    {
        int          selected  = AppManager.getSelected();
        VsqTrack     vsq_track = vsq.Track[selected];
        RendererKind kind      = VsqFileEx.getTrackRendererKind(vsq_track);

        if (kind != RendererKind.UTAU)
        {
            return(ScriptReturnStatus.NOT_EDITED);
        }
        bool edited = false;

        foreach (var item in AppManager.itemSelection.getEventIterator())
        {
            VsqEvent original = item.original;
            if (original.ID.type != VsqIDType.Anote)
            {
                continue;
            }
            VsqEvent     singer = vsq_track.getSingerEventAt(original.Clock);
            SingerConfig sc     = AppManager.getSingerInfoUtau(singer.ID.IconHandle.Language, singer.ID.IconHandle.Program);
            if (sc != null && AppManager.mUtauVoiceDB.ContainsKey(sc.VOICEIDSTR))
            {
                string      phrase    = original.ID.LyricHandle.L0.Phrase;
                UtauVoiceDB db        = AppManager.mUtauVoiceDB[sc.VOICEIDSTR];
                int         CheckNote = original.ID.Note;
                if (original.UstEvent != null)
                {
                    CheckNote = original.UstEvent.ReplaceNoteID > 0 ? original.UstEvent.ReplaceNoteID : original.ID.Note;
                }
                OtoArgs  oa      = db.attachFileNameFromLyric(phrase, CheckNote);
                VsqEvent editing = vsq_track.findEventFromID(original.InternalID);
                if (editing.UstEvent == null)
                {
                    editing.UstEvent = new UstEvent();
                }
                editing.UstEvent.setVoiceOverlap(oa.msOverlap);
                editing.UstEvent.setPreUtterance(oa.msPreUtterance);
                edited = true;
            }
        }

        return(edited ? ScriptReturnStatus.EDITED : ScriptReturnStatus.NOT_EDITED);
    }
Пример #2
0
        public void test()
        {
            var config = new SingerConfig();

            config.VOICEIDSTR = "./fixture/utau_voice_db";
            var db = new UtauVoiceDB(config);
            {
                var actual = db.attachFileNameFromLyric("あ", 60);
                Assert.AreEqual("あ", actual.Alias);
                Assert.AreEqual("あ.wav", actual.fileName);
                Assert.AreEqual(6f, actual.msOffset);
                Assert.AreEqual(52f, actual.msConsonant);
                Assert.AreEqual(69f, actual.msBlank);
                Assert.AreEqual(1f, actual.msPreUtterance);
                Assert.AreEqual(2f, actual.msOverlap);
            }
            {
                var actual = db.attachFileNameFromLyric("わ", 61);
                Assert.AreEqual("わ↑", actual.Alias);
                Assert.AreEqual(@"A\わ↑.wav", actual.fileName);
            }
        }