Write audio data to wave file

Source: Internet
Author: User

Using the Cwavefile class in the DirectX SDK, you can read and write wave files, create a new wave file, and write header and audio data to a file:

Cwavefile *g_pwavefile; WaveFormatEx Wfxinput; ZeroMemory (&wfxinput,sizeof (wfxinput)); Wfxinput.wformattag = WAVE_FORMAT_PCM; Wfxinput.nsamplespersec = 48000; Wfxinput.wbitspersample = 32; Wfxinput.nchannels = 2; Wfxinput.nblockalign = Wfxinput.nchannels * (WFXINPUT.WBITSPERSAMPLE/8); wfxinput.navgbytespersec = wfxinput.nblockalign * WFXINPUT.NSAMPLESPERSEC; G_pwavefile = new Cwavefile; if (FAILED (G_pwavefile->open (L "C:\\users\\administrator\\desktop\\test.wav", &wfxinput,wavefile_write))) {  g_pwavefile->close ();} UINT wsize=0; if (FAILED (G_pwavefile->write (Len, Paudiodata, &wsize))  assert (NULL); G_pwavefile->close ();// Do not close the file header does not write to the file

AC qq:1245178753

This address: http://blog.csdn.net/u011417605/article/details/51334003

Write audio data to wave file

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.