Methods and considerations for performing WAV files

zhaozj2021-02-11  180

Method and precautions for the WAVE file and the precautions are much more articles in this area. I don't want to say more, but recently, some netizens say that he has made a "project", but how can it be sent? Sound, or is the BEEP sound of the speaker.

Later, the author found the information, and made a "project" according to their methods; the results were the same as that netizen. This in the end is why?

Let's talk about how the general article is saying.

The comparative "popular" statement is: "16-bit Delphi 1.0 and 32-bit Delphi2.0, 3.0 provide resource compilation tools, where Delphi 1.0 resource compiler is Brcc.exe, Delphi 2.0 resource compiler called BRCC32 .Exe is used to compile 32-bit resources, all resource compilers only provide command line versions, no Windows version. Making a resource generally passes the following steps:

1) Write .rc file

..Rc file is the source file of the resource, the compiler also compiles this file, generating .res' resource file first creates a plain text file in our project subdirectory, named Sound.rc, a line in the file, content for:

Sound1 WAV Sound.wav

Sound.wav is a normal sound file under Windows

2) Compile it

After playing the BRCC Sound.rc hard disk in DOS, after it is completed, it is compiled.

3) Production procedure

This is also the most complex, flexible step. Start Windows, start Delphi, and save files in our project in subdirectory in our project. Looking for such a line in Unit1.Pas

{$ R * .dfm}

State our resource files behind

{$ R snound.res}

Then, in Form1, two global variables are declared

PTRSOUND: PCHAR; HRES: THANDLE; {handle; {handle {handle {handle {handle {handle {handle;

Write the following code in the create event of Form1

procedure TForm1.FormCreate (Sender: TObject); var hResInfo: THandle; begin hResInfo: = FindResource (HInstance, 'SOUND1', 'WAVE'); hRes: = LoadResource (HInstance, hResInfo); if hRes> 32 then {its a Good load} begin {lock the resource} PTRSOUND: = LOCKRESOURCE (HRES); END;

Then put a button button1 in Form1, write the following code:

Procedure TForm1.Button1Click (Sender: TOBJECT); Begin SndPlaySound (PTRSound, SND_ASYNC OR SND_MEMORY); END; you can run at this time. "

is that true?

In fact, the file name of the resource file is not as follows, otherwise, huh, huh, the speaker will be beep, don't believe you try.

The following author writes the steps that can run the source code (of course your resource file cannot be wrong):

1) Write .rc file

..Rc file is the source file of the resource, the compiler also compiles this file, generates .res' resource file first creates a plain text file in our project subdirectory, named PAD.RC, writing a line in the file, The content is: // pay attention! The name of the resource file cannot be the same as the Wave file name! Sound1 WAV Sound.wav

Sound.wav is a normal sound file under Windows

2) Compile it

After playing BRCC32 PAD.RC at DOS, it is already BRCC32, which is already BRCC32, and I don't know how to have BRCC? ?

3) Production procedure

Launch Delphi under Windows, create a new project, save the files into the subdirectory in our project. Find in Unit1.Pas

{$ R * .dfm}

State our resource files behind

{$ R pad.res}

Then, in Form1, two global variables are declared

PTRSOUND: PCHAR; HRES: THANDLE; {handle; {handle {handle {handle {handle; {handle;

Write the following code in the create event of Form1

procedure TForm1.FormCreate (Sender: TObject); var hResInfo: THandle; begin hResInfo: = FindResource (HInstance, 'SOUND1', 'WAVE'); hRes: = LoadResource (HInstance, hResInfo); if hRes> 32 then {its a Good load} begin {lock the resource} PTRSOUND: = LOCKRESOURCE (HRES); END;

Then put a button button1 in Form1, write the following code:

Procedure TForm1.Button1Click (Sender: TOBJECT); Begin SndPlaySound (PTRSOUND, SND_ASYNC OR SND_MEMORY); END;

Click Compile, Run, press Button1, you can hear the contents of the WAVE file in the speaker.

In this way, a small project is completed. Try it!

转载请注明原文地址:https://www.9cbs.com/read-5295.html

New Post(0)