Windows.

         

Test.c


, ­, DIGPAK MIDPAK.

/* */

/* TEST.C DIGPAK */

/* MIDPAK. DIGPAK

MIDPAK, */

/* SOUNDRV.COM MIDPAK.COM/MIDPAK.ADV/MIDPAK.AD. 젠 */

/* MIDI- TEST.XMI, */

/* TEST1.SND TEST2.SND */ /****************************************************************/

/* : John W. Ratcliff () 1994 */

/* CompuServe: 70253,3237 */

/* Genie: J.RATCLIFF3 */

/* BBS: 1-314-939-0200 */

/* : */



/* 747 Napa Lane */

/* St. Charles, 63304 */

/* */

/* */

/*********************************************'******************/

#include <stdio.h>

#include <stdlib.h>

#include <malloc.h>

#include "keys.h" //

//

#include "support.h" //

//

#include "loader.h" //

// MIDPAK/DIGPAK

#include "midpak.h" //

// MIDPAK

#include "digplay.h" //

// DIGPAK

#include "doscalls.h" //

// DOS-

#define NOBJ 4 //




static char *Names [NOBJ]= //

{

"TEST1.SND", "TEST2.SND", "PEND.3ND", "TEST.SND" };

static SNDSTRUC *snd; // DIGPAK

static char *soundbuffer=0; //

static long int ssize[NOBJ]; //

static int NALLOC=0;

char *Sounds[NOBJ]; //

void UnloadSounds(void); //

int LoadSounds(void); //

void PlaySound(int sound); //

void TestDigPak(void); // 頠

// DIGPAK

// .

// DOS .

// .

unsigned char far * far memalloc(long int siz) {

unsigned char far *mem;

mem = farmalloc(siz) ; //

// return(mem);

}

void far memfree(char far *)

farfree(memory); //

//

}

void main(void)

{

long int siz;

char *fname;

//

// DIGPAK

if ( !LoadDigPak("SOUNDRV.COM") )

{

printf("Failed to load sound driver.\n");

exit(l);

} if ( !InitDigPak() ) // DIGPAK

{

//

// .

UnLoadDigPak();

printf("Failed to initialize sound driver.\n") ;

exit(l);

}

if ( LoadMidPak('MIDPAK.COM", "MIDPAK.ADV", "MIDPAK.AD") ) // MIDPAK {

printf("Loaded MIDPAK. MIDPAK.ADV and MIDPAK.AD into Low Men\n");

if ( InitMidPak() )

{

printf("MIDPAK driver initialized.\n");



fname = floadlow("TEST.XMI",&siz); //

if ( fname }

{

printf("Loaded TEST.XMI %d bytes long.\n",siz);

RegisterXmidi(fname,siz); // XMIDI

//

printf("Sequence registered, now playing.\n") ;

PlaySequence(0); //

//

SegueSequence (1,-1); //

//

//

//

// 119

}

} else

printf("Failed to initialize MIDPAK driver.\n");

}

TestDigPak(); // /

// DIGPAK

UnLoadMidPak(); // MIDPAK ,

//

UnLoadDigPak(); // DIGPAK ,

//

RemoveVectorLoader() ;

}

void TestDigPak(void)

{

int i,key,sound;

printf("Loading digital sound effects.\n");

if ( LoadSounds() ) //

{

//

printf(" Select an sound effect to play. [ESC] when finished playing around.\n");

for (i=0; i<NOBJ; i++)

{

printf("%c %s\n",i+'A',Names[i]) ;

}

do

{

if ( keystat() ) //

{

key = getkey(); //

if ( key >= ' a' && key <= ' z') key-=32;

//

if ( key >= '' && key <= 'Z')

{

sound = key-'A';

if ( sound < NOBJ ) PlaySound(sound);

}

} while ( key != 27 );

UnloadSounds(} ;

}

}

//

int LoadSounds(void)

{

int fph;

long int siz.end;

int i, handler;

int select;

for (i=0; i<NOBJ; i++)

{

Sounds[i] = fload(Names[i], &siz);;

if ( !Sounds[i] )

{

printf("File '%s' not found.\n"/Names[i]) ;

return(0) ;

}

ssize[i] = siz;

snd.frequency = 11000;

snci. sound = Sounds [i];

snd.sndlen = ssize[i]; //

//

MassageAudio(&snd) ;

printf("Sound Loaded '%s'.\n",Names[i]);

}

return(1) ;

}

void UnloadSounds(void) {

int i;

for (i=0; i < nalloc; i++) memfree(Sounds[i]);

if ( soundbuffer )

{

realfree(snd) ;

realfree(soundbuffer);

}

NALLOC=0 ;

}

void PlaySound(int sound)

{

if ( !soundbuffer }

{

snd = (SNDSTRUC *) realalloc(sizeof(SNDSTRUC));

snd->frequency = 11000;

soundbuffer = realalloc(65535);

}

StopSound(); //

snd.frequency = 11000;

snd.sound = Sounds[i];

snd.sndlen = ssize[i]; //

//

DigPlay2(&snd); //

// -

}