#include <stdio.h>
#include <stdlib.h>
#include "main.h"
int volume;
bool stopped;
bool loop;
void display_menu( void );
void display_menu( void )
{
printf( "\n\nMenu:\n----------\n" );
printf( "q - Quit\n" );
printf( "p - Pause\n" );
printf( "u - Volume Up\n" );
printf( "d - Volume Down\n" );
printf( "a - Play again/Restart\n" );
printf( "l - Toggle Looping\n" );
printf( "\n\n" );
}
int main( void )
{
bool done = FALSE;
static unsigned int trigger = 0;
static unsigned int count = 0;
if ( init_dx() == FALSE )
{
printf( "\n\nCould not initialize DirectX! Press any key to quit...\n\n" );
getche();
return 0;
}
printf( "Playing song...\n\n" );
display_menu();
while ( done == FALSE )
{
if ( kbhit() == 0 )
{
count = GetTickCount();
if ( count-trigger >= 2100 ) {
trigger = count; handle_dx(FALSE);
}
}
else
{
char c = getche();
switch ( tolower(c) )
{
case 'q': done = TRUE;
break;
case 'm':
display_menu();
break;
case 'p':
if ( stopped == FALSE )
{
stop_wave(song);
printf("\n\nSong now stopped.\n\n" );
}
else
{
play_wave(song, FALSE);
printf( "\n\nSong now playing.\n\n");
}
display_menu();
break;
case 'a':
stopped = FALSE;
handle_dx(TRUE); printf( "\n\nPlaying song...\n\n\n" );
display_menu();
break;
case 'l':
if ( loop == FALSE )
loop = TRUE;
else
loop = FALSE;
printf( "\n\nLooping is now %s\n\n", (loop == FALSE ? "off" : "on" ) );
break;
case 'u':
if ( stopped == FALSE )
{
volume += 100;
set_volume( song, volume );
printf( "\n\nVolume now set to %d\n\n", (volume+10000) );
}
else
printf( "\n\nThe song is stopped!\n\n" );
break;
case 'd':
if ( stopped == FALSE )
{
volume -= 100;
set_volume( song, volume );
printf( "\n\nVolume now set to %d\n\n", (volume+10000) );
}
else
printf( "\n\nThe song is stopped!\n\n" );
break;
}
}
}
delete_wave(song); ds->lpVtbl->Release(ds); mmioClose( wave, 0 ); printf( "\n\n\n\nThanks for using Odis\' streaming audio v1.0!\n\n" );
getche();
return 0;
}