/* ============  CRE 3D Audio CRE_TRON API Library Header  ============ */
/* ===            Copyright (c) 1991-2000  by AuSIM, Inc.           === */
/* ===                      All rights reserved.                    === */
/* ==================================================================== */

#ifndef CRE_TRON_H
 #define CRE_TRON_H

#ifndef ATRON_H
 #include "atron.h"
#endif

#ifdef WIN32
  #if		defined	AUSIM3D_EXPORTS
  #define	AUSIM3D_API	__declspec(dllexport)
  #elif	defined	USE_AUSIM3D_DLL
  #define	AUSIM3D_API	__declspec(dllimport)
  #else
  #define	AUSIM3D_API	
  #endif
#else  /* !WIN32 */
  #define AUSIM3D_API
#endif 

/* -- the CRE_TRON API is defined as regular C functions
   ---- which makes them universally accessible to both C and C++ programs  */
#ifdef __cplusplus
 extern "C" {
#endif

enum CRELOCATEEXDESC_VECTORS {
  CLED_POSITION       = 1<<0,
  CLED_DEPART_VELOC   = 1<<1,
  CLED_DEPART_ACCEL   = 1<<2,
  CLED_APPROACH_VELOC = 1<<3,
  CLED_APPROACH_ACCEL = 1<<4
};

enum CRELOCATEEXDESC_COMPONENTS {
  CLED_LOCATION      = 1<<0,
  CLED_ORIENT_EULER  = 1<<1,
  CLED_ORIENT_QUAT   = 1<<2
};

#pragma pack( push, before_packed_structure, 4)

typedef struct CreLocateExDesc_vector_struct
{
  unsigned int comp_mask;
  float        location[3];
  float        orientation[4];
} CreLocateExDesc_vector;

typedef struct CreLocateExDesc_struct
{
  unsigned int size;
  unsigned int vector_mask;
  CreLocateExDesc_vector 
    position, depart_veloc, depart_accel, approach_veloc, approach_accel;
} CreLocateExDesc;

#pragma pack( pop, before_packed_structure )


#ifndef EXCLUDE_CRE_TRON_API

/* == Function Prototypes ============================================== */
/* -- System functions -- */
AUSIM3D_API int  cre_init          (int driver, int head, int sources, int mode);
AUSIM3D_API int  cre_update_audio  (void);
AUSIM3D_API int  cre_hold_audio    (int state);  /* suspends consumption of audio */
AUSIM3D_API int  cre_close         (int driver, int head);
AUSIM3D_API void cre_end           (void);   /* atexit() compatible closer  */

/* -- Listener functions -- */
AUSIM3D_API int  cre_define_head   (int id, int prm, int pts, const void *data);
AUSIM3D_API int  cre_locate_head   (int id, const float *hloc);

/* -- Source functions -- */
AUSIM3D_API int  cre_select_source (int id, int input);
AUSIM3D_API int  cre_direct_source (int id, float r_fld, float i_fld);
AUSIM3D_API int  cre_define_source (int id, int prm, int pts, const void *data);
AUSIM3D_API int  cre_locate_source (int id, const float *sloc);
AUSIM3D_API int  cre_amplfy_source (int id, float dB);
AUSIM3D_API int  cre_pmeter_source (int id, float *power);

/* -- Propagation Medium functions -- */
AUSIM3D_API int  cre_define_medium (int volm, int prm, int pts, const void *data);

/* -- Channel routing controller -- */
AUSIM3D_API int  cre_define_router (int id, int prm, int pts, const void *data);

/* -- Psycho-Acoustic Research functions -- */
AUSIM3D_API int  cre_set_rel_pos   (int head, int src, float azim,
                                           float elev,
                                           float gain);
AUSIM3D_API int  cre_get_polar     (int head, int src, float *polar);

/* -- Client string message handlers -- */
AUSIM3D_API int  cre_fetch_message (int msg, char *buffer, int bufsize);
AUSIM3D_API int  cre_fetch_error   (int msg, char *buffer, int bufsize);
AUSIM3D_API int  cre_fetch_version (int lvl, char *buffer, int bufsize);
AUSIM3D_API int  cre_fetch_value   (int prm);

/* -- Query functions -- */
/*    see ATRNqueryXxxx enums in atron.h   */
AUSIM3D_API int  cre_query_system  (int id, int prm, int pts, void *data);
AUSIM3D_API int  cre_query_head    (int id, int prm, int pts, void *data);
AUSIM3D_API int  cre_query_source  (int id, int prm, int pts, void *data);
AUSIM3D_API int  cre_query_medium  (int id, int prm, int pts, void *data);
AUSIM3D_API int  cre_query_router  (int id, int prm, int pts, void *data);

/* -- Atron client test functions -- */
/* Use "verbose" only if a console is attached to the calling application */
AUSIM3D_API int  cre_test_atron    (int verbose);
AUSIM3D_API int  cre_reset_atron   (int verbose);
AUSIM3D_API int  cre_client_nap    (unsigned long msecs);

/* -- Locate Ex functions -- */
AUSIM3D_API int cre_locate_head_ex  (int head_id, const CreLocateExDesc *description);
AUSIM3D_API int cre_locate_source_ex(int src_id , const CreLocateExDesc *description);

#endif //EXCLUDE_CRE_TRON_API

#ifdef __cplusplus
 }
#endif

#define cre_exit cre_end   /* atexit() compatible closer  */

#endif          /* CRE_TRON_H */


