public void initialize() { midiAdapter.initialize(); int outDeviceCount = midiAdapter.midiOutDeviceCount; for (int i = 0; i < outDeviceCount; i++) { outDeviceList.Add(midiAdapter.getMidiOutDeviceName(i)); } int inDeviceCount = midiAdapter.midiInDeviceCount; for (int i = 0; i < inDeviceCount; i++) { inDeviceList.Add(midiAdapter.getMidiInDeviceName(i)); } whiteKeyCountInOctave = 0; for (int i = 0; i < ChordBasic.toneCount; i++) { if (ChordBasic.isWhiteKey(i)) { whiteKeyCountInOctave++; } } }
public void initialize() { Write("Load chord infomation\n"); ChordBasic.initialize(); Write("Load pad infomation\n"); loadPadInfo(); Write("Load chord progression database\n"); cpd.initialize(); Write("Load chord progression suggest\n"); cps.initialize(); cps.read(cpd.enabledFileList); Write("Initialize midi devices\n"); mm.initialize(); Write("Initialize voicing manage\n"); VoicingManage.createInstance(); createScaleLabel(); createTonePad(); createChannelSelector(); createProgramSelector(); createKeySelector(); mm.setCanvas(KeyboardCanvas); initializeUI(); }
public void paintPlayedNote(int[] notes) { foreach (UIElement uie in uieList) { canvas.Children.Remove(uie); } foreach (int note in notes) { double position = getWhiteKeyCount(note) * keyWidth; if (ChordBasic.isWhiteKey(note)) { position += keyWidth / 2; } position -= ellipseSize / 2; Ellipse el = new Ellipse(); el.Fill = Brushes.Red; el.Width = ellipseSize; el.Height = ellipseSize; Canvas.SetLeft(el, position); if (ChordBasic.isWhiteKey(note)) { Canvas.SetTop(el, ellipseHeight); } else { Canvas.SetTop(el, blackKeyEllipseHeight); } canvas.Children.Add(el); uieList.Add(el); } }
private void createKeySelector() { for (int i = 0; i < ChordBasic.toneCount; i++) { ComboBox_ChooseKey.Items.Add(ChordBasic.getTone(i).name); } ComboBox_ChooseKey.SelectionChanged += new SelectionChangedEventHandler(Callback_KeyChanged); ComboBox_ChooseKey.SelectedIndex = 0; }
// initialize and file load private void initialize() { Label_FileName.Content = myTargetFile; Slider_ShiftBit.Minimum = 8; Slider_ShiftBit.Maximum = 16; Slider_ShiftBit.IsSnapToTickEnabled = true; Slider_ShiftBit.DataContext = this; shiftBitSetting = 10; Slider_BlockBit.Minimum = 8; Slider_BlockBit.Maximum = 16; Slider_BlockBit.IsSnapToTickEnabled = true; Slider_BlockBit.DataContext = this; blockBitSetting = 14; ComboBox_WindowFunction.Items.Add("ハミング窓"); ComboBox_WindowFunction.Items.Add("ハン窓"); ComboBox_WindowFunction.Items.Add("矩形窓"); ComboBox_WindowFunction.SelectedIndex = 0; Canvas_Keyboard.Height = 128 * yScale; for (int note = 0; note < 128; note++) { Rectangle rect = new Rectangle(); rect.Width = 50; rect.Height = yScale; if (ChordBasic.isWhiteKey(note)) { if (note == ChordBasic.toneList[0].noteNumber) { rect.Fill = Brushes.LightGray; } rect.Stroke = Brushes.Black; } else { rect.Fill = Brushes.Black; } rect.StrokeThickness = 1; Canvas.SetLeft(rect, 0); Canvas.SetTop(rect, (127 - note) * yScale); Canvas_Keyboard.Children.Add(rect); keyboardList.Add(rect); } releaseTime = 0.1; fileLoadWorker = new BackgroundWorker(); fileLoadWorker.WorkerReportsProgress = true; fileLoadWorker.WorkerSupportsCancellation = true; fileLoadWorker.DoWork += new DoWorkEventHandler(doFileLoad); fileLoadWorker.ProgressChanged += new ProgressChangedEventHandler(progressChangedFileLoad); fileLoadWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(fileLoadCompleted); fileLoadWorker.RunWorkerAsync(); }
private void loadPadInfo() { XmlReader xml; xml = XmlReader.Create(new StreamReader("Resource/ChordPad.xml")); while (xml.Read()) { if (xml.NodeType == XmlNodeType.Element && xml.Name == "pad") { int id; string notation; id = int.Parse(xml.GetAttribute("id")); notation = xml.GetAttribute("notation"); var res = Harmony.createHarmony(notation); if (res != null) { harmonyToId.Add(res.uniqueId, harmonies.Count); harmonies.Add(res); } } } xml.Close(); for (int x = 0; x < ChordBasic.toneCount; x++) { for (int y = 0; y < harmonies.Count; y++) { chordPadList.Add(new ChordPad(x, y, new Chord(ChordBasic.getTone(x), harmonies[y]))); } } xml = XmlReader.Create(new StreamReader("Resource/ChordRole.xml")); while (xml.Read()) { if (xml.NodeType == XmlNodeType.Element && xml.Name == "role") { string roleChordString = xml.GetAttribute("chord"); var chordPad = chordPadList.Find(m => m.chord.ToString() == roleChordString); if (chordPad != null) { if (xml.GetAttribute("scale") == "M") { chordPad.roleInMajor = xml.GetAttribute("name"); } else { chordPad.roleInMinor = xml.GetAttribute("name"); } } } } xml.Close(); isMajor = true; }
private int getWhiteKeyCount(int note) { int octFromLowestKey = (note - lowestKey) / ChordBasic.toneCount; int keyCount = octFromLowestKey * whiteKeyCountInOctave; for (int i = octFromLowestKey * ChordBasic.toneCount + lowestKey; i < note; i++) { if (ChordBasic.isWhiteKey(i)) { keyCount++; } } return(keyCount); }
public void paintKeyboard() { foreach (UIElement uie in keyboardUieList) { canvas.Children.Remove(uie); } double position = 0; keyWidth = canvas.ActualWidth / (getWhiteKeyCount(highestKey) - getWhiteKeyCount(lowestKey)); blackKeyWidth = keyWidth / 2; Rectangle rect; for (int i = lowestKey; i < highestKey; i++) { if (ChordBasic.isWhiteKey(i)) { rect = new Rectangle() { Stroke = Brushes.Black }; rect.Width = keyWidth; rect.Height = keyHeight; Canvas.SetLeft(rect, position); Canvas.SetTop(rect, 0); canvas.Children.Add(rect); keyboardUieList.Add(rect); position += keyWidth; } else { rect = new Rectangle() { Fill = Brushes.Black }; rect.Width = blackKeyWidth; rect.Height = blackKeyHeight; Canvas.SetLeft(rect, position - blackKeyWidth / 2); Canvas.SetTop(rect, 0); canvas.Children.Add(rect); keyboardUieList.Add(rect); } } }