1 //封装的BASS MIDI中的若干API函数,通过动态加载的方式 2 #pragma once 3 #include "DllLib.h" 4 typedef DWORD HSOUNDFONT; // soundfont handle 5 struct BASS_MIDI_FONT 6 { 7 HSOUNDFONT font; // soundfont 8 int preset; // preset number (-1=all) 9 int bank; 10 }; 11 12 struct BASS_MIDI_FONTINFO 13 { 14 const char *name; 15 const char *copyright; 16 const char *comment; 17 DWORD presets; // number of presets/instruments 18 DWORD samsize; // total size (in bytes) of the sample data 19 DWORD samload; // amount of sample data currently loaded 20 DWORD samtype; // sample format (CTYPE) if packed 21 }; 22 23 struct BASS_MIDI_MARK 24 { 25 DWORD track; // track containing marker 26 DWORD pos; // marker position 27 const char *text; // marker text 28 }; 29 30 #define BASS_POS_MIDI_TICK 2 // tick position 31 32 #define MIDI_EVENT_TEMPO 62 33 34 // Marker types 35 #define BASS_MIDI_MARK_LYRIC 2 // lyric 36 #define BASS_MIDI_MARK_TEXT 3 // text 37 #define BASS_MIDI_MARK_TRACK 7 // track name 38 39 #define BASS_SYNC_MIDI_MARK 0x10000 40 41 #define BASS_ATTRIB_MIDI_PPQN 0x12000 42 43 class CBASSMidiLibrary : public CDllLib 44 { 45 typedef HSOUNDFONT (WINAPI *_BASS_MIDI_FontInit)(const void* file, DWORD flags); 46 typedef BOOL (WINAPI *_BASS_MIDI_StreamSetFonts)(HSTREAM handle, const void* fonts, DWORD count); 47 typedef BOOL (WINAPI *_BASS_MIDI_FontGetInfo)(HSOUNDFONT handle, BASS_MIDI_FONTINFO *info ); 48 typedef BOOL (WINAPI *_BASS_MIDI_FontFree)(HSOUNDFONT handle); 49 typedef DWORD (WINAPI *_BASS_MIDI_StreamGetEvent)(HSTREAM handle, DWORD chan, DWORD event); 50 typedef BOOL(WINAPI *_BASS_MIDI_StreamGetMark)(HSTREAM handle, DWORD type, DWORD index, BASS_MIDI_MARK *mark); 51 public: 52 CBASSMidiLibrary(); 53 ~CBASSMidiLibrary(); 54 55 //BASS MIDI库中的函数指针 56 _BASS_MIDI_FontInit BASS_MIDI_FontInit; 57 _BASS_MIDI_StreamSetFonts BASS_MIDI_StreamSetFonts; 58 _BASS_MIDI_FontGetInfo BASS_MIDI_FontGetInfo; 59 _BASS_MIDI_FontFree BASS_MIDI_FontFree; 60 _BASS_MIDI_StreamGetEvent BASS_MIDI_StreamGetEvent; 61 _BASS_MIDI_StreamGetMark BASS_MIDI_StreamGetMark; 62 63 private: 64 virtual bool GetFunction() override; 65 66 }; 67 68