コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: PTruscott/InTime
 private void PlayNote(int handle, Note thisNote)
 {
     //don't want drumbeats to be recorded
     if (thisNote.GetInstrument() != 99)
     {
         playingNotes.Add(new NoteTuple(4 + currentTime, thisNote));
     }
     midiNote(handle, thisNote);
 }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: PTruscott/InTime
        private void midiNote(int handle, Note thisNote)
        {
            //midiOutOpen(ref handle, 0, null, 0, 0);
            //converts the user input to hex
            string velHex = 60.ToString("X");

            if (typeSlider.Value == 1)
            {
                var vel = (thisNote.GetVelocity() * 6);
                switch (thisNote.GetInstrument())
                {
                case 94:
                    vel *= 4;
                    break;

                case 93:
                    vel *= 3;
                    break;

                case 92:
                    vel *= 2;
                    break;
                }

                velHex = vel.ToString("X");
            }
            string noteHex = thisNote.GetNote().ToString("X");
            string insHex  = thisNote.GetInstrument().ToString();
            //builds into a hex string
            string s = string.Format("0x00{0}{1}{2}", velHex, noteHex, insHex);
            //converts to an integer
            int value = (int)new Int32Converter().ConvertFromString(s);

            //plays the note
            midiOutShortMsg(handle, value);
        }