Keyboard - Using C Programming Language

 









"Keyboard" is a simple project made using computer programming language. I have integrated every components of the code inside the main function. The bad part of this project is that the time of sound that is played is constant to it is obvious that there will be defect in timing. As I have used delay(250); for determination of  time of play, sound is produced for one fourth of a second. The good part is that you can change 250 to any time you think is suitable. Remember the time placed inside delay function is in millisecond not in second.


This code is compatible with TURBO C++ compiler only. 


How to download the source code?

  • Click here for source code.
  • New window will open where there is a source code of this project. You can download that code.
  • Remember to run this code in Turbo C++ compiler.

 

Demo of the project

Check out the following video for the demo of this project. 


 For more source code and tutorial, SUBSCRBE to my YouTube channel.

Development platform

Computer programming language has been used to develop this project.

 

Compiler

Turbo C has been used as compiler. The compiler version for Turbo C that is used is 3.7.8.9 which is also the latest one.


Header files used

The header files used in this project are as follows :

  1. Conio
  2. Dos
  3. Graphics
  4. Stdio
  5. Stdlib


Library functions used

The following library functions has been used

  1. Under conio header file
    1. Clrscr
    2. Getch
  2. Under dos header file
    1. Delay
    2. Nosound
    3. Sound
  3. Under graphics header file
    1. Closegraph
    2. Floodfill
    3. Initgraph
    4. Line
    5. Outtextxy
    6. Rectangle
    7. Setfillstyle
    8. Setcolor
  4. Under stdio header file
    1. Library function 1
  5. Under stdlib header file 
    1. Exit 


Concepts used

Topics/ concepts of this language that you need to know for making this type of game :

  1. For loop looping statement
  2. Graphics
  3. Switch case statement


 

Code logic

The duration time of sound that is played is constant which is the bad part of this project. Hence, it is obvious that there will be defect in timing. As 250 millisecond has been used for determination of  duration of playtime of each note, sound is produced for one fourth of a second. The pros part is that you can change 250 to any time value you think is suitable. Remember the time placed inside delay function is in millisecond not in second.


The most important task in this project was to produce musical notes. I used following frequencies as parameter for sound function in this project.

Musical Note

Frequency

Frequency

C

523.3

1047

C#

554.4

1109

D

587.3

1175

D#

622.3

1245

E

659.3

1319

F

698.5

1397

F#

740.0

1480

G

784.0

1568

G#

830.6

1661

A

880.6

1760

A#

932.3

1865

B

987.8

1976

No comments:

Post a Comment

Article Ad1