Results 1 to 3 of 3
  1. #1
    mwb1234's Avatar
    Join Date
    May 2009
    Gender
    male
    Posts
    460
    Reputation
    7
    Thanks
    65

    [RELEASE] My Boredom Shows! Look!

    Hey guys I figured that it was time to help the MPGH community as I have taken so much from you guys...

    So here we go. How to make a simple Metronome that keeps perfect time:

    So now we must start by making a VC++ project. I use VC++ Express Edition 2008. Dev-C++ will not work for this tutorial.

    So first what you are going to want to do after you have made the VC++ Console application project, is to get a short beep or tick .wav file. I have a little blub thing available to download.

    Now in the solution manager create a new header file. We will name this file Includes.h

    In the header file type this:

    [PHP]
    #pragma once;
    #define VK_A 0x41
    #define VK_B 0x42
    #define VK_C 0x43
    #define VK_D 0x44
    #define VK_E 0x45
    #define VK_F 0x46
    #define VK_G 0x47
    #define VK_H 0x48
    #define VK_I 0x49
    #define VK_J 0x4A//Theses define the alphabet Keys
    #define VK_K 0x4B
    #define VK_L 0x4C
    #define VK_M 0x4D
    #define VK_N 0x4E
    #define VK_O 0x4F
    #define VK_P 0x50
    #define VK_Q 0x51
    #define VK_R 0x52
    #define VK_S 0x53
    #define VK_T 0x54
    #define VK_U 0x55
    #define VK_V 0x56
    #define VK_W 0x57
    #define VK_X 0x58
    #define VK_Y 0x59
    #define VK_Z 0x5A
    #define VK_PLUS 0x6B
    #define VK_MINUS 0x6D
    #include <iostream>//Used for console commands such as cout, cin, etc..
    #include <windows.h>//Use this file to include hotkeys in the metronome
    #include "TellTime.h" //Another header we will make.
    #include <mmsystem.h>//Allows output of sound
    #pragma comment(lib, "winmm.lib")//Link mmsystem.h to winmm.lib
    using namespace std;
    [/PHP]

    Phew. That was a LOT of work. Now lets start on "TellTime.h" the most important piece of our code. When we are done with this, I'll break it down for you:

    [PHP]
    #pragma once;//So that this file is not included more than once.
    using namespace std;//To use console commands
    #include "Includers.h"//Includes the file we just made
    int TellTime(int bpm)
    {
    cout << "Hit home to pause and change BPM. Hit home again to continue. For a BPM check hit home.\n";
    int ticks;
    while(1){
    ticks = 60000/bpm;
    PlaySound(L"tick.wav", NULL, SND_ASYNC | SND_FILENAME);
    Sleep(ticks);
    if(GetAsyncKeyState(VK_DELETE))break;
    if(GetAsyncKeyState(VK_HOME)){
    cout << "Your current BPM is: " << bpm << endl;
    cout << "Plus & Minus changes it \n";
    while(1){
    if(GetAsyncKeyState(VK_PLUS)){bpm++;if(bpm % 5 == 0){cout << bpm << endl;}}
    if(GetAsyncKeyState(VK_MINUS)){bpm--;if(bpm % 5 == 0){cout << bpm << endl;}}
    Sleep(100);
    if(GetAsyncKeyState(VK_HOME)){
    cout << "New BPM is: " << bpm << endl;
    system("PAUSE");
    break;
    }
    }
    }
    }
    return 0;
    }



    int GetBpm()
    {
    int bpm = 60;
    cout << "How many BPM? Hit plus to increase, and minus to decrease. \nStarts at 60 BPM\nHit Insert to continue when you are done.\n";
    while(1){
    if(GetAsyncKeyState(VK_PLUS)){bpm++;if(bpm % 5 == 0){cout << bpm << endl;}}
    if(GetAsyncKeyState(VK_MINUS)){bpm--;if(bpm % 5 == 0){cout << bpm << endl;}}
    if(GetAsyncKeyState(VK_INSERT))break;
    Sleep(100);
    }
    return bpm;
    }
    [/PHP]

    Now to decipher how this code works.

    [PHP]
    int TellTime(){
    //code
    }
    [/PHP]

    Gets the Beats per Minutes you want and returns them. This will then be the input into the function:

    [PHP]
    int TellTime(int bpm){
    //code
    }[/PHP]

    TellTime function will take your beats per minute and then Sleep for 60000/bpm milliseconds. This will take you to a millisecond number such as 1000 for 60 bpm... Then the most important part of this function

    [PHP]
    PlaySound(L"tick.wav", NULL, SND_ASYNC | SND_FILENAME);
    [/PHP]

    This plays the sound "tick.wav" from the current directory. Nothing else needs to be worried about.

    Now all we have left is to link the functions in Main.cpp.

    Create a new source code and insert this to link it.

    [PHP]
    #include "Includers.h"
    using namespace std;
    int GetBpm(); //Declares you want use of this function
    int TellTime(int bpm); //Also declares you want use of this function

    int main(){
    start:
    int bpm;//Creates an integer with no value, named bpm
    bpm = GetBpm(); //Stores the return value of GetBpm() into the int bpm
    TellTime(bpm); //Makes it go tick to the time of your custom bpm...
    cout << "Start again? (Y/N)";
    while(1){
    if(GetAsyncKeyState(VK_Y))goto start;
    if(GetAsyncKeyState(VK_N))break;
    }
    return 0;
    }
    [/PHP]

    Now all that is left is to hit F5 and you will Build + Go. Then you can try out the program.

    Hit That Thanks Button!

  2. The Following 3 Users Say Thank You to mwb1234 For This Useful Post:

    Hell_Demon (06-01-2010),lalakijilp (06-01-2010),why06 (05-31-2010)

  3. #2
    why06's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    IBM
    Posts
    4,304
    Reputation
    170
    Thanks
    2,204
    My Mood
    Flirty
    well that's helpful. If you put all the keys into a header file I would download it n keep it somewhere. course I can just make my own header to put em in.

    "Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."
    - Dwight D. Eisenhower

  4. #3
    **HellaGoodCoders**'s Avatar
    Join Date
    May 2010
    Gender
    male
    Posts
    17
    Reputation
    10
    Thanks
    6
    I did put all the keys in a header file. They just have some extra stuff. It took a long time to finish this project. My comp == So retarded
    EDIT: Oh btw this is mwb1234

Similar Threads

  1. Replies: 30
    Last Post: 01-30-2010, 10:21 AM
  2. [Release]Best CA mod ever (!!) Makes ur hands look like Zadan's hand!!
    By Protect in forum Combat Arms Mods & Rez Modding
    Replies: 21
    Last Post: 01-06-2010, 09:24 AM
  3. [possible re-release]Minion please look here
    By esxsposer2 in forum Combat Arms Hacks & Cheats
    Replies: 20
    Last Post: 08-20-2009, 12:37 AM
  4. Replies: 13
    Last Post: 07-13-2009, 12:32 AM
  5. [Release]IP/MAC Banned? Look No Further!
    By ShawnRocks in forum Combat Arms Hacks & Cheats
    Replies: 21
    Last Post: 09-04-2008, 08:58 PM