예제 #1
0
        public Basic3D()
        {
            InitializeComponent();

            Info.Text = AppResources.Basics3DInfo;

            listenerPos.Set(0f, 0f, 0f);
            Global.Yse.Listener.Pos(listenerPos / 10f);

            sound1.Create("contact", null, true);
            sound1Pos.Set(-100f, 30f, 0f);
            sound1.SetPos(sound1Pos / 10f);
            sound1.Play();

            sound2.Create("drone", null, true);
            sound2Pos.Set(100f, -10f, 0f);
            sound2.SetPos(sound2Pos / 10f);
            sound2.Play();
        }
예제 #2
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)));
        }