2015/11/141 Audio I/O Speaker : Wei-Shin Pan DATE : 2009.11.19.

Slides:



Advertisements
Similar presentations
Sampled Audio. We store digitised audio samples. This is the main audio data. In a file (e.g..wav format) we also need some header information. We will.
Advertisements

A Phonetician ’ s Guide to Audio Formats Chilin Shih University of Illinois at Urbana Champaign LSA 2006January 5-8, 2006.
                      Digital Audio 1.
A stereo audio file 1. Audio Channels Number of audio channels determines number of waveforms in a recording Two relevant types of recording Stereo recording.
Sound in multimedia How many of you like the use of audio in The Universal Machine? What about The Universal Computer? Why or why not? Does your preference.
4.1Different Audio Attributes 4.2Common Audio File Formats 4.3Balancing between File Size and Audio Quality 4.4Making Audio Elements Fit Our Needs.
1. Digitization of Sound What is Sound? Sound is a wave phenomenon like light, but is macroscopic and involves molecules of air being compressed and expanded.
Audio 2 Subject:T0934 / Multimedia Programming Foundation Session:9 Tahun:2009 Versi:1/0.
1 Audio input and output Speaker: Ching Chen Chang Date:
WaveIO Speaker: Paul Date: Outline Wave File Format Multi-Media API (Output) Damo Multi-Media API (Input) Damo Reference 2.
Technology ICT Option: Audio.
SWE 423: Multimedia Systems Chapter 3: Audio Technology (2)
Image and Sound Editing Raed S. Rasheed Digital Sound Digital sound types – Monophonic sound – Stereophonic sound – Quadraphonic sound – Surround.
Image and Sound Editing Raed S. Rasheed Sound What is sound? How is sound recorded? How is sound recorded digitally ? How does audio get digitized.
CSCI 3280 Tutorial 3 Project (C++)
1 Digital Audio Storage Formats. 2 Formats  There are many different formats for storing and communicating digital audio:  CD audio  Wav  Aiff  Au.
Web siteWeb site ExamplesExamples 1 Mode of Operation Protected mode  4 GB  32-bit address  Windows, Linux Real-address mode  1 MB space  20-bit address.
Java Audio.
Using ‘random’ numbers Some ways the standard UNIX ‘rand()’ library-function can be deployed to generate graphics and sound.
Project 1 Speech Detection Due: Sunday, February 1 st, 11:59pm.
Introduction To XAudio2 © Allan C. Milne Abertay University v
SMAF What Is SMAF? What Is Is SMAF? What Can Use SMAF? SMAF Structure How SMAF files are Created MIDI and SMAF Demo.
Speech Detection Project 1. Outline Motivation Problem Statement Details Hints.
Chapter 9 Audio.
Windows audio architecture Win MM Application DirectSound Application SysAudio.SYS Kmixer.SYS WinMM.DLLDSound.DLL Device Drive Container USB Device Driver.
GODIAN MABINDAH RUTHERFORD UNUSI RICHARD MWANGI.  Differential coding operates by making numbers small. This is a major goal in compression technology:
University of Calgary – CPSC 441. C PROGRAM  Collection of functions  One function “main()” is called by the operating system as the starting function.
How to Add WMI Interfaces to SCSIPort and Storport Miniports
A Simple Two-Pass Assembler
Digital Music to Sheet Music Hugh Smith. Abstract Electronic music has been steadily expand- ing over the past years. Many file formats have come into.
DirectShow.
CP104 Introduction to Programming File I/O Lecture 33 __ 1 File Input/Output Text file and binary files File Input/output File input / output functions.
AUDIO MEDIA 1 Created } “Borrowed” } Microphone MIDI keyboard CD’s & flash drives Internet Audio Sources 2.
Signal Digitization Analog vs Digital Signals An Analog Signal A Digital Signal What type of signal do we encounter in nature?
TWAIN Open industry standard interface for the input devices to capture multimedia objects More and more sophisticated devies are developed to cater to.
Anatomy of a Sound File v © Allan C. Milne Abertay University.
Advanced File Operations Chapter File Operations File: a set of data stored on a computer, often on a disk drive Programs can read from, write to.
Multimedia File Format Heejune AHN Embedded Communications Laboratory Seoul National Univ. of Technology Fall 2011 Last updated
Sound Conversion Chilin Shih University of Illinois — Urbana Champaign E-MELD Conference 2003 July 11 th -13th LSA Institute Michigan State University.
Sound DirectMusic & DirectSound. DirectShow Video Formats DirectShow is an open architecture, it can support any format as long as there are filters to.
Speech Processing and Recognition © Florida Institute of Technology Access audio data in real time and apply to speech recognition Final Exam Project By.
Audio Yu Feng CGDD Review 1. Set up 2. IOS sound – Core Audio – Short Sound – Long Sound – Control Sound – Background Sound 3.Cocos2d sound.
Digital Music to Sheet Music Hugh Smith. Abstract Electronic music has been steadily expand- ing over the past years. Many file formats have come into.
Chapter 13 DirectSound 로 잡음 만들기. 2 History of Sound Programming Sound programming always gets put off until the end DOS –Third party sound libraries:
Sound DirectMusic & DirectSound. Sound Formats Wav Midi (Musical Instrument Digital Interface) DLS (Downloadable Sounds) DirectMusic Producer Segments.
1 H.323 網路電話音訊監控與錄製系統之研製 The design and implementation of audio monitoring and recording system for H.323-based internet phone Advisor : Dr. Kai-Wei Ke.
1 Audio input and output Speaker: Ching Chen Chang Date:
Basic I/O in C Computer Organization I 1 August 2009 © McQuain, Feng & Ribbens Stream Model of I/O header file: A stream provides a connection.
Multimedia and weBLOGging Grade 7-9 | Cahaya Bangsa Classical School (C) 2010 Digital Media Production Facility 04 – Audio Basic.
Digital Audio III. Sound compression (I) Compression of sound data requires different techniques from those for graphical data Requirements are less stringent.
Chapter -7 Basic function of Input/output system basics and file processing Stream classes : I/O Streams. A stream is a source or destination for collection.
1 CSC103: Introduction to Computer and Programming Lecture No 27.
Audio Definition Model for Flexible File Formats Dave Marston BBC R&D.
Chapter 16 GPDUMB Engine Part II. 2 GPDUMB2 Engine.
C Programming Day 2. 2 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/LA07/003 Version No. 1.0 Union –mechanism to create user defined data types.
Silberschatz and Galvin  C Programming Language Kingdom of Saudi Arabia Ministry of Higher Education Al-Majma’ah University College of Education.
Yongchang, Kai, Justin, Rama
Objective % Explain concepts used to create digital audio.
Chapter 22 – part a Stream refer to any source of input or any destination for output. Many small programs, obtain all their input from one stream usually.
Chapter 7 Text Input/Output Objectives
Multimedia Systems and Applications
Objective % Explain concepts used to create digital audio.
Ken D. Nguyen Department of Computer Science Georgia State University
Technology ICT Option: Audio.
A Simple Two-Pass Assembler
System Programming by Leland L. Beck Chapter 2
Technology ICT Option: Audio.
Ken D. Nguyen Department of Computer Science Georgia State University
Chapter 9 Audio.
Professor Jodi Neely-Ritz University of Florida
Presentation transcript:

2015/11/141 Audio I/O Speaker : Wei-Shin Pan DATE :

2015/11/142 Outline Multimedia API (Input) Media file saving Wave file format Demo (Record and save) Multimedia API (Output) Demo (Play media file)

2015/11/143 MultiMedia API (Input)

Sampling

Quantization

Digital singal

2015/11/147 WAVEFORMATEX It defines the format of waveform-audio data. typedef struct { WORD wFormatTag; WORD nChannels; DWORD nSamplesPerSec; DWORD nAvgBytesPerSec; WORD nBlockAlign; WORD wBitsPerSample; WORD cbSize; } WAVEFORMATEX;

2015/11/148 WAVEHDR It defines the header used to identify a waveform-audio buffer. typedef struct wavehdr { LPSTR lpData; DWORD dwBufferLength; DWORD dwBytesRecorded; DWORD_PTR dwUser; DWORD dwFlags; DWORD dwLoops; struct wavehdr_tag * lpNext; DWORD_PTR reserved; } WAVEHDR, *LPWAVEHDR;

2015/11/149 waveInOpen() Open the given waveform-audio input device for recording. MMRESULT waveInOpen( LPHWAVEIN phwi, UINT_PTR uDeviceID, LPWAVEFORMATEX pwfx, DWORD_PTR dwCallback, DWORD_PTR dwCallbackInstance, DWORD fdwOpen );

2015/11/1410 waveInprepareHeader() It prepares a buffer for waveform input. MMRESULT waveInPrepareHeader( HWAVEIN hwi, LPWAVEHDR pwh, UINT cbwh );

2015/11/1411 waveInAddBuffer() Sends an input buffer to the specified waveform-audio input device. MMRESULT waveInAddBuffer( HWAVEIN hwi, LPWAVEHDR pwh, UINT cbwh );

2015/11/1412 waveInStart() Start input on the specified waveform input device. MMRESULT waveInStart( HWAVEIN hwi );

2015/11/1413 waveInReset() Stop input on the given waveform- audio input device and resets the current position to zero. MMRESULT waveInReset( HWAVEIN hwi );

2015/11/1414 waveInUnprepareheader() Clean up the preparation performed by waveInPrepareHeader. MMRESULT waveInUnprepareHeader( HWAVEIN hwi, LPWAVEHDR pwh, UINT cbwh );

2015/11/1415 waveInClose() Close the specified waveform-audio input device. MMRESULT waveInClose( HWAVEIN hwi );

2015/11/1416 Process of recording waveInOpen() -> waveInPrepareHeader() - > waveInAddBuffer() -> waveInStart() -> waveInStop() -> waveInUnprepareHeader -> waveInClose() Send voice stream by oRTP

2015/11/1417 Wave file format RIFF (Resource Interchange File Format) RIFF file = One Header (id,size,form type) + Subchunks (id,size,data) WAV 、 AVI files…etc

2015/11/1418 Wave file format

2015/11/1419 RIFF chunk spec. ChunkID (4 bytes) // "RIFF" ChunkSize (4 bytes) Format (4 bytes) // "WAVE"

2015/11/1420 Fmt chunk spec. Subchunk1ID (4 bytes) ex: 'fmt '(+ space) Subchunk1Size (4 bytes) ex: 16 or 18 AudioFormat (2 bytes) ex: PCM = 1 (0x0001) NumChannels (2 bytes) ex: 1-mono 2-Stereo SampleRate (4 bytes) ex: 8000 ~ ByteRate (4 bytes) ex: SampleRate * NumChannels * BitsPerSample/8 BlockAlign (2 bytes) ex: == NumChannels * BitsPerSample/8 BitPerSample (2 bytes) ex: 8 bits = 8, 16bits...etc (optional) ExtraparamSize (2 bytes) (if dump file in hex mode : 00 00) 若是 PCM ,則沒有額外資料 ! (x) ExtraParams ! X bytes

2015/11/1421 Data chunk spec. subchunk2 ID (4 bytes) // 'data' subchunk2 Size (4 bytes) // == NumSamples * NumChannels * BitsPerSample/8 Data ( * bytes )

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

2015/11/1423 mmioFOURCC() The mmioFOURCC macro converts four characters into a four-character code. FOURCC mmioFOURCC( CHAR ch0, CHAR ch1, CHAR ch2, CHAR ch3 ); It returns the four-character code created from the given characters.

2015/11/1424 mmioOpen() Open a file. HMMIO mmioOpen( LPSTR Filename, MMIOINFO mmioinfo, DWORD dwOpenFlags ); 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.

2015/11/1425 mmioCreateChunk() Creates a chunk in a RIFFfile that was opened,and the current file position is the beginning of the data portion of the new chunk. MMRESULT mmioCreateChunk( HMMIO hmmio, MMCKINFO &ck, UINT wFlags ); wFlags : MMIO_CREATERIFF 、 MMIO_CREATELIST It returns MMSYSERR_NOERROR if successful

2015/11/1426 mmioWrite() Writes a specified number of bytes to a file opened. LONG mmioWrite( HMMIO hmmio, char * pch, LONG cch ); Returns the number of bytes actually written. If it’s an error, return -1.

2015/11/1427 mmioAscend() Ascends out of a chunk in a RIFF file, and the current file position is the location following the end of the chunk MMRESULT mmioAscend( HMMIO hmmio, MMCKINFO &ck, UINT wFlags ); wFlags : must be zero. It returns MMSYSERR_NOERROR if successful or an error otherwise.

2015/11/1428 mmioClose() closes a file that was opened by using the mmioOpen() function. MMRESULT mmioClose( HMMIO hmmio, UINT wFlags ); It returns zero if successful or an error otherwise.

2015/11/1429 Process of saving file If the chunk is “ RIFF ” then mmioOpen() -> mmioFOURCC() -> mmioCreateChunk() -> mmioAscend() Fmt & data chunk mmioOpen() -> mmioFOURCC() -> mmioCreateChunk() -> mmiowrite ->mmioAscend() -> mmioClose()

2015/11/1430 Demo & dump file d e f3 3c 13 3c f9 18 f9 34 e7 23 a6 3c f2 24 f2 11 ce 1a 0d (Sample shown in hex number)

2015/11/1431 MultiMeadia API(Output)

2015/11/1432 waveOutOpen() Open a specified waveform output device for playback. MMRESULT waveOutOpen( LPHWAVEOUT phwo, UINT uDeviceID, LPWAVEFORMATEX pwfx, DWORD dwCallback, DWORD dwInstance, DWORD fdwOpen ); It Returns MMSYSERR_NOERROR if successful.

2015/11/1433 waveOutPrepareHeader() Prepare a waveform data block for playback. MMRESULT waveOutPrepareHeader( HWAVEOUT hwo, LPWAVEHDR pwh, UINT cbwh ); It returns MMSYSERR_NOERROR if successful.

2015/11/1434 waveOutWrite() Send a data block to the specified waveform output device. MMRESULT waveOutWrite( HWAVEOUT hwo, LPWAVEHDR pwh, UINT cbwh ); It returns MMSYSERR_NOERROR if successful.

2015/11/1435 waveOutReset() Stop playback on a specified waveform output device and resets the current position to 0. MMRESULT waveOutReset( HWAVEOUT hwo ); It returns MMSYSERR_NOERROR if successful.

2015/11/1436 waveOutUnprepareHeader() Clean up the preparation performed by waveOutPrepareHeader. MMRESULT waveOutUnprepareHeader( HWAVEO UT hwo, LPWAVEHDR pwh, UINT cbwh ); It returns MMSYSERR_NOERROR if successful.

2015/11/1437 waveOutClose( ) Close the specified waveform output device. MMRESULT waveOutClose( HWAVEOUT hwo ); It returns MMSYSERR_NOERROR if successful.

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

2015/11/1439 mmioRead() reads a specified number of bytes from a file opened by using the mmioOpen function. LONG mmioRead( HMMIO hmmio, HPSTR pch, LONG cch ); Return the number of bytes actually read. If there is an error, then return value -1.

2015/11/1440 Process of playing file If the chunk is RIFF chunk then mmioOpen() -> mmioDescend() Fmt & data chunk mmioOpen() -> mmioDescend() -> mmioRead() -> mmioAscend -> mmioClose() waveOutOpen() ->waveOutPrepareHeader()-> waveOutWrite()->waveOutPause()-> waveOutUnprepareHeader()-> waveOutClose()

2015/11/1441 Demo (play file) Environment windows XP Visual studio 2005 WaveIN, WaveOUT, WAV

2015/11/1442 Reference (ALLinONE) xt (WAVEOUT) xt makingwave.txt (WAVEIN + SAVE) makingwave.txt WaveFormat/ WaveFormat/ 113_ChingChen_MultimediaFileIO.ppt ( 兢真學姐的簡報 ) 113_ChingChen_MultimediaFileIO.ppt ( msdn )