#include #include #include #include #include #include #include #include #include #include #include /* Function Prototypes */ SaveVoiceFile(char *,char far *) ; struct EMMMoveStruct moverec; unsigned int xmshandle, xmsfree,xmstot; long freq; int infilter,outfilter,hilo; unsigned char *instr[] = {"On ","Off"}; unsigned char *outstr[] = {"On ","Off"}; unsigned char *hilostr[] = {"Low","High"}; main() { int k; init(); make_header(); while(1) { clrscr(); printf("(R)ecord (P)lay (F)requency (H)igh/Low input filter\n"); printf("(I)nput filter on/off (O)utput filter on/off (Q)uit\n\n"); printf("Freq: %6u I-filter: %s O-filter: %s High/Low: %s\n", (unsigned int)freq,instr[infilter],outstr[outfilter],hilostr[hilo]); k = (bioskey(0) >> 8) & 0xff; switch(k){ case 0x10 : { ctvm_terminate() ; XMS_FreeEMB(xmshandle); exit(0); } case 0x13 : Record();break; case 0x19 : Play();break; case 0x21 : SetFreq();break; case 0x23 : sethilo();break; case 0x17 : setinfilter();break; case 0x18 : setoutfilter();break; } } } init() { extern char far * near voice_drv; /* Retrieve the BLASTER environment settings */ if ( ! GetEnvSetting() ) { if (sbc_check_card() & 4) { if (sbc_test_int()) { if (sbc_test_dma() >= 0) { if ((voice_drv = LoadDriver("CT-VOICE.DRV")) != 0) { if (!ctvm_init()) { ctvm_speaker(0) ; if(!XMS_Setup()) { printf("No XMS handler installed!\n"); exit(1); } XMS_FreeMem(&xmsfree,&xmstot); XMS_AllocEMB(xmsfree,&xmshandle); infilter = 0; outfilter = 0; hilo = 1; freq = 22050L; ctvm_set_input_freq(hilo); ctvm_ANFI_control(infilter); ctvm_DNFI_control(outfilter); } } } 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"); } make_header() { int Handle ; long lVoiceSize ; VOCHDR stHeader ; strcpy(stHeader.id,"Creative Voice File\x0\0x1A") ; stHeader.voice_offset = sizeof(VOCHDR) ; stHeader.version = 0x10a ; stHeader.check_code = ~stHeader.version + 0x1234 ; moverec.TLen = 32; moverec.SHand = 0; moverec.SOff = (unsigned long)&stHeader; moverec.DHand = xmshandle; moverec.DOff = 0; if(XMS_MoveEMB(&moverec)) printf("MoveEMB error!\n"); } Record() { int RetVal = 0 ; ctvm_speaker(0) ; ctvm_set_input_source(3); /* line-in */ if (! ctvm_inputxms(xmshandle,(unsigned int)freq,26L,xmsfree-1)) { RetVal = 1 ; printf("\nRecording, any key stops...\n"); while(ct_voice_status) { if(kbhit()) if(((bioskey(0) >> 8) & 0xFF) == 1) break; } ctvm_stop(); } else printf("Faan oxo!\n"); } Play() { ctvm_speaker(1); ctvm_outputxms(xmshandle,26L); while(ct_voice_status){ if(kbhit()) if(((bioskey(0) >> 8) & 0xff) == 1) break; } ctvm_stop(); } SetFreq() { unsigned char freqs[20]; gotoxy(1,7); printf("Sampling frequency: "); gets(freqs); freq = atol(freqs); } sethilo() { hilo ^= 1; gotoxy(4,56); printf("%s",hilostr[hilo]); ctvm_set_input_freq(hilo); } setinfilter() { infilter ^= 1; gotoxy(4,25); printf("%s",instr[infilter]); ctvm_ANFI_control(infilter); } setoutfilter() { outfilter ^= 1; gotoxy(4,40); printf("%s",outstr[outfilter]); ctvm_DNFI_control(outfilter); } .