Top Banner
WaveIO Speaker: Paul Date:2013.08.07 1
27

WaveIO Speaker: Paul Date:2013.08.07 1. Outline Wave File Format Multi-Media API (Output) Damo Multi-Media API (Input) Damo Reference 2.

Dec 15, 2015

Download

Documents

Devon Oates
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: WaveIO Speaker: Paul Date:2013.08.07 1. Outline Wave File Format Multi-Media API (Output) Damo Multi-Media API (Input) Damo Reference 2.

WaveIO

Speaker: PaulDate:2013.08.07

1

Page 2: WaveIO Speaker: Paul Date:2013.08.07 1. Outline Wave File Format Multi-Media API (Output) Damo Multi-Media API (Input) Damo Reference 2.

Outline

• Wave File Format• Multi-Media API (Output)• Damo• Multi-Media API (Input)• Damo• Reference

2

Page 3: WaveIO Speaker: Paul Date:2013.08.07 1. Outline Wave File Format Multi-Media API (Output) Damo Multi-Media API (Input) Damo Reference 2.

Wave File Format

3

Page 4: WaveIO Speaker: Paul Date:2013.08.07 1. Outline Wave File Format Multi-Media API (Output) Damo Multi-Media API (Input) Damo Reference 2.

WAVEFORMATEX• typedef struct { WORD wFormatTag; WORD nChannels; DWORD nSamplesPerSec; DWORD nAvgBytesPerSec; WORD nBlockAlign; WORD wBitsPerSample; WORD cbSize; } WAVEFORMATEX; • This structure defines the format of waveform-audio data.

4

Page 5: WaveIO Speaker: Paul Date:2013.08.07 1. Outline Wave File Format Multi-Media API (Output) Damo Multi-Media API (Input) Damo Reference 2.

WAVEHDR• typedef struct { LPSTR lpData; DWORD dwBufferLength; DWORD dwBytesRecorded; DWORD dwUser; DWORD dwFlags; DWORD dwLoops; struct wavehdr_tag* lpNext; DWORD reserved; } WAVEHDR;• This structure defines the header used to identify a waveform-audio

buffer.

5

Page 6: WaveIO Speaker: Paul Date:2013.08.07 1. Outline Wave File Format Multi-Media API (Output) Damo Multi-Media API (Input) Damo Reference 2.

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.

6

Page 7: WaveIO Speaker: Paul Date:2013.08.07 1. Outline Wave File Format Multi-Media API (Output) Damo Multi-Media API (Input) Damo Reference 2.

mmioOpen()

• HMMIO mmioOpen( LPSTR Filename, MMIOINFO mmioinfo, DWORD dwOpenFlags );

• The mmioOpen function opens a file for unbuffered or buffered I/O.

• Returns a handle of the opened file. • If the file cannot be opened, the return value is NULL. • dwOpenFlags :MMIO_CREATE、MMIO_WRITE、MMIO_RE

AD …etc.

7

Page 8: WaveIO Speaker: Paul Date:2013.08.07 1. Outline Wave File Format Multi-Media API (Output) Damo Multi-Media API (Input) Damo Reference 2.

mmioCreateChunk()

• MMRESULT mmioCreateChunk( HMMIO hmmio, MMCKINFO &ck, UINT wFlags );

• The mmioCreateChunk function creates a chunk in a RIFF file that was opened by using the mmioOpen function.

• wFlags :MMIO_CREATERIFF • Returns MMSYSERR_NOERROR if successful

8

Page 9: WaveIO Speaker: Paul Date:2013.08.07 1. Outline Wave File Format Multi-Media API (Output) Damo Multi-Media API (Input) Damo Reference 2.

mmioFOURCC()

• FOURCC mmioFOURCC( CHAR ch0, CHAR ch1, CHAR ch2, CHAR ch3 );

• The mmioFOURCC macro converts four characters into a four-character code.

• Returns the four-character code created from the given characters.

9

Page 10: WaveIO Speaker: Paul Date:2013.08.07 1. Outline Wave File Format Multi-Media API (Output) Damo Multi-Media API (Input) Damo Reference 2.

mmioWrite()

• LONG mmioWrite( HMMIO hmmio, char _huge* pch, LONG cch );

• The mmioWrite function writes a specified number of bytes to a file opened by using the mmioOpen function

• Returns the number of bytes actually written.

10

Page 11: WaveIO Speaker: Paul Date:2013.08.07 1. Outline Wave File Format Multi-Media API (Output) Damo Multi-Media API (Input) Damo Reference 2.

mmioAscend()

• MMRESULT mmioAscend( HMMIO hmmio, MMCKINFO &ck, UINT wFlags );

• The mmioAscend function ascends out of a chunk in a RIFF file

• wFlags : must be zero.• Returns MMSYSERR_NOERROR if successful

11

Page 12: WaveIO Speaker: Paul Date:2013.08.07 1. Outline Wave File Format Multi-Media API (Output) Damo Multi-Media API (Input) Damo Reference 2.

mmioClose()

• MMRESULT mmioClose( HMMIO hmmio, UINT wFlags );

• Returns zero if successful or an error otherwise.

12

Page 13: WaveIO Speaker: Paul Date:2013.08.07 1. Outline Wave File Format Multi-Media API (Output) Damo Multi-Media API (Input) Damo Reference 2.

waveOutOpen()

• MMRESULT waveOutOpen( HWAVEOUT &ohandle, UINT uDeviceID, WAVEFORMATEX &wf, DWORD dwCallback, DWORD dwInstance, DWORD fdwOpen );

• Opens a specified waveform output device for playback.

• Returns MMSYSERR_NOERROR if successful.

13

Page 14: WaveIO Speaker: Paul Date:2013.08.07 1. Outline Wave File Format Multi-Media API (Output) Damo Multi-Media API (Input) Damo Reference 2.

waveOutPrepareHeader()

• MMRESULT waveOutPrepareHeader( HWAVEOUT ohandle, WAVEHDR &wh, UINT cbwh );

• Prepares a waveform data block for playback.• Returns MMSYSERR_NOERROR if successful.

14

Page 15: WaveIO Speaker: Paul Date:2013.08.07 1. Outline Wave File Format Multi-Media API (Output) Damo Multi-Media API (Input) Damo Reference 2.

waveOutWrite()

• MMRESULT waveOutWrite( HWAVEOUT ohandle, WAVEHDR &wh, UINT cbwh );

• Sends a data block to the specified waveform output device.

• Returns MMSYSERR_NOERROR if successful.

15

Page 16: WaveIO Speaker: Paul Date:2013.08.07 1. Outline Wave File Format Multi-Media API (Output) Damo Multi-Media API (Input) Damo Reference 2.

waveOutReset()

• MMRESULT waveOutReset( HWAVEOUT ohandle );

• Stops playback on a specified waveform output device and resets the current position to 0.

• Returns MMSYSERR_NOERROR if successful.

16

Page 17: WaveIO Speaker: Paul Date:2013.08.07 1. Outline Wave File Format Multi-Media API (Output) Damo Multi-Media API (Input) Damo Reference 2.

waveOutUnprepareHeader()

• MMRESULT waveOutUnprepareHeader( HWAVEOUT ohandle, WAVEHDR &wh, UINT cbwh );

• Cleans up the preparation performed by waveOutPrepareHeader.

• Returns MMSYSERR_NOERROR if successful.

17

Page 18: WaveIO Speaker: Paul Date:2013.08.07 1. Outline Wave File Format Multi-Media API (Output) Damo Multi-Media API (Input) Damo Reference 2.

waveOutClose( )

• MMRESULT waveOutClose( HWAVEOUT ohandle );

• Closes the specified waveform output device.• Returns MMSYSERR_NOERROR if successful.

18

Page 19: WaveIO Speaker: Paul Date:2013.08.07 1. Outline Wave File Format Multi-Media API (Output) Damo Multi-Media API (Input) Damo Reference 2.

waveInOpen()

• MMRESULT waveInOpen(HWAVEIN &ihandle, UINT DeviceID, WAVEFORMATEX &waveformat, DWORD dwCallback, DWORD dwInstance, DWORD fdwOpen );

• Open a specified waveform input device for recording. • uDeviceID : WAVE_MAPPER • fdwOpen :CALLBACK_WINDOW ,CALLBACK_THREAD

• Return MMSYSERR_NOERROR means success

19

Page 20: WaveIO Speaker: Paul Date:2013.08.07 1. Outline Wave File Format Multi-Media API (Output) Damo Multi-Media API (Input) Damo Reference 2.

waveInPrepareHeader()

• MMRESULT waveInPrepareHeader( HWAVEIN ihandle, WAVEHDR &wh, UINT cbwh );

• Prepares a buffer for waveform input. • Returns MMSYSERR_NOERROR if successful.

20

Page 21: WaveIO Speaker: Paul Date:2013.08.07 1. Outline Wave File Format Multi-Media API (Output) Damo Multi-Media API (Input) Damo Reference 2.

waveInAddBuffer()

• MMRESULT waveInAddBuffer( HWAVEIN ihandle, WAVEHDR &wh, UINT cbwh );

• Sends an input buffer to the specified waveform-audio input device.

• Returns MMSYSERR_NOERROR if successful.

21

Page 22: WaveIO Speaker: Paul Date:2013.08.07 1. Outline Wave File Format Multi-Media API (Output) Damo Multi-Media API (Input) Damo Reference 2.

waveInStart()

• MMRESULT waveInStart( HWAVEIN ihandle );

• Starts input on the specified waveform input device.

• Returns MMSYSERR_NOERROR if successful.

22

Page 23: WaveIO Speaker: Paul Date:2013.08.07 1. Outline Wave File Format Multi-Media API (Output) Damo Multi-Media API (Input) Damo Reference 2.

waveInReset()

• MMRESULT waveInReset( HWAVEIN ihandle ); • Stops input on a specified waveform input

device and resets the current position to 0. • Returns MMSYSERR_NOERROR if successful.

23

Page 24: WaveIO Speaker: Paul Date:2013.08.07 1. Outline Wave File Format Multi-Media API (Output) Damo Multi-Media API (Input) Damo Reference 2.

waveInUnprepareHeader()

• MMRESULT waveInUnprepareHeader( HWAVEIN ihandle, WAVEHDR &wh, UINT cbwh );

• Cleans up the preparation performed by waveInPrepareHeader.

• Returns MMSYSERR_NOERROR if successful.

24

Page 25: WaveIO Speaker: Paul Date:2013.08.07 1. Outline Wave File Format Multi-Media API (Output) Damo Multi-Media API (Input) Damo Reference 2.

waveInClose()

• MMRESULT waveInClose( HWAVEIN ihandle);• Closes the specified waveform-audio input

device. • Returns MMSYSERR_NOERROR if successful.

25

Page 26: WaveIO Speaker: Paul Date:2013.08.07 1. Outline Wave File Format Multi-Media API (Output) Damo Multi-Media API (Input) Damo Reference 2.

Demo

26

Page 27: WaveIO Speaker: Paul Date:2013.08.07 1. Outline Wave File Format Multi-Media API (Output) Damo Multi-Media API (Input) Damo Reference 2.

Reference

• Wavefomathttps://ccrma.stanford.edu/courses/422/projects/WaveFormat/http://www.sonicspot.com/guide/wavefiles.html

• Multimedia FILE I/Ohttp://msdn.microsoft.com/zh-tw/library/windows/desktop/dd743576(v=vs.85).aspx

Waveform Audio http://en.wikipedia.org/wiki/WAV

27