46
CSCI 3280 Tutorial 3 Project C++ Han Chu [email protected]

CSCI 3280 Tutorial 3 Project ( C++ ) Han Chu [email protected] [email protected]

Embed Size (px)

Citation preview

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

CSCI 3280 Tutorial 3Project( C++)

Han [email protected]

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

Grouping 5 students in one group Deadline: 10 Feb 2015 [email protected] Grouping information

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

2

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

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

Introduction

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

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

Introduction

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

P2P Karaoke System

Introduction

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

Audio Play

Introduction

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

Lyrics display

Introduction

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

Local Karaoke System + P2P streaming feature

Project in details

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

Karaoke System

9

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

1 , User Interface

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

Requirement 1

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

2 , Music management

Management of music files

Files Detection

Database to store music information

Requirement 2

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

3 , Music information display

Music title Singer Album Display them in your GUI

Requirement 3

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

4 , Multi-Keyword Searching

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

Requirement 4

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

5 , Music Playback Very easy

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

Finish?

You need to understand the Wav format

Requirement 5

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

6 , Lyrics display

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

Requirement 6

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

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

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

17

P2P

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

Network connection At least 3 terminals

Enhanced Features Broadcasting

Tracker Server

Requirement 1

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

Real-time streaming

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

Requirement 2

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

Network music searching

Requirement 3

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

Media file management

Requirement 4

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

Peer-to-Peer

Requirement 5

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

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

More than 3 clients

Others

Enhance Features

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

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

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

Demonstrate every basic requirement every enhanced features

10-mins Demonstration

2-mins Q&A

Project in detail

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

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

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

Demonstrate all of your program features.

Don’t close/restart your program without permission.

Unstable performance may lead to mark deduction.

Project in detail

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

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

Project in detail

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

Audio Play

29

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

Main topic:

1, Low Level API

2, Wave File Format

3, Procedure

4, Other Useful Functions

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

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

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

Full control by your code!

Low Level API

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

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

WAV File format

RIFF (Resource Interchange File Format)

Size storage uses Little-endian

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

WAV File format

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

Windows API

windows.h mmsystem.h Function:

mmioXXXX() waveOutXXXX( )

Hints: Google is your friend!

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

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

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

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

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

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

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

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

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

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

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

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

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 );

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

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 );

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

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);

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

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

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

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

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

Thank you.

Han [email protected]