Example #1
0
        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++;
                }
            }
        }
Example #2
0
 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);
     }
 }
Example #3
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();
        }
Example #4
0
        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);
        }
Example #5
0
        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);
                }
            }
        }