Esempio n. 1
0
        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));
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        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;
        }
Esempio n. 3
0
 public InstrumentCon(string insName, InstrumentConfig config) : base(insName, config)
 {
     isRinging = false;
 }
Esempio n. 4
0
 public InstrumentDis(string insName, InstrumentConfig config) : base(insName, config)
 {
 }