SB AWE32 Developer's Information Pack
PART V 3D Positional Audio API
••
106
Copyright
Creative Technology Ltd., 1994-1996
Version 3.00
awe32SoundPad.SPad1 = awe32SPad1Obj;
/* install GM presets */
awe32SoundPad.SPad2 = awe32SPad2Obj;
awe32SoundPad.SPad3 = awe32SPad3Obj;
awe32SoundPad.SPad4 = awe32SPad4Obj;
awe32SoundPad.SPad5 = awe32SPad5Obj;
awe32SoundPad.SPad6 = awe32SPad6Obj;
awe32SoundPad.SPad7 = awe32SPad7Obj;
awe32InitMIDI();
Detect and initialize the mouse driver. This program won’t run without a mouse.
regs.x.ax = 0;
int86(0x33, ®s, ®s);
if (regs.x.ax == 0) {
printf("Cannot initialize mouse\n");
return -1;
}
regs.x.ax = 0x1;
int86(0x33, ®s, ®s);
Loading a sound sample (sound.raw) as SoundFont into MIDI bank 1, instrument 0.
sp.total_banks = 2;
bsize[0] = 0;
bsize[1] = awe32DramSize * 2;
/* use all available DRAM */
sp.banksizes = bsize;
awe32DefineBankSizes(&sp);
fp = fopen("sound.raw", "rb");
if (!fp) {
printf("Cannot open \"sound.raw\"\n");
return -1;
}
wp.tag = 0x101;
wp.bank_no = 1;
wp.sample_size = 49429;
/* hard-coded info about sound.raw */
wp.samples_per_sec = 44100;
wp.bits_per_sample = 16;
wp.no_channels = 1;
wp.looping = 1;
wp.startloop = 0;
wp.endloop = 49425;
wp.release = 0;
if (awe32WPLoadRequest(&wp)) {
printf("awe32WPLoadRequest failed\n");
return -1;
}
wp.data = packet;
while (wp.no_wave_packets--) {
fread(packet, 1, PACKETSIZE, fp);
awe32WPStreamWave(&wp);
}
fclose(fp);
wp.presets = preset;
/* SoundFont preset space */
awe32WPBuildSFont(&wp);
Initialize the 3D Positional Audio Library and creative an emitter base on the loaded sound sample.
c3daInit();
c3daCreateEmitter(&em, 1, 0, 60);
c3daSetEmitterMIDISource(&em, 1, 0, 60);
c3daSetEmitterSoundState(&em, c3daSTART);
Save current interrupt vector and hook on to interrupt 1CH.
prev_intr = _dos_getvect(0x1c);
_dos_setvect(0x1c, newintr);
The position update loop. Loop forever until a key is hit. Once count changes its value, update the emitter
position.