コード例 #1
0
        public void timer1_Tick(object sender, EventArgs e)
        {
            if (vm.Poll() is true)
            {
                //Console.WriteLine("poll - "+vm.Poll().ToString());
                foreach (KeyValuePair <string, string> vVar in voicemeeterVarNames)
                {
                    //Console.WriteLine(vm.GetParam(vVar.Key).ToString());
                    //var mymessage = new SharpOSC.OscMessage(vVar.Key, (float)vm.GetParam(vVar.Key));
                    //if (mymessage != null)
                    //{
                    float tmpVar = (float)vm.GetParam(vVar.Key);
                    if (voicemeeterVars[vVar.Key] != tmpVar)
                    {
                        voicemeeterVars[vVar.Key] = tmpVar;
                        oscSender.Send(new SharpOSC.OscMessage(vVar.Value, tmpVar));
                        oscSender.Send(new SharpOSC.OscMessage(vVar.Value + "/Text", tmpVar));
                    }

                    //}
                }

                foreach (KeyValuePair <string, string> vVar in voicemeeterXYVarNames)
                {
                    string value   = vVar.Value;
                    float  tmpVarX = (float)vm.GetParam(vVar.Key + "_x");
                    float  tmpVarY = (float)vm.GetParam(vVar.Key + "_y");

                    //Console.WriteLine(tmpVarX.ToString() + " - " + tmpVarY.ToString());
                    if (vVar.Key.Contains("fx"))
                    {
                        value = vVar.Value + "y";
                    }
                    if (vVar.Key.Contains("Pan"))
                    {
                        //Console.WriteLine("PANNNN!!!!!!!!");
                        if (vVar.Key.Contains("5") || vVar.Key.Contains("6") || vVar.Key.Contains("7"))
                        {
                            //Console.WriteLine("5, 6, OR 7!!!!!!!!");
                            tmpVarY = ConvertRange((float)-0.5, (float)0.5, (float)-1, (float)1, tmpVarY);
                            tmpVarX = ConvertRange((float)-0.5, (float)0.5, (float)-1, (float)1, tmpVarX);
                        }
                        else
                        {
                            //tmpVarX = ConvertRange((float)-0.5, (float)0.5, (float)0, (float)1, tmpVarX);
                            tmpVarY = ConvertRange((float)0, (float)1, (float)-0.5, (float)0.5, tmpVarY);
                        }
                    }
                    else
                    {
                        //tmpVarY = ConvertRange((float)-0.5, (float)0.5, (float)0, (float)1,tmpVarY);
                        tmpVarY = ConvertRange((float)0, (float)1, (float)-0.5, (float)0.5, tmpVarY);
                    }


                    if (voicemeeterXYVars[vVar.Key + "_x"] != tmpVarX || voicemeeterXYVars[vVar.Key + "_y"] != tmpVarY)
                    {
                        voicemeeterXYVars[vVar.Key + "_x"] = tmpVarX;
                        voicemeeterXYVars[vVar.Key + "_y"] = tmpVarY;
                        oscSender.Send(new SharpOSC.OscMessage(value, tmpVarY, tmpVarX));
                        oscSender.Send(new SharpOSC.OscMessage(value + "/Text", tmpVarY + " - " + tmpVarX));
                        System.Threading.Thread.Sleep(10);
                        //Console.WriteLine(vVar.Key + " - " + value.ToString());
                    }
                }
            }
        }