1 / 21

Multimedia File I/O

Multimedia File I/O. Speaker: Ching Chen Chang Date:2006.11.13. Outline. Multimedia File I/O Sample program recordingmakingwave.cpp Waveout.cpp. Multi-Media API (Input). waveInOpen() waveInPrepareHeader() waveInAddBuffer() waveInStart() waveInUnprepareHeader() waveInClose().

cassia
Télécharger la présentation

Multimedia File I/O

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Multimedia File I/O Speaker: Ching Chen Chang Date:2006.11.13

  2. Outline • Multimedia File I/O • Sample program • recordingmakingwave.cpp • Waveout.cpp

  3. Multi-Media API (Input) • waveInOpen() • waveInPrepareHeader() • waveInAddBuffer() • waveInStart() • waveInUnprepareHeader() • waveInClose()

  4. Wave File Format(1/3) RIFF (Resource Interchange File Format) • A binary Multimedia file format. • RIFF provides an excellent way to store all these varied types of data. • WAV、AVI 、ANI …etc.

  5. Wave File Format(2/3) • A binary Multimedia file format containing multiple nested data structures. • Storing data in tagged chunks. • Structure of Chunk 1.Chunk ID(4 characters) 2.Chunk size 3.Chunk data

  6. Wave File Format(3/3)

  7. MMCKINFO • typedef struct { FOURCC ckid; DWORD cksize; FOURCC fccType; DWORD dwDataOffset; DWORD dwFlags; } MMCKINFO; • The structure contains information about a chunk in a RIFF file.

  8. mmioFOURCC() • FOURCC mmioFOURCC( CHAR ch0, CHAR ch1, CHAR ch2, CHAR ch3 ); • The mmioFOURCC macro converts four characters into a four-character code. • FOURCC(Four-Character Code) • Returns the four-character code created from the given characters.

  9. mmioOpen() • HMMIO mmioOpen( LPSTR Filename, MMIOINFO mmioinfo, DWORD dwOpenFlags ); • Open a file. • Returns a handle of the opened file. • If the file cannot be opened, the return value is NULL. • dwOpenFlags:MMIO_CREATE、MMIO_WRITE、MMIO_READ …etc.

  10. mmioCreateChunk() • MMRESULT mmioCreateChunk( HMMIO hmmio, MMCKINFO &ck, UINT wFlags ); • Creates a chunk in a RIFF file that was opened ,and the current file position =>is the beginning of the data portion of the new chunk. • wFlags :MMIO_CREATERIFF 、MMIO_CREATELIST • Returns MMSYSERR_NOERROR if successful

  11. mmioWrite() • LONG mmioWrite( HMMIO hmmio, char * pch, LONG cch ); • Writes a specified number of bytes to a file opened. • Returns the number of bytes actually written. • If there is an error, return -1.

  12. mmioAscend() • MMRESULT mmioAscend( HMMIO hmmio, MMCKINFO &ck, UINT wFlags ); • Ascends out of a chunk in a RIFF file , and the current file position is the location following the end of the chunk • wFlags : must be zero. • Returns MMSYSERR_NOERROR if successful

  13. mmioClose() • MMRESULT mmioClose( HMMIO hmmio, UINT wFlags ); • Returns zero if successful.

  14. Sample program • Record • Produce the Wave file • Recordingmakingwave.cpp • http://ms11.voip.edu.tw/~beautidays/recordingmakingwave.txt

  15. Multimedia File I/O • Save Wave File mmioOpen() mmioCreateChunk() mmioWrite() mmioAscend() mmioClose() • Read Wave File mmioOpen() mmioDescend()  mmioRead() mmioAscend() mmioClose()

  16. mmioDescend() • MMRESULT mmioDescend( HMMIO hmmio, MMCKINFO lpck, MMCKINFO lpckParent, UINT wFlags ); • Descends into a chunk of a RIFF file that was opened. It can also search for a given chunk. • wFlags:MMIO_FINDCHUNK、MMIO_FINDRIFF • Returns MMSYSERR_NOERROR if successful • If the chunk is not founded, return MMIOERR_CHUNKNOTFOUND.

  17. mmioRead() • LONG mmioRead( HMMIO hmmio, HPSTR pch, LONG cch ); • Returns the number of bytes actually read. • If there is an error, then return value -1.

  18. Multi-Media API (Input) • waveOutOpen() • waveOutPrepareHeader() • waveOutWrite() • waveOutPause() • waveOutUnprepareHeader() • waveOutClose()

  19. Sample Program • Play a wav file. • Waveout.txt • http://ms11.voip.edu.tw/~beautidays/waveout.txt

  20. Reference(1/2) • Wavefomat http://ccrma.stanford.edu/CCRMA/Courses/422 /projects/WaveFormat/ http://www.sonicspot.com/guide/wavefiles.html • Multimedia FILE I/O http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_multimedia_file_i_o.asp

  21. Reference(2/2) • Waveform Audio http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_about_waveform_audio.asp • RIFF http://www.oreilly.com/www/centers/gff/formats/micriff/ http://www.geocities.com/siliconvalley/bay/9932/zxs.html

More Related