/* ========= CRE_WAVE.H -- Waveform Playback Interface ========= */ /* == Copyright (c) 1992-96 by Crystal River Engineering, Inc. == */ /* == Updated 1997-2001 by AuSIM, Inc. == */ /* ================================================================ */ #ifndef CRE_WAVE_H #define CRE_WAVE_H #ifdef WIN32 #if defined AUSIM3D_EXPORTS #define CRE_WAVE_API __declspec(dllexport) #elif defined USE_AUSIM3D_DLL #define CRE_WAVE_API __declspec(dllimport) #else #define CRE_WAVE_API #endif #else /* !WIN32 */ #define CRE_WAVE_API #endif /* == Waveform allocation limit == */ #define MAX_WAVEFORMS 512 /* limit to < 13 bits for ATRON */ #define MAX_WAVEBUFFERS 0x07FF /* limit to 12 bits for ATRON */ #define WAVE_EnvVar "WAVEFORM" /* directory for all waveforms */ /* == Client READ-ONLY WaveForm Structure == */ /* Note -----------------------------------------------------------* Application programmer may use the wavFt::next structure member for their own use. It is initially set to NULL. ----------------------------------------------------------------*/ typedef struct wavFs { const char *fname; /* host soundfile filename */ void *pSignal; /* pointer to the signal buffers */ void *synch; /* synch's with this signal */ struct wavFs *next, /* linked-list pointer for user */ *duplist; /* duplicate list for multi-heads */ float sampleRate, /* in Hz; assumes 44.1kHz */ pitchFactor; /* pitch shift factor */ short numChannels, /* 1 = mono; 2 = stereo/biphonal */ sampleSize, /* in bytes: 1 = 8-bit, 2 = 16-bit */ frameSize, /* in bytes: samplesize * channels */ diskBased, /* boolean, TRUE if file still open */ waveId, /* remote serial identifier */ sourceId, /* value = -1, if not attached */ listnrId; /* value = -1, if not attached */ unsigned long numFrames, /* total frames in file */ remFrames, /* no. frames in selection NOT yet loaded */ selFrames, /* length of signal selection */ startFrame, /* beginning of signal selection (>= 0) */ loopCount; /* loop count and stop (-1 == forever) */ } wavFt; typedef wavFt *pwavFt; /* == WaveForm control messages == */ /* RFRS : Refresh - Re-reads the signal from disk PSET : Pointer Set - Sets the current signal pointer to given position RWND : Rewind - Effectively PSET 0 NOLP : No Loop - Turns off the loop flag, does not affect play state STRT : Start - Rewinds and plays, combo of RWND|PLAY, does not affect loop flag PLAY : Play - Enables play from the current position, does not affect loop flag LOOP : Loop Play - Enables play from the current position, sets loop flag STOP : Stop - Halts play state, does not affect loop flag STAT : State - Queries current state as 32-bit bit-field PTCH : Pitch Shift - Shifts pitch by given factor LPST : Loop Set - Define loop start, end, count WDAT : WavFt Data - Fills the current state into the wavFt structure SYNC : Sync - Synchronizes signal play state to another signal TRGR : Trigger - Sets action from one signal to another with wavSDt FULL : Reserved CHNL : Reserved */ enum wave_ctrl { /* == commands independent of source id == */ WaveCTRL_RFRS, WaveCTRL_PSET, WaveCTRL_RWND, WaveCTRL_NOLP, /* == commands dependent on both wave pointer and source id == */ WaveCTRL_STRT, WaveCTRL_PLAY, WaveCTRL_LOOP, /* == commands independent of wave pointer == */ WaveCTRL_STOP, /* == commands MAY be independent of wave pointer xor source id == */ WaveCTRL_STAT, /* == commands independent of source id, require data == */ WaveCTRL_SYNC, WaveCTRL_PTCH, WaveCTRL_LPST, /* no data used */ WaveCTRL_WDAT, /* ATRON command to fill wave structure, no data */ WaveCTRL_TRGR, WaveCTRL_FULL, WaveCTRL_CHNL, WaveCTRL_LAST }; /* Note: AuSIM3D waits on update_audio for ctrl_wave commands unless the engine is in "Legacy Sync Mode". */ typedef struct wavSDs { wavFt * pwav; /* pointer to wave to sync'd or triggerd */ int tsrc; /* target source for sync'ing or triggering on */ unsigned ofst; /* offset in current waveform for sync or trigger */ int cmsg; /* WaveCTRL_ message to trigger */ } wavSDt; #define WaveCTRL_FSTAT WaveCTRL_WDAT #ifdef __cplusplus extern "C" { #endif /* == CRE_WAVE extension == */ #ifndef EXCLUDE_WAVE_API CRE_WAVE_API wavFt *cre_open_wave (const char *wavefile, int mode); CRE_WAVE_API int cre_ctrl_wave (int src, wavFt *wave, int cmd, void *data); CRE_WAVE_API int cre_close_wave (wavFt *wave); #endif #ifdef __cplusplus } #endif #endif /* CRE_WAVE_H */