private void InternalInitialize() { var asm = GetType().Assembly; var allResources = asm.GetManifestResourceNames(); // Load All Sources for (byte i = 0; i < 128; i++) { // Instruments { if (allResources.FirstOrDefault(n => n.StartsWith($"GroorineCore.Presets.Inst.{i}")) is string name) { var src = ReadAudioSourceStream(name, asm.GetManifestResourceStream(name)); AddInstrument(i, new Instrument(i, src)); } else { AddInstrument(i, new Instrument(i, new AudioSourceSine())); } } // Drum { if (allResources.FirstOrDefault(n => n.StartsWith($"GroorineCore.Presets.Drum.{i}")) is string name) { var src = ReadAudioSourceStream(name, asm.GetManifestResourceStream(name)); Drumset?.Add(new Instrument(i, src)); } } } }
public MainWindow() { InitializeComponent(); if (serverURL == "") { textBox1.Text = "URL不明!"; } else { textBox1.Text = channel; websocket = new WebSocket(serverURL); websocket.Closed += new EventHandler(websocket_Closed); websocket.Error += new EventHandler<SuperSocket.ClientEngine.ErrorEventArgs>(websocket_Error); websocket.MessageReceived += new EventHandler<MessageReceivedEventArgs>(websocket_MessageReceived); websocket.Opened += new EventHandler(websocket_Opened); websocket.Open(); drumset = new Drumset(); drumset.SetElements( new CircleTarget("RideCymbal", new Position3D(0.4, 0.3, 2.0), 0.3), new CircleTarget("HiHat", new Position3D(-0.7, 0.1, 2.4), 0.3), new CircleTarget("Drum1", new Position3D(-0.2, 0.0, 2.2), 0.3), new CircleTarget("Drum2", new Position3D(0.5, 0.1, 2.6), 0.3) ); System.Console.WriteLine("Loaded"); foreach (var potentialSensor in KinectSensor.KinectSensors) { if (potentialSensor.Status == KinectStatus.Connected) { this.sensor = potentialSensor; break; } } if (null != this.sensor) { // Turn on the skeleton stream to receive skeleton frames this.sensor.SkeletonStream.Enable(); // Add an event handler to be called whenever there is new color frame data this.sensor.SkeletonFrameReady += this.SensorSkeletonFrameReady; // Start the sensor! try { this.sensor.Start(); } catch (IOException) { this.sensor = null; } } this.sensor.SkeletonStream.TrackingMode = SkeletonTrackingMode.Seated; } }