Exemple #1
0
 public Pin(ArduinoConfig config, OscTree.Object parent)
 {
     Config = config;
     if (Config.Mode.Equals("Digital Out", StringComparison.CurrentCultureIgnoreCase))
     {
         parent.Endpoints.Add(new OscTree.Endpoint(Config.Name, OnOsc, new Type[] { typeof(bool) }));
         digital = true;
     }
     else if (Config.Mode.Equals("Digital In", StringComparison.CurrentCultureIgnoreCase))
     {
         digital = true;
     }
     else if (Config.Mode.Equals("Analog In", StringComparison.CurrentCultureIgnoreCase))
     {
         if (Config.LowValue < Config.HighValue)
         {
             offset = Config.LowValue;
             float range = Config.HighValue - Config.LowValue;
             scale = range / 1024f;
         }
         else if (Config.HighValue < Config.LowValue)
         {
             offset = Config.LowValue;
             float range = Config.LowValue - Config.HighValue;
             scale = -(range / 1024f);
         }
         digital = false;
     }
 }
Exemple #2
0
        public MTPad(JObject obj)
        {
            OscJsonObject json = new OscJsonObject(obj);

            oscObject = new OscTree.Object(new OscTree.Address(json.Name, json.UID), typeof(float));

            ForeGround        = json.Color;
            BackGround        = json.Background;
            OscObject.Targets = json.Targets;
            Visible           = json.Visible;

            oscObject.Endpoints.Add(new OscTree.Endpoint("Visible", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Visible = OscParser.ToBool(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("ForegroundColor", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { ForeGround = OscParser.ToColor(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("BackgroundColor", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { BackGround = OscParser.ToColor(args); });
            }));

            this.TouchChanged += MTPad_TouchChanged;
        }
Exemple #3
0
        public Output(JObject obj, OscTree.Tree oscParent, OutputList parent)
        {
            id          = obj.ContainsKey("ID") ? (string)obj["ID"] : String.Empty;
            Name        = obj.ContainsKey("Name") ? (string)obj["Name"] : string.Empty;
            Description = obj.ContainsKey("Description") ? (string)obj["Description"] : string.Empty;
            type        = obj.ContainsKey("Type") ? StringToOutputtype((string)obj["Type"]) : OutputType.MIDI;
            var details = obj.ContainsKey("Details") ? obj["Details"] : null;

            setOutput((JObject)details);

            this.parent = parent;

            osc = new OscTree.Object(new OscTree.Address(Name, id), typeof(int));
            oscParent.Add(osc);
            osc.Endpoints.Add(new OscTree.Endpoint("Send", (args) =>
            {
                if (output == null)
                {
                    return;
                }
                if (args.Count() > 0)
                {
                    output.SendInt(Convert.ToInt32(args[0]));
                }
            }, typeof(int)));
        }
Exemple #4
0
        public TextBox(JObject obj)
        {
            OscJsonObject json = new OscJsonObject(obj);

            oscObject = new OscTree.Object(new OscTree.Address(json.Name, json.UID), typeof(string));

            Text              = json.Content as string;
            FontSize          = json.FontSize;
            OscObject.Targets = json.Targets;
            IsVisible         = json.Visible;

            oscObject.Endpoints.Add(new OscTree.Endpoint("Text", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Text = OscParser.ToString(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("FontSize", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { FontSize = OscParser.ToInt(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("Visible", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { IsVisible = OscParser.ToBool(args); });
            }));

            TextChanged += TextBox_TextChanged;
        }
Exemple #5
0
        public Label(JObject obj)
        {
            OscJsonObject json = new OscJsonObject(obj);

            oscObject = new OscTree.Object(new OscTree.Address(json.Name, json.UID), typeof(int));

            Text            = (string)json.Content;
            TextColor       = json.Color;
            BackgroundColor = json.Background;
            FontSize        = json.FontSize;

            if (json.Bold)
            {
                if (json.Italic)
                {
                    FontAttributes = Xamarin.Forms.FontAttributes.Bold | Xamarin.Forms.FontAttributes.Italic;
                }
                else
                {
                    FontAttributes = Xamarin.Forms.FontAttributes.Bold;
                }
            }
            else if (json.Italic)
            {
                FontAttributes = Xamarin.Forms.FontAttributes.Italic;
            }
            HorizontalTextAlignment = json.HAlign;
            IsVisible = json.Visible;

            oscObject.Endpoints.Add(new OscTree.Endpoint("Text", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Text = OscParser.ToString(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("FontSize", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { FontSize = OscParser.ToInt(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("Visible", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { IsVisible = OscParser.ToBool(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("TextColor", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { TextColor = OscParser.ToColor(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("BackgroundColor", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { BackgroundColor = OscParser.ToColor(args); });
            }));
        }
Exemple #6
0
        public override void LoadContent()
        {
            if (Global.Yse == null)
            {
                return;
            }

            if (osc == null)
            {
                osc = new OscTree.Object(new OscTree.Address(Name, ID), typeof(object));
                Global.OscLocal.Add(osc);
            }

            sound.Stop();
            patcher.Clear();
            patcher.ParseJSON(Content);

            osc.Endpoints.List.Clear();
            for (uint i = 0; i < patcher.NumObjects(); i++)
            {
                object obj  = patcher.GetHandleFromList(i);
                string name = ((IYse.IHandle)obj).Name;
                if (name.Equals(".r"))
                {
                    string args = ((IYse.IHandle)obj).GetArgs();
                    osc.Endpoints.Add(new OscTree.Endpoint(args, (values) =>
                    {
                        if (values == null)
                        {
                            ((IYse.IHandle)obj).SetBang(0);
                        }
                        else if (values[0] is int)
                        {
                            ((IYse.IHandle)obj).SetIntData(0, (int)values[0]);
                        }
                        else if (values[0] is float)
                        {
                            ((IYse.IHandle)obj).SetFloatData(0, (float)values[0]);
                        }
                        else if (values[0] is bool)
                        {
                            ((IYse.IHandle)obj).SetIntData(0, (bool)values[0] == true ? 1 : 0);
                        }
                        else if (values[0] is string)
                        {
                            ((IYse.IHandle)obj).SetListData(0, (string)values[0]);
                        }
                    }));
                }
            }
        }
Exemple #7
0
        public RouteSelector(OscTree.Object origin, OscTree.Tree root, bool showClear = false)
        {
            InitializeComponent();
            Origin = origin;
            SidePanelVisible(false, false);

            SetRoot(root);

            if (!showClear)
            {
                ClearButton.Visibility = Visibility.Hidden;
            }

            serverSide = Osc.Tree.Server.Contains(origin);
            ComboBoxGroups.ItemsSource = Project.Project.Current.Groups.List;
        }
Exemple #8
0
        public Slider(JObject obj)
        {
            OscJsonObject json = new OscJsonObject(obj);

            oscObject = new OscTree.Object(new OscTree.Address(json.Name, json.UID), typeof(float));

            Minimum           = json.Minimum;
            Maximum           = json.Maximum;
            ForeGround        = json.Color;
            Handle            = json.Handle;
            Background        = json.Background;
            OscObject.Targets = json.Targets;
            Visible           = json.Visible;

            oscObject.Endpoints.Add(new OscTree.Endpoint("Value", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Value = OscParser.ToFloat(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("Minimum", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Minimum = OscParser.ToFloat(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("Maximum", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Maximum = OscParser.ToFloat(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("Visible", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Visible = OscParser.ToBool(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("ForegroundColor", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { ForeGround = OscParser.ToColor(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("BackgroundColor", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Background = OscParser.ToColor(args); });
            }));

            ValueChanged += Slider_ValueChanged;
        }
Exemple #9
0
        public Knob(JObject obj)
        {
            OscJsonObject json = new OscJsonObject(obj);

            oscObject = new OscTree.Object(new OscTree.Address(json.Name, json.UID), typeof(float));

            Minimum           = json.Minimum;
            Maximum           = json.Maximum;
            Color             = json.Color;
            DisplayName       = json.Content as string;
            ShowValue         = json.ShowValue;
            OscObject.Targets = json.Targets;
            Visible           = json.Visible;

            oscObject.Endpoints.Add(new OscTree.Endpoint("Value", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Value = OscParser.ToFloat(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("Minimum", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Minimum = OscParser.ToFloat(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("Maximum", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Maximum = OscParser.ToFloat(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("ShowValue", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { ShowValue = OscParser.ToBool(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("Visible", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Visible = OscParser.ToBool(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("Color", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Color = OscParser.ToColor(args); });
            }));

            this.ValueChanged += Knob_ValueChanged;
        }
Exemple #10
0
        public Button(JObject obj)
        {
            OscJsonObject json = new OscJsonObject(obj);

            oscObject = new OscTree.Object(new OscTree.Address(json.Name, json.UID), typeof(bool));

            Text              = json.Content as string;
            ForeGround        = json.Color;
            BackGround        = json.Background;
            TextScale         = json.TextScale;
            OscObject.Targets = json.Targets;
            IsToggle          = json.IsToggle;
            Visible           = json.Visible;

            oscObject.Endpoints.Add(new OscTree.Endpoint("Text", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Text = OscParser.ToString(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("TextScale", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { TextScale = (yGui.Scale)OscParser.ToInt(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("Visible", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Visible = OscParser.ToBool(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("ForegroundColor", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { TextColor = OscParser.ToColor(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("BackgroundColor", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { BackgroundColor = OscParser.ToColor(args); });
            }));

            Pressed += Button_Pressed;
        }
Exemple #11
0
        public XYPad(JObject obj)
        {
            OscJsonObject json = new OscJsonObject(obj);

            oscObject = new OscTree.Object(new OscTree.Address(json.Name, json.UID), typeof(Point));

            ForeGround        = json.Color;
            Border            = json.Color;
            Centered          = json.Centered;
            ShowValue         = json.ShowValue;
            OscObject.Targets = json.Targets;
            Visible           = json.Visible;

            oscObject.Endpoints.Add(new OscTree.Endpoint("Coordinate", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Value = OscParser.ToPoint(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("Centered", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Centered = OscParser.ToBool(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("Visible", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Visible = OscParser.ToBool(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("ForegroundColor", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { ForeGround = OscParser.ToColor(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("BorderColor", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Border = OscParser.ToColor(args); });
            }));

            ValueChanged += XYPad_ValueChanged;
        }
Exemple #12
0
        public Led(JObject obj)
        {
            OscJsonObject json = new OscJsonObject(obj);

            oscObject = new OscTree.Object(new OscTree.Address(json.Name, json.UID), typeof(int));

            Color   = json.Color;
            Scale   = json.Scale;
            Visible = json.Visible;

            oscObject.Endpoints.Add(new OscTree.Endpoint("Blink", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() =>
                {
                    int time = 100;
                    if (args.Length > 0)
                    {
                        if (args[0] is int)
                        {
                            time = (int)args[0];
                        }
                        else if (args[0] is float)
                        {
                            time = (int)args[0];
                        }
                    }
                    Blink(time);
                });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("Visible", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Visible = OscParser.ToBool(args); });
            }));

            oscObject.Endpoints.Add(new OscTree.Endpoint("Color", (args) =>
            {
                Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { Color = OscParser.ToColor(args); });
            }));
        }
 public void SetOscParent(OscTree.Object parent)
 {
     oscParent = parent;
 }
Exemple #14
0
        public SoundControl(JObject obj, OscTree.Tree oscParent, string soundPath, SoundGrid parentGrid)
        {
            InitializeComponent();

            originalFileName = obj.ContainsKey("OriginalFileName") ? (string)obj["OriginalFileName"] : String.Empty;
            projectFileName  = obj.ContainsKey("ProjectFileName") ? (string)obj["ProjectFileName"] : String.Empty;
            id              = obj.ContainsKey("ID") ? (string)obj["ID"] : String.Empty;
            soundName       = obj.ContainsKey("Name") ? (string)obj["Name"] : string.Empty;
            Loop            = obj.ContainsKey("Loop") ? (bool)obj["Loop"] : false;
            this.parentGrid = parentGrid;


            this.DataContext = this;

            if (projectFileName != string.Empty)
            {
                sound = Yse.Yse.Handle.Interface.NewSound();

                var path = System.IO.Path.Combine(soundPath, projectFileName);
                sound.Create(path, null, false, 1, true);
                sound.Doppler          = false;
                PositionSlider.Minimum = 0;
                PositionSlider.Maximum = sound.Length;
            }

            osc = new OscTree.Object(new OscTree.Address(soundName, id), typeof(float));
            oscParent.Add(osc);
            osc.Endpoints.Add(new OscTree.Endpoint("Play", (args) =>
            {
                if (sound == null)
                {
                    return;
                }

                if (args.Count() > 0)
                {
                    try
                    {
                        if (Convert.ToBoolean(args[0]) == true)
                        {
                            sound.Play();
                        }
                        else
                        {
                            sound.Stop();
                        }
                    }
                    catch (Exception)
                    {
                        sound.Play();
                    }
                }
                else
                {
                    sound.Play();
                }
            }, typeof(bool)));

            osc.Endpoints.Add(new OscTree.Endpoint("Restart", (args) =>
            {
                if (sound == null)
                {
                    return;
                }
                if (sound.Playing)
                {
                    sound.Time = 0;
                }
                else
                {
                    sound.Play();
                }
            }));

            osc.Endpoints.Add(new OscTree.Endpoint("Stop", (args) =>
            {
                if (sound == null)
                {
                    return;
                }
                sound.Stop();
            }, typeof(bool)));

            osc.Endpoints.Add(new OscTree.Endpoint("Pause", (args) =>
            {
                if (sound == null)
                {
                    return;
                }
                sound.Pause();
            }, typeof(bool)));

            osc.Endpoints.Add(new OscTree.Endpoint("Time", (args) =>
            {
                if (sound == null)
                {
                    return;
                }

                if (args.Count() > 0)
                {
                    sound.Time = Convert.ToSingle(args[0]);
                }
            }, typeof(float)));

            osc.Endpoints.Add(new OscTree.Endpoint("Volume", (args) =>
            {
                if (sound == null)
                {
                    return;
                }
                if (args.Count() > 0)
                {
                    sound.Volume = Convert.ToSingle(args[0]);
                }
            }, typeof(float)));

            osc.Endpoints.Add(new OscTree.Endpoint("Speed", (args) =>
            {
                if (sound == null)
                {
                    return;
                }
                if (args.Count() > 0)
                {
                    sound.Speed = Convert.ToSingle(args[0]);
                }
            }, typeof(float)));

            osc.Endpoints.Add(new OscTree.Endpoint("Loop", (args) =>
            {
                if (sound == null)
                {
                    return;
                }
                if (args.Count() > 0)
                {
                    sound.Loop = Convert.ToBoolean(args[0]);
                }
            }, typeof(bool)));

            osc.Endpoints.Add(new OscTree.Endpoint("Pos", (args) =>
            {
                if (sound == null)
                {
                    return;
                }
                try
                {
                    IYse.Pos pos = new IYse.Pos();
                    if (args.Count() > 1)
                    {
                        pos.X = Convert.ToSingle(args[0]) * 10;
                        pos.Z = Convert.ToSingle(args[1]) * 10;
                    }
                    sound.SetPos(pos);
                }
                catch (Exception) { }
            }, typeof(object)));
        }