home *** CD-ROM | disk | FTP | other *** search
- /* ------------------------------------------------------------------------ */
- /* @@ Source Documentation *** TC Version *** */
- /* */
- /* Copyright (c) Creative Technology Pte Ltd, 1991. All rights reserved. */
- /* */
- /* TITLE : DEMOVDP.C */
- /* */
- /* DESCRIPTION : */
- /* This program demostrates how to perform voice out using the */
- /* CTVDSK.DRV driver. The voice out is using the Disk Double */
- /* Buffering method. */
- /* */
- /* The program checks BLASTER environment for the Card settings. */
- /* It also performs test base on BLASTER environment settings to */
- /* ensure they are tally with the hardware settings on the Card. */
- /* */
- /* Note that the program included the module LOADDRV.C to load */
- /* the loadable CTVDSK.DRV into memory. */
- /* */
- /* ------------------------------------------------------------------------ */
-
- #include <dos.h>
- #include <bios.h>
- #include <stdio.h>
- #include <fcntl.h>
-
- #include <sbc.h>
- #include <sbcvoice.h>
-
- #include "loaddrv.c"
-
-
- main ()
- {
- extern char far * near ctvdsk_drv;
-
-
- /* Retrieve the BLASTER environment settings */
- if ( ! GetEnvSetting() )
- {
- if (sbc_check_card() & 4)
- {
- if (sbc_test_int())
- {
- if (sbc_test_dma() >= 0)
- {
- if ((ctvdsk_drv = LoadDriver("CTVDSK.DRV")) != 0 )
- {
- if ( !ctvd_init(16) )
- {
- OutputFile("DEMO.VOC") ;
-
- ctvd_terminate() ;
- }
- else
- ShowError() ;
- }
- }
- else
- printf("Error on DMA channel.\n");
- }
- else
- printf("Error on interrupt.\n");
- }
- else
- printf("Sound Blaster Card not found or wrong I/O settings.\n") ;
- }
- else
- printf("BLASTER environment not set or incomplete or invalid.\n");
- }
-
-
- /* ------------------------------------------------------------------------ */
- /* @@ Usage */
- /* */
- /* OutputFile (char *szFilename) */
- /* */
- /* DESCRIPTION: */
- /* Output voice with the filename specified. */
- /* */
- /* ENTRY: */
- /* szFilename :- filename to be output. */
- /* */
- /* EXIT: */
- /* None. */
- /* */
- /* ------------------------------------------------------------------------ */
-
- OutputFile (char *szFilename)
- {
- int Handle ;
-
-
- /* Open and play the voice file */
- if ( (Handle=_open(szFilename, O_RDONLY)) != -1 )
- {
- ctvd_speaker(1) ;
-
- if ( ctvd_output(Handle) == NO_ERROR )
- {
- PlayVoiceInBkgnd () ;
-
- if ( ctvd_drv_error () )
- ShowError () ;
- else
- printf ("Voice output ended.\n") ;
- }
- else
- ShowError () ;
-
- _close (Handle) ;
- }
- else
- printf ( "Open %s file error\n", szFilename ) ;
- }
-
-
- /* ------------------------------------------------------------------------ */
- /* @@ Usage */
- /* */
- /* PlayVoiceInBkgnd (void) */
- /* */
- /* DESCRIPTION: */
- /* Control voice plaing at the background using keyboard. */
- /* */
- /* ENTRY: */
- /* None. */
- /* */
- /* EXIT: */
- /* None. */
- /* */
- /* ------------------------------------------------------------------------ */
-
- #pragma loop_opt(off) /* turn off loop optimiaztion */
- PlayVoiceInBkgnd (void)
- {
- /* Polls for hot key while playing voice file */
- while ( ct_voice_status )
- {
- if ( bioskey(1) )
- {
- switch ( bioskey(0) & 0xff )
- {
- case 0x1b : ctvd_stop () ;
- printf ("Voice stopped.\n") ;
- break ;
-
- case ' ' : ctvd_pause () ;
- printf ( "Pause...\n"
- "Pressed any key to continue.\n" );
- bioskey(0) ;
- ctvd_continue () ;
- break ;
-
- case 0x0d : ctvd_break_loop(1) ;
- printf( "Break-out takes place immediately\n") ;
- break ;
-
- case 0x9 : ctvd_break_loop(0) ;
- printf( "Break-out takes place after the current"
- " loop finishes\n" ) ;
- break ;
- }
- }
- }
- }
- #pragma loop_opt()
-
-
- /* ------------------------------------------------------------------------ */
- /* @@ Usage */
- /* */
- /* ShowError (void) */
- /* */
- /* DESCRIPTION: */
- /* Display error occurred during the process of voice I/O. */
- /* */
- /* ENTRY: */
- /* None. */
- /* */
- /* EXIT: */
- /* None. */
- /* */
- /* ------------------------------------------------------------------------ */
-
- ShowError (void)
- {
- int Err ;
-
-
- /* Show the driver error and the DOS extended error code */
- Err = ctvd_drv_error() ;
-
- printf("Driver error = %2d\n", Err) ;
-
- Err = ctvd_ext_error();
- if ( Err != 0 )
- printf ("DOS error = %2d\n", Err) ;
- }
-
-