Exemplo n.º 1
0
        public MainWindow()
        {
            InitializeComponent();
            Root = new OscTree.Tree(new OscTree.Address("Root", "Root"));
            Gui2.OscTree.Endpoints.Add(new OscTree.Endpoint("Activate", (args) => { }, typeof(object)));
            Root.Add(Gui1.OscTree);
            Root.Add(Gui2.OscTree);

            GuiInspector.OscRoot = Root;

            Gui1.SetInspector(GuiInspector);
            Gui2.SetInspector(GuiInspector);
            Gui1.SetGridSize(4, 4);
            Gui2.SetGridSize(8, 8);
        }
Exemplo n.º 2
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)));
        }
Exemplo n.º 3
0
        public static void Init()
        {
            Root.Add(Server);
            Root.Add(Client);

            LocalClient.IgnoreInGui = true;
            LocalClient.ReRoute    += ((OscTree.Route route, object[] arguments) =>
            {
                // if this route is used on the server, it is for testing. Just route to the normal client tree.
                var newRoute = new OscTree.Route(route.OriginalName, route.Type);
                newRoute.CurrentStep = route.CurrentStep;
                Client.Deliver(newRoute, arguments);
            });
            Root.Add(LocalClient);


            AllClients.IgnoreInGui = true;
            AllClients.ReRoute    += ((OscTree.Route route, object[] arguments) =>
            {
                string newRoute = route.OriginalName.Remove(0, 1);
                string[] parts = newRoute.Split('/');
                parts[1] = "LocalClient";
                newRoute = string.Empty;
                foreach (var part in parts)
                {
                    newRoute += "/" + part;
                }

                foreach (var client in ClientList.Handle.List.Values)
                {
                    client.Send.ToClient(newRoute, arguments);
                }
            });
            Root.Add(AllClients);


            Server.Add(ServerPatchers);
            Server.Add(ServerSounds);
            Server.Add(ServerScripts);
            Server.Add(ServerRouters);

            Client.Add(ClientScripts);
        }
Exemplo n.º 4
0
        public MainPage()
        {
            InitializeComponent();
            Tree = new OscTree.Tree(new OscTree.Address("Root", "Root"));

            Tree.Add(OscView.OscTree);

            var    assembly = IntrospectionExtensions.GetTypeInfo(typeof(MainPage)).Assembly;
            Stream stream   = assembly.GetManifestResourceStream("OscGuiDemo.gui1.json");
            string text     = string.Empty;

            using (var reader = new StreamReader(stream))
            {
                text = reader.ReadToEnd();
            }
            OscView.LoadJSON(text);
            OscView.LoadJSON(text);
        }
Exemplo n.º 5
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)));
        }