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]); } })); } } }
protected override void OnDisappearing() { snare.Stop(); reverb.Active = false; snare.Dispose(); base.OnDisappearing(); }
private void ButtonStop(object sender, EventArgs e) { sound.Stop(); }
private void ButtonStop(object sender, EventArgs e) { sound.Stop(); playing = false; }
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))); }