Waveoutopen and waveoutwrite system function usage programming for sound playback

Source: Internet
Author: User
// VC console # include <windows. h> # include <stdio. h> # pragma comment (Lib, "winmm. lib ") # define mute_length 128 # define sample_rate 11025 void main () {handle hevent = createevent (null, false, false, text (" PCM write ")); Hwaveout Hwaveout; // waveform audio output handle char mute [mute_length]; // mute symbol string Waveformatex Waveformat = {wave_format_pcm, 1, sample_rate, sample_rate, 1, 8, 0}; // set the waveform audio format WavehdrWavehdr = {0, mute_length, 0, 0, 0, 1, null, 0}; // audio data header fillmemory (mute, mute_length, (byte) 0x80 ); // fill the wavehdr with the mute symbol. lpdata = mute; // initialize the information header pointer // enable the audio device Waveoutopen (& Hwaveout, wave_mapper, & waveformat, (DWORD) hevent, 0, callback_event); // prepare the information HeaderWaveoutprepareheader (Hwaveout, & wavehdr, sizeof (wavehdr); While (1) {// play mute symbol Waveoutwrite (Hwaveout, & wavehdr, sizeof (wavehdr); printf ("."); waitforsingleobject (hevent, infinite );}}


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.