Download presentation
Presentation is loading. Please wait.
1
CSCI 3280 Tutorial 3 Project (C++)
Han Chu
2
Grouping chan@cse.cuhk.edu.hk 5 students in one group
Deadline: 10 Feb 2015 Grouping information Student name: xxx, SID: xxxxxxxxxx
3
Introduction Demonstration + Report (hardcopy)
Any language (e.g. C++/C, C#, Java…)
4
Introduction Assessment: Basic requirements & Originality: 50%
Enhanced features: % Innovation: % Demonstration and report: %
5
Introduction P2P Karaoke System
6
Introduction Audio Play
7
Introduction Lyrics display
8
Project in details Local Karaoke System + P2P streaming feature
9
Karaoke System
10
Requirement 1 1,User Interface Play button Stop button List control
Add/remove information Lyrics display
11
Requirement 2 2,Music management Management of music files
Files Detection Database to store music information
12
Requirement 3 3,Music information display Music title Singer Album
Display them in your GUI
13
Requirement 4 4,Multi-Keyword Searching
Using the information in database Search the audio file Multi-keyword Result displayed in the list control
14
Requirement 5 5,Music Playback Very easy
Playsound(“C:\\a.wav”,0,SND_ASYNC|SND_FILE NAME); Finish? You need to understand the Wav format
15
Requirement 6 6,Lyrics display Read the lyrics from the txt file
Display it in the UI
16
Enhanced Features 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
17
P2P
18
Requirement 1 Enhanced Features Broadcasting Network connection
At least 3 terminals Enhanced Features Broadcasting Tracker Server
19
Requirement 2 Real-time streaming Play the audio as soon as possible
Steaming by using buffers At least two buffers should be used in a streaming Buffer no more than 50% of a file before you play it
20
Requirement 3 Network music searching
Searching Database on each client Show the result in a list The same song should be displayed once only
21
Requirement 4 Media file management Choose a music in the results
Local music should have higher priority to play Stream the audio file from other computers
22
Requirement 5 Peer-to-Peer Get data from at least two clients
Play data in an interleaving way Act like a client or a server
23
Enhance Features Support other audio format (e.g. Video Streaming)
More than 3 clients Others
24
Project in detail 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
25
Project in detail Demonstrate 10-mins Demonstration 2-mins Q&A
every basic requirement every enhanced features 10-mins Demonstration 2-mins Q&A
26
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.
27
Project in detail Demonstrate all of your program features.
Don’t close/restart your program without permission. Unstable performance may lead to mark deduction.
28
Project in detail Develop a user friendly UI Balanced workload
Well prepare for the demonstration
29
Audio Play
30
4, Other Useful Functions
Main topic: 1, Low Level API 2, Wave File Format 3, Procedure 4, Other Useful Functions
31
High-level: calling one function ?
Low Level API Windows APIs High-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
32
Full control by your code!
Low Level API Full control by your code!
33
Size storage uses Little-endian
WAV File format RIFF (Resource Interchange File Format) Size storage uses Little-endian
34
WAV File format
35
http://www.blitter.com/~russtopia/MIDI/~jglatt/tech/mmio .htm
Windows API windows.h mmsystem.h Function: mmioXXXX() waveOutXXXX( ) Hints: Google is your friend! .htm
36
HMMIO mmioOpen (LPSTR filename, LPMMIOINFO info, DWORD flags);
Procedure Open a wav File Go into RIFF chunk Go into fmt chunk Go into data chunk Escape from Sub chunk Read Sub chunk Info Open audio device Prepare buffers Read data chunk data Close audio device Close the wav file Play back buffer data HMMIO mmioOpen (LPSTR filename, LPMMIOINFO info, DWORD flags); Opens a file for unbuffered or buffer ed I/O
37
Procedure Descends into a chunk of a RIFF file
Open a wav File Go into RIFF chunk Go into fmt chunk Go into data chunk Escape from Sub chunk Read Sub chunk Info Open audio device Prepare buffers Read data chunk data Close audio device Close the wav file Play back buffer data mmioDescend (HMMIO h, LPMMCKINO lpck, LPMMCKINFO lpckParent, UNIT flags); Descends into a chunk of a RIFF file
38
Procedure reads a specified number of bytes from a file
Open a wav File Go into RIFF chunk Go into fmt chunk Go into data chunk Escape from Sub chunk Read Sub chunk Info Open audio device Prepare buffers Read data chunk data Close audio device Close the wav file Play back buffer data LONG mmioRead (HMMIO h, HPSTR pch, LONG cch); reads a specified number of bytes from a file
39
mmioAscend(HMMIO h, LPMMCKINFO lpck, UINT flags);
Procedure Open a wav File Go into RIFF chunk Go into fmt chunk Go into data chunk Escape from Sub chunk Read Sub chunk Info Open audio device Prepare buffers Read data chunk data Close audio device Close the wav file Play back buffer data mmioAscend(HMMIO h, LPMMCKINFO lpck, UINT flags); Ascends out of a chunk in a RIFF file
40
Procedure Open a wav File Go into RIFF chunk Go into fmt chunk Go into data chunk Escape from Sub chunk Read Sub chunk Info Open audio device Prepare buffers Read data chunk data Close audio device Close the wav file Play back buffer data waveOutOpen(LPHWAVEOUT phwo, UINT uDeviceID, LPWAVEFORMATEX pwfx, DWORD dwCallback, DWORD Instance, DWORD fdwOpen );
41
waveOutPrepareHeader(HWAVEOUT hwo, LPWAVEHDR pwh, UINT cbwh );
Procedure Open a wav File Go into RIFF chunk Go into fmt chunk Go into data chunk Escape from Sub chunk Read Sub chunk Info Open audio device Prepare buffers Read data chunk data Close audio device Close the wav file Play back buffer data waveOutPrepareHeader(HWAVEOUT hwo, LPWAVEHDR pwh, UINT cbwh );
42
waveOutWrite (HWAVEOUT hwo, LPWAVEHDR pwh, UINT cbwh );
Procedure Open a wav File Go into RIFF chunk Go into fmt chunk Go into data chunk Escape from Sub chunk Read Sub chunk Info Open audio device Prepare buffers Read data chunk data Close audio device Close the wav file Play back buffer data waveOutWrite (HWAVEOUT hwo, LPWAVEHDR pwh, UINT cbwh );
43
mmioClose (HMMIO h, UINT wflags);
Procedure Open a wav File Go into RIFF chunk Go into fmt chunk Go into data chunk Escape from Sub chunk Read Sub chunk Info Open audio device Prepare buffers Read data chunk data Close audio device Close the wav file Play back buffer data mmioClose (HMMIO h, UINT wflags); mmioClose (hmmioIn, 0);
44
waveOutClose (HWAVEOUT hwo);
Procedure Open a wav File Go into RIFF chunk Go into fmt chunk Go into data chunk Escape from Sub chunk Read Sub chunk Info Open audio device Prepare buffers Read data chunk data Close audio device Close the wav file Play back buffer data waveOutClose (HWAVEOUT hwo); waveOutClose (hAudioOut);
45
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
46
Han Chu chan@cse.cuhk.edu.hk
Thank you. Han Chu
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.