// Mmsystem play audio in WAV format// Mmsystem supports *. wav sound format snd-> soundrecorderUsesMmsystem; // reference mmsystem// Play the system sound{. Default // This is a string ('str ').MailbeepSystemexclamationSystemexitSystemhand}Playsound ('systemeg', 0, snd_async); // A pchar string// Play the sound in the list boxPlaysound (pchar (listbox1.items [li
The first 12 bytes of the wave file can be described as follows:
Triff = record ckid: DWORD; {'riff'} cksize: DWORD; {file size, excluding the first 8 bytes} fcctype: DWORD; {'wave '} end;
We can read the first 12 bytes of a file to determine whether it is a wave file.
Uses mmsystem, ioutils; {ioutils is used here. tfile. openread easily creates a file stream} procedure tform1.formcreate (Sender: tobject); var Riff: Record ckid, cksize, fcctype:
Check to see if the sound card is installed
uses mmsystem; ... function Soundkarte:Boolean; begin Result := WaveOutGetNumDevs >0; end;
Detect sound card exists
If you're doing some sort of multimedia player program, in order to improve the fault tolerance of the system, we must use some detection system functions, which detect whether the existence of a sound card is a problem, the following procedures to help you busy, first of all need to join th
This example shows how to play a specified sound file in a loop while the program is running.
First add the MMSystem to the uses section of the program, and then add the following code during the initialization of the form:
procedure TForm1.FormCreate(Sender: TObject);begin SndPlaySound(’c:\RECYCLE.WAV’,SND_ASYNC or SND_LOOP);end;
In this way, at the beginning of the program operation, the program will continue to play the sound file C:\RECYCLE thr
formats can be converted to each other.
The complete list of currently installed codec can be obtained by viewing the multimedia section in the control panel.
ACM API
ACM is the abbreviation of audio compression manager, which is translated as the audio compression manager. It is an interface function library compiled by Microsoft to call the codec function. It should have been declared in the mmsystem. Pas unit, but Borland omitted it for some
In Delphi, A tthread multi-thread class is provided. developers can customize the multi-thread function based on their own needs, and the timer has a wide range of applications in multithreading. Here, let's just talk about some key issues about waitforsingleobject as a timer. (For more information about timer, see "Deep Adventure".)Waitforsingleobject is an API function. To use this function, you must call createevent and timesetevent before using it. However, the positions declared in the even
that you can directly call the routines in these units without adding the unit reference name. For example:Messagebeep (0 );
This is not required:Windows. messagebeep (0 );
Although this routine is declared in a Windows unit.Note: If the Interface part contains the uses part, the uses reserved word must be followed by the reserved word interface, although it can be different from the same row.
In the above example, all referenced units are standard units, and some of them are used in almost all
First, modify the previously defined readwavefile unit and add an openresource () method to it to directly read the "wave" data in the resource file;
To avoid confusion, change the unit name readwavefile to readwave at the same time, and change the class name treadwavefile to treadwave.
{Modified readwave unit: Read the format, data, and data size of the wave from a file or resource} unit readwave; interfaceuses windows, classes, sysutils, mmsyste
following describes the above three steps for directsound: 1. there are two ways to add a warehouse receiving connection. You can select the setting option in the project menu bar and write it in the column connecting this item object to the library module.
Dsound. Lib dxguid. Lib two strings; you can also put these two strings in the workspace by adding files. 2. Add the
The directsound class name cannot be identified. Check the folder settings in the setting options of the tool menu item
);Waveoutclose (hwaveout );Localunlock (m_hformat );Localfree (m_hformat );Delete [] lpdata;Note: 1) the declaration of the above audio device and sound file operation function is included in mmsystem. the # include "mmsystem. H "statement to add the header file. At the same time, you must add dynamic connection import and export to winmm during compilation. lib. The specific implementation method is to se
audio fileIf (waveoutopen ( hwaveout, devsnum, lpformat, null, null, callback_null )! = 0){// Failed to open the wave out devices}// Prepare the data to be playedPwaveouthdr. lpdata = (hpstr) lpdata;Pwaveouthdr. dwbufferlength = m_wavelong;Pwaveouthdr. dwflags = 0;If (waveoutprepareheader (hwaveout, pwaveouthdr, sizeof (wavehdr ))! = 0){// Failed to prepare the wave data buffer}// Play the audio data fileIf (waveoutwrite (hwaveout, pwaveouthdr, sizeof (wavehdr ))! = 0){// Failed to write the
}// Disable the audio output device and release the memoryWaveoutreset (hwaveout );Waveoutclose (hwaveout );Localunlock (m_hformat );Localfree (m_hformat );Delete [] lpdata;Note: 1) the declaration of the above audio device and sound file operation function is included in mmsystem. the # include "mmsystem. H "statement to add the header file. At the same time, you must add dynamic connection import and expo
("mysound. wav", snd_async );
Note: when using the playsound function, you need to add winmm. lib and the header file mmsystem. h.Setting method:In the VC compiler, choose Project> setting> link> Object/library modules and add winmm. lib to the edit box.Add the statement # include
The playsound function is used to play wav files in VC.1. Function details:The playsound function is declared as follows:Bool playsound (lpcstr pszsound, hmodule hmod, DWO
This problem occurs because some header files must contain the windows. h header files. For example, when mmsystem. h is used.
# Ifndef setjmp_test_h# Define setjmp_test_h# Include # Ifdef _ cplusplusExtern "C "{# Endif# Define maxtask 20/* Maximum number of tasks */# Define taskid unsigned charTypedef void (* functask) (void );Enum taskstatus {Ready = 0,/*** create a task waiting for CPU **/Runing,/******* the task is running *******/Suspend,/*******
, which contains several API instructions and calls. That's easy to find. Let's take a look at the APIS it uses: auxGetNumDevs, auxGetDevCaps, auxSetVolume, and auxGetVolume. It looks like these Apis.
Use the file search function provided by windows to search for files with auxSetVolume *. pas in all Delphi source code and control source code, only in mmsystem. pas. Check out the relevant statements. I did not know enough about delphi. I forgot to che
started.Program.Solution:A. If you are on the console, You can temporarily copy a copy of copy userinit.exe userinit32.exe.B 、if you can modify the registration table in the window, search for all userinit32.exeand change it to userinit.exe
6. Delete the mmsystem content in the run entry in the registry. The content is C:/winnt/rundll.exe mmsystem. dll ....Location: HKEY_LOCAL_MACHINE/software/Microsoft/
(program list 1.2 ). The second version (program list 1.3) can run in any system as long as there is a built-in speaker. You 'd better run both programs, because you should try to understand the messagebeep process as much as possible.
Program list 1.2 chimes. cpp Program
// Program CHIMES.CPP#defineSTRICT#include
The chimes program calls a function sndplaysound, which is part of the Windows multimedia category. This function is used to play wav files. Note the # define strict directive in
I tried to implement this function and found a lot of information, which was not powerful. Finally, I found that what Microsoft gave was usable, in general, the mixer API is used to open the mixer device, obtain audio line information, and then set attributes. After this is done, it can be used in programs you write, such as players.
There are several functions in total:
Through these nine APIs, we can control the audio input and output devices. In fact, you can define these functions in C: /pr
If you're doing some sort of multimedia player program, in order to improve the fault tolerance of the system, we must use some detection system functions, which detect whether the existence of a sound card is a problem, the following procedures to help you busy, first of all need to join the uses part of the MMSystem, and then detect the sound card when the form is created:
procedure TForm1.FormCreate(Sender: TObject);var i:Integer;begini := auxGetN
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.