This is a program that allows user to play different types of music with simple and user-friendly interface. It has two variations of music which are Jazz and Blues and it also improvise itself behind the screen. How the design is completed and implemented is as follow.
The structure of the design is shown in [Figure 1] and the functions descriptions in [Table 1]
|Function Name |Input Parameters |Return Values |Description | |main |None |Integer, error level passed to |Driving functions, always returns| | | |environment |to zero | |display_welcome |None |None |Display welcome message and key | | | | |usages | |play_jazz |Key [j] (int) |Integer, a set of notes to be |Apart form playing the set notes,| | | |played. |the clips can be improvised by | | | | |using randomized array lists to | | | | |vary the chords. | |play_blues |Key [b] (int) | | | |random_number |jscale_note (array) |Integer, the chords that a | | | |bscale_note (array) |progression is based on. | | |stop |Key [s] (int) |zero |Set the volume to zero to stop | | | | |music playing. |
Though, while implementing the design, several changes are made. The functions are structured as below. [Figure 2] [pic]
It can be clearly seen that random_number is called within two music-playing functions and that stop function is no longer exist. It is replaced by kbhit and getch functions. If the user presses ‘s’ key, the music stops after finishing one loop. Nevertheless, there is no way to stop the music as soon as ‘s’ is pressed. Maybe it is result from the lack of my knowledge of C language. Since random_number can be called by simply set pitch, for example, to pitch = (lowest limit, highest limit), there is no need to create a separate function of it.
In terms of music, the two kinds are composed according to Figure 3 and Figure 4, which are as same as the design. [pic]
Figure 3. Jazz music 
Figure 4. Blues music 
The Source Code is listed in [Appendix I]
Testing and Verification
After Building the program, the output screen is shown in [Figure 5] and the screen after Executing is shown in [Figure 6]. [pic]
To test the program, ‘j’ is first pressed and the Jazz music can be heard. Secondly, press ‘s’ and the music will stop after playing a loop. It does the same when starting with ‘b’ or press ‘b’ after the music stops. If ‘q’ is pressed, there will be a line saying “Press any key to continue”.
1. User interface
Welcome to PlayIt! This is a program that plays Jazz...