SB AWE32 Developer's Information Pack
PART V 3D Positional Audio API
••
107
Copyright
Creative Technology Ltd., 1994-1996
Version 3.00
current = count;
while (!kbhit()) {
while (current == count) ;
/* wait til count changes */
current = count;
regs.x.ax = 3;
int86(0x33, ®s, ®s);
/* get mouse position */
x = regs.x.cx - 320;
y = regs.x.dx - 96;
/* rotate -90 degree along z-axis */
c3daSetEmitterPosition(&em, -y/2, -x/2, 0);
}
getch();
Terminates.
_dos_setvect(0x1c, prev_intr);
regs.x.ax = 0x21;
int86(0x33, ®s, ®s);
awe32Terminate();
return 0;
}
Implementing Receiver Orientation
For efficiency reasons, the 3D Positional Audio Library does not provide the ability to change a
receiver’s orienation - all receivers have a fixed orientation where the head is facing along the positive
x-axis and the left ear is along the positive-y-axis. This chapter gives a simple example of how to
implement receiver orientation functionality.
The basic idea is that changing a receiver’s orientation is equivalent to appropriately moving all the
emitters around a receiver with a fixed orientation. This example uses yaw, pitch, and roll to transform
a recevier’s orientation from the default fixed orientation to a new one. To equivalently move the
emitters, the “inverse” transform is applied to all the emitters.
/*
* This example is sample code to handle receiver orientation since
* the basic c3da core does not allow a change in receiver orienation.
* There are two routines defined in this example:
*
*
setEmitterPosition - a replacement for c3daSetEmitterPosition
*
setReceiverOrientation - a new routine to handle receiver
orientation
*/
#include <math.h>
#include "ctaweapi.h"
#define NUMBER_OF_EMITTERS
4
#define DEG2RAD
0.017453f;
/*
* example utility structs
*/
typedef struct _Emitter {
int
x;
/* world x position */
int
y;
/* world y position */
int z;
/* world z position */
c3daEmitter em;
/* handle to c3da core emitter */
/* need to be "created" using */
/* c3daCreateEmitter */
} Emitter;
typedef struct _Receiver {
float
a[9];
/* rotation matrix for yaw, pitch, roll */
/* A = | a[0] a[1] a[2] | */