zoukankan      html  css  js  c++  java
  • 电子琴源码

    #include <windows.h>
    #include <stdio.h>
    #pragma comment(lib,"winmm.lib")
    
    HMIDIOUT handle;
    
    unsigned long result = midiOutOpen(&handle, 0, 0, 0, CALLBACK_NULL), device = 0; //键盘midi
    HANDLE hIn = GetStdHandle(STD_INPUT_HANDLE);//鼠标操作
    HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
    DWORD state = 0, res;
    INPUT_RECORD mouseRec;
    
    int main()
    {
        COORD size = {90, 25};
        SetConsoleScreenBufferSize(hOut, size); // 重新设置缓冲区大小
        SMALL_RECT rc = {0, 0, 90 - 1, 25 - 1}; // 重置窗口位置和大小
        SetConsoleWindowInfo(hOut, true , &rc);
        SetConsoleTextAttribute(hOut, 0xF0);
        char table[] =
            "  █ █ ▕  █ █ █ ▕  █ █ ▕  █ █ █ ▕  █ █ ▕  █ █ █ ▕\n"\
            "  █ █ ▕  █ █ █ ▕  █ █ ▕  █ █ █ ▕  █ █ ▕  █ █ █ ▕\n"\
            "  █ █ ▕  █ █ █ ▕  █ █ ▕  █ █ █ ▕  █ █ ▕  █ █ █ ▕\n"\
            " ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕\n"\
            " ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕\n"\
            " ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕\n"\
            " ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕ ▕\n"\
            "▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔\n";
        puts(table);
        printf("Q\tW\tE\tR\t\tU\tI\tO \nC2\tD2\tE2\tF2\t\tG2\tA2\tB2\nA\tS\tD\tF\t\tJ\tK\tL \nC1\tD1\tE1\tF1\t\tG1\tA1\tB1\nZ\tX\tC\tV\t\tM\t,\t. \nC0\tD0\tE0\tF0\t\tG0\tA0\tB0\n");
        while(1)
        {
            if(GetAsyncKeyState(65))midiOutShortMsg(handle, 0x00603C90);//A
            if(GetAsyncKeyState(83))midiOutShortMsg(handle, 0x00603E90);//S
            if(GetAsyncKeyState(68))midiOutShortMsg(handle, 0x00604090);//D
            if(GetAsyncKeyState(70))midiOutShortMsg(handle, 0x00604190);//F
            if(GetAsyncKeyState(74))midiOutShortMsg(handle, 0x00604390);//J
            if(GetAsyncKeyState(75))midiOutShortMsg(handle, 0x00604590);//K
            if(GetAsyncKeyState(76))midiOutShortMsg(handle, 0x00604790);//L
            if(GetAsyncKeyState(90))midiOutShortMsg(handle, 0x00603090);//Z
            if(GetAsyncKeyState(88))midiOutShortMsg(handle, 0x00603290);//X
            if(GetAsyncKeyState(67))midiOutShortMsg(handle, 0x00603490);//C
            if(GetAsyncKeyState(86))midiOutShortMsg(handle, 0x00603590);//V
            if(GetAsyncKeyState(77))midiOutShortMsg(handle, 0x00603790);//M
            if(GetAsyncKeyState(188))midiOutShortMsg(handle, 0x00603990);//,
            if(GetAsyncKeyState(190))midiOutShortMsg(handle, 0x00603b90);//.
            if(GetAsyncKeyState(81))midiOutShortMsg(handle, 0x00604890);//Q
            if(GetAsyncKeyState(87))midiOutShortMsg(handle, 0x00604a90);//W
            if(GetAsyncKeyState(69))midiOutShortMsg(handle, 0x00604c90);//E
            if(GetAsyncKeyState(82))midiOutShortMsg(handle, 0x00604d90);//R
            if(GetAsyncKeyState(85))midiOutShortMsg(handle, 0x00604f90);//U
            if(GetAsyncKeyState(73))midiOutShortMsg(handle, 0x00605190);//I
            if(GetAsyncKeyState(79))midiOutShortMsg(handle, 0x00605390);//O
    
            ReadConsoleInput(hIn, &mouseRec, 1, &res);
            if (mouseRec.Event.MouseEvent.dwMousePosition.Y < 7 && mouseRec.Event.MouseEvent.dwButtonState == FROM_LEFT_1ST_BUTTON_PRESSED) //左键
            {
                switch(mouseRec.Event.MouseEvent.dwMousePosition.X / 4)
                {
                case 7:
                    midiOutShortMsg(handle, 0x00603C90);
                    break;
                case 8:
                    midiOutShortMsg(handle, 0x00603E90);
                    break;
                case 9:
                    midiOutShortMsg(handle, 0x00604090);
                    break;
                case 10:
                    midiOutShortMsg(handle, 0x00604190);
                    break;
                case 11:
                    midiOutShortMsg(handle, 0x00604390);
                    break;
                case 12:
                    midiOutShortMsg(handle, 0x00604590);
                    break;
                case 13:
                    midiOutShortMsg(handle, 0x00604790);
                    break;
                case 0:
                    midiOutShortMsg(handle, 0x00603090);
                    break;
                case 1:
                    midiOutShortMsg(handle, 0x00603290);
                    break;
                case 2:
                    midiOutShortMsg(handle, 0x00603490);
                    break;
                case 3:
                    midiOutShortMsg(handle, 0x00603590);
                    break;
                case 4:
                    midiOutShortMsg(handle, 0x00603790);
                    break;
                case 5:
                    midiOutShortMsg(handle, 0x00603990);
                    break;
                case 6:
                    midiOutShortMsg(handle, 0x00603b90);
                    break;
                case 14:
                    midiOutShortMsg(handle, 0x00604890);
                    break;
                case 15:
                    midiOutShortMsg(handle, 0x00604a90);
                    break;
                case 16:
                    midiOutShortMsg(handle, 0x00604c90);
                    break;
                case 17:
                    midiOutShortMsg(handle, 0x00604d90);
                    break;
                case 18:
                    midiOutShortMsg(handle, 0x00604f90);
                    break;
                case 19:
                    midiOutShortMsg(handle, 0x00605190);
                    break;
                case 20:
                    midiOutShortMsg(handle, 0x00605390);
                    break;
                default:
                    break;
                }
            }
        }
        return 0;
    }
    

      

  • 相关阅读:
    大屏设计
    ES6课程---11、promise对象实例
    ES6课程---10、promise对象
    心得体悟帖---200502(读西游记之修心)
    ES6参考---promise对象结构分析
    javascript疑难问题---18、回调函数做异步操作
    javascript疑难问题---17、js中in关键字使用总结
    javascript疑难问题---16、类数组对象转换成数组
    javascript疑难问题---15、类数组对象
    心得体悟帖---200501(情感回馈,一般你怎么对待别人,别人也会怎么对待你)
  • 原文地址:https://www.cnblogs.com/hxsyl/p/2624246.html
Copyright © 2011-2022 走看看