#pragma once #include "..\munga\audlvl.h" #include "l4audhdw.h" #include "openal/al.h" enum SampleChannel { CHANNEL_LEFT, CHANNEL_RIGHT, CHANNEL_CENTER }; enum SampleLoop { LoopAtWill, //Will play once or loop as desired ForceStatic, //Plays only once even if looped LoopAlways, //Ramp up and then down SampleLoopMax }; struct SAMPLEINFO { int bufferIndex; bool implemented; const char *file; SampleChannel chan; SampleLoop loop; // (task #50, AUDIO_FIDELITY F1/F13) full-zone metadata from the SF2 banks: // the authored MIDI note SELECTS zones by [keyLo,keyHi]; loop regions are // sub-ranges in sample frames (AL_SOFT_loop_points); releaseSec is the // authored releaseVolEnv fade applied on Stop instead of an instant cut. int keyLo; int keyHi; int loopStart; int loopEnd; float releaseSec; }; // AllExplosion (bank2 p125) authors 25 layered zones -- the largest preset. const int MAX_PRESET_SAMPLES = 25; struct PRESETINFO { int sampleNum; SAMPLEINFO samples[MAX_PRESET_SAMPLES]; bool is3d; }; extern PRESETINFO allPresets[2][128]; bool PRESET_isImplemented(int bank, int preset); int PRESET_getNumSamples(int bank, int preset); SAMPLEINFO PRESET_getSampleInfo(int bank, int preset, int sampleInd); void PRESET_setBufferIndex(int bank, int preset, int sampleInd, int index); // (task #50, AUDIO_FIDELITY F13) authored release fades: StopNote registers a // dB-linear gain ramp instead of cutting; AudioHead::Execute services them. void PRESET_serviceReleaseFades(float elapsed_seconds); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PatchLevelOfDetail ~~~~~~~~~~~~~~~~~~~~~~~~~~ typedef MIDIValue SBKPatchID; typedef MIDIValue SBKBankID; class PatchLevelOfDetail: public AudioLevelOfDetail { public: // //----------------------------------------------------------------------- // Construction, Destruction, Testing //----------------------------------------------------------------------- // PatchLevelOfDetail(PlugStream *stream); ~PatchLevelOfDetail(); void PlayNote(SourceSet sourceSet, int note); void StopNote(SourceSet sourceSet); Logical TestInstance() const; virtual AudioVoiceCount GetVoiceCount() {return PRESET_getNumSamples(bankID,patchID);} // (task #50) expose the authored bank/patch so the game-side footstep // intensity send can identify footstep sources precisely. int GetBankID() const { return (int)bankID; } int GetPatchID() const { return (int)patchID; } // //----------------------------------------------------------------------- // BuildFromPage //----------------------------------------------------------------------- // static void BuildFromPage( PlugStream *stream, NameList *name_list, ClassID class_ID, ObjectID object_ID ); // //----------------------------------------------------------------------- // Accessors //----------------------------------------------------------------------- // void SetupPatch(SourceSet sourceSet, int note); MIDINRPNValue GetMaxMIDIFilterCutoff() {return maxMIDIFilterCutoff;} private: // //----------------------------------------------------------------------- // Private data //----------------------------------------------------------------------- // SBKBankID bankID; SBKPatchID patchID; MIDINRPNValue maxMIDIFilterCutoff; #ifdef LAB_ONLY int setupCount; #endif // // Keep table of created patchs to verify that duplicates // are not created // #if DEBUG_LEVEL>0 static TableOf patchTableSocket; #endif }; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PatchResource ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ class PatchResource: public AudioResource { public: // //----------------------------------------------------------------------- // Construction, Destruction, Testing //----------------------------------------------------------------------- // PatchResource(PlugStream *stream); ~PatchResource(); void PlayNote(SourceSet sourceSet, int note); void StopNote(SourceSet sourceSet); Logical TestInstance() const; // //----------------------------------------------------------------------- // BuildFromPage //----------------------------------------------------------------------- // static void BuildFromPage( PlugStream *stream, NameList *name_list, ClassID class_ID, ObjectID object_ID ); // //----------------------------------------------------------------------- // Accessors //----------------------------------------------------------------------- // void SetupPatch(SourceSet sourceSet, int note); MIDINRPNValue GetMaxMIDIFilterCutoff(); // (task #50) authored bank/patch pass-throughs (the LOD accessor is // protected on AudioResource) -- zone metadata lookups at the source layer. int GetBankID(); int GetPatchID(); };