Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<dos.h>
- #include <conio.h>
- #include<stdio.h>
- #include<string>
- #include<string.h>
- #include<windows.h>
- // --------- DZWIEKI --------- //
- #define C 16.35
- #define Cis 17.325
- #define D 18.35625
- #define Dis 19.44375
- #define E 20.6
- #define F 21.825
- #define Fis 23.125
- #define G 24.5
- #define Gis 25.95625
- #define A 27.5
- #define B 29.1375
- #define H 30.86875
- #define C2 32.70625
- // --------- DZWIEKI ----------//
- class keyboard
- {
- public:
- int tempo, Hz;
- char key, oktawa, dzwiek, wybor;
- keyboard();
- void graj();
- void menu();
- void rysuj();
- void oktawy();
- void utwory();
- void pomoc();
- };
- //-----------class keyboard----------------//
- keyboard::keyboard()
- {
- clrscr();
- }
- //-------------konstruktor---------------//
- void keyboard::graj()
- {
- rysuj(); // rysowanie klawiszy
- tempo = 0;
- pomoc();
- do{
- gotoxy(60, 3);
- textcolor(15); cprintf("Tempo: "); textcolor(14); cprintf("%d", tempo);
- gotoxy(60,4);
- textcolor(15); cprintf("Oktawa: "); textcolor(14); cprintf("%c", oktawa);
- gotoxy(1, 16);
- gotoxy(60,5);
- textcolor(15); cprintf("Grany dzwiek: ");textcolor(13); cprintf("%c", dzwiek);
- gotoxy(1, 16);
- // textcolor(15); cprintf("Aby zobaczyc pomoc wcisnij: "); textcolor(14); cprintf("F1");
- key = getch();
- gotoxy(60, 6);
- printf(" ");
- switch(key)
- {
- case 122:
- {
- Beep(C * Hz, tempo);
- dzwiek = 'C';
- break;
- }
- case 115:
- {
- Beep(Cis * Hz, tempo);
- dzwiek = 'C';
- break;
- }
- case 120:
- {
- Beep(D * Hz, tempo);
- dzwiek = 'D';
- break;
- }
- case 100:
- {
- Beep(Dis * Hz, tempo);
- dzwiek = 'D';
- break;
- }
- case 99:
- {
- Beep(E * Hz, tempo);
- dzwiek = 'E';
- break;
- }
- case 118:
- {
- Beep(F * Hz, tempo);
- dzwiek = 'F';
- break;
- }
- case 103:
- {
- Beep(Fis * Hz, tempo);
- dzwiek = 'F';
- break;
- }
- case 98:
- {
- Beep(G * Hz, tempo);
- dzwiek = 'G';
- break;
- }
- case 104:
- {
- Beep(Gis * Hz, tempo);
- dzwiek = 'G';
- break;
- }
- case 110:
- {
- Beep(A * Hz, tempo);
- dzwiek = 'A';
- break;
- }
- case 106:
- {
- Beep(B * Hz, tempo);
- dzwiek = 'B';
- break;
- }
- case 109:
- {
- Beep(H * Hz, tempo);
- dzwiek = 'H';
- break;
- }
- case 44:
- {
- Beep(C2 * Hz, tempo);
- dzwiek = 'C';
- break;
- }
- case 9:
- {
- gotoxy(67, 3);
- printf(" ");
- gotoxy(67, 3);
- scanf("%d", &tempo);
- break;
- }
- case 49:
- {
- Hz = 1;
- oktawa = 'S';
- break;
- }
- case 50:
- {
- Hz = 2;
- oktawa = 'K';
- break;
- }
- case 51:
- {
- Hz = 4;
- oktawa = 'W';
- break;
- }
- case 52:
- {
- Hz = 8;
- oktawa = 'M';
- break;
- }
- case 53:
- {
- Hz = 16;
- oktawa = 'R';
- break;
- }
- case 54:
- {
- Hz = 32;
- oktawa = 'D';
- break;
- }
- case 55:
- {
- Hz = 64;
- oktawa = 'T';
- break;
- }
- case 56:
- {
- Hz = 128;
- oktawa = 'C';
- break;
- }
- case 57:
- {
- Hz = 256;
- oktawa = 'P';
- break;
- }
- case 48:
- {
- Hz = 512;
- oktawa = 'S';
- break;
- }
- case 96:
- {
- oktawy();
- break;
- }
- case 59:
- {
- pomoc();
- break;
- }
- default:
- {
- gotoxy(60, 6);
- textcolor(11);
- cprintf("Niewlasciwy wybor");
- break;
- }
- }
- }while(key!='q');
- getch();
- }
- //-----------void graj---------------//
- void keyboard::pomoc()
- {
- gotoxy(1, 16);
- textcolor(15); cprintf("Aby zmienic tempo wcisnij: ");textcolor(14); cprintf("TAB");
- gotoxy(1, 17);
- textcolor(15); cprintf("Aby zmienic oktawe wcisnij: ");textcolor(14); cprintf("TYLDA");
- gotoxy(1, 18);
- textcolor(13); cprintf("Badz, ");
- gotoxy(1, 19);
- textcolor(15); cprintf("Wcisnij jeden z klawiszy: ");
- gotoxy(1, 20);
- textcolor(14); cprintf("1 - Subkontra");
- gotoxy(20, 20);
- cprintf("2 - Kontra");
- gotoxy(1, 21);
- cprintf("3 - Wielka");
- gotoxy(20, 21);
- cprintf("4 - Mala");
- gotoxy(1, 22);
- cprintf("5 - Razkreslna");
- gotoxy(20, 22);
- cprintf("6 - Dwukreslna");
- gotoxy(1, 23);
- cprintf("7 - Trzykreslna");
- gotoxy(20, 23);
- cprintf("8 - Czterokreslna");
- gotoxy(1, 24);
- cprintf("9 - Pieciokreslna");
- gotoxy(20, 24);
- cprintf("0 - Szesckreslna");
- }
- void keyboard::menu()
- {
- clrscr();
- gotoxy(1,1);
- textcolor(12);
- textbackground(3);
- cprintf(" VIRTUAL KEYBOARD ");
- textbackground(0);
- gotoxy(1,3);
- textcolor(15); cprintf("Co chcesz zrobic: ");
- gotoxy(1, 4);
- textcolor(14); cprintf("* G - Grac na Instrumencie");
- gotoxy(1, 5);
- textcolor(14); cprintf("* P - Posluchac Utworow");
- gotoxy(1,6);
- textcolor(14); cprintf("* Q - Wylaczyc Program");
- gotoxy(1, 7);
- printf(": ");
- scanf("%c", &wybor);
- switch(wybor)
- {
- case 'g':
- case 'G':
- {
- graj();
- break;
- }
- case 'p':
- case 'P':
- {
- gotoxy(1, 9);
- textcolor(15);cprintf("Co chcesz zagrac: ");
- gotoxy(1, 10);
- textcolor(14);cprintf("*S - Sweet Child 'O Mine");
- gotoxy(1, 11);
- textcolor(14);cprintf("*K - Wlazl Kotek na Plotek");
- gotoxy(1, 12);
- printf(": ");
- scanf("%c", &wybor);
- scanf("%c", &wybor);
- utwory();
- break;
- }
- }
- }
- //-------------void menu------------//
- void keyboard::oktawy()
- {
- Hz = 0;
- gotoxy(68, 4);
- printf(" ");
- gotoxy(68,4);
- scanf("%c", &oktawa);
- scanf("%c", &oktawa);
- textbackground(16);
- switch(oktawa)
- {
- case 'sk':
- case 'SK':
- case 'Sk':
- case 'sK':
- {
- Hz = 1;
- break;
- }
- case 'k':
- case 'K':
- {
- Hz = 2;
- break;
- }
- case 'w':
- case 'W':
- {
- Hz = 4;
- break;
- }
- case 'm':
- case 'M':
- {
- Hz = 8;
- break;
- }
- case 'r':
- case 'R':
- {
- Hz = 16;
- break;
- }
- case 'd':
- case 'D':
- {
- Hz = 32;
- break;
- }
- case 't':
- case 'T':
- {
- Hz = 64;
- break;
- }
- case 'c':
- case 'C':
- {
- Hz = 128;
- break;
- }
- case 'p':
- case 'P':
- {
- Hz = 256;
- break;
- }
- case 's':
- case 'S':
- {
- Hz = 512;
- break;
- }
- default :
- {
- menu();
- break;
- }
- }
- }
- void keyboard::utwory()
- {
- switch(wybor)
- {
- case 's':
- case 'S':
- {
- for(int i=1; i<=1;i++)
- {
- for(int i =1 ; i<=2; i++)
- {
- Beep(32* 18.35625, 230);
- Beep(64*18.35625, 230);
- Beep(32* 27.5, 230);
- Beep(32* 24.5, 230);
- Beep(128* 24.5, 230);
- Beep(128* 17.325, 230);
- Beep(128* 23.125, 230);
- Beep(128* 17.325, 230);
- }
- for(int i=1;i<=2;i++)
- {
- Beep(32* 27.5, 230);
- Beep(64*18.35625, 230);
- Beep(32* 27.5, 230);
- Beep(32* 24.5, 230);
- Beep(128* 24.5, 230);
- Beep(128* 17.325, 230);
- Beep(128* 23.125, 230);
- Beep(128* 17.325, 230);
- }
- for(int i=1;i<=2;i++)
- {
- Beep(128* 18.35625, 230);
- Beep(64*18.35625, 230);
- Beep(32* 27.5, 230);
- Beep(32* 24.5, 230);
- Beep(128* 24.5, 230);
- Beep(128* 17.325, 230);
- Beep(128* 23.125, 230);
- Beep(128* 17.325, 230);
- }
- for(int i =1 ; i<=2; i++)
- {
- Beep(32* 18.35625, 230);
- Beep(64*18.35625, 230);
- Beep(32* 27.5, 230);
- Beep(32* 24.5, 230);
- Beep(128* 24.5, 230);
- Beep(128* 17.325, 230);
- Beep(128* 23.125, 230);
- Beep(128* 17.325, 230);
- }
- }
- for(int i =1 ; i<=2; i++)
- {
- Beep(32* 18.35625, 230);
- Beep(64*18.35625, 230);
- Beep(32* 27.5, 230);
- Beep(32* 24.5, 230);
- Beep(128* 24.5, 230);
- Beep(128* 17.325, 230);
- Beep(128* 23.125, 230);
- Beep(128* 17.325, 230);
- }
- for(int i=1;i<=2;i++)
- {
- Beep(32* 27.5, 230);
- Beep(64*18.35625, 230);
- Beep(32* 27.5, 230);
- Beep(32* 24.5, 230);
- Beep(128* 24.5, 230);
- Beep(128* 17.325, 230);
- Beep(128* 23.125, 230);
- Beep(128* 17.325, 230);
- }
- for(int i=1;i<=2;i++)
- {
- Beep(128* 18.35625, 230);
- Beep(64*18.35625, 230);
- Beep(32* 27.5, 230);
- Beep(32* 24.5, 230);
- Beep(128* 24.5, 230);
- Beep(128* 17.325, 230);
- Beep(128* 23.125, 230);
- Beep(128* 17.325, 230);
- }
- Beep(128* 20.6, 230);
- Beep(32* 27.5, 230);
- Beep(64* 18.35625, 230);
- Beep(32* 27.5, 230);
- Beep(128* 20.6, 230);
- Beep(32* 27.5, 230);
- Beep(128* 23.125, 230);
- Beep(32* 27.5, 230);
- Beep(128* 24.5, 230);
- Beep(32* 27.5, 230);
- Beep(128* 23.125, 230);
- Beep(32* 20.6, 230);
- Beep(128* 20.6, 230);
- Beep(32* 27.5, 230);
- Beep(64* 18.35625 , 230);
- Beep(32* 27.5, 230);
- Beep(64 * 18.35625, 230);
- menu();
- break;
- }
- case 'k':
- case 'K':
- {
- Beep(32 * 24.5, 400);
- Beep(32* 20.6, 400);
- Beep(32* 20.6, 400);
- Beep(32* 21.825, 400);
- Beep(32* 18.35625, 400);
- Beep(32* 18.35625, 400);
- Beep(32* 16.35, 200);
- Beep(32* 20.6, 200);
- Beep(32* 24.5, 200);
- Beep(20, 1000);
- Beep(32* 16.35, 200);
- Beep(32* 20.6, 200);
- Beep(32* 24.5, 200);
- Beep(20, 1000);
- Beep(32 * 24.5, 400);
- Beep(32* 20.6, 400);
- Beep(32* 20.6, 400);
- Beep(32* 21.825, 400);
- Beep(32* 18.35625, 400);
- Beep(32* 18.35625, 400);
- Beep(32* 16.35, 200);
- Beep(32* 20.6, 200);
- Beep(32* 16.35, 200);
- menu();
- break;
- }
- }
- menu();
- menu();
- menu();
- }
- void keyboard::rysuj()
- {
- clrscr();
- gotoxy(1,1);
- textcolor(12);
- textbackground(3);
- cprintf(" VIRTUAL KEYBOARD ");
- printf(" _______________________________________________________\n");
- printf("| | | | | | | | | | | | |\n");
- printf("| | | | | | | | | | | | |\n");
- printf("| | | | | | | | | | | | |\n");
- printf("| | | | | | | | | | | | |\n");
- printf("| | S | | D | | | G | | H | | J | |\n");
- printf("| | | | | | | | | | | | |\n");
- printf("| |___| |___| | |___| |___| |___| |\n");
- printf("| | | | | | | |\n");
- printf("| | | | | | | |\n");
- printf("| Z | X | V | B | N | M | < |\n");
- printf("| | | | | | | |\n");
- printf("|_______|_______|_______|_______|_______|_______|_______|\n");
- textbackground(16);
- }
- //-----------void rysuj--------------//
- int main()
- {
- //------------------OKNO STARTOWE-------------------------//
- char znaki[40]="-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/-\|/";
- gotoxy(26,2);
- textcolor(8);
- cprintf("\n VIRTUAL KEYBOARD");
- gotoxy(27.5,10);
- textcolor(3);
- cprintf("\nWykonanie: Patryk Gliszczynski\n");
- gotoxy(20, 16);
- printf("|__________________________________________|");
- gotoxy(20,17);
- printf("| |");
- for(int i=0;i<20;i++)
- {
- gotoxy(30.5,13);
- textcolor(3);
- cprintf(" Loading... %c",znaki[i]);
- Sleep(100);
- }
- keyboard instrument;
- instrument.menu();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement