CSCI 3280 Tutorial 3 Project ( C++ ) Han Chu chan@cse.cuhk.edu.hk chan@cse.cuhk.edu.hk.

Post on 19-Dec-2015

336 views 3 download

Tags:

Transcript of CSCI 3280 Tutorial 3 Project ( C++ ) Han Chu chan@cse.cuhk.edu.hk chan@cse.cuhk.edu.hk.

CSCI 3280 Tutorial 3Project( C++)

Han Chuchan@cse.cuhk.edu.hk

Grouping 5 students in one group Deadline: 10 Feb 2015 chan@cse.cuhk.edu.hk Grouping information

Student name: xxx, SID: xxxxxxxxxxStudent name: xxx, SID: xxxxxxxxxxStudent name: xxx, SID: xxxxxxxxxxStudent name: xxx, SID: xxxxxxxxxxStudent name: xxx, SID: xxxxxxxxxx

2

Demonstration + Report (hardcopy) Any language (e.g. C++/C, C#, Java…)

Introduction

Assessment: Basic requirements & Originality: 50% Enhanced features: 30% Innovation: 10% Demonstration and report: 10%

Introduction

P2P Karaoke System

Introduction

Audio Play

Introduction

Lyrics display

Introduction

Local Karaoke System + P2P streaming feature

Project in details

Karaoke System

9

1 , User Interface

Play button Stop button List control Add/remove information Lyrics display

Requirement 1

2 , Music management

Management of music files

Files Detection

Database to store music information

Requirement 2

3 , Music information display

Music title Singer Album Display them in your GUI

Requirement 3

4 , Multi-Keyword Searching

Using the information in database Search the audio file Multi-keyword Result displayed in the list control

Requirement 4

5 , Music Playback Very easy

Playsound(“C:\\a.wav”,0,SND_ASYNC|SND_FILENAME);

Finish?

You need to understand the Wav format

Requirement 5

6 , Lyrics display

Read the lyrics from the txt file Display it in the UI

Requirement 6

7 , Suggested Enhanced Features

Support other audio format; this can be based on a third-party library.

Video playing Dynamical effects Visualization Any other creative ideas to enhance the

system

Enhanced Features

17

P2P

Network connection At least 3 terminals

Enhanced Features Broadcasting

Tracker Server

Requirement 1

Real-time streaming

Buffer no more than 50% of a file before you play it

Requirement 2

Network music searching

Requirement 3

Media file management

Requirement 4

Peer-to-Peer

Requirement 5

Support other audio format (e.g. Video Streaming)

More than 3 clients

Others

Enhance Features

1~2 pages’s report write down

team number team member’s name team member’s student ID workload division program’s operation manual third-party library enhanced features

Project in detail

Demonstrate every basic requirement every enhanced features

10-mins Demonstration

2-mins Q&A

Project in detail

All members must attend any machines well prepared setup your environment download the necessary resources prepare your own audio files get back your submitted CD-R. copy your program to the demonstrate machine Demo starts when you run your program.

Project in detail

Demonstrate all of your program features.

Don’t close/restart your program without permission.

Unstable performance may lead to mark deduction.

Project in detail

Develop a user friendly UI Balanced workload Well prepare for the demonstration

Project in detail

Audio Play

29

Main topic:

1, Low Level API

2, Wave File Format

3, Procedure

4, Other Useful Functions

Low Level API

Windows APIsHigh-level: calling one function ?

PlaySound(“c:\\abc.wav“,0,SND_ASYNC|SND_FILENAME)

Low-level: manipulating the sound data manually

DirectX APIs

Third-party codes

Full control by your code!

Low Level API

http://www.topherlee.com/software/pcm-tut-wavformat.html

WAV File format

RIFF (Resource Interchange File Format)

Size storage uses Little-endian

WAV File format

Windows API

windows.h mmsystem.h Function:

mmioXXXX() waveOutXXXX( )

Hints: Google is your friend!

http://www.blitter.com/~russtopia/MIDI/~jglatt/tech/mmio.htm

Procedure

Open a wav File

Go into RIFF chunk

Go into fmt chunk

Read Sub chunk Info

Escape from Sub chunk

Go into data chunk

Open audio device

Prepare buffers

Read data chunk data

Play back buffer data

Close the wav file

Close audio device

HMMIO mmioOpen (LPSTR filename, LPMMIOINFO info, DWORD flags);

Opens a file for unbuffered or buffer ed I/O

Procedure

Open a wav File

Go into RIFF chunk

Go into fmt chunk

Read Sub chunk Info

Escape from Sub chunk

Go into data chunk

Open audio device

Prepare buffers

Read data chunk data

Play back buffer data

Close the wav file

Close audio device

mmioDescend (HMMIO h, LPMMCKINO lpck, LPMMCKINFO lpckParent, UNIT flags);Descends into a chunk of a RIFF file

Procedure

Open a wav File

Go into RIFF chunk

Go into fmt chunk

Read Sub chunk Info

Escape from Sub chunk

Go into data chunk

Open audio device

Prepare buffers

Read data chunk data

Play back buffer data

Close the wav file

Close audio device

LONG mmioRead (HMMIO h, HPSTR pch, LONG cch); reads a specified number of bytes from a file

Procedure

Open a wav File

Go into RIFF chunk

Go into fmt chunk

Read Sub chunk Info

Escape from Sub chunk

Go into data chunk

Open audio device

Prepare buffers

Read data chunk data

Play back buffer data

Close the wav file

Close audio device

mmioAscend(HMMIO h, LPMMCKINFO lpck, UINT flags);

Ascends out of a chunk in a RIFF file

waveOutOpen(LPHWAVEOUT phwo, UINT uDeviceID, LPWAVEFORMATEX pwfx, DWORD dwCallback, DWORD Instance,

DWORD fdwOpen );

Procedure

Open a wav File

Go into RIFF chunk

Go into fmt chunk

Read Sub chunk Info

Escape from Sub chunk

Go into data chunk

Open audio device

Prepare buffers

Read data chunk data

Play back buffer data

Close the wav file

Close audio device

Procedure

Open a wav File

Go into RIFF chunk

Go into fmt chunk

Read Sub chunk Info

Escape from Sub chunk

Go into data chunk

Open audio device

Prepare buffers

Read data chunk data

Play back buffer data

Close the wav file

Close audio devicewaveOutPrepareHeader(HWAVEOUT hwo, LPWAVEHDR pwh, UINT

cbwh );

Procedure

Open a wav File

Go into RIFF chunk

Go into fmt chunk

Read Sub chunk Info

Escape from Sub chunk

Go into data chunk

Open audio device

Prepare buffers

Read data chunk data

Play back buffer data

Close the wav file

Close audio device

waveOutWrite (HWAVEOUT hwo, LPWAVEHDR pwh, UINT cbwh );

Procedure

Open a wav File

Go into RIFF chunk

Go into fmt chunk

Read Sub chunk Info

Escape from Sub chunk

Go into data chunk

Open audio device

Prepare buffers

Read data chunk data

Play back buffer data

Close the wav file

Close audio device

mmioClose (HMMIO h, UINT wflags);

mmioClose (hmmioIn, 0);

waveOutClose (HWAVEOUT hwo);

waveOutClose (hAudioOut);

Procedure

Open a wav File

Go into RIFF chunk

Go into fmt chunk

Read Sub chunk Info

Escape from Sub chunk

Go into data chunk

Open audio device

Prepare buffers

Read data chunk data

Play back buffer data

Close the wav file

Close audio device

Other useful functions

waveOutSetVolume(HWAVEOUT hwo,DWORD dwVolume);

between 0xFFFF and 0x0000 0xFFFF is the full volume. The low order word of dwVolume is the left-channel volume The high order word is the right-channel volume

waveOutGetErrorText(MMRESULT mmrError, LPSTR pszText, UINT cchText );

almost every waveOut calls returns a MMRESULT variable, any value other than MMSYSERR_NOERROR indicates failure

pszText is the string buffer cchText is the size of the buffer

Thank you.

Han Chuchan@cse.cuhk.edu.hk