public void InitInstruments() { string text = System.IO.File.OpenText("config.json").ReadToEnd(); var dic = JsonConvert.DeserializeObject <Dictionary <string, InstrumentConfig> >(text); instruments = new Dictionary <string, InstrumentBase>(); //add all instruments; var config = new InstrumentConfig(); { foreach (var gestureName in DiscreteGestureNames) { dic.TryGetValue(gestureName, out config); if (config != null) { if (config.isDiscrete) { instruments.Add(gestureName, new InstrumentDis(gestureName, config)); } else { instruments.Add(gestureName, new InstrumentCon(gestureName, config)); } } } } }
public InstrumentBase(string insName, InstrumentConfig config) { //这里必须是主程序(Microsoft.Samples.Kinect.DiscreteGestureBasics)的namespace string npName = Assembly.GetExecutingAssembly().GetName().Name.ToString(); string musicPath = @".music"; var assembly = Assembly.GetExecutingAssembly(); System.IO.Stream stream = assembly.GetManifestResourceStream(npName + musicPath + "." + insName + ".wav"); sp = new SoundPlayer(stream); threshold = config.threshold; delay = config.delay; }
public InstrumentCon(string insName, InstrumentConfig config) : base(insName, config) { isRinging = false; }
public InstrumentDis(string insName, InstrumentConfig config) : base(insName, config) { }