예제 #1
0
        private decimal GetSliderValue(int avatorIdx, EnumVoiceEffect effect)
        {
            decimal          value         = 0.00m;
            FormsTextBox     TargetTextBox = null;
            AvatorParam_VREX avator        = AvatorParams[avatorIdx] as AvatorParam_VREX;

            switch (effect)
            {
            case EnumVoiceEffect.volume:
                TargetTextBox = avator.AvatorUI.VolumeText;
                break;

            case EnumVoiceEffect.speed:
                TargetTextBox = avator.AvatorUI.SpeedText;
                break;

            case EnumVoiceEffect.pitch:
                TargetTextBox = avator.AvatorUI.PitchText;
                break;

            case EnumVoiceEffect.intonation:
                TargetTextBox = avator.AvatorUI.IntonationText;
                break;
            }

            if (TargetTextBox != null)
            {
                value = Convert.ToDecimal(TargetTextBox.Text);
            }

            return(value);
        }
예제 #2
0
        private void ResetParameters(Val_Talker val_, Dictionary <string, WPFSlider> _interface)
        {
            TalkerPrimitive defaultParam = talkerDefaultParamList[val_.talkerRealName];

            AvatorParam_VREX avator = AvatorParams[ConvertNametoIndex(val_)] as AvatorParam_VREX;


            foreach (KeyValuePair <string, EffectValueInfo> val__ in defaultParam.VoiceEffects)
            {
                FormsTextBox TargetTextBox = null;
                double       value         = 0.00;
                if (val__.Key == "音量")
                {
                    TargetTextBox = avator.AvatorUI.VolumeText;
                    value         = (double)val__.Value.val;
                }
                else if (val__.Key == "話速")
                {
                    TargetTextBox = avator.AvatorUI.SpeedText;
                    value         = (double)val__.Value.val;
                }
                else if (val__.Key == "高さ")
                {
                    TargetTextBox = avator.AvatorUI.PitchText;
                    value         = (double)val__.Value.val;
                }
                else if (val__.Key == "抑揚")
                {
                    TargetTextBox = avator.AvatorUI.IntonationText;
                    value         = (double)val__.Value.val;
                }
                else
                {
                    break;
                }


                if (TargetTextBox != null)
                {
                    TargetTextBox.EmulateChangeText(string.Format("{0:0.00}", value));
                }
            }
        }
예제 #3
0
        private void ApplyEffectParameters(Val_Talker val_, Dictionary <string, WPFSlider> _interface)
        {
            FormsTextBox     TargetTextBox = null;
            double           value         = 0.00;
            AvatorParam_VREX avator        = AvatorParams[ConvertNametoIndex(val_)] as AvatorParam_VREX;

            foreach (var effect in avator.VoiceEffects)
            {
                switch (effect.Key)
                {
                case EnumVoiceEffect.volume:
                    TargetTextBox = avator.AvatorUI.VolumeText;
                    value         = (double)val_.parametor["音量"].val_decimal;
                    break;

                case EnumVoiceEffect.speed:
                    TargetTextBox = avator.AvatorUI.SpeedText;
                    value         = (double)val_.parametor["話速"].val_decimal;
                    break;

                case EnumVoiceEffect.pitch:
                    TargetTextBox = avator.AvatorUI.PitchText;
                    value         = (double)val_.parametor["高さ"].val_decimal;
                    break;

                case EnumVoiceEffect.intonation:
                    TargetTextBox = avator.AvatorUI.IntonationText;
                    value         = (double)val_.parametor["抑揚"].val_decimal;
                    break;
                }

                if (TargetTextBox != null)
                {
                    TargetTextBox.EmulateChangeText(string.Format("{0:0.00}", value));
                }
            }
        }
예제 #4
0
        /// <summary>
        /// 指定話者で指定テキストで発声
        /// </summary>
        /// <param name="cid">話者CID</param>
        /// <param name="talkText">発声させるテキスト</param>
        /// <returns>発声にかかった時間(ミリ秒)</returns>
        public double Play(Val_Talker talker, string talkText)
        {
            Stopwatch        stopWatch = new Stopwatch();
            int              avatorIdx = ConvertNametoIndex(talker);
            AvatorParam_VREX avator    = AvatorParams[avatorIdx] as AvatorParam_VREX;

//            avator.Semaphore.Wait();

            if (avator.AvatorUI.PlayButton == null)
            {
                return(0.0);
            }
            if (avator.AvatorUI.SaveButton == null)
            {
                return(0.0);
            }
            if (avator.AvatorUI.TalkTextBox == null)
            {
                return(0.0);
            }

            dynamic VoiceroidExUiTab = new FormsTabControl(avator.AvatorUI.uiTreeTop.IdentifyFromZIndex(2, 0, 0, 0, 0));

            VoiceroidExUiTab.EmulateTabSelect(2);

            //            ApplyEffectParameters(avatorIdx);
            //            ApplyEmotionParameters(avatorIdx);

            ApplyEffectParameters(talker, apply_interface[talker.talkerRealName]);

            // 再生中なので再生終了を待つ(音声保存ボタンがEnableになるのを待つ)
            if (!avator.AvatorUI.SaveButton.Enabled)
            {
                while (!avator.AvatorUI.SaveButton.Enabled)
                {
                    Thread.Sleep(10);
                }
            }

            avator.AvatorUI.TalkTextBox["Text"](talkText);
            Thread.Sleep(10);

            stopWatch.Start();

            avator.AvatorUI.PlayButton.EmulateClick();

            // 再生開始を待つ(音声保存ボタンがDisableになるのを待つ)
            if (avator.AvatorUI.SaveButton.Enabled)
            {
                while (avator.AvatorUI.SaveButton.Enabled)
                {
                    Thread.Sleep(10);
                }
            }

//            ResetParameters(talker, apply_interface[talker.talkerRealName], apply_interface_emotion[talker.talkerRealName]);

            // 再生終了を待つ(音声保存ボタンがEnableになるのを待つ)
            if (!avator.AvatorUI.SaveButton.Enabled)
            {
                while (!avator.AvatorUI.SaveButton.Enabled)
                {
                    Thread.Sleep(10);
                }
            }

            ResetParameters(talker, apply_interface[talker.talkerRealName]);
            stopWatch.Stop();
//            avator.Semaphore.Release();

            return(stopWatch.ElapsedMilliseconds);
        }
예제 #5
0
        private List <AvatorParam_VREX> GetVoiceroidProcess()
        {
            Process[] ProcessList = Process.GetProcesses();
            List <AvatorParam_VREX> VoiceroidProcesses = new List <AvatorParam_VREX>();

//            for (int idxp = 0; idxp < VoiceroidExTitles.Length; idxp++)
//            {
//               string WinTitle1 = VoiceroidExTitles[idxp];
//                string WinTitle2 = WinTitle1 + "*";
//
//                foreach (Process p in ProcessList)
//                {
//                    if ((p.MainWindowHandle != IntPtr.Zero) &&
//                        ((p.MainWindowTitle.Equals(WinTitle1)) || (p.MainWindowTitle.Equals(WinTitle2))))
//                    {
//                        VoiceroidEx.AvatorParam avator = new VoiceroidEx.AvatorParam();
//                        avator.AvatorIndex = idxp;
//                        avator.AvatorName = VoiceroidExTitles[idxp];
//                        avator.AvatorProcess = p;
//
//                        VoiceroidProcesses.Add(avator);
//                        break;
//                    }
//                }
//            }

            int idx = 0;

            foreach (string prodTitle in VoiceroidExTitles)
            {
                string WinTitle1 = prodTitle;
                string WinTitle2 = WinTitle1 + "*";

                foreach (Process p in ProcessList)
                {
//                    uiTreeTop = WindowControl.FromZTop(_app);

                    if ((p.MainWindowHandle != IntPtr.Zero) &&
                        ((p.MainWindowTitle.Equals(WinTitle1)) || (p.MainWindowTitle.Equals(WinTitle2))))
                    {
                        WindowsAppFriend _app;
                        //x86のプロセスでアタッチしてその通信情報を引き継ぐためのバイナリを生成
                        var myProcess = Process.GetCurrentProcess();
                        var binPath   = Path.GetTempFileName();
                        Process.Start("Attachx86.exe", $"{p.Id} {myProcess.Id} {binPath}").WaitForExit();

                        //バイナリを元にWindowsAppFriend生成
                        var bin = File.ReadAllBytes(binPath);
                        File.Delete(binPath);

                        //以降はx64のプロセスからx86のプロセスが操作できる
                        _app = new WindowsAppFriend(p.MainWindowHandle, bin);



                        AvatorParam_VREX avator = new AvatorParam_VREX();
                        avator.AvatorIndex   = idx;
                        avator.AvatorName    = prodTitle;
                        avator.AvatorProcess = _app;

                        VoiceroidProcesses.Add(avator);
                        idx++;

                        break;
                    }
                }
            }

            return(VoiceroidProcesses);
        }