Multimedia file IO

xiaoxiao2021-03-06  39

Multimedia file I / O is similar to normal file I / O, but supports multimedia "Riff" format and provides buffer and non-buffer file I / O.

All multimedia file I / O function names are MMIO, and the message is prefixed for MMIO.

Low-level waveform audio function:

Low-level audio services allow users to deal directly with the audio device driver, directly control audio devices such as waveforms, MIDI playback and recording, low-level audio functions are unrelated interfaces.

The low-level audio function prefix is ​​Wave, press the input function, and the output function is divided into Wavein ×××× and Waveout ××××.

The playback process of waveform audio:

First, we want to call multimedia file I / O functions MMIO ×××× (), and generate the structure and data required in WAVE playback according to multimedia file I / O, and use these structures and data for Waveout ×××× () Function playback. The user can tamper with the WAVE file and "FMT" block according to the needs of encryption, and only the data block is retained. Or compress it, you can still have a data file in memory as long as you play back. And remember the file audio format and size, you can play up the audio.

Common MMIO functions and implementation process:

MmiOopen () Opens a Riff file

MmioDescend () enters block

Mmioread (); this RIFF file

Mmioascend (); jumping out

Mmioclose (); Turn off PIFF file

For blocks, entering blocks and jumping blocks are paired.

Read the read process of the WAV file:

MmioPen () Opens the file

MmioDescend ("Wave") enters "FMT" block

Mmioread () reads Wave file format information

MmiOascend () jumps out of the "FMT" block

MmioDescend ("DATA") enters "DATA" block

Mmioread () read WAVE data information

Mmioclose () Close the file.

The process of outputting the WAV file:

Waveoutopen () Opens an output device

WaveoutPrepareHeader () Prepare Wave Data Headers.

WaveoutWrite () Write the data into the device and start playing

WaveoutReset () stops playing and resets the manager

Waveoutclose () and close player

WaveoutunpareHeader () Clean WaveoutPrepareHeader prepared WaveoutPrepareHeader.

Example:

This instance implemented function is to open the background music and then join a dubble every five seconds. Background music will stop playing, you can listen to the background dubbing dubbing ... the actual effect generated by dubbing. In order to implement this function, we have packaged a class. Everyone can find these two files "Wavemix..h" and "Wavemix.cpp" on the CD.

First of all, let's take a look at "WAVMix.h", which defines a class called "mwave",

The member functions are: constructor, destructuring function, open (open file), play (play file), add (to buffer Mix Mix file), STOP (stop broadcast), Close (turn off output device, class reinitialization ).

Now we will build a dialog-based program in front. The two files are added to the "File View". Open "Wavemixdlg.h", plus "#include" wavemix.h ","

Add a private data "Mwave Mwave" in class Class CWAVEMixDLG to add member online onlnitdialog () and Ontime (),

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

New Post(0)