Beep is crazy, so make your motherboard happy.

Source: Internet
Author: User

The main board can sing and play beautiful music based on the music. Do you believe it? Believe it or not, I believe it, ^ _ ^.

Windows API provides such a wonderful pronunciation function, which is the beep function. Beep can be used to control the voice frequency and festival beats of the Main Board speaker to play beautiful music. This article uses the music notation to play several beautiful songs to show beep's crazy charm.

First, let's refer to the beep function prototype:

BOOL Beep(  DWORD dwFreq,  DWORD dwDuration);

Parameter description:

Dwfreq specifies the frequency to be sent (from 37hz to 32767Hz)
Dwduration specifies the pronunciation length in milliseconds.

According to the profile, we know that music scores used for music performances are composed of syllables and beats. Different syllables are sounds of different frequencies. Let's take a look at the imitation syllables of the PC motherboard speakers:

Program Implementation:

/*************************************** * **************************** Copyright (c) jerry Jiang * file name: multithreaddlg. CPP * Author: Jerry Jiang * Create Time: 2011-10-7 14:41:02 * mail: jbiaojerry@gmail.com * blog: http://blog.csdn.net/jerryjbiao * description: beep functions play farewell, legend, and happy birthday song *************************** **************************************** */# include <iostream> # include <windows. h> using namespace STD; // defines the const int a1 = 131; const int a2 = 147; const int a3 = 165; const int A4 = 175; const int A5 = 196; const int A6 = 220; const int A7 = 247; // defines the mediainfo const int b1 = 262; const int b2 = 296; const int B3 = 330; const int B4 = 349; const int B5 = 392; const int B6 = 440; const int B7 = 494; // defines the tweeter const int C1 = 523; const int C2 = 587; const int C3 = 659; const int C4 = 698; const int C5 = 784; const int C6 = 880; const int C7 = 988; // define high level const int d1 = 1047; const int D2 = 1175; const int D3 = 1319; const int D4 = 1397; const int D5 = 1568; const int D6 = 1760; const int D7 = 1976; // define the cycle const int onebeat = 600; const int halfbeat = 300; void happybirthday (); void legend (); void sendoff (); int main () {cout <"**************************" <Endl; cout <"* 1-Farewell *" <Endl; cout <"* 2-legend *" <Endl; cout <"* 3-happy birthday to you *" <Endl; cout <"**************************" <Endl; cout <"select a song:" <Endl; int num = 0; CIN> num; Switch (Num) {Case 1: cout <"you have selected: 1-Farewell "<Endl; sendoff (); break; Case 2: cout <" you selected: 2-Legend "<Endl; legend (); break; case 3: cout <"you selected: 3-Happy birthday to you" <Endl; happybirthday (); break; default: break;} return 0;} void happybirthday () {BEEP (C5, halfbeat); BEEP (C5, halfbeat); BEEP (C6, onebeat); BEEP (C5, onebeat); BEEP (D1, onebeat); BEEP (C7, onebeat * 2); BEEP (C5, halfbeat); BEEP (C5, halfbeat); BEEP (C6, onebeat); BEEP (C5, onebeat); BEEP (D2, onebeat ); beep (D1, onebeat * 2); BEEP (C5, halfbeat); BEEP (C5, halfbeat); BEEP (D5, onebeat); BEEP (D3, onebeat ); beep (D1, onebeat); BEEP (C7, onebeat); BEEP (D4, halfbeat); BEEP (D4, halfbeat); BEEP (D3, onebeat); BEEP (D1, onebeat); BEEP (D2, onebeat); BEEP (D1, onebeat * 2); BEEP (C5, halfbeat); BEEP (C5, halfbeat); BEEP (D5, onebeat ); beep (D3, onebeat); BEEP (D1, onebeat); BEEP (C7, halfbeat); BEEP (C6, onebeat * 2); BEEP (D4, halfbeat ); beep (D4, halfbeat); BEEP (D3, onebeat); BEEP (D1, onebeat); BEEP (D2, onebeat); BEEP (D1, onebeat * 3 );} void legend () {// just because you have taken a look at BEEP (C1, halfbeat); BEEP (C1, onebeat); BEEP (C1, onebeat ); beep (C3, onebeat); BEEP (C2, onebeat); BEEP (C2, halfbeat); BEEP (C2, halfbeat/2); BEEP (C1, halfbeat ); beep (C1, onebeat); BEEP (C1, halfbeat); BEEP (C2, onebeat); BEEP (C2, onebeat); BEEP (C1, halfbeat); BEEP (B6, halfbeat); BEEP (B6, halfbeat/2); BEEP (B6, onebeat * 2); // never forget your face BEEP (B7, halfbeat); BEEP (B7, halfbeat); BEEP (B7, onebeat); BEEP (C1, halfbeat); BEEP (C2, halfbeat); BEEP (C2, onebeat); BEEP (B7, onebeat ); beep (B6, halfbeat); BEEP (B5, halfbeat); BEEP (B3, halfbeat); BEEP (B3, onebeat * 2 ); // dream of meeting BEEP (C3, halfbeat), beep (C2, halfbeat), beep (C3, onebeat), and beep (C3, halfbeat) One day by accident ); beep (C3, halfbeat/2); BEEP (C2, halfbeat); BEEP (C2, onebeat); BEEP (C2, halfbeat/2); BEEP (C1, halfbeat ); beep (C1, onebeat); BEEP (C2, onebeat); BEEP (B6, onebeat); BEEP (B6, halfbeat); BEEP (B6, halfbeat/2 ); beep (C2, halfbeat); BEEP (C1, halfbeat/2); BEEP (C1, onebeat * 2); // from now on, I miss BEEP (B7, halfbeat ); beep (B7, halfbeat); BEEP (B7, onebeat); BEEP (C1, halfbeat); BEEP (C2, halfbeat/2); BEEP (C2, onebeat ); beep (C2, onebeat); BEEP (B6, halfbeat); BEEP (B5, onebeat); BEEP (B3, onebeat * 2 ); // BEEP (C5, onebeat); BEEP (C2, halfbeat/2); BEEP (C2, onebeat); BEEP (C3, onebeat); BEEP (C3, onebeat ); beep (C5, onebeat); BEEP (C2, halfbeat); BEEP (C2, onebeat); BEEP (D1, halfbeat); BEEP (B6, onebeat * 2 ); sleep (50); // when you miss you in front of beep (C2, onebeat); BEEP (B6, halfbeat/2); BEEP (B6, onebeat); BEEP (C3, onebeat); BEEP (C2, onebeat); BEEP (C1, halfbeat/2); BEEP (C1, onebeat); BEEP (C1, onebeat); BEEP (B5, onebeat * 2); // BEEP (C5, onebeat); BEEP (C2, halfbeat/2); BEEP (C2, onebeat); BEEP (C3, onebeat); BEEP (C5, onebeat); BEEP (C2, halfbeat); BEEP (C2, onebeat); BEEP (D1, onebeat); BEEP (B6, onebeat * 2 ); sleep (50); // when you miss you, beep (C2, onebeat); BEEP (B6, halfbeat/2); BEEP (B6, onebeat); BEEP (C3, onebeat); BEEP (C2, onebeat); BEEP (C1, halfbeat/2); BEEP (C1, onebeat); BEEP (C1, onebeat); BEEP (B5, onebeat * 2); // we would rather believe that we had an appointment with BEEP (C1, halfbeat); BEEP (C1, halfbeat); BEEP (C1, onebeat); BEEP (B5, halfbeat ); beep (C1, halfbeat/2); BEEP (C1, onebeat); BEEP (C5, onebeat); BEEP (D4, onebeat); BEEP (C3, onebeat ); beep (C2, onebeat); BEEP (C1, halfbeat/2); BEEP (C1, onebeat * 2); // The love story in this life will not change BEEP (C1, halfbeat ); beep (C3, halfbeat); BEEP (C5, halfbeat); BEEP (C6, onebeat); BEEP (C5, halfbeat); BEEP (C6, halfbeat/2 ); beep (C6, halfbeat); BEEP (C5, onebeat); BEEP (C6, onebeat); BEEP (C5, halfbeat); BEEP (C3, halfbeat); BEEP (C3, halfbeat); BEEP (C2, onebeat); BEEP (C3, halfbeat/2); BEEP (C3, onebeat * 2); // you would rather use this life to discover BEEP (C1, halfbeat); BEEP (C1, halfbeat); BEEP (C1, onebeat); BEEP (B5, halfbeat); BEEP (C1, halfbeat/2); BEEP (C1, onebeat ); beep (C5, onebeat); BEEP (D4, onebeat); BEEP (C3, onebeat); BEEP (C2, onebeat); BEEP (C1, halfbeat/2 ); beep (C1, onebeat * 2); // BEEP (C1, halfbeat); BEEP (C3, halfbeat); BEEP (C5, halfbeat ); beep (C6, onebeat); BEEP (C5, halfbeat); BEEP (C6, halfbeat/2); BEEP (C6, halfbeat); BEEP (C5, onebeat ); beep (C6, onebeat); BEEP (C5, halfbeat); BEEP (C3, halfbeat/2); BEEP (C5, onebeat); BEEP (C5, onebeat * 4 );} void sendoff () {// farewell const int one_beep = 600; const int half_beep = 300; const int note_1 = 440; const int note_2 = 495; const int note_3 = 550; const int note_4 = 587; const int note_5 = 660; const int note_6 = 733; const int note_7 = 825; // BEEP (note_5, one_beep); BEEP (note_3, half_beep); BEEP (note_5, half_beep); BEEP (note_1 * 2, one_beep * 2); // BEEP (note_6, one_beep); BEEP (note_1 * 2, one_beep); BEEP (note_5, one_beep * 2); // BEEP (note_5, one_beep); BEEP (note_1, half_beep); BEEP (note_2, half_beep ); beep (note_3, one_beep); BEEP (note_2, half_beep); BEEP (note_1, half_beep); BEEP (note_2, one_beep * 4 ); // BEEP (note_5, one_beep); BEEP (note_3, half_beep); BEEP (note_5, half_beep); BEEP (note_1 * 2, half_beep * 3 ); beep (note_7, half_beep); BEEP (note_6, one_beep); BEEP (note_1 * 2, one_beep); BEEP (note_5, one_beep * 2); // BEEP (note_5, one_beep); BEEP (note_2, half_beep); BEEP (note_3, half_beep); BEEP (note_4, half_beep * 3); BEEP (INT) (note_7/2 + 0.5 ), half_beep); BEEP (note_1, one_beep * 4); // BEEP (note_6, one_beep); BEEP (note_1 * 2, one_beep); BEEP (note_1 * 2, one_beep * 2); // BEEP (note_7, one_beep); BEEP (note_6, half_beep); BEEP (note_7, half_beep); BEEP (note_1 * 2, one_beep * 2); // BEEP (note_6, half_beep); BEEP (note_7, half_beep); BEEP (note_1 * 2, half_beep); BEEP (note_6, half_beep ); beep (note_6, half_beep); BEEP (note_5, half_beep); BEEP (note_3, half_beep); BEEP (note_1, half_beep); BEEP (note_2, one_beep * 4 ); // complete the remaining happy BEEP (note_5, one_beep); BEEP (note_3, half_beep); BEEP (note_5, half_beep); BEEP (note_1 * 2, half_beep * 3 ); beep (note_7, half_beep); BEEP (note_6, one_beep); BEEP (note_1 * 2, one_beep); BEEP (note_5, one_beep * 2 ); // do not dream cold BEEP (note_5, one_beep); BEEP (note_2, half_beep); BEEP (note_3, half_beep); BEEP (note_4, half_beep * 3 ); beep (INT) (note_7/2 + 0.5), half_beep); BEEP (note_1, one_beep * 3); sleep (10000 );}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.