public void Properties() { ScalePattern sp = new ScalePattern("a", new int[] { 0, 1, 2, 3 }); Assert.AreEqual(sp.Name, "a"); Assert.AreEqual(sp.Ascent.Length, 4); }
public MainWindow() { InitializeComponent(); // startup our midi! OutputDevice = OutputDevice.InstalledDevices[0]; OutputDevice.Open(); //OutputDevice.SilenceAllNotes(); leftChannel = Channel.Channel1; rightChannel = Channel.Channel2; // set instruments OutputDevice.SendProgramChange(leftChannel, leftInstrument); OutputDevice.SendProgramChange(rightChannel, rightInstrument); // draw a load of rectangles for the notes for (int i = 0; i < 12; i++) { // right hand NoteRectangle noteRectangle = new NoteRectangle() { OutputDevice = OutputDevice, Channel = rightChannel, //Pitch = scale.NoteSequence[i % 7].PitchInOctave(3 + (i / 7 % 2)), Rectangle = new Rectangle() }; rightNotes.Add(noteRectangle); noteRectangle.Rectangle.Height = 40; noteRectangle.Rectangle.Width = 640; noteRectangle.Rectangle.StrokeThickness = i % 7 == 0 ? 4 : 1; noteRectangle.Rectangle.Stroke = i % 7 == 0 ? Brushes.White : Brushes.Gray; //noteRectangle.Rectangle.Fill = Brushes.Green; noteRectangle.Rectangle.Opacity = 0.4; //noteRectangle.Rectangle.Stroke.Opacity = 0.5; MainCanvas.Children.Add(noteRectangle.Rectangle); Canvas.SetLeft(noteRectangle.Rectangle, 0.0); Canvas.SetTop(noteRectangle.Rectangle, 480 - 40 - i * 40); } // initially just give it the scale of C scaleNote = new Note('C'); scalePattern = Scale.Major; setScale(); // connect to our node server socket = new Client("http://127.0.0.1:8080/kinect"); // url to nodejs /*socket.Opened += SocketOpened; * socket.Message += SocketMessage; * socket.SocketConnectionClosed += SocketConnectionClosed; * socket.Error += SocketError;*/ }
private void Window_Loaded(object sender, RoutedEventArgs e) { kinectSensorChooser1.KinectSensorChanged += new DependencyPropertyChangedEventHandler(kinectSensorChooser1_KinectSensorChanged); // register for 'connect' event with io server socket.On("connect", (fn) => { //lblSocket.Content = "Connected"; //lblSocket.Foreground = new SolidColorBrush(Colors.Green); Dispatcher.Invoke(new Action(() => lblSocket.Foreground = new SolidColorBrush(Colors.Green))); Dispatcher.Invoke(new Action(() => lblSocket.Content = "Connected")); //MessageBox.Show("connected"); }); // register for 'update' events - message is a json 'Part' object socket.On("keyscale", (data) => { //MessageBox.Show(data.Json.ToJsonString()); string note = data.Json.Args[0]["key"]; string key = data.Json.Args[0]["scale"]; scaleNote = new Note(note); switch (key) { case "Chromatic": scalePattern = Scale.Chromatic; break; case "HarmonicMinor": scalePattern = Scale.HarmonicMinor; break; case "NaturalMinor": scalePattern = Scale.NaturalMinor; break; case "Major": scalePattern = Scale.Major; break; } setScale(); //MessageBox.Show(String.Format("Note: {0}, Tone: {1}", note, key)); //Console.WriteLine(" raw message: {0}", data.RawMessage); //Console.WriteLine(" string message: {0}", data.MessageText); //Console.WriteLine(" json data string: {0}", data.Json.ToJsonString()); //Console.WriteLine(" json raw: {0}", data.Json.Args[0]); // cast message as Part - use type cast helper /*Part part = data.Json.GetFirstArgAs<Part>(); * Console.WriteLine(" Part Level: {0}\r\n", part.Level);*/ }); // make the socket.io connection socket.Connect(); }
private void cmbScaleMode_SelectionChanged(object sender, SelectionChangedEventArgs e) { object item = ((ComboBox)sender).SelectedItem; ComboBoxItem cmbitem = (ComboBoxItem)item; switch (cmbitem.Content.ToString()) { case "Chromatic": scalePattern = Scale.Chromatic; break; case "HarmonicMinor": scalePattern = Scale.HarmonicMinor; break; case "NaturalMinor": scalePattern = Scale.NaturalMinor; break; case "Major": scalePattern = Scale.Major; break; } setScale(); }