diff --git a/.gitignore b/.gitignore index 8f5c2fda..67aab3e4 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,6 @@ /*.vcxproj.user /.vs /Debug -/OmniMIDIv2/ /OmniMIDI/*.dll /OmniMIDI/*.exe /OmniMIDI/*.exp @@ -115,3 +114,6 @@ output/Test OmniMIDI Configurator.bat output/OmniMIDIDevEnum.exe OmniMapper/OmniMapper/OmniMIDI.h OmniMIDIConfigurator/.vs/ +OmniMIDIv2/.vs/ +OmniMIDIv2/x64/ +OmniMIDIv2/OmniMIDI.vcxproj.user diff --git a/OmniMIDIv2/ErrSys.cpp b/OmniMIDIv2/ErrSys.cpp new file mode 100644 index 00000000..a24ba24d --- /dev/null +++ b/OmniMIDIv2/ErrSys.cpp @@ -0,0 +1,71 @@ +/* +OmniMIDI v15+ (Rewrite) for Windows NT + +This file contains the required code to run the driver under Windows 7 SP1 and later. +This file is useful only if you want to compile the driver under Windows, it's not needed for Linux/macOS porting. +*/ + +#include "pch.h" +#include "ErrSys.h" + +#ifdef _WIN32 + +void ErrorSystem::WinErr::Log(const wchar_t* Message, const wchar_t* Position, const wchar_t* File, const wchar_t* Line) { + wchar_t* Buf = new wchar_t[SZBufSize]; + + swprintf_s(Buf, BufSize, L"DEBUG MSG FROM %s.\n\nFile: %s\nLine: %s\n\nMessage: %s", Position, File, Line, Message); + + OutputDebugString(Buf); + +#ifdef _DEBUG + MessageBox(NULL, Buf, L"Shakra - Debug message", MB_OK | MB_SYSTEMMODAL | MB_ICONWARNING); +#endif + + delete[] Buf; +} + +void ErrorSystem::WinErr::ThrowError(const wchar_t* Error, const wchar_t* Position, const wchar_t* File, const wchar_t* Line, bool IsSeriousError) { + int GLE = GetLastError(); + wchar_t* Buf = nullptr; + LPWSTR GLEBuf = nullptr; + + if (!Error) { + size_t MsgBufSize = FormatMessageW( + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS | + FORMAT_MESSAGE_ALLOCATE_BUFFER, + NULL, GLE, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPWSTR)&GLEBuf, 0, NULL); + + MessageBox(NULL, GLEBuf, L"Shakra - Error", IsSeriousError ? MB_ICONERROR : MB_ICONWARNING | MB_OK | MB_SYSTEMMODAL); + + LocalFree(GLEBuf); + } + else { + Buf = new wchar_t[SZBufSize]; +#ifdef _DEBUG + swprintf_s(Buf, BufSize, L"An error has occured in the \"%s\" function!\n\nFile: %s\nLine: %s\n\nError: %s", Position, File, Line, Error); +#else + swprintf_s(Buf, BufSize, L"An error has occured in the \"%s\" function!\n\nError: %s", Position, Error); +#endif + + MessageBox(NULL, Buf, L"Shakra - Error", IsSeriousError ? MB_ICONERROR : MB_ICONWARNING | MB_OK | MB_SYSTEMMODAL); + + delete[] Buf; + } +} + +void ErrorSystem::WinErr::ThrowFatalError(const wchar_t* Error) { + wchar_t* Buf = new wchar_t[SZBufSize]; + + swprintf_s(Buf, BufSize, L"A fatal error has occured from which the driver is unable to recover!\n\nError: %s", Error); + + MessageBox(NULL, Buf, L"Shakra - FATAL ERROR", MB_ICONERROR | MB_OK | MB_SYSTEMMODAL); + + delete[] Buf; + + throw ::GetLastError(); +} + +#endif \ No newline at end of file diff --git a/OmniMIDIv2/ErrSys.h b/OmniMIDIv2/ErrSys.h new file mode 100644 index 00000000..11cc839f --- /dev/null +++ b/OmniMIDIv2/ErrSys.h @@ -0,0 +1,49 @@ +/* +Shakra Driver component for Windows +This .h file contains the required code to run the driver under Windows 8.1 and later. + +This file is useful only if you want to compile the driver under Windows, it's not needed for Linux/macOS porting. +*/ + +#ifndef _ERRSYS_H +#define _ERRSYS_H + +#pragma once + +#define S2(x) #x // Convert to string +#define S1(x) S2(x) // Convert to string +#define FU _T(__FUNCTION__) // Function +#define LI _T(S1(__LINE__)) // Line +#define FI _T(__FILE__) // File + +#define NERROR(x, y, z) x.ThrowError(y, FU, FI, LI, z) +#define FNERROR(x, y) x.ThrowFatalError(y) + +#if _DEBUG +#define LOG(x, y) x.Log(y, FU, FI, LI) +#define LOGV(x, y) x.Log(_T(S1(y)), FU, FI, LI) +#else +#define LOG(x, y) NULL +#define LOGV(x, y) NULL +#endif + +#include +#include +#include + +using namespace std; + +namespace ErrorSystem { + class WinErr { + private: + static const int BufSize = 2048; + static const int SZBufSize = sizeof(wchar_t) * BufSize; + + public: + void Log(const wchar_t* Error, const wchar_t* Position, const wchar_t* File, const wchar_t* Line); + void ThrowError(const wchar_t* Error, const wchar_t* Position, const wchar_t* File, const wchar_t* Line, bool IsSeriousError); + void ThrowFatalError(const wchar_t* Error); + }; +} + +#endif \ No newline at end of file diff --git a/OmniMIDIv2/OmniMIDI.sln b/OmniMIDIv2/OmniMIDI.sln new file mode 100644 index 00000000..9d0f6e1b --- /dev/null +++ b/OmniMIDIv2/OmniMIDI.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33530.505 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OmniMIDI", "OmniMIDI.vcxproj", "{042EAA44-6BE1-4D89-882B-058828E659D7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {042EAA44-6BE1-4D89-882B-058828E659D7}.Debug|x64.ActiveCfg = Debug|x64 + {042EAA44-6BE1-4D89-882B-058828E659D7}.Debug|x64.Build.0 = Debug|x64 + {042EAA44-6BE1-4D89-882B-058828E659D7}.Debug|x86.ActiveCfg = Debug|Win32 + {042EAA44-6BE1-4D89-882B-058828E659D7}.Debug|x86.Build.0 = Debug|Win32 + {042EAA44-6BE1-4D89-882B-058828E659D7}.Release|x64.ActiveCfg = Release|x64 + {042EAA44-6BE1-4D89-882B-058828E659D7}.Release|x64.Build.0 = Release|x64 + {042EAA44-6BE1-4D89-882B-058828E659D7}.Release|x86.ActiveCfg = Release|Win32 + {042EAA44-6BE1-4D89-882B-058828E659D7}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {97AA32E0-DD72-40F2-A259-E766EFC08FC8} + EndGlobalSection +EndGlobal diff --git a/OmniMIDIv2/OmniMIDI.vcxproj b/OmniMIDIv2/OmniMIDI.vcxproj new file mode 100644 index 00000000..a1f5d532 --- /dev/null +++ b/OmniMIDIv2/OmniMIDI.vcxproj @@ -0,0 +1,188 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {042eaa44-6be1-4d89-882b-058828e659d7} + OmniMIDI + 10.0 + + + + DynamicLibrary + true + v143 + Unicode + + + DynamicLibrary + false + v143 + true + Unicode + + + DynamicLibrary + true + v143 + Unicode + + + DynamicLibrary + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(ProjectDir)\inc + + + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(ProjectDir)\inc + + + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(ProjectDir)\inc + + + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(ProjectDir)\inc + + + + Level3 + true + WIN32;_DEBUG;OMNIMIDI_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + Use + pch.h + + + Windows + true + false + winmm.lib;%(AdditionalDependencies) + 10.0 + + + + + Level3 + true + true + true + WIN32;NDEBUG;OMNIMIDI_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + Use + pch.h + + + Windows + true + true + true + false + winmm.lib;%(AdditionalDependencies) + 10.0 + + + + + Level3 + true + _DEBUG;OMNIMIDI_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + Use + pch.h + + + Windows + true + false + winmm.lib;%(AdditionalDependencies) + 10.0 + + + + + Level3 + true + true + true + NDEBUG;OMNIMIDI_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + Use + pch.h + + + Windows + true + true + true + false + winmm.lib;%(AdditionalDependencies) + 10.0 + + + + + + + + + + + + + + + + + + Create + Create + Create + Create + + + + + + + + + \ No newline at end of file diff --git a/OmniMIDIv2/OmniMIDI.vcxproj.filters b/OmniMIDIv2/OmniMIDI.vcxproj.filters new file mode 100644 index 00000000..c257d9cb --- /dev/null +++ b/OmniMIDIv2/OmniMIDI.vcxproj.filters @@ -0,0 +1,89 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {32b66a3e-4ffa-4bd6-9277-e81d845d2197} + + + {db341718-4333-4734-8506-58b9d687a68c} + + + {3676059e-76d4-4f8e-a9d4-be90f349aca7} + + + {e5436d45-82c9-4c9b-8407-fe7364b499ef} + + + {589c6ff6-91d5-437f-9b8d-842df0074ff9} + + + {cbe897c2-9634-4044-b9a6-d87f99a66b7e} + + + {2af71ab6-7d05-445e-896e-add295b6cf71} + + + {42ab0514-ea83-41b8-a996-853b7e93bcfb} + + + {962b29bc-2133-4b6c-b50e-8b1a821913b0} + + + + + Header Files\Extensions + + + Header Files\Mandatory + + + Header Files\Mandatory + + + Header Files\WDM + + + Header Files\Synthesizer + + + + + Source Files + + + Source Files\Extensions + + + Source Files\WDM + + + Source Files\WDM + + + Source Files\Synthesizer + + + Source Files\Synthesizer\BASS + + + Source Files\Synthesizer\BASS + + + + + Header Files\WDM + + + \ No newline at end of file diff --git a/OmniMIDIv2/SynthMain.cpp b/OmniMIDIv2/SynthMain.cpp new file mode 100644 index 00000000..5151730c --- /dev/null +++ b/OmniMIDIv2/SynthMain.cpp @@ -0,0 +1,412 @@ +/* +OmniMIDI v15+ (Rewrite) for Windows NT + +This file contains the required code to run the driver under Windows 7 SP1 and later. +This file is useful only if you want to compile the driver under Windows, it's not needed for Linux/macOS porting. +*/ + +#include "pch.h" +#include "SynthMain.h" + +bool OmniMIDI::SynthModule::LoadLib(Lib* Target) { + wchar_t SysDir[MAX_PATH] = { 0 }; + wchar_t DLLPath[MAX_PATH] = { 0 }; + WIN32_FIND_DATA FD = { 0 }; + + // Check if library is loaded + if (Target->Library == nullptr) { + // If not, begin loading process + // LOG(SynErr, L"Loading library..."); + // LOG(SynErr, Target->Path); + + // Check if the host MIDI application has a version of the library + // in memory already. + if ((Target->Library = GetModuleHandle(Target->Path)) != nullptr) + { + // (TODO) Make it so we can load our own version of it + // For now, just make the driver try and use that instead + return (Target->AppSelfHosted = true); + } + // Otherwise, let's load our own + else { + // Let's get the system path + PWSTR Dir; + LSTATUS Success = SHGetKnownFolderPath(FOLDERID_System, 0, NULL, &Dir); + bool Good = SUCCEEDED(Success); + assert(Good == true); + + if (Good) + { + Success = StringCchPrintfW(SysDir, sizeof(SysDir), L"%ws", Dir); + Good = SUCCEEDED(Success); + assert(Good == true); + } + + CoTaskMemFree((LPVOID)Dir); + + LOG(SynErr, SysDir); + + // If we failed to get a system path, + // return false + if (!Good) + return false; + + int swp = swprintf_s(DLLPath, MAX_PATH, L"%s\\OmniMIDI\\%s.dll\0", SysDir, Target->Path); + assert(swp != -1); + + // LOG(SynErr, DLLPath); + + if (FindFirstFile(DLLPath, &FD) == INVALID_HANDLE_VALUE) + return false; + else { + Target->Library = LoadLibrary(DLLPath); + assert(Target->Library != 0); + + if (!Target->Library) + return false; + } + } + } + + return true; +} + +bool OmniMIDI::SynthModule::UnloadLib(Lib* Target) { + // Check if library is already loaded + if (Target->Library != nullptr) { + // Check if the library was originally loaded by the + // hosting MIDI application, this happens sometimes. + if (Target->AppSelfHosted) + { + // It was, set Lib to nullptr and return true + Target->AppSelfHosted = false; + Target->Library = nullptr; + return true; + } + + Target->Initialized = false; + Target->LoadFailed = false; + + bool r = FreeLibrary(Target->Library); + assert(r == true); + + Target->Library = nullptr; + } + + // It is, return true + return true; +} + +void OmniMIDI::SynthModule::LoadFunc(Lib* Target, void* Func, const char* FuncName) { + // If target is already initialized, just return + if (Target->Initialized) + return; + + if (Target->Library == nullptr) + { + if (!LoadLib(Target)) + Target->LoadFailed = true; + } + + if (Target->Library != nullptr) { + // Load the func (This macro makes it so much easier) + *((void**)&Func) = GetProcAddress(Target->Library, FuncName); + + assert(*((void**)&Func) != 0); + + // Check if the function does in fact exist, if it doesn't then die + if (!(*((void**)&Func) != 0)) + Target->LoadFailed = true; + } +} + +bool OmniMIDI::SynthModule::LoadFuncs() { + if (!BAudLib.Path) + BAudLib.Path = L"BASS"; + + if (!BMidLib.Path) + BMidLib.Path = L"BASSMIDI"; + + int limit = sizeof(LibImports) / sizeof(LibImports[0]); + + for (int i = 0; i < limit; i++) + { + if (!LoadLib(&BAudLib)) + return false; + + *(LibImports[i].ptr) = (void*)GetProcAddress(BAudLib.Library, LibImports[i].name); + if (*(LibImports[i].ptr)) + continue; + + if (!LoadLib(&BMidLib)) + return false; + + *(LibImports[i].ptr) = (void*)GetProcAddress(BMidLib.Library, LibImports[i].name); + if (*(LibImports[i].ptr)) + continue; + } + + // Sanity check + for (int i = 0; i < limit; i++) + { + if (!*(LibImports[i].ptr)) + { + LOG(SynErr, L"A function could not be loaded."); + return false; + } + } + + return !(BAudLib.LoadFailed && BMidLib.LoadFailed); +} + +bool OmniMIDI::SynthModule::UnloadFuncs() { + int limit = sizeof(LibImports) / sizeof(LibImports[0]); + + for (int i = 0; i < limit; i++) + *(LibImports[i].ptr) = nullptr; + + if (!UnloadLib(&BAudLib)) + return false; + + if (!UnloadLib(&BMidLib)) + return false; + + return true; +} + +bool OmniMIDI::SynthModule::LoadSynthModule() { + // LOG(SynErr, L"LoadSynthModule called."); + if (LoadFuncs()) { + // LOG(SynErr, L"LoadFuncs succeeded."); + // TODO + return true; + } + + return false; +} + +bool OmniMIDI::SynthModule::UnloadSynthModule() { + // LOG(SynErr, L"UnloadSynthModule called."); + if (UnloadFuncs()) { + // LOG(SynErr, L"UnloadFuncs succeeded."); + // TODO + return true; + } + + return false; +} + +bool OmniMIDI::SynthModule::StartSynthModule() { + if (BASS_Init(-1, 48000, BASS_DEVICE_STEREO | BASS_DEVICE_SOFTWARE, nullptr, nullptr)) + { + AudioStream = BASS_MIDI_StreamCreate(16, BASS_SAMPLE_FLOAT | BASS_MIDI_ASYNC, 0); + if (!AudioStream) + { + LOG(SynErr, L"BASS_MIDI_StreamCreate failed!"); + return false; + } + + SoundFonts = (BASS_MIDI_FONTEX*)malloc(1 * sizeof(BASS_MIDI_FONTEX)); + assert(SoundFonts != 0); + + if (!SoundFonts) { + LOG(SynErr, L"SoundFonts failed!"); + StopSynthModule(); + return false; + } + + SoundFonts[0].font = BASS_MIDI_FontInit(L"gm.sf2", BASS_UNICODE | BASS_MIDI_FONT_NOLIMITS | BASS_MIDI_FONT_MMAP); + SoundFonts[0].spreset = -1; // all presets + SoundFonts[0].sbank = -1; // all banks + SoundFonts[0].dpreset = -1; // all presets + SoundFonts[0].dbank = 0; // default banks + SoundFonts[0].dbanklsb = 0; // destination bank LSB 0 + + BASS_MIDI_FontLoad(SoundFonts[0].font, SoundFonts[0].spreset, SoundFonts[0].sbank); + BASS_MIDI_StreamSetFonts(AudioStream, SoundFonts, 1 | BASS_MIDI_FONT_EX); + + BASS_SetConfig(BASS_CONFIG_UPDATEPERIOD, 5); + BASS_SetConfig(BASS_CONFIG_UPDATETHREADS, 4); + + BASS_ChannelSetAttribute(AudioStream, BASS_ATTRIB_BUFFER, 0); + + if (!BASS_ChannelPlay(AudioStream, false)) + { + LOG(SynErr, L"BASS_ChannelPlay failed."); + return false; + } + + return true; + } + + LOG(SynErr, L"BASS_Init failed."); + return false; +} + +bool OmniMIDI::SynthModule::StopSynthModule() { + if (SoundFonts && SoundFonts[0].font) { + BASS_MIDI_FontFree(SoundFonts[0].font); + free(SoundFonts); + LOG(SynErr, L"SoundFonts freed."); + } + + BASS_ChannelStop(AudioStream); + BASS_StreamFree(AudioStream); + AudioStream = 0; + LOG(SynErr, L"BASS_StreamFree called!"); + + BASS_Free(); + LOG(SynErr, L"BASS freed."); + + return true; +} + +SynthResult OmniMIDI::SynthModule::UPlayShortEvent(unsigned int ev) { + /* + + For more info about how an event is structured, read this doc from Microsoft: + https://learn.microsoft.com/en-us/windows/win32/api/mmeapi/nf-mmeapi-midioutshortmsg + + - + TL;DR is here though: + Let's assume that we have an event coming through, of value 0x007F7F95. + + The high-order byte of the high word is ignored. + + The low-order of the high word contains the first part of the data, which, for + a NoteOn event, is the key number (from 0 to 127). + + The high-order of the low word contains the second part of the data, which, for + a NoteOn event, is the velocity of the key (again, from 0 to 127). + + The low-order byte of the low word contains two nibbles combined into one. + The first nibble contains the type of event (1001 is 0x9, which is a NoteOn), + while the second nibble contains the channel (0101 is 0x5, which is the 5th channel). + + So, in short, we can read it as follows: + 0x957F7F should press the 128th key on the keyboard at full velocity, on MIDI channel 5. + + But hey! We can also receive events with a long running status, which means there's no status byte! + That event, if we consider the same example from before, will look like this: 0x00007F7F + + Such event will only work if the driver receives a status event, which will be stored in memory. + So, in a sequence of data like this: + .. + 1. 0x00044A90 (NoteOn on key 75 at velocity 10) + 2. 0x00007F7F (... then on key 128 at velocity 127) + 3. 0x00006031 (... then on key 50 at velocity 96) + 4. 0x0000605F (... and finally on key 95 at velocity 96) + .. + The same status from event 1 will be applied to all the status-less events from 2 and onwards. + - + + INFO: ev will be recasted as char in some parts of the code, since those parts + do not require the high-word part of the unsigned int. + + */ + + unsigned int r = 0; + unsigned int tev = ev; + + if (CHKLRS(GETSTATUS(tev)) != 0) LastRunningStatus = GETSTATUS(tev); + else tev = ev << 8 | LastRunningStatus; + + unsigned int ch = tev & 0xF; + unsigned int evt = 0; + unsigned int param = GETFP(tev); + + unsigned int cmd = GETCMD(tev); + unsigned int len = 3; + bool ok = true; + + switch (LastRunningStatus) { + // Handle 0xFF (GS reset) first! + default: + switch (GETCMD(ev)) { + case MIDI_NOTEON: + evt = MIDI_EVENT_NOTE; + break; + case MIDI_NOTEOFF: + evt = MIDI_EVENT_NOTE; + param = (char)param; + break; + case MIDI_POLYAFTER: + evt = MIDI_EVENT_KEYPRES; + break; + case MIDI_PROGCHAN: + evt = MIDI_EVENT_PROGRAM; + param = (char)param; + break; + case MIDI_CHANAFTER: + evt = MIDI_EVENT_CHANPRES; + param = (char)param; + break; + default: + if (tev == 0x7FFFFFFF) { + for (int i = 0; i < 16; i++) { + if (!BASS_MIDI_StreamEvent(AudioStream, i, MIDI_EVENT_SYSTEM, MIDI_SYSTEM_XG)) + ok = false; + } + return ok ? SYNTH_OK : SYNTH_INVALPARAM; + } + + // Some events do not have a specific counter part on BASSMIDI's side, so they have + // to be directly fed to the library by using the BASS_MIDI_EVENTS_RAW flag. + if (!(tev - 0x80 & 0xC0)) + { + r = BASS_MIDI_StreamEvents(AudioStream, BASS_MIDI_EVENTS_RAW, &tev, 3); + return (r != -1) ? SYNTH_OK : SYNTH_INVALPARAM; + } + + if (!((tev - 0xC0) & 0xE0)) len = 2; + else if (GETCMD(tev) == 0xF0) + { + switch (tev & 0xF) + { + case 3: + len = 2; + break; + default: + // Not supported by OmniMIDI! + return false; + } + } + + r = BASS_MIDI_StreamEvents(AudioStream, BASS_MIDI_EVENTS_RAW, &tev, len); + return (r > -1) ? SYNTH_OK : SYNTH_INVALPARAM; + } + } + + r = BASS_MIDI_StreamEvent(AudioStream, ch, evt, param); + return (r > -1) ? SYNTH_OK : SYNTH_INVALPARAM; +} + +SynthResult OmniMIDI::SynthModule::PlayShortEvent(unsigned int ev) { + if (BMidLib.Initialized && !BMidLib.LoadFailed) + return UPlayShortEvent(ev); + else + return SYNTH_NOTINIT; +} + +SynthResult OmniMIDI::SynthModule::UPlayLongEvent(char* ev, unsigned int size) { + unsigned int r = BASS_MIDI_StreamEvents(AudioStream, BASS_MIDI_EVENTS_RAW, ev, size); + return (r != -1) ? SYNTH_OK : SYNTH_INVALPARAM; +} + +SynthResult OmniMIDI::SynthModule::PlayLongEvent(char* ev, unsigned int size) { + if (!BMidLib.Initialized) + return SYNTH_NOTINIT; + + if (BMidLib.LoadFailed) + return SYNTH_INITERR; + + // No buffer? + if (size < 1) + return SYNTH_OK; + + // The maximum size for a long header is 64K! + if (size > 65535) + return SYNTH_INVALPARAM; + + return UPlayLongEvent(ev, size); +} \ No newline at end of file diff --git a/OmniMIDIv2/SynthMain.h b/OmniMIDIv2/SynthMain.h new file mode 100644 index 00000000..8d29c692 --- /dev/null +++ b/OmniMIDIv2/SynthMain.h @@ -0,0 +1,148 @@ +/* +OmniMIDI v15+ (Rewrite) for Windows NT + +This file contains the required code to run the driver under Windows 7 SP1 and later. +This file is useful only if you want to compile the driver under Windows, it's not needed for Linux/macOS porting. +*/ + +#ifndef _SYNTHMAIN_H +#define _SYNTHMAIN_H + +#pragma once + +typedef unsigned int SynthResult; + +#define CHKLRS(f) (f & 0x80) +#define GETCMD(f) (f & 0xF0) +#define GETCHANNEL(f) (f & 0xF) +#define GETSTATUS(f) (f & 0xFF) +#define GETSP(f) (f >> 16) +#define GETFP(f) (f >> 8) + +// +#define MIDI_NOTEOFF 0x80 +#define MIDI_NOTEON 0x90 +#define MIDI_POLYAFTER 0xA0 +#define MIDI_CMC 0xB0 +#define MIDI_PROGCHAN 0xC0 +#define MIDI_CHANAFTER 0xD0 +#define MIDI_PITCHWHEEL 0xE0 + +// TBD +#define MIDI_SYSEXBEG 0xF0 +#define MIDI_SYSEXEND 0xF7 +#define MIDI_COOKPLPLAY 0xFA +#define MIDI_COOKPLCONT 0xFB +#define MIDI_COOKPLSTOP 0xFC +#define MIDI_SENSING 0xFE +#define MIDI_SYSRESET 0xFF + +// ERRORS +#define SYNTH_OK 0x00 +#define SYNTH_NOTINIT 0x01 +#define SYNTH_INITERR 0x02 +#define SYNTH_INVALPARAM 0x03 + +#define fv2fn(f) (#f) +#define ImpFunc(f) {(void**)&##f, #f} + +#include +#include +#include +#include +#include +#include "ErrSys.h" + +using namespace std; + +namespace { + struct LibImport + { + void** ptr; + const char* name; + } + + LibImports[] = { + // BASS + ImpFunc(BASS_ChannelFlags), + ImpFunc(BASS_ChannelGetAttribute), + ImpFunc(BASS_ChannelGetData), + ImpFunc(BASS_ChannelGetLevelEx), + ImpFunc(BASS_ChannelIsActive), + ImpFunc(BASS_ChannelPlay), + ImpFunc(BASS_ChannelRemoveFX), + ImpFunc(BASS_ChannelSeconds2Bytes), + ImpFunc(BASS_ChannelSetAttribute), + ImpFunc(BASS_ChannelSetDevice), + ImpFunc(BASS_ChannelSetFX), + ImpFunc(BASS_ChannelStop), + ImpFunc(BASS_ChannelUpdate), + ImpFunc(BASS_ErrorGetCode), + ImpFunc(BASS_FXSetParameters), + ImpFunc(BASS_Free), + ImpFunc(BASS_GetDevice), + ImpFunc(BASS_GetDeviceInfo), + ImpFunc(BASS_GetInfo), + ImpFunc(BASS_Init), + ImpFunc(BASS_PluginFree), + ImpFunc(BASS_SetConfig), + ImpFunc(BASS_Stop), + ImpFunc(BASS_StreamFree), + + // BASSMIDI + ImpFunc(BASS_MIDI_FontFree), + ImpFunc(BASS_MIDI_FontInit), + ImpFunc(BASS_MIDI_FontLoad), + ImpFunc(BASS_MIDI_StreamCreate), + ImpFunc(BASS_MIDI_StreamEvent), + ImpFunc(BASS_MIDI_StreamEvents), + ImpFunc(BASS_MIDI_StreamGetEvent), + ImpFunc(BASS_MIDI_StreamLoadSamples), + ImpFunc(BASS_MIDI_StreamSetFonts), + ImpFunc(BASS_MIDI_StreamGetChannel) + }; +} + +namespace OmniMIDI { + struct Lib { + const wchar_t* Path; + HMODULE Library = nullptr; + bool Initialized = true; + bool LoadFailed = false; + bool AppSelfHosted = false; + }; + + class SynthModule { + private: + ErrorSystem::WinErr SynErr; + + Lib BAudLib; + Lib BMidLib; + + unsigned int AudioStream; + BASS_MIDI_FONTEX* SoundFonts; + + char LastRunningStatus = 0x0; + + void LoadFunc(Lib* target, void* func, const char* funcName); + bool LoadLib(Lib* Target); + bool UnloadLib(Lib* Target); + bool LoadFuncs(); + bool UnloadFuncs(); + + public: + bool LoadSynthModule(); + bool UnloadSynthModule(); + bool StartSynthModule(); + bool StopSynthModule(); + bool ChangeSetting(unsigned int setting, void* var, size_t size); + + // Event handling system + SynthResult PlayShortEvent(unsigned int ev); + SynthResult UPlayShortEvent(unsigned int ev); + SynthResult PlayLongEvent(char* ev, unsigned int size); + SynthResult UPlayLongEvent(char* ev, unsigned int size); + }; +} + +#endif \ No newline at end of file diff --git a/OmniMIDIv2/WDMDrv.cpp b/OmniMIDIv2/WDMDrv.cpp new file mode 100644 index 00000000..a23528a9 --- /dev/null +++ b/OmniMIDIv2/WDMDrv.cpp @@ -0,0 +1,223 @@ +/* +OmniMIDI v15+ (Rewrite) for Windows NT + +This file contains the required code to run the driver under Windows 7 SP1 and later. +This file is useful only if you want to compile the driver under Windows, it's not needed for Linux/macOS porting. +*/ + +#include "pch.h" +#include "WDMDrv.h" + +#ifdef _WIN32 + +bool WinDriver::DriverMask::ChangeSettings(short NMID, short NPID, short NT, short NS) { + // TODO: Check if the values contain valid technologies/support flags + + this->ManufacturerID = NMID; + this->ProductID = NPID; + this->Technology = NT; + this->Support = NS; + + return true; +} + +unsigned long WinDriver::DriverMask::GiveCaps(UINT DeviceIdentifier, PVOID CapsPointer, DWORD CapsSize) { + wchar_t DevName[MAXPNAMELEN] = { 0 }; + MIDIOUTCAPSA CapsA; + MIDIOUTCAPSW CapsW; + MIDIOUTCAPS2A Caps2A; + MIDIOUTCAPS2W Caps2W; + size_t WCSTSRetVal; + + // Why would this happen? Stupid MIDI app dev smh + if (CapsPointer == nullptr) + { + NERROR(MaskErr, L"A null pointer has been passed to the function. The driver can't share its info with the application.", false); + return MMSYSERR_INVALPARAM; + } + + if (CapsSize == 0) { + NERROR(MaskErr, L"CapsSize has a value of 0, how is the driver supposed to determine the subtype of the struct?", false); + return MMSYSERR_INVALPARAM; + } + + swprintf_s(DevName, MAXPNAMELEN, this->TemplateName, DeviceIdentifier); + + // I have to support all this s**t or else it won't work in some apps smh + switch (CapsSize) { + case (sizeof(MIDIOUTCAPSA)): + wcstombs_s(&WCSTSRetVal, CapsA.szPname, sizeof(CapsA.szPname), DevName, MAXPNAMELEN); + CapsA.dwSupport = this->Support; + CapsA.wChannelMask = 0xFFFF; + CapsA.wMid = this->ManufacturerID; + CapsA.wPid = this->ProductID; + CapsA.wTechnology = this->Technology; + CapsA.wNotes = 65535; + CapsA.wVoices = 65535; + CapsA.vDriverVersion = MAKEWORD(6, 2); + memcpy((LPMIDIOUTCAPSA)CapsPointer, &CapsA, min(CapsSize, sizeof(CapsA))); + break; + + case (sizeof(MIDIOUTCAPSW)): + wcsncpy_s(CapsW.szPname, DevName, MAXPNAMELEN); + CapsW.dwSupport = this->Support; + CapsW.wChannelMask = 0xFFFF; + CapsW.wMid = this->ManufacturerID; + CapsW.wPid = this->ProductID; + CapsW.wTechnology = this->Technology; + CapsW.wNotes = 65535; + CapsW.wVoices = 65535; + CapsW.vDriverVersion = MAKEWORD(6, 2); + memcpy((LPMIDIOUTCAPSW)CapsPointer, &CapsW, min(CapsSize, sizeof(CapsW))); + break; + + case (sizeof(MIDIOUTCAPS2A)): + wcstombs_s(&WCSTSRetVal, Caps2A.szPname, sizeof(Caps2A.szPname), DevName, MAXPNAMELEN); + Caps2A.dwSupport = this->Support; + Caps2A.wChannelMask = 0xFFFF; + Caps2A.wMid = this->ManufacturerID; + Caps2A.wPid = this->ProductID; + Caps2A.wTechnology = this->Technology; + Caps2A.wNotes = 65535; + Caps2A.wVoices = 65535; + Caps2A.vDriverVersion = MAKEWORD(6, 2); + memcpy((LPMIDIOUTCAPS2A)CapsPointer, &Caps2A, min(CapsSize, sizeof(Caps2A))); + break; + + case (sizeof(MIDIOUTCAPS2W)): + wcsncpy_s(Caps2W.szPname, DevName, MAXPNAMELEN); + Caps2W.dwSupport = this->Support; + Caps2W.wChannelMask = 0xFFFF; + Caps2W.wMid = this->ManufacturerID; + Caps2W.wPid = this->ProductID; + Caps2W.wTechnology = this->Technology; + Caps2W.wNotes = 65535; + Caps2W.wVoices = 65535; + Caps2W.vDriverVersion = MAKEWORD(6, 2); + memcpy((LPMIDIOUTCAPS2W)CapsPointer, &Caps2W, min(CapsSize, sizeof(Caps2W))); + break; + } + + LOG(MaskErr, L"Caps have been shared with the app."); + return MMSYSERR_NOERROR; +} + +bool WinDriver::DriverCallback::PrepareCallbackFunction(MIDIOPENDESC* OpInfStruct, DWORD CallbackMode) { + // Save the pointer's address to memory + this->WMMHandle = OpInfStruct->hMidi; + + // Check if the app wants the driver to do callbacks + if (CallbackMode != CALLBACK_NULL) { + if (OpInfStruct->dwCallback != 0) { + this->Callback = OpInfStruct->dwCallback; + this->CallbackMode = CallbackMode; + this->Instance = OpInfStruct->dwInstance; + } + + // If callback mode is specified but no callback address is specified, abort the initialization + else { + NERROR(CallbackErr, L"No memory address has been specified for the callback function.", false); + return false; + } + } + + return true; +} + +bool WinDriver::DriverCallback::ClearCallbackFunction() { + this->WMMHandle = nullptr; + this->Callback = 0; + this->CallbackMode = CALLBACK_NULL; + this->Instance = 0; + + return true; +} + +void WinDriver::DriverCallback::CallbackFunction(DWORD Message, DWORD_PTR Arg1, DWORD_PTR Arg2) { + WMMC Callback = nullptr; + int ReturnMessage = 0; + + switch (this->CallbackMode & CALLBACK_TYPEMASK) { + + case CALLBACK_FUNCTION: // Use a custom function to notify the app + // Use the app's custom function to send the callback + (*(WMMC)this->Callback)((HMIDIOUT)(this->WMMHandle), Message, this->Instance, Arg1, Arg2); + break; + + case CALLBACK_EVENT: // Set an event to notify the app + ReturnMessage = SetEvent((HANDLE)(this->Callback)); + break; + + case CALLBACK_THREAD: // Send a message to a thread to notify the app + ReturnMessage = PostThreadMessage((DWORD)(this->Callback), Message, Arg1, Arg2); + break; + + case CALLBACK_WINDOW: // Send a message to the app's main window + ReturnMessage = PostMessage((HWND)(this->Callback), Message, Arg1, Arg2); + break; + + default: // stub + break; + + } +} + +bool WinDriver::DriverComponent::SetDriverHandle(HDRVR Handle) { + // The app tried to initialize the driver with no pointer? + if (Handle == nullptr) { + NERROR(DrvErr, L"A null pointer has been passed to the function.", true); + return false; + } + + // We already have the same pointer in memory. + if (this->DrvHandle == Handle) { + LOG(DrvErr, L"We already have the handle stored in memory. The app has Alzheimer's I guess?"); + return true; + } + + // A pointer is already stored in the variable, UnSetDriverHandle hasn't been called + if (this->DrvHandle != nullptr) { + NERROR(DrvErr, L"DrvHandle has been set in a previous call and not freed.", false); + return false; + } + + // All good, save the pointer to a local variable and return true + this->DrvHandle = Handle; + return true; +} + +bool WinDriver::DriverComponent::UnsetDriverHandle() { + // Warn through stdout if the app is trying to free the driver twice + if (this->DrvHandle == nullptr) + LOG(DrvErr, L"The application called UnsetDriverHandle even though there's no handle set. Bad design?"); + + // Free the driver by setting the local variable to nullptr, then return true + this->DrvHandle = nullptr; + return true; +} + +bool WinDriver::DriverComponent::OpenDriver(MIDIOPENDESC* OpInfStruct, DWORD CallbackMode, DWORD_PTR CookedPlayerAddress) { + if (OpInfStruct->hMidi == nullptr) { + NERROR(DrvErr, L"No valid HMIDI pointer has been specified.", false); + return false; + } + + // Check if the app wants a cooked player + if (CallbackMode & 0x00000002L) { + if (CookedPlayerAddress == NULL) { + NERROR(DrvErr, L"No memory address has been specified for the MIDI_IO_COOKED player.", false); + return false; + } + // stub + } + + // Everything is hunky-dory, proceed + return true; +} + +bool WinDriver::DriverComponent::CloseDriver() { + // stub + return true; +} + +#endif \ No newline at end of file diff --git a/OmniMIDIv2/WDMDrv.h b/OmniMIDIv2/WDMDrv.h new file mode 100644 index 00000000..6eb11aee --- /dev/null +++ b/OmniMIDIv2/WDMDrv.h @@ -0,0 +1,85 @@ +/* +OmniMIDI v15+ (Rewrite) for Windows NT + +This file contains the required code to run the driver under Windows 7 SP1 and later. +This file is useful only if you want to compile the driver under Windows, it's not needed for Linux/macOS porting. +*/ + +#ifndef _WDMDRV_H +#define _WDMDRV_H + +#pragma once + +#include +#include +#include +#include +#include +#include "ErrSys.h" + +using namespace std; + +namespace WinDriver { + typedef VOID(CALLBACK* WMMC)(HMIDIOUT, DWORD, DWORD_PTR, DWORD_PTR, DWORD_PTR); + + class DriverMask { + private: + const wchar_t* TemplateName = L"OmniMIDI (Port %d)\0"; + + unsigned short ManufacturerID = 0xFFFF; + unsigned short ProductID = 0xFFFF; + unsigned short Technology = MOD_SWSYNTH; + unsigned short Support = MIDICAPS_VOLUME; + + ErrorSystem::WinErr MaskErr; + + public: + // Change settings + bool ChangeSettings(short, short, short, short); + unsigned long GiveCaps(UINT, PVOID, DWORD); + }; + + class DriverCallback { + + private: + HMIDI WMMHandle = nullptr; + DWORD CallbackMode = 0; + DWORD_PTR Callback = 0; + DWORD_PTR Instance = 0; + + ErrorSystem::WinErr CallbackErr; + + public: + // Callbacks + bool PrepareCallbackFunction(MIDIOPENDESC*, DWORD); + bool ClearCallbackFunction(); + void CallbackFunction(DWORD, DWORD_PTR, DWORD_PTR); + + }; + + class DriverComponent { + + private: + HDRVR DrvHandle = nullptr; + HMODULE LibHandle = nullptr; + + ErrorSystem::WinErr DrvErr; + + public: + + // Opening and closing the driver + bool SetDriverHandle(HDRVR); + bool UnsetDriverHandle(); + + // Setting the driver's pointer for the app + bool OpenDriver(MIDIOPENDESC*, DWORD, DWORD_PTR); + bool CloseDriver(); + }; + + class Blacklist { + private: + + }; +} + +#endif \ No newline at end of file diff --git a/OmniMIDIv2/WDMEntry.cpp b/OmniMIDIv2/WDMEntry.cpp new file mode 100644 index 00000000..23fd76c2 --- /dev/null +++ b/OmniMIDIv2/WDMEntry.cpp @@ -0,0 +1,125 @@ +/* +OmniMIDI v15+ (Rewrite) for Windows NT + +This file contains the required code to run the driver under Windows 7 SP1 and later. +This file is useful only if you want to compile the driver under Windows, it's not needed for Linux/macOS porting. +*/ + +#include "pch.h" +#include "WDMEntry.h" + +static ErrorSystem::WinErr WDMErr; +static WinDriver::DriverCallback fDriverCallback; +static WinDriver::DriverComponent DriverComponent; +static WinDriver::DriverMask DriverMask; +static OmniMIDI::SynthModule SynthModule; + +extern "C" __declspec(dllexport) +BOOL APIENTRY DllMain(HMODULE hModule, DWORD ReasonForCall, LPVOID lpReserved) +{ + switch (ReasonForCall) + { + case DLL_PROCESS_ATTACH: + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + case DLL_PROCESS_DETACH: + break; + } + return TRUE; +} + +extern "C" __declspec(dllexport) +LRESULT WINAPI DriverProc(DWORD DriverIdentifier, HDRVR DriverHandle, UINT Message, LONG Param1, LONG Param2) { + switch (Message) { + case DRV_LOAD: + return DriverComponent.SetDriverHandle(DriverHandle); + case DRV_FREE: + return DriverComponent.UnsetDriverHandle(); + + case DRV_OPEN: + case DRV_CLOSE: + return DRVCNF_OK; + + case DRV_QUERYCONFIGURE: + return DRVCNF_CANCEL; + + case DRV_ENABLE: + case DRV_DISABLE: + return DRVCNF_OK; + + case DRV_INSTALL: + return DRVCNF_OK; + + case DRV_REMOVE: + return DRVCNF_OK; + } + + return DefDriverProc(DriverIdentifier, DriverHandle, Message, Param1, Param2); +} + +extern "C" __declspec(dllexport) +MMRESULT WINAPI modMessage(UINT DeviceID, UINT Message, DWORD_PTR UserPointer, DWORD_PTR Param1, DWORD_PTR Param2) { + LPMIDIHDR hdr = nullptr; + MMRESULT r = MMSYSERR_NOERROR; + + switch (Message) { + case MODM_DATA: + return (SynthModule.PlayShortEvent((DWORD)Param1) == SYNTH_OK) ? MMSYSERR_NOERROR : MMSYSERR_INVALPARAM; + + case MODM_LONGDATA: + hdr = ((LPMIDIHDR)Param1); + r = SynthModule.PlayLongEvent(hdr->lpData, hdr->dwBytesRecorded); + fDriverCallback.CallbackFunction(MOM_DONE, (DWORD)Param1, 0); + return (r == SYNTH_OK) ? MMSYSERR_NOERROR : MMSYSERR_INVALPARAM; + + case MODM_RESET: + return (SynthModule.PlayShortEvent(0x7FFFFFFF) == SYNTH_OK) ? MMSYSERR_NOERROR : MMSYSERR_INVALPARAM; + + case MODM_OPEN: + if (SynthModule.LoadSynthModule()) { + if (SynthModule.StartSynthModule()) { + if (fDriverCallback.PrepareCallbackFunction((LPMIDIOPENDESC)Param1, (DWORD)Param2)) + { + fDriverCallback.CallbackFunction(MOM_OPEN, 0, 0); + return MMSYSERR_NOERROR; + } + } + SynthModule.StopSynthModule(); + } + SynthModule.UnloadSynthModule(); + + LOG(WDMErr, L"MODM_OPEN failed."); + return MMSYSERR_NOTENABLED; + + case MODM_CLOSE: + if (SynthModule.StopSynthModule()) { + // if (SynthModule.UnloadSynthModule()) { + fDriverCallback.CallbackFunction(MOM_CLOSE, 0, 0); + if (fDriverCallback.ClearCallbackFunction()) + { + return MMSYSERR_NOERROR; + } + // } + } + + LOG(WDMErr, L"MODM_CLOSE failed."); + return MMSYSERR_ALLOCATED; + + case MODM_GETNUMDEVS: + return 1; + + case MODM_GETDEVCAPS: + return DriverMask.GiveCaps(DeviceID, (PVOID)Param1, (DWORD)Param2); + + case MODM_SETVOLUME: + case MODM_GETVOLUME: + case MODM_CACHEPATCHES: + case MODM_CACHEDRUMPATCHES: + case DRV_QUERYDEVICEINTERFACESIZE: + case DRV_QUERYDEVICEINTERFACE: + return MMSYSERR_NOERROR; + + default: + return MMSYSERR_NOTSUPPORTED; + } +} \ No newline at end of file diff --git a/OmniMIDIv2/WDMEntry.h b/OmniMIDIv2/WDMEntry.h new file mode 100644 index 00000000..2e7e5641 --- /dev/null +++ b/OmniMIDIv2/WDMEntry.h @@ -0,0 +1,58 @@ +/* +OmniMIDI v15+ (Rewrite) for Windows NT + +This file contains the required code to run the driver under Windows 7 SP1 and later. +This file is useful only if you want to compile the driver under Windows, it's not needed for Linux/macOS porting. +*/ + +#ifndef _WDMENTRY_H +#define _WDMENTRY_H + +#pragma once + +#include +#include +#include +#include +#include "ErrSys.h" +#include "WDMDrv.h" +#include "SynthMain.h" + +#ifdef DEFINE_DEVPROPKEY +#undef DEFINE_DEVPROPKEY +#endif +#define DEFINE_DEVPROPKEY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8, pid) EXTERN_C const DEVPROPKEY DECLSPEC_SELECTANY name = { { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }, pid } + +// Copied from devpkey.h in the WinDDK +DEFINE_DEVPROPKEY(DEVPKEY_Device_BusReportedDeviceDesc, 0x540b947e, 0x8b40, 0x45bc, 0xa8, 0xa2, 0x6a, 0x0b, 0x89, 0x4c, 0xbd, 0xa2, 4); // DEVPROP_TYPE_STRING +DEFINE_DEVPROPKEY(DEVPKEY_Device_ContainerId, 0x8c7ed206, 0x3f8a, 0x4827, 0xb3, 0xab, 0xae, 0x9e, 0x1f, 0xae, 0xfc, 0x6c, 2); // DEVPROP_TYPE_GUID +DEFINE_DEVPROPKEY(DEVPKEY_Device_FriendlyName, 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 14); // DEVPROP_TYPE_STRING +DEFINE_DEVPROPKEY(DEVPKEY_DeviceDisplay_Category, 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 0x5a); // DEVPROP_TYPE_STRING_LIST +DEFINE_DEVPROPKEY(DEVPKEY_Device_LocationInfo, 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 15); // DEVPROP_TYPE_STRING +DEFINE_DEVPROPKEY(DEVPKEY_Device_Manufacturer, 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 13); // DEVPROP_TYPE_STRING +DEFINE_DEVPROPKEY(DEVPKEY_Device_SecuritySDS, 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 26); // DEVPROP_TYPE_SECURITY_DESCRIPTOR_STRING + +// IsWoW64Process +typedef WINBASEAPI BOOL(WINAPI* fIW64P)(_In_ HANDLE, _Out_ PBOOL); + +const GUID DevGUID = GUID_DEVCLASS_MEDIA; +const wchar_t DEVICE_NAME_MEDIA[] = L"MEDIA"; +const wchar_t DEVICE_DESCRIPTION[] = L"OmniMIDI for Windows NT"; +const wchar_t DRIVER_PROVIDER_NAME[] = L"Keppy's Software"; +const wchar_t DRIVER_CLASS_PROP_DRIVER_DESC[] = L"DriverDesc"; +const wchar_t DRIVER_CLASS_PROP_PROVIDER_NAME[] = L"ProviderName"; +const wchar_t DRIVER_CLASS_SUBKEY_DRIVERS[] = L"Drivers"; +const wchar_t DRIVER_CLASS_PROP_SUBCLASSES[] = L"SubClasses"; +const wchar_t DRIVER_CLASS_SUBCLASSES[] = L"midi"; +const wchar_t DRIVER_SUBCLASS_SUBKEYS[] = L"midi\\OmniMIDI.dll"; +const wchar_t DRIVER_SUBCLASS_PROP_DRIVER[] = L"Driver"; +const wchar_t DRIVER_SUBCLASS_PROP_DESCRIPTION[] = L"Description"; +const wchar_t DRIVER_SUBCLASS_PROP_ALIAS[] = L"Alias"; +const wchar_t SHAKRA_DRIVER_NAME[] = L"OmniMIDI.dll"; + +static bool DriverBusy = false; + +// MIDI REG +const wchar_t MIDI_REGISTRY_ENTRY_TEMPLATE[] = L"midi%d"; + +#endif \ No newline at end of file diff --git a/OmniMIDIv2/bass.cpp b/OmniMIDIv2/bass.cpp new file mode 100644 index 00000000..9a576531 --- /dev/null +++ b/OmniMIDIv2/bass.cpp @@ -0,0 +1,129 @@ +/* + + OmniMIDI v15+ (Rewrite) for Windows NT + + This file contains the required code to run the driver under Windows 7 SP1 and later. + This file is useful only if you want to compile the driver under Windows, it's not needed for Linux/macOS porting. + +*/ + +#include "pch.h" +#include + +BOOL(WINAPI* BASS_SetConfig)(DWORD option, DWORD value) = 0; +DWORD(WINAPI* BASS_GetConfig)(DWORD option) = 0; +BOOL(WINAPI* BASS_SetConfigPtr)(DWORD option, const void* value) = 0; +const void* (WINAPI* BASS_GetConfigPtr)(DWORD option) = 0; +DWORD(WINAPI* BASS_GetVersion)(void) = 0; +int (WINAPI* BASS_ErrorGetCode)(void) = 0; + +BOOL(WINAPI* BASS_GetDeviceInfo)(DWORD device, BASS_DEVICEINFO* info) = 0; +#if defined(_WIN32) && !defined(_WIN32_WCE) && !(defined(WINAPI_FAMILY) && WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP) +BOOL(WINAPI* BASS_Init)(int device, DWORD freq, DWORD flags, HWND win, const void* dsguid) = 0; +#else +BOOL(WINAPI* BASS_Init)(int device, DWORD freq, DWORD flags, void* win, const void* dsguid) = 0; +#endif +BOOL(WINAPI* BASS_Free)(void) = 0; +BOOL(WINAPI* BASS_SetDevice)(DWORD device) = 0; +DWORD(WINAPI* BASS_GetDevice)(void) = 0; +BOOL(WINAPI* BASS_GetInfo)(BASS_INFO* info) = 0; +BOOL(WINAPI* BASS_Start)(void) = 0; +BOOL(WINAPI* BASS_Stop)(void) = 0; +BOOL(WINAPI* BASS_Pause)(void) = 0; +DWORD(WINAPI* BASS_IsStarted)(void) = 0; +BOOL(WINAPI* BASS_Update)(DWORD length) = 0; +float (WINAPI* BASS_GetCPU)(void) = 0; +BOOL(WINAPI* BASS_SetVolume)(float volume) = 0; +float (WINAPI* BASS_GetVolume)(void) = 0; +#if defined(_WIN32) && !defined(_WIN32_WCE) && !(defined(WINAPI_FAMILY) && WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP) +void* (WINAPI* BASS_GetDSoundObject)(DWORD object) = 0; +#endif + +BOOL(WINAPI* BASS_Set3DFactors)(float distf, float rollf, float doppf) = 0; +BOOL(WINAPI* BASS_Get3DFactors)(float* distf, float* rollf, float* doppf) = 0; +BOOL(WINAPI* BASS_Set3DPosition)(const BASS_3DVECTOR* pos, const BASS_3DVECTOR* vel, const BASS_3DVECTOR* front, const BASS_3DVECTOR* top) = 0; +BOOL(WINAPI* BASS_Get3DPosition)(BASS_3DVECTOR* pos, BASS_3DVECTOR* vel, BASS_3DVECTOR* front, BASS_3DVECTOR* top) = 0; +void (WINAPI* BASS_Apply3D)(void) = 0; + +HPLUGIN(WINAPI* BASS_PluginLoad)(const char* file, DWORD flags) = 0; +BOOL(WINAPI* BASS_PluginFree)(HPLUGIN handle) = 0; +BOOL(WINAPI* BASS_PluginEnable)(HPLUGIN handle, BOOL enable) = 0; +const BASS_PLUGININFO* (WINAPI* BASS_PluginGetInfo)(HPLUGIN handle) = 0; + +HSAMPLE(WINAPI* BASS_SampleLoad)(BOOL mem, const void* file, QWORD offset, DWORD length, DWORD max, DWORD flags) = 0; +HSAMPLE(WINAPI* BASS_SampleCreate)(DWORD length, DWORD freq, DWORD chans, DWORD max, DWORD flags) = 0; +BOOL(WINAPI* BASS_SampleFree)(HSAMPLE handle) = 0; +BOOL(WINAPI* BASS_SampleSetData)(HSAMPLE handle, const void* buffer) = 0; +BOOL(WINAPI* BASS_SampleGetData)(HSAMPLE handle, void* buffer) = 0; +BOOL(WINAPI* BASS_SampleGetInfo)(HSAMPLE handle, BASS_SAMPLE* info) = 0; +BOOL(WINAPI* BASS_SampleSetInfo)(HSAMPLE handle, const BASS_SAMPLE* info) = 0; +DWORD(WINAPI* BASS_SampleGetChannel)(HSAMPLE handle, DWORD flags) = 0; +DWORD(WINAPI* BASS_SampleGetChannels)(HSAMPLE handle, HCHANNEL* channels) = 0; +BOOL(WINAPI* BASS_SampleStop)(HSAMPLE handle) = 0; + +HSTREAM(WINAPI* BASS_StreamCreate)(DWORD freq, DWORD chans, DWORD flags, STREAMPROC* proc, void* user) = 0; +HSTREAM(WINAPI* BASS_StreamCreateFile)(BOOL mem, const void* file, QWORD offset, QWORD length, DWORD flags) = 0; +HSTREAM(WINAPI* BASS_StreamCreateURL)(const char* url, DWORD offset, DWORD flags, DOWNLOADPROC* proc, void* user) = 0; +HSTREAM(WINAPI* BASS_StreamCreateFileUser)(DWORD system, DWORD flags, const BASS_FILEPROCS* proc, void* user) = 0; +BOOL(WINAPI* BASS_StreamFree)(HSTREAM handle) = 0; +QWORD(WINAPI* BASS_StreamGetFilePosition)(HSTREAM handle, DWORD mode) = 0; +DWORD(WINAPI* BASS_StreamPutData)(HSTREAM handle, const void* buffer, DWORD length) = 0; +DWORD(WINAPI* BASS_StreamPutFileData)(HSTREAM handle, const void* buffer, DWORD length) = 0; + +HMUSIC(WINAPI* BASS_MusicLoad)(BOOL mem, const void* file, QWORD offset, DWORD length, DWORD flags, DWORD freq) = 0; +BOOL(WINAPI* BASS_MusicFree)(HMUSIC handle) = 0; + +BOOL(WINAPI* BASS_RecordGetDeviceInfo)(DWORD device, BASS_DEVICEINFO* info) = 0; +BOOL(WINAPI* BASS_RecordInit)(int device) = 0; +BOOL(WINAPI* BASS_RecordFree)(void) = 0; +BOOL(WINAPI* BASS_RecordSetDevice)(DWORD device) = 0; +DWORD(WINAPI* BASS_RecordGetDevice)(void) = 0; +BOOL(WINAPI* BASS_RecordGetInfo)(BASS_RECORDINFO* info) = 0; +const char* (WINAPI* BASS_RecordGetInputName)(int input) = 0; +BOOL(WINAPI* BASS_RecordSetInput)(int input, DWORD flags, float volume) = 0; +DWORD(WINAPI* BASS_RecordGetInput)(int input, float* volume) = 0; +HRECORD(WINAPI* BASS_RecordStart)(DWORD freq, DWORD chans, DWORD flags, RECORDPROC* proc, void* user) = 0; + +double (WINAPI* BASS_ChannelBytes2Seconds)(DWORD handle, QWORD pos) = 0; +QWORD(WINAPI* BASS_ChannelSeconds2Bytes)(DWORD handle, double pos) = 0; +DWORD(WINAPI* BASS_ChannelGetDevice)(DWORD handle) = 0; +BOOL(WINAPI* BASS_ChannelSetDevice)(DWORD handle, DWORD device) = 0; +DWORD(WINAPI* BASS_ChannelIsActive)(DWORD handle) = 0; +BOOL(WINAPI* BASS_ChannelGetInfo)(DWORD handle, BASS_CHANNELINFO* info) = 0; +const char* (WINAPI* BASS_ChannelGetTags)(DWORD handle, DWORD tags) = 0; +DWORD(WINAPI* BASS_ChannelFlags)(DWORD handle, DWORD flags, DWORD mask) = 0; +BOOL(WINAPI* BASS_ChannelLock)(DWORD handle, BOOL lock) = 0; +BOOL(WINAPI* BASS_ChannelFree)(DWORD handle) = 0; +BOOL(WINAPI* BASS_ChannelPlay)(DWORD handle, BOOL restart) = 0; +BOOL(WINAPI* BASS_ChannelStop)(DWORD handle) = 0; +BOOL(WINAPI* BASS_ChannelPause)(DWORD handle) = 0; +BOOL(WINAPI* BASS_ChannelUpdate)(DWORD handle, DWORD length) = 0; +BOOL(WINAPI* BASS_ChannelSetAttribute)(DWORD handle, DWORD attrib, float value) = 0; +BOOL(WINAPI* BASS_ChannelGetAttribute)(DWORD handle, DWORD attrib, float* value) = 0; +BOOL(WINAPI* BASS_ChannelSlideAttribute)(DWORD handle, DWORD attrib, float value, DWORD time) = 0; +BOOL(WINAPI* BASS_ChannelIsSliding)(DWORD handle, DWORD attrib) = 0; +BOOL(WINAPI* BASS_ChannelSetAttributeEx)(DWORD handle, DWORD attrib, void* value, DWORD size) = 0; +DWORD(WINAPI* BASS_ChannelGetAttributeEx)(DWORD handle, DWORD attrib, void* value, DWORD size) = 0; +BOOL(WINAPI* BASS_ChannelSet3DAttributes)(DWORD handle, int mode, float min, float max, int iangle, int oangle, float outvol) = 0; +BOOL(WINAPI* BASS_ChannelGet3DAttributes)(DWORD handle, DWORD* mode, float* min, float* max, DWORD* iangle, DWORD* oangle, float* outvol) = 0; +BOOL(WINAPI* BASS_ChannelSet3DPosition)(DWORD handle, const BASS_3DVECTOR* pos, const BASS_3DVECTOR* orient, const BASS_3DVECTOR* vel) = 0; +BOOL(WINAPI* BASS_ChannelGet3DPosition)(DWORD handle, BASS_3DVECTOR* pos, BASS_3DVECTOR* orient, BASS_3DVECTOR* vel) = 0; +QWORD(WINAPI* BASS_ChannelGetLength)(DWORD handle, DWORD mode) = 0; +BOOL(WINAPI* BASS_ChannelSetPosition)(DWORD handle, QWORD pos, DWORD mode) = 0; +QWORD(WINAPI* BASS_ChannelGetPosition)(DWORD handle, DWORD mode) = 0; +DWORD(WINAPI* BASS_ChannelGetLevel)(DWORD handle) = 0; +BOOL(WINAPI* BASS_ChannelGetLevelEx)(DWORD handle, float* levels, float length, DWORD flags) = 0; +DWORD(WINAPI* BASS_ChannelGetData)(DWORD handle, void* buffer, DWORD length) = 0; +HSYNC(WINAPI* BASS_ChannelSetSync)(DWORD handle, DWORD type, QWORD param, SYNCPROC* proc, void* user) = 0; +BOOL(WINAPI* BASS_ChannelRemoveSync)(DWORD handle, HSYNC sync) = 0; +BOOL(WINAPI* BASS_ChannelSetLink)(DWORD handle, DWORD chan) = 0; +BOOL(WINAPI* BASS_ChannelRemoveLink)(DWORD handle, DWORD chan) = 0; +HDSP(WINAPI* BASS_ChannelSetDSP)(DWORD handle, DSPPROC* proc, void* user, int priority) = 0; +BOOL(WINAPI* BASS_ChannelRemoveDSP)(DWORD handle, HDSP dsp) = 0; +HFX(WINAPI* BASS_ChannelSetFX)(DWORD handle, DWORD type, int priority) = 0; +BOOL(WINAPI* BASS_ChannelRemoveFX)(DWORD handle, HFX fx) = 0; + +BOOL(WINAPI* BASS_FXSetParameters)(HFX handle, const void* params) = 0; +BOOL(WINAPI* BASS_FXGetParameters)(HFX handle, void* params) = 0; +BOOL(WINAPI* BASS_FXSetPriority)(HFX handle, int priority) = 0; +BOOL(WINAPI* BASS_FXReset)(DWORD handle) = 0; \ No newline at end of file diff --git a/OmniMIDIv2/bassmidi.cpp b/OmniMIDIv2/bassmidi.cpp new file mode 100644 index 00000000..8829ee21 --- /dev/null +++ b/OmniMIDIv2/bassmidi.cpp @@ -0,0 +1,56 @@ +/* + + OmniMIDI v15+ (Rewrite) for Windows NT + + This file contains the required code to run the driver under Windows 7 SP1 and later. + This file is useful only if you want to compile the driver under Windows, it's not needed for Linux/macOS porting. + +*/ + +#include "pch.h" +#include + +DWORD(WINAPI* BASS_MIDI_GetVersion)(void) = 0; + +HSTREAM(WINAPI* BASS_MIDI_StreamCreate)(DWORD channels, DWORD flags, DWORD freq) = 0; +HSTREAM(WINAPI* BASS_MIDI_StreamCreateFile)(BOOL mem, const void* file, QWORD offset, QWORD length, DWORD flags, DWORD freq) = 0; +HSTREAM(WINAPI* BASS_MIDI_StreamCreateURL)(const char* url, DWORD offset, DWORD flags, DOWNLOADPROC* proc, void* user, DWORD freq) = 0; +HSTREAM(WINAPI* BASS_MIDI_StreamCreateFileUser)(DWORD system, DWORD flags, const BASS_FILEPROCS* procs, void* user, DWORD freq) = 0; +HSTREAM(WINAPI* BASS_MIDI_StreamCreateEvents)(const BASS_MIDI_EVENT* events, DWORD ppqn, DWORD flags, DWORD freq) = 0; +BOOL(WINAPI* BASS_MIDI_StreamGetMark)(HSTREAM handle, DWORD type, DWORD index, BASS_MIDI_MARK* mark) = 0; +DWORD(WINAPI* BASS_MIDI_StreamGetMarks)(HSTREAM handle, int track, DWORD type, BASS_MIDI_MARK* marks) = 0; +BOOL(WINAPI* BASS_MIDI_StreamSetFonts)(HSTREAM handle, const void* fonts, DWORD count) = 0; +DWORD(WINAPI* BASS_MIDI_StreamGetFonts)(HSTREAM handle, void* fonts, DWORD count) = 0; +BOOL(WINAPI* BASS_MIDI_StreamLoadSamples)(HSTREAM handle) = 0; +BOOL(WINAPI* BASS_MIDI_StreamEvent)(HSTREAM handle, DWORD chan, DWORD event, DWORD param) = 0; +DWORD(WINAPI* BASS_MIDI_StreamEvents)(HSTREAM handle, DWORD mode, const void* events, DWORD length) = 0; +DWORD(WINAPI* BASS_MIDI_StreamGetEvent)(HSTREAM handle, DWORD chan, DWORD event) = 0; +DWORD(WINAPI* BASS_MIDI_StreamGetEvents)(HSTREAM handle, int track, DWORD filter, BASS_MIDI_EVENT* events) = 0; +DWORD(WINAPI* BASS_MIDI_StreamGetEventsEx)(HSTREAM handle, int track, DWORD filter, BASS_MIDI_EVENT* events, DWORD start, DWORD count) = 0; +BOOL(WINAPI* BASS_MIDI_StreamGetPreset)(HSTREAM handle, DWORD chan, BASS_MIDI_FONT* font) = 0; +HSTREAM(WINAPI* BASS_MIDI_StreamGetChannel)(HSTREAM handle, DWORD chan) = 0; +BOOL(WINAPI* BASS_MIDI_StreamSetFilter)(HSTREAM handle, BOOL seeking, MIDIFILTERPROC* proc, void* user) = 0; + +HSOUNDFONT(WINAPI* BASS_MIDI_FontInit)(const void* file, DWORD flags) = 0; +HSOUNDFONT(WINAPI* BASS_MIDI_FontInitUser)(const BASS_FILEPROCS* procs, void* user, DWORD flags) = 0; +BOOL(WINAPI* BASS_MIDI_FontFree)(HSOUNDFONT handle) = 0; +BOOL(WINAPI* BASS_MIDI_FontGetInfo)(HSOUNDFONT handle, BASS_MIDI_FONTINFO* info) = 0; +BOOL(WINAPI* BASS_MIDI_FontGetPresets)(HSOUNDFONT handle, DWORD* presets) = 0; +const char* (WINAPI* BASS_MIDI_FontGetPreset)(HSOUNDFONT handle, int preset, int bank) = 0; +BOOL(WINAPI* BASS_MIDI_FontLoad)(HSOUNDFONT handle, int preset, int bank) = 0; +BOOL(WINAPI* BASS_MIDI_FontLoadEx)(HSOUNDFONT handle, int preset, int bank, DWORD length, DWORD flags) = 0; +BOOL(WINAPI* BASS_MIDI_FontUnload)(HSOUNDFONT handle, int preset, int bank) = 0; +BOOL(WINAPI* BASS_MIDI_FontCompact)(HSOUNDFONT handle) = 0; +BOOL(WINAPI* BASS_MIDI_FontPack)(HSOUNDFONT handle, const void* outfile, const void* encoder, DWORD flags) = 0; +BOOL(WINAPI* BASS_MIDI_FontUnpack)(HSOUNDFONT handle, const void* outfile, DWORD flags) = 0; +DWORD(WINAPI* BASS_MIDI_FontFlags)(HSOUNDFONT handle, DWORD flags, DWORD mask) = 0; +BOOL(WINAPI* BASS_MIDI_FontSetVolume)(HSOUNDFONT handle, float volume) = 0; +float (WINAPI* BASS_MIDI_FontGetVolume)(HSOUNDFONT handle) = 0; + +DWORD(WINAPI* BASS_MIDI_ConvertEvents)(const BYTE* data, DWORD length, BASS_MIDI_EVENT* events, DWORD count, DWORD flags) = 0; + +BOOL(WINAPI* BASS_MIDI_InGetDeviceInfo)(DWORD device, BASS_MIDI_DEVICEINFO* info) = 0; +BOOL(WINAPI* BASS_MIDI_InInit)(DWORD device, MIDIINPROC* proc, void* user) = 0; +BOOL(WINAPI* BASS_MIDI_InFree)(DWORD device) = 0; +BOOL(WINAPI* BASS_MIDI_InStart)(DWORD device) = 0; +BOOL(WINAPI* BASS_MIDI_InStop)(DWORD device) = 0; \ No newline at end of file diff --git a/OmniMIDIv2/framework.h b/OmniMIDIv2/framework.h new file mode 100644 index 00000000..54b83e94 --- /dev/null +++ b/OmniMIDIv2/framework.h @@ -0,0 +1,5 @@ +#pragma once + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +// Windows Header Files +#include diff --git a/OmniMIDIv2/inc/bass.h b/OmniMIDIv2/inc/bass.h new file mode 100644 index 00000000..63f3a978 --- /dev/null +++ b/OmniMIDIv2/inc/bass.h @@ -0,0 +1,1094 @@ +/* + + OmniMIDI v15+ (Rewrite) for Windows NT + + This file contains the required code to run the driver under Windows 7 SP1 and later. + This file is useful only if you want to compile the driver under Windows, it's not needed for Linux/macOS porting. + This header has been modified to work properly with the new rewrite. + + Original header: BASS 2.4 C/C++ header file + Copyright (c) 1999-2021 Un4seen Developments Ltd. + + See the BASS.CHM file for more detailed documentation + +*/ + +#pragma once + +#ifndef _BASS_H +#define _BASS_H + +#ifdef _WIN32 +#ifdef WINAPI_FAMILY +#include +#endif +#include +typedef unsigned __int64 QWORD; +#else +#include +#define WINAPI +#define CALLBACK +typedef uint8_t BYTE; +typedef uint16_t WORD; +typedef uint32_t DWORD; +typedef uint64_t QWORD; +#ifdef __OBJC__ +typedef int BOOL32; +#define BOOL BOOL32 // override objc's BOOL +#else +typedef int BOOL; +#endif +#ifndef TRUE +#define TRUE 1 +#define FALSE 0 +#endif +#define LOBYTE(a) (BYTE)(a) +#define HIBYTE(a) (BYTE)((a)>>8) +#define LOWORD(a) (WORD)(a) +#define HIWORD(a) (WORD)((a)>>16) +#define MAKEWORD(a,b) (WORD)(((a)&0xff)|((b)<<8)) +#define MAKELONG(a,b) (DWORD)(((a)&0xffff)|((b)<<16)) +#endif + +#define BASSVERSION 0x204 // API version +#define BASSVERSIONTEXT "2.4" +#define BASSVERSIONTEXTW _T(BASSVERSIONTEXT) + +#define BASSDEF(f) WINAPI f + +typedef DWORD HMUSIC; // MOD music handle +typedef DWORD HSAMPLE; // sample handle +typedef DWORD HCHANNEL; // sample playback handle +typedef DWORD HSTREAM; // sample stream handle +typedef DWORD HRECORD; // recording handle +typedef DWORD HSYNC; // synchronizer handle +typedef DWORD HDSP; // DSP handle +typedef DWORD HFX; // effect handle +typedef DWORD HPLUGIN; // plugin handle + +// Error codes returned by BASS_ErrorGetCode +#define BASS_OK 0 // all is OK +#define BASS_ERROR_MEM 1 // memory error +#define BASS_ERROR_FILEOPEN 2 // can't open the file +#define BASS_ERROR_DRIVER 3 // can't find a free/valid driver +#define BASS_ERROR_BUFLOST 4 // the sample buffer was lost +#define BASS_ERROR_HANDLE 5 // invalid handle +#define BASS_ERROR_FORMAT 6 // unsupported sample format +#define BASS_ERROR_POSITION 7 // invalid position +#define BASS_ERROR_INIT 8 // BASS_Init has not been successfully called +#define BASS_ERROR_START 9 // BASS_Start has not been successfully called +#define BASS_ERROR_SSL 10 // SSL/HTTPS support isn't available +#define BASS_ERROR_REINIT 11 // device needs to be reinitialized +#define BASS_ERROR_ALREADY 14 // already initialized/paused/whatever +#define BASS_ERROR_NOTAUDIO 17 // file does not contain audio +#define BASS_ERROR_NOCHAN 18 // can't get a free channel +#define BASS_ERROR_ILLTYPE 19 // an illegal type was specified +#define BASS_ERROR_ILLPARAM 20 // an illegal parameter was specified +#define BASS_ERROR_NO3D 21 // no 3D support +#define BASS_ERROR_NOEAX 22 // no EAX support +#define BASS_ERROR_DEVICE 23 // illegal device number +#define BASS_ERROR_NOPLAY 24 // not playing +#define BASS_ERROR_FREQ 25 // illegal sample rate +#define BASS_ERROR_NOTFILE 27 // the stream is not a file stream +#define BASS_ERROR_NOHW 29 // no hardware voices available +#define BASS_ERROR_EMPTY 31 // the MOD music has no sequence data +#define BASS_ERROR_NONET 32 // no internet connection could be opened +#define BASS_ERROR_CREATE 33 // couldn't create the file +#define BASS_ERROR_NOFX 34 // effects are not available +#define BASS_ERROR_NOTAVAIL 37 // requested data/action is not available +#define BASS_ERROR_DECODE 38 // the channel is/isn't a "decoding channel" +#define BASS_ERROR_DX 39 // a sufficient DirectX version is not installed +#define BASS_ERROR_TIMEOUT 40 // connection timedout +#define BASS_ERROR_FILEFORM 41 // unsupported file format +#define BASS_ERROR_SPEAKER 42 // unavailable speaker +#define BASS_ERROR_VERSION 43 // invalid BASS version (used by add-ons) +#define BASS_ERROR_CODEC 44 // codec is not available/supported +#define BASS_ERROR_ENDED 45 // the channel/file has ended +#define BASS_ERROR_BUSY 46 // the device is busy +#define BASS_ERROR_UNSTREAMABLE 47 // unstreamable file +#define BASS_ERROR_PROTOCOL 48 // unsupported protocol +#define BASS_ERROR_UNKNOWN -1 // some other mystery problem + +// BASS_SetConfig options +#define BASS_CONFIG_BUFFER 0 +#define BASS_CONFIG_UPDATEPERIOD 1 +#define BASS_CONFIG_GVOL_SAMPLE 4 +#define BASS_CONFIG_GVOL_STREAM 5 +#define BASS_CONFIG_GVOL_MUSIC 6 +#define BASS_CONFIG_CURVE_VOL 7 +#define BASS_CONFIG_CURVE_PAN 8 +#define BASS_CONFIG_FLOATDSP 9 +#define BASS_CONFIG_3DALGORITHM 10 +#define BASS_CONFIG_NET_TIMEOUT 11 +#define BASS_CONFIG_NET_BUFFER 12 +#define BASS_CONFIG_PAUSE_NOPLAY 13 +#define BASS_CONFIG_NET_PREBUF 15 +#define BASS_CONFIG_NET_PASSIVE 18 +#define BASS_CONFIG_REC_BUFFER 19 +#define BASS_CONFIG_NET_PLAYLIST 21 +#define BASS_CONFIG_MUSIC_VIRTUAL 22 +#define BASS_CONFIG_VERIFY 23 +#define BASS_CONFIG_UPDATETHREADS 24 +#define BASS_CONFIG_DEV_BUFFER 27 +#define BASS_CONFIG_REC_LOOPBACK 28 +#define BASS_CONFIG_VISTA_TRUEPOS 30 +#define BASS_CONFIG_IOS_SESSION 34 +#define BASS_CONFIG_IOS_MIXAUDIO 34 +#define BASS_CONFIG_DEV_DEFAULT 36 +#define BASS_CONFIG_NET_READTIMEOUT 37 +#define BASS_CONFIG_VISTA_SPEAKERS 38 +#define BASS_CONFIG_IOS_SPEAKER 39 +#define BASS_CONFIG_MF_DISABLE 40 +#define BASS_CONFIG_HANDLES 41 +#define BASS_CONFIG_UNICODE 42 +#define BASS_CONFIG_SRC 43 +#define BASS_CONFIG_SRC_SAMPLE 44 +#define BASS_CONFIG_ASYNCFILE_BUFFER 45 +#define BASS_CONFIG_OGG_PRESCAN 47 +#define BASS_CONFIG_MF_VIDEO 48 +#define BASS_CONFIG_AIRPLAY 49 +#define BASS_CONFIG_DEV_NONSTOP 50 +#define BASS_CONFIG_IOS_NOCATEGORY 51 +#define BASS_CONFIG_VERIFY_NET 52 +#define BASS_CONFIG_DEV_PERIOD 53 +#define BASS_CONFIG_FLOAT 54 +#define BASS_CONFIG_NET_SEEK 56 +#define BASS_CONFIG_AM_DISABLE 58 +#define BASS_CONFIG_NET_PLAYLIST_DEPTH 59 +#define BASS_CONFIG_NET_PREBUF_WAIT 60 +#define BASS_CONFIG_ANDROID_SESSIONID 62 +#define BASS_CONFIG_WASAPI_PERSIST 65 +#define BASS_CONFIG_REC_WASAPI 66 +#define BASS_CONFIG_ANDROID_AAUDIO 67 +#define BASS_CONFIG_SAMPLE_ONEHANDLE 69 +#define BASS_CONFIG_DEV_TIMEOUT 70 +#define BASS_CONFIG_NET_META 71 +#define BASS_CONFIG_NET_RESTRATE 72 + +// BASS_SetConfigPtr options +#define BASS_CONFIG_NET_AGENT 16 +#define BASS_CONFIG_NET_PROXY 17 +#define BASS_CONFIG_IOS_NOTIFY 46 +#define BASS_CONFIG_LIBSSL 64 + +#define BASS_CONFIG_THREAD 0x40000000 // flag: thread-specific setting + +// BASS_CONFIG_IOS_SESSION flags +#define BASS_IOS_SESSION_MIX 1 +#define BASS_IOS_SESSION_DUCK 2 +#define BASS_IOS_SESSION_AMBIENT 4 +#define BASS_IOS_SESSION_SPEAKER 8 +#define BASS_IOS_SESSION_DISABLE 16 + +// BASS_Init flags +#define BASS_DEVICE_8BITS 1 // unused +#define BASS_DEVICE_MONO 2 // mono +#define BASS_DEVICE_3D 4 // unused +#define BASS_DEVICE_16BITS 8 // limit output to 16-bit +#define BASS_DEVICE_REINIT 128 // reinitialize +#define BASS_DEVICE_LATENCY 0x100 // unused +#define BASS_DEVICE_CPSPEAKERS 0x400 // unused +#define BASS_DEVICE_SPEAKERS 0x800 // force enabling of speaker assignment +#define BASS_DEVICE_NOSPEAKER 0x1000 // ignore speaker arrangement +#define BASS_DEVICE_DMIX 0x2000 // use ALSA "dmix" plugin +#define BASS_DEVICE_FREQ 0x4000 // set device sample rate +#define BASS_DEVICE_STEREO 0x8000 // limit output to stereo +#define BASS_DEVICE_HOG 0x10000 // hog/exclusive mode +#define BASS_DEVICE_AUDIOTRACK 0x20000 // use AudioTrack output +#define BASS_DEVICE_DSOUND 0x40000 // use DirectSound output +#define BASS_DEVICE_SOFTWARE 0x80000 // disable hardware/fastpath output + +// DirectSound interfaces (for use with BASS_GetDSoundObject) +#define BASS_OBJECT_DS 1 // IDirectSound +#define BASS_OBJECT_DS3DL 2 // IDirectSound3DListener + +// Device info structure +typedef struct { +#if defined(_WIN32_WCE) || (defined(WINAPI_FAMILY) && WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP) + const wchar_t *name; // description + const wchar_t *driver; // driver +#else + const char *name; // description + const char *driver; // driver +#endif + DWORD flags; +} BASS_DEVICEINFO; + +// BASS_DEVICEINFO flags +#define BASS_DEVICE_ENABLED 1 +#define BASS_DEVICE_DEFAULT 2 +#define BASS_DEVICE_INIT 4 +#define BASS_DEVICE_LOOPBACK 8 +#define BASS_DEVICE_DEFAULTCOM 128 + +#define BASS_DEVICE_TYPE_MASK 0xff000000 +#define BASS_DEVICE_TYPE_NETWORK 0x01000000 +#define BASS_DEVICE_TYPE_SPEAKERS 0x02000000 +#define BASS_DEVICE_TYPE_LINE 0x03000000 +#define BASS_DEVICE_TYPE_HEADPHONES 0x04000000 +#define BASS_DEVICE_TYPE_MICROPHONE 0x05000000 +#define BASS_DEVICE_TYPE_HEADSET 0x06000000 +#define BASS_DEVICE_TYPE_HANDSET 0x07000000 +#define BASS_DEVICE_TYPE_DIGITAL 0x08000000 +#define BASS_DEVICE_TYPE_SPDIF 0x09000000 +#define BASS_DEVICE_TYPE_HDMI 0x0a000000 +#define BASS_DEVICE_TYPE_DISPLAYPORT 0x40000000 + +// BASS_GetDeviceInfo flags +#define BASS_DEVICES_AIRPLAY 0x1000000 + +typedef struct { + DWORD flags; // device capabilities (DSCAPS_xxx flags) + DWORD hwsize; // unused + DWORD hwfree; // unused + DWORD freesam; // unused + DWORD free3d; // unused + DWORD minrate; // unused + DWORD maxrate; // unused + BOOL eax; // unused + DWORD minbuf; // recommended minimum buffer length in ms + DWORD dsver; // DirectSound version + DWORD latency; // average delay (in ms) before start of playback + DWORD initflags; // BASS_Init "flags" parameter + DWORD speakers; // number of speakers available + DWORD freq; // current output rate +} BASS_INFO; + +// BASS_INFO flags (from DSOUND.H) +#define DSCAPS_EMULDRIVER 0x00000020 // device does not have hardware DirectSound support +#define DSCAPS_CERTIFIED 0x00000040 // device driver has been certified by Microsoft + +#define DSCAPS_HARDWARE 0x80000000 // hardware mixed + +// Recording device info structure +typedef struct { + DWORD flags; // device capabilities (DSCCAPS_xxx flags) + DWORD formats; // supported standard formats (WAVE_FORMAT_xxx flags) + DWORD inputs; // number of inputs + BOOL singlein; // TRUE = only 1 input can be set at a time + DWORD freq; // current input rate +} BASS_RECORDINFO; + +// BASS_RECORDINFO flags (from DSOUND.H) +#define DSCCAPS_EMULDRIVER DSCAPS_EMULDRIVER // device does not have hardware DirectSound recording support +#define DSCCAPS_CERTIFIED DSCAPS_CERTIFIED // device driver has been certified by Microsoft + +// defines for formats field of BASS_RECORDINFO (from MMSYSTEM.H) +#ifndef WAVE_FORMAT_1M08 +#define WAVE_FORMAT_1M08 0x00000001 /* 11.025 kHz, Mono, 8-bit */ +#define WAVE_FORMAT_1S08 0x00000002 /* 11.025 kHz, Stereo, 8-bit */ +#define WAVE_FORMAT_1M16 0x00000004 /* 11.025 kHz, Mono, 16-bit */ +#define WAVE_FORMAT_1S16 0x00000008 /* 11.025 kHz, Stereo, 16-bit */ +#define WAVE_FORMAT_2M08 0x00000010 /* 22.05 kHz, Mono, 8-bit */ +#define WAVE_FORMAT_2S08 0x00000020 /* 22.05 kHz, Stereo, 8-bit */ +#define WAVE_FORMAT_2M16 0x00000040 /* 22.05 kHz, Mono, 16-bit */ +#define WAVE_FORMAT_2S16 0x00000080 /* 22.05 kHz, Stereo, 16-bit */ +#define WAVE_FORMAT_4M08 0x00000100 /* 44.1 kHz, Mono, 8-bit */ +#define WAVE_FORMAT_4S08 0x00000200 /* 44.1 kHz, Stereo, 8-bit */ +#define WAVE_FORMAT_4M16 0x00000400 /* 44.1 kHz, Mono, 16-bit */ +#define WAVE_FORMAT_4S16 0x00000800 /* 44.1 kHz, Stereo, 16-bit */ +#endif + +// Sample info structure +typedef struct { + DWORD freq; // default playback rate + float volume; // default volume (0-1) + float pan; // default pan (-1=left, 0=middle, 1=right) + DWORD flags; // BASS_SAMPLE_xxx flags + DWORD length; // length (in bytes) + DWORD max; // maximum simultaneous playbacks + DWORD origres; // original resolution + DWORD chans; // number of channels + DWORD mingap; // minimum gap (ms) between creating channels + DWORD mode3d; // BASS_3DMODE_xxx mode + float mindist; // minimum distance + float maxdist; // maximum distance + DWORD iangle; // angle of inside projection cone + DWORD oangle; // angle of outside projection cone + float outvol; // delta-volume outside the projection cone + DWORD vam; // unused + DWORD priority; // unused +} BASS_SAMPLE; + +#define BASS_SAMPLE_8BITS 1 // 8 bit +#define BASS_SAMPLE_FLOAT 256 // 32 bit floating-point +#define BASS_SAMPLE_MONO 2 // mono +#define BASS_SAMPLE_LOOP 4 // looped +#define BASS_SAMPLE_3D 8 // 3D functionality +#define BASS_SAMPLE_SOFTWARE 16 // unused +#define BASS_SAMPLE_MUTEMAX 32 // mute at max distance (3D only) +#define BASS_SAMPLE_VAM 64 // unused +#define BASS_SAMPLE_FX 128 // unused +#define BASS_SAMPLE_OVER_VOL 0x10000 // override lowest volume +#define BASS_SAMPLE_OVER_POS 0x20000 // override longest playing +#define BASS_SAMPLE_OVER_DIST 0x30000 // override furthest from listener (3D only) + +#define BASS_STREAM_PRESCAN 0x20000 // scan file for accurate seeking and length +#define BASS_STREAM_AUTOFREE 0x40000 // automatically free the stream when it stops/ends +#define BASS_STREAM_RESTRATE 0x80000 // restrict the download rate of internet file stream +#define BASS_STREAM_BLOCK 0x100000 // download internet file stream in small blocks +#define BASS_STREAM_DECODE 0x200000 // don't play the stream, only decode +#define BASS_STREAM_STATUS 0x800000 // give server status info (HTTP/ICY tags) in DOWNLOADPROC + +#define BASS_MP3_IGNOREDELAY 0x200 // ignore LAME/Xing/VBRI/iTunes delay & padding info +#define BASS_MP3_SETPOS BASS_STREAM_PRESCAN + +#define BASS_MUSIC_FLOAT BASS_SAMPLE_FLOAT +#define BASS_MUSIC_MONO BASS_SAMPLE_MONO +#define BASS_MUSIC_LOOP BASS_SAMPLE_LOOP +#define BASS_MUSIC_3D BASS_SAMPLE_3D +#define BASS_MUSIC_FX BASS_SAMPLE_FX +#define BASS_MUSIC_AUTOFREE BASS_STREAM_AUTOFREE +#define BASS_MUSIC_DECODE BASS_STREAM_DECODE +#define BASS_MUSIC_PRESCAN BASS_STREAM_PRESCAN // calculate playback length +#define BASS_MUSIC_CALCLEN BASS_MUSIC_PRESCAN +#define BASS_MUSIC_RAMP 0x200 // normal ramping +#define BASS_MUSIC_RAMPS 0x400 // sensitive ramping +#define BASS_MUSIC_SURROUND 0x800 // surround sound +#define BASS_MUSIC_SURROUND2 0x1000 // surround sound (mode 2) +#define BASS_MUSIC_FT2PAN 0x2000 // apply FastTracker 2 panning to XM files +#define BASS_MUSIC_FT2MOD 0x2000 // play .MOD as FastTracker 2 does +#define BASS_MUSIC_PT1MOD 0x4000 // play .MOD as ProTracker 1 does +#define BASS_MUSIC_NONINTER 0x10000 // non-interpolated sample mixing +#define BASS_MUSIC_SINCINTER 0x800000 // sinc interpolated sample mixing +#define BASS_MUSIC_POSRESET 0x8000 // stop all notes when moving position +#define BASS_MUSIC_POSRESETEX 0x400000 // stop all notes and reset bmp/etc when moving position +#define BASS_MUSIC_STOPBACK 0x80000 // stop the music on a backwards jump effect +#define BASS_MUSIC_NOSAMPLE 0x100000 // don't load the samples + +// Speaker assignment flags +#define BASS_SPEAKER_FRONT 0x1000000 // front speakers +#define BASS_SPEAKER_REAR 0x2000000 // rear/side speakers +#define BASS_SPEAKER_CENLFE 0x3000000 // center & LFE speakers (5.1) +#define BASS_SPEAKER_REAR2 0x4000000 // rear center speakers (7.1) +#define BASS_SPEAKER_N(n) ((n)<<24) // n'th pair of speakers (max 15) +#define BASS_SPEAKER_LEFT 0x10000000 // modifier: left +#define BASS_SPEAKER_RIGHT 0x20000000 // modifier: right +#define BASS_SPEAKER_FRONTLEFT BASS_SPEAKER_FRONT|BASS_SPEAKER_LEFT +#define BASS_SPEAKER_FRONTRIGHT BASS_SPEAKER_FRONT|BASS_SPEAKER_RIGHT +#define BASS_SPEAKER_REARLEFT BASS_SPEAKER_REAR|BASS_SPEAKER_LEFT +#define BASS_SPEAKER_REARRIGHT BASS_SPEAKER_REAR|BASS_SPEAKER_RIGHT +#define BASS_SPEAKER_CENTER BASS_SPEAKER_CENLFE|BASS_SPEAKER_LEFT +#define BASS_SPEAKER_LFE BASS_SPEAKER_CENLFE|BASS_SPEAKER_RIGHT +#define BASS_SPEAKER_REAR2LEFT BASS_SPEAKER_REAR2|BASS_SPEAKER_LEFT +#define BASS_SPEAKER_REAR2RIGHT BASS_SPEAKER_REAR2|BASS_SPEAKER_RIGHT + +#define BASS_ASYNCFILE 0x40000000 // read file asynchronously +#define BASS_UNICODE 0x80000000 // UTF-16 + +#define BASS_RECORD_PAUSE 0x8000 // start recording paused +#define BASS_RECORD_ECHOCANCEL 0x2000 +#define BASS_RECORD_AGC 0x4000 + +// DX7 voice allocation & management flags +#define BASS_VAM_HARDWARE 1 +#define BASS_VAM_SOFTWARE 2 +#define BASS_VAM_TERM_TIME 4 +#define BASS_VAM_TERM_DIST 8 +#define BASS_VAM_TERM_PRIO 16 + +// Channel info structure +typedef struct { + DWORD freq; // default playback rate + DWORD chans; // channels + DWORD flags; + DWORD ctype; // type of channel + DWORD origres; // original resolution + HPLUGIN plugin; + HSAMPLE sample; + const char *filename; +} BASS_CHANNELINFO; + +#define BASS_ORIGRES_FLOAT 0x10000 + +// BASS_CHANNELINFO types +#define BASS_CTYPE_SAMPLE 1 +#define BASS_CTYPE_RECORD 2 +#define BASS_CTYPE_STREAM 0x10000 +#define BASS_CTYPE_STREAM_VORBIS 0x10002 +#define BASS_CTYPE_STREAM_OGG 0x10002 +#define BASS_CTYPE_STREAM_MP1 0x10003 +#define BASS_CTYPE_STREAM_MP2 0x10004 +#define BASS_CTYPE_STREAM_MP3 0x10005 +#define BASS_CTYPE_STREAM_AIFF 0x10006 +#define BASS_CTYPE_STREAM_CA 0x10007 +#define BASS_CTYPE_STREAM_MF 0x10008 +#define BASS_CTYPE_STREAM_AM 0x10009 +#define BASS_CTYPE_STREAM_SAMPLE 0x1000a +#define BASS_CTYPE_STREAM_DUMMY 0x18000 +#define BASS_CTYPE_STREAM_DEVICE 0x18001 +#define BASS_CTYPE_STREAM_WAV 0x40000 // WAVE flag (LOWORD=codec) +#define BASS_CTYPE_STREAM_WAV_PCM 0x50001 +#define BASS_CTYPE_STREAM_WAV_FLOAT 0x50003 +#define BASS_CTYPE_MUSIC_MOD 0x20000 +#define BASS_CTYPE_MUSIC_MTM 0x20001 +#define BASS_CTYPE_MUSIC_S3M 0x20002 +#define BASS_CTYPE_MUSIC_XM 0x20003 +#define BASS_CTYPE_MUSIC_IT 0x20004 +#define BASS_CTYPE_MUSIC_MO3 0x00100 // MO3 flag + +typedef struct { + DWORD ctype; // channel type +#if defined(_WIN32_WCE) || (defined(WINAPI_FAMILY) && WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP) + const wchar_t *name; // format description + const wchar_t *exts; // file extension filter (*.ext1;*.ext2;etc...) +#else + const char *name; // format description + const char *exts; // file extension filter (*.ext1;*.ext2;etc...) +#endif +} BASS_PLUGINFORM; + +typedef struct { + DWORD version; // version (same form as BASS_GetVersion) + DWORD formatc; // number of formats + const BASS_PLUGINFORM *formats; // the array of formats +} BASS_PLUGININFO; + +// 3D vector (for 3D positions/velocities/orientations) +typedef struct BASS_3DVECTOR { +#ifdef __cplusplus + BASS_3DVECTOR() { x = 0.0f; y = 0.0f; z = 0.0f; }; + BASS_3DVECTOR(float _x, float _y, float _z) : x(_x), y(_y), z(_z) {}; +#endif + float x; // +=right, -=left + float y; // +=up, -=down + float z; // +=front, -=behind +} BASS_3DVECTOR; + +// 3D channel modes +#define BASS_3DMODE_NORMAL 0 // normal 3D processing +#define BASS_3DMODE_RELATIVE 1 // position is relative to the listener +#define BASS_3DMODE_OFF 2 // no 3D processing + +// software 3D mixing algorithms (used with BASS_CONFIG_3DALGORITHM) +#define BASS_3DALG_DEFAULT 0 +#define BASS_3DALG_OFF 1 +#define BASS_3DALG_FULL 2 +#define BASS_3DALG_LIGHT 3 + +// BASS_SampleGetChannel flags +#define BASS_SAMCHAN_NEW 1 // get a new playback channel +#define BASS_SAMCHAN_STREAM 2 // create a stream + +typedef DWORD (CALLBACK STREAMPROC)(HSTREAM handle, void *buffer, DWORD length, void *user); +/* User stream callback function. +handle : The stream that needs writing +buffer : Buffer to write the samples in +length : Number of bytes to write +user : The 'user' parameter value given when calling BASS_StreamCreate +RETURN : Number of bytes written. Set the BASS_STREAMPROC_END flag to end the stream. */ + +#define BASS_STREAMPROC_END 0x80000000 // end of user stream flag + +// Special STREAMPROCs +#define STREAMPROC_DUMMY (STREAMPROC*)0 // "dummy" stream +#define STREAMPROC_PUSH (STREAMPROC*)-1 // push stream +#define STREAMPROC_DEVICE (STREAMPROC*)-2 // device mix stream +#define STREAMPROC_DEVICE_3D (STREAMPROC*)-3 // device 3D mix stream + +// BASS_StreamCreateFileUser file systems +#define STREAMFILE_NOBUFFER 0 +#define STREAMFILE_BUFFER 1 +#define STREAMFILE_BUFFERPUSH 2 + +// User file stream callback functions +typedef void (CALLBACK FILECLOSEPROC)(void *user); +typedef QWORD (CALLBACK FILELENPROC)(void *user); +typedef DWORD (CALLBACK FILEREADPROC)(void *buffer, DWORD length, void *user); +typedef BOOL (CALLBACK FILESEEKPROC)(QWORD offset, void *user); + +typedef struct { + FILECLOSEPROC *close; + FILELENPROC *length; + FILEREADPROC *read; + FILESEEKPROC *seek; +} BASS_FILEPROCS; + +// BASS_StreamPutFileData options +#define BASS_FILEDATA_END 0 // end & close the file + +// BASS_StreamGetFilePosition modes +#define BASS_FILEPOS_CURRENT 0 +#define BASS_FILEPOS_DECODE BASS_FILEPOS_CURRENT +#define BASS_FILEPOS_DOWNLOAD 1 +#define BASS_FILEPOS_END 2 +#define BASS_FILEPOS_START 3 +#define BASS_FILEPOS_CONNECTED 4 +#define BASS_FILEPOS_BUFFER 5 +#define BASS_FILEPOS_SOCKET 6 +#define BASS_FILEPOS_ASYNCBUF 7 +#define BASS_FILEPOS_SIZE 8 +#define BASS_FILEPOS_BUFFERING 9 +#define BASS_FILEPOS_AVAILABLE 10 + +typedef void (CALLBACK DOWNLOADPROC)(const void *buffer, DWORD length, void *user); +/* Internet stream download callback function. +buffer : Buffer containing the downloaded data... NULL=end of download +length : Number of bytes in the buffer +user : The 'user' parameter value given when calling BASS_StreamCreateURL */ + +// BASS_ChannelSetSync types +#define BASS_SYNC_POS 0 +#define BASS_SYNC_END 2 +#define BASS_SYNC_META 4 +#define BASS_SYNC_SLIDE 5 +#define BASS_SYNC_STALL 6 +#define BASS_SYNC_DOWNLOAD 7 +#define BASS_SYNC_FREE 8 +#define BASS_SYNC_SETPOS 11 +#define BASS_SYNC_MUSICPOS 10 +#define BASS_SYNC_MUSICINST 1 +#define BASS_SYNC_MUSICFX 3 +#define BASS_SYNC_OGG_CHANGE 12 +#define BASS_SYNC_DEV_FAIL 14 +#define BASS_SYNC_DEV_FORMAT 15 +#define BASS_SYNC_THREAD 0x20000000 // flag: call sync in other thread +#define BASS_SYNC_MIXTIME 0x40000000 // flag: sync at mixtime, else at playtime +#define BASS_SYNC_ONETIME 0x80000000 // flag: sync only once, else continuously + +typedef void (CALLBACK SYNCPROC)(HSYNC handle, DWORD channel, DWORD data, void *user); +/* Sync callback function. +handle : The sync that has occured +channel: Channel that the sync occured in +data : Additional data associated with the sync's occurance +user : The 'user' parameter given when calling BASS_ChannelSetSync */ + +typedef void (CALLBACK DSPPROC)(HDSP handle, DWORD channel, void *buffer, DWORD length, void *user); +/* DSP callback function. +handle : The DSP handle +channel: Channel that the DSP is being applied to +buffer : Buffer to apply the DSP to +length : Number of bytes in the buffer +user : The 'user' parameter given when calling BASS_ChannelSetDSP */ + +typedef BOOL (CALLBACK RECORDPROC)(HRECORD handle, const void *buffer, DWORD length, void *user); +/* Recording callback function. +handle : The recording handle +buffer : Buffer containing the recorded sample data +length : Number of bytes +user : The 'user' parameter value given when calling BASS_RecordStart +RETURN : TRUE = continue recording, FALSE = stop */ + +// BASS_ChannelIsActive return values +#define BASS_ACTIVE_STOPPED 0 +#define BASS_ACTIVE_PLAYING 1 +#define BASS_ACTIVE_STALLED 2 +#define BASS_ACTIVE_PAUSED 3 +#define BASS_ACTIVE_PAUSED_DEVICE 4 + +// Channel attributes +#define BASS_ATTRIB_FREQ 1 +#define BASS_ATTRIB_VOL 2 +#define BASS_ATTRIB_PAN 3 +#define BASS_ATTRIB_EAXMIX 4 +#define BASS_ATTRIB_NOBUFFER 5 +#define BASS_ATTRIB_VBR 6 +#define BASS_ATTRIB_CPU 7 +#define BASS_ATTRIB_SRC 8 +#define BASS_ATTRIB_NET_RESUME 9 +#define BASS_ATTRIB_SCANINFO 10 +#define BASS_ATTRIB_NORAMP 11 +#define BASS_ATTRIB_BITRATE 12 +#define BASS_ATTRIB_BUFFER 13 +#define BASS_ATTRIB_GRANULE 14 +#define BASS_ATTRIB_USER 15 +#define BASS_ATTRIB_TAIL 16 +#define BASS_ATTRIB_PUSH_LIMIT 17 +#define BASS_ATTRIB_MUSIC_AMPLIFY 0x100 +#define BASS_ATTRIB_MUSIC_PANSEP 0x101 +#define BASS_ATTRIB_MUSIC_PSCALER 0x102 +#define BASS_ATTRIB_MUSIC_BPM 0x103 +#define BASS_ATTRIB_MUSIC_SPEED 0x104 +#define BASS_ATTRIB_MUSIC_VOL_GLOBAL 0x105 +#define BASS_ATTRIB_MUSIC_ACTIVE 0x106 +#define BASS_ATTRIB_MUSIC_VOL_CHAN 0x200 // + channel # +#define BASS_ATTRIB_MUSIC_VOL_INST 0x300 // + instrument # + +// BASS_ChannelSlideAttribute flags +#define BASS_SLIDE_LOG 0x1000000 + +// BASS_ChannelGetData flags +#define BASS_DATA_AVAILABLE 0 // query how much data is buffered +#define BASS_DATA_NOREMOVE 0x10000000 // flag: don't remove data from recording buffer +#define BASS_DATA_FIXED 0x20000000 // flag: return 8.24 fixed-point data +#define BASS_DATA_FLOAT 0x40000000 // flag: return floating-point sample data +#define BASS_DATA_FFT256 0x80000000 // 256 sample FFT +#define BASS_DATA_FFT512 0x80000001 // 512 FFT +#define BASS_DATA_FFT1024 0x80000002 // 1024 FFT +#define BASS_DATA_FFT2048 0x80000003 // 2048 FFT +#define BASS_DATA_FFT4096 0x80000004 // 4096 FFT +#define BASS_DATA_FFT8192 0x80000005 // 8192 FFT +#define BASS_DATA_FFT16384 0x80000006 // 16384 FFT +#define BASS_DATA_FFT32768 0x80000007 // 32768 FFT +#define BASS_DATA_FFT_INDIVIDUAL 0x10 // FFT flag: FFT for each channel, else all combined +#define BASS_DATA_FFT_NOWINDOW 0x20 // FFT flag: no Hanning window +#define BASS_DATA_FFT_REMOVEDC 0x40 // FFT flag: pre-remove DC bias +#define BASS_DATA_FFT_COMPLEX 0x80 // FFT flag: return complex data +#define BASS_DATA_FFT_NYQUIST 0x100 // FFT flag: return extra Nyquist value + +// BASS_ChannelGetLevelEx flags +#define BASS_LEVEL_MONO 1 // get mono level +#define BASS_LEVEL_STEREO 2 // get stereo level +#define BASS_LEVEL_RMS 4 // get RMS levels +#define BASS_LEVEL_VOLPAN 8 // apply VOL/PAN attributes to the levels +#define BASS_LEVEL_NOREMOVE 16 // don't remove data from recording buffer + +// BASS_ChannelGetTags types : what's returned +#define BASS_TAG_ID3 0 // ID3v1 tags : TAG_ID3 structure +#define BASS_TAG_ID3V2 1 // ID3v2 tags : variable length block +#define BASS_TAG_OGG 2 // OGG comments : series of null-terminated UTF-8 strings +#define BASS_TAG_HTTP 3 // HTTP headers : series of null-terminated ASCII strings +#define BASS_TAG_ICY 4 // ICY headers : series of null-terminated ANSI strings +#define BASS_TAG_META 5 // ICY metadata : ANSI string +#define BASS_TAG_APE 6 // APE tags : series of null-terminated UTF-8 strings +#define BASS_TAG_MP4 7 // MP4/iTunes metadata : series of null-terminated UTF-8 strings +#define BASS_TAG_WMA 8 // WMA tags : series of null-terminated UTF-8 strings +#define BASS_TAG_VENDOR 9 // OGG encoder : UTF-8 string +#define BASS_TAG_LYRICS3 10 // Lyric3v2 tag : ASCII string +#define BASS_TAG_CA_CODEC 11 // CoreAudio codec info : TAG_CA_CODEC structure +#define BASS_TAG_MF 13 // Media Foundation tags : series of null-terminated UTF-8 strings +#define BASS_TAG_WAVEFORMAT 14 // WAVE format : WAVEFORMATEEX structure +#define BASS_TAG_AM_NAME 16 // Android Media codec name : ASCII string +#define BASS_TAG_ID3V2_2 17 // ID3v2 tags (2nd block) : variable length block +#define BASS_TAG_AM_MIME 18 // Android Media MIME type : ASCII string +#define BASS_TAG_LOCATION 19 // redirected URL : ASCII string +#define BASS_TAG_RIFF_INFO 0x100 // RIFF "INFO" tags : series of null-terminated ANSI strings +#define BASS_TAG_RIFF_BEXT 0x101 // RIFF/BWF "bext" tags : TAG_BEXT structure +#define BASS_TAG_RIFF_CART 0x102 // RIFF/BWF "cart" tags : TAG_CART structure +#define BASS_TAG_RIFF_DISP 0x103 // RIFF "DISP" text tag : ANSI string +#define BASS_TAG_RIFF_CUE 0x104 // RIFF "cue " chunk : TAG_CUE structure +#define BASS_TAG_RIFF_SMPL 0x105 // RIFF "smpl" chunk : TAG_SMPL structure +#define BASS_TAG_APE_BINARY 0x1000 // + index #, binary APE tag : TAG_APE_BINARY structure +#define BASS_TAG_MUSIC_NAME 0x10000 // MOD music name : ANSI string +#define BASS_TAG_MUSIC_MESSAGE 0x10001 // MOD message : ANSI string +#define BASS_TAG_MUSIC_ORDERS 0x10002 // MOD order list : BYTE array of pattern numbers +#define BASS_TAG_MUSIC_AUTH 0x10003 // MOD author : UTF-8 string +#define BASS_TAG_MUSIC_INST 0x10100 // + instrument #, MOD instrument name : ANSI string +#define BASS_TAG_MUSIC_CHAN 0x10200 // + channel #, MOD channel name : ANSI string +#define BASS_TAG_MUSIC_SAMPLE 0x10300 // + sample #, MOD sample name : ANSI string + +// ID3v1 tag structure +typedef struct { + char id[3]; + char title[30]; + char artist[30]; + char album[30]; + char year[4]; + char comment[30]; + BYTE genre; +} TAG_ID3; + +// Binary APE tag structure +typedef struct { + const char *key; + const void *data; + DWORD length; +} TAG_APE_BINARY; + +// BWF "bext" tag structure +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4200) +#endif +#pragma pack(push,1) +typedef struct { + char Description[256]; // description + char Originator[32]; // name of the originator + char OriginatorReference[32]; // reference of the originator + char OriginationDate[10]; // date of creation (yyyy-mm-dd) + char OriginationTime[8]; // time of creation (hh-mm-ss) + QWORD TimeReference; // first sample count since midnight (little-endian) + WORD Version; // BWF version (little-endian) + BYTE UMID[64]; // SMPTE UMID + BYTE Reserved[190]; +#if defined(__GNUC__) && __GNUC__<3 + char CodingHistory[0]; // history +#elif 1 // change to 0 if compiler fails the following line + char CodingHistory[]; // history +#else + char CodingHistory[1]; // history +#endif +} TAG_BEXT; +#pragma pack(pop) + +// BWF "cart" tag structures +typedef struct +{ + DWORD dwUsage; // FOURCC timer usage ID + DWORD dwValue; // timer value in samples from head +} TAG_CART_TIMER; + +typedef struct +{ + char Version[4]; // version of the data structure + char Title[64]; // title of cart audio sequence + char Artist[64]; // artist or creator name + char CutID[64]; // cut number identification + char ClientID[64]; // client identification + char Category[64]; // category ID, PSA, NEWS, etc + char Classification[64]; // classification or auxiliary key + char OutCue[64]; // out cue text + char StartDate[10]; // yyyy-mm-dd + char StartTime[8]; // hh:mm:ss + char EndDate[10]; // yyyy-mm-dd + char EndTime[8]; // hh:mm:ss + char ProducerAppID[64]; // name of vendor or application + char ProducerAppVersion[64]; // version of producer application + char UserDef[64]; // user defined text + DWORD dwLevelReference; // sample value for 0 dB reference + TAG_CART_TIMER PostTimer[8]; // 8 time markers after head + char Reserved[276]; + char URL[1024]; // uniform resource locator +#if defined(__GNUC__) && __GNUC__<3 + char TagText[0]; // free form text for scripts or tags +#elif 1 // change to 0 if compiler fails the following line + char TagText[]; // free form text for scripts or tags +#else + char TagText[1]; // free form text for scripts or tags +#endif +} TAG_CART; + +// RIFF "cue " tag structures +typedef struct +{ + DWORD dwName; + DWORD dwPosition; + DWORD fccChunk; + DWORD dwChunkStart; + DWORD dwBlockStart; + DWORD dwSampleOffset; +} TAG_CUE_POINT; + +typedef struct +{ + DWORD dwCuePoints; +#if defined(__GNUC__) && __GNUC__<3 + TAG_CUE_POINT CuePoints[0]; +#elif 1 // change to 0 if compiler fails the following line + TAG_CUE_POINT CuePoints[]; +#else + TAG_CUE_POINT CuePoints[1]; +#endif +} TAG_CUE; + +// RIFF "smpl" tag structures +typedef struct +{ + DWORD dwIdentifier; + DWORD dwType; + DWORD dwStart; + DWORD dwEnd; + DWORD dwFraction; + DWORD dwPlayCount; +} TAG_SMPL_LOOP; + +typedef struct +{ + DWORD dwManufacturer; + DWORD dwProduct; + DWORD dwSamplePeriod; + DWORD dwMIDIUnityNote; + DWORD dwMIDIPitchFraction; + DWORD dwSMPTEFormat; + DWORD dwSMPTEOffset; + DWORD cSampleLoops; + DWORD cbSamplerData; +#if defined(__GNUC__) && __GNUC__<3 + TAG_SMPL_LOOP SampleLoops[0]; +#elif 1 // change to 0 if compiler fails the following line + TAG_SMPL_LOOP SampleLoops[]; +#else + TAG_SMPL_LOOP SampleLoops[1]; +#endif +} TAG_SMPL; +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +// CoreAudio codec info structure +typedef struct { + DWORD ftype; // file format + DWORD atype; // audio format + const char *name; // description +} TAG_CA_CODEC; + +#ifndef _WAVEFORMATEX_ +#define _WAVEFORMATEX_ +#pragma pack(push,1) +typedef struct tWAVEFORMATEX +{ + WORD wFormatTag; + WORD nChannels; + DWORD nSamplesPerSec; + DWORD nAvgBytesPerSec; + WORD nBlockAlign; + WORD wBitsPerSample; + WORD cbSize; +} WAVEFORMATEX, *PWAVEFORMATEX, *LPWAVEFORMATEX; +typedef const WAVEFORMATEX *LPCWAVEFORMATEX; +#pragma pack(pop) +#endif + +// BASS_ChannelGetLength/GetPosition/SetPosition modes +#define BASS_POS_BYTE 0 // byte position +#define BASS_POS_MUSIC_ORDER 1 // order.row position, MAKELONG(order,row) +#define BASS_POS_OGG 3 // OGG bitstream number +#define BASS_POS_END 0x10 // trimmed end position +#define BASS_POS_LOOP 0x11 // loop start positiom +#define BASS_POS_FLUSH 0x1000000 // flag: flush decoder/FX buffers +#define BASS_POS_RESET 0x2000000 // flag: reset user file buffers +#define BASS_POS_RELATIVE 0x4000000 // flag: seek relative to the current position +#define BASS_POS_INEXACT 0x8000000 // flag: allow seeking to inexact position +#define BASS_POS_DECODE 0x10000000 // flag: get the decoding (not playing) position +#define BASS_POS_DECODETO 0x20000000 // flag: decode to the position instead of seeking +#define BASS_POS_SCAN 0x40000000 // flag: scan to the position + +// BASS_ChannelSetDevice/GetDevice option +#define BASS_NODEVICE 0x20000 + +// BASS_RecordSetInput flags +#define BASS_INPUT_OFF 0x10000 +#define BASS_INPUT_ON 0x20000 + +#define BASS_INPUT_TYPE_MASK 0xff000000 +#define BASS_INPUT_TYPE_UNDEF 0x00000000 +#define BASS_INPUT_TYPE_DIGITAL 0x01000000 +#define BASS_INPUT_TYPE_LINE 0x02000000 +#define BASS_INPUT_TYPE_MIC 0x03000000 +#define BASS_INPUT_TYPE_SYNTH 0x04000000 +#define BASS_INPUT_TYPE_CD 0x05000000 +#define BASS_INPUT_TYPE_PHONE 0x06000000 +#define BASS_INPUT_TYPE_SPEAKER 0x07000000 +#define BASS_INPUT_TYPE_WAVE 0x08000000 +#define BASS_INPUT_TYPE_AUX 0x09000000 +#define BASS_INPUT_TYPE_ANALOG 0x0a000000 + +// BASS_ChannelSetFX effect types +#define BASS_FX_DX8_CHORUS 0 +#define BASS_FX_DX8_COMPRESSOR 1 +#define BASS_FX_DX8_DISTORTION 2 +#define BASS_FX_DX8_ECHO 3 +#define BASS_FX_DX8_FLANGER 4 +#define BASS_FX_DX8_GARGLE 5 +#define BASS_FX_DX8_I3DL2REVERB 6 +#define BASS_FX_DX8_PARAMEQ 7 +#define BASS_FX_DX8_REVERB 8 +#define BASS_FX_VOLUME 9 + +typedef struct { + float fWetDryMix; + float fDepth; + float fFeedback; + float fFrequency; + DWORD lWaveform; // 0=triangle, 1=sine + float fDelay; + DWORD lPhase; // BASS_DX8_PHASE_xxx +} BASS_DX8_CHORUS; + +typedef struct { + float fGain; + float fAttack; + float fRelease; + float fThreshold; + float fRatio; + float fPredelay; +} BASS_DX8_COMPRESSOR; + +typedef struct { + float fGain; + float fEdge; + float fPostEQCenterFrequency; + float fPostEQBandwidth; + float fPreLowpassCutoff; +} BASS_DX8_DISTORTION; + +typedef struct { + float fWetDryMix; + float fFeedback; + float fLeftDelay; + float fRightDelay; + BOOL lPanDelay; +} BASS_DX8_ECHO; + +typedef struct { + float fWetDryMix; + float fDepth; + float fFeedback; + float fFrequency; + DWORD lWaveform; // 0=triangle, 1=sine + float fDelay; + DWORD lPhase; // BASS_DX8_PHASE_xxx +} BASS_DX8_FLANGER; + +typedef struct { + DWORD dwRateHz; // Rate of modulation in hz + DWORD dwWaveShape; // 0=triangle, 1=square +} BASS_DX8_GARGLE; + +typedef struct { + int lRoom; // [-10000, 0] default: -1000 mB + int lRoomHF; // [-10000, 0] default: 0 mB + float flRoomRolloffFactor; // [0.0, 10.0] default: 0.0 + float flDecayTime; // [0.1, 20.0] default: 1.49s + float flDecayHFRatio; // [0.1, 2.0] default: 0.83 + int lReflections; // [-10000, 1000] default: -2602 mB + float flReflectionsDelay; // [0.0, 0.3] default: 0.007 s + int lReverb; // [-10000, 2000] default: 200 mB + float flReverbDelay; // [0.0, 0.1] default: 0.011 s + float flDiffusion; // [0.0, 100.0] default: 100.0 % + float flDensity; // [0.0, 100.0] default: 100.0 % + float flHFReference; // [20.0, 20000.0] default: 5000.0 Hz +} BASS_DX8_I3DL2REVERB; + +typedef struct { + float fCenter; + float fBandwidth; + float fGain; +} BASS_DX8_PARAMEQ; + +typedef struct { + float fInGain; // [-96.0,0.0] default: 0.0 dB + float fReverbMix; // [-96.0,0.0] default: 0.0 db + float fReverbTime; // [0.001,3000.0] default: 1000.0 ms + float fHighFreqRTRatio; // [0.001,0.999] default: 0.001 +} BASS_DX8_REVERB; + +#define BASS_DX8_PHASE_NEG_180 0 +#define BASS_DX8_PHASE_NEG_90 1 +#define BASS_DX8_PHASE_ZERO 2 +#define BASS_DX8_PHASE_90 3 +#define BASS_DX8_PHASE_180 4 + +typedef struct { + float fTarget; + float fCurrent; + float fTime; + DWORD lCurve; +} BASS_FX_VOLUME_PARAM; + +typedef void (CALLBACK IOSNOTIFYPROC)(DWORD status); +/* iOS notification callback function. +status : The notification (BASS_IOSNOTIFY_xxx) */ + +#define BASS_IOSNOTIFY_INTERRUPT 1 // interruption started +#define BASS_IOSNOTIFY_INTERRUPT_END 2 // interruption ended + +extern BOOL(WINAPI* BASS_SetConfig)(DWORD option, DWORD value); +extern DWORD(WINAPI* BASS_GetConfig)(DWORD option); +extern BOOL(WINAPI* BASS_SetConfigPtr)(DWORD option, const void* value); +extern const void* (WINAPI* BASS_GetConfigPtr)(DWORD option); +extern DWORD(WINAPI* BASS_GetVersion)(void); +extern int (WINAPI* BASS_ErrorGetCode)(void); + +extern BOOL(WINAPI* BASS_GetDeviceInfo)(DWORD device, BASS_DEVICEINFO* info); +#if defined(_WIN32) && !defined(_WIN32_WCE) && !(defined(WINAPI_FAMILY) && WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP) +extern BOOL(WINAPI* BASS_Init)(int device, DWORD freq, DWORD flags, HWND win, const void* dsguid); +#else +extern BOOL(WINAPI* BASS_Init)(int device, DWORD freq, DWORD flags, void* win, const void* dsguid); +#endif +extern BOOL(WINAPI* BASS_Free)(void); +extern BOOL(WINAPI* BASS_SetDevice)(DWORD device); +extern DWORD(WINAPI* BASS_GetDevice)(void); +extern BOOL(WINAPI* BASS_GetInfo)(BASS_INFO* info); +extern BOOL(WINAPI* BASS_Start)(void); +extern BOOL(WINAPI* BASS_Stop)(void); +extern BOOL(WINAPI* BASS_Pause)(void); +extern DWORD(WINAPI* BASS_IsStarted)(void); +extern BOOL(WINAPI* BASS_Update)(DWORD length); +extern float (WINAPI* BASS_GetCPU)(void); +extern BOOL(WINAPI* BASS_SetVolume)(float volume); +extern float (WINAPI* BASS_GetVolume)(void); +#if defined(_WIN32) && !defined(_WIN32_WCE) && !(defined(WINAPI_FAMILY) && WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP) +extern void* (WINAPI* BASS_GetDSoundObject)(DWORD object); +#endif + +extern BOOL(WINAPI* BASS_Set3DFactors)(float distf, float rollf, float doppf); +extern BOOL(WINAPI* BASS_Get3DFactors)(float* distf, float* rollf, float* doppf); +extern BOOL(WINAPI* BASS_Set3DPosition)(const BASS_3DVECTOR* pos, const BASS_3DVECTOR* vel, const BASS_3DVECTOR* front, const BASS_3DVECTOR* top); +extern BOOL(WINAPI* BASS_Get3DPosition)(BASS_3DVECTOR* pos, BASS_3DVECTOR* vel, BASS_3DVECTOR* front, BASS_3DVECTOR* top); +extern void (WINAPI* BASS_Apply3D)(void); + +extern HPLUGIN(WINAPI* BASS_PluginLoad)(const char* file, DWORD flags); +extern BOOL(WINAPI* BASS_PluginFree)(HPLUGIN handle); +extern BOOL(WINAPI* BASS_PluginEnable)(HPLUGIN handle, BOOL enable); +extern const BASS_PLUGININFO* (WINAPI* BASS_PluginGetInfo)(HPLUGIN handle); + +extern HSAMPLE(WINAPI* BASS_SampleLoad)(BOOL mem, const void* file, QWORD offset, DWORD length, DWORD max, DWORD flags); +extern HSAMPLE(WINAPI* BASS_SampleCreate)(DWORD length, DWORD freq, DWORD chans, DWORD max, DWORD flags); +extern BOOL(WINAPI* BASS_SampleFree)(HSAMPLE handle); +extern BOOL(WINAPI* BASS_SampleSetData)(HSAMPLE handle, const void* buffer); +extern BOOL(WINAPI* BASS_SampleGetData)(HSAMPLE handle, void* buffer); +extern BOOL(WINAPI* BASS_SampleGetInfo)(HSAMPLE handle, BASS_SAMPLE* info); +extern BOOL(WINAPI* BASS_SampleSetInfo)(HSAMPLE handle, const BASS_SAMPLE* info); +extern DWORD(WINAPI* BASS_SampleGetChannel)(HSAMPLE handle, DWORD flags); +extern DWORD(WINAPI* BASS_SampleGetChannels)(HSAMPLE handle, HCHANNEL* channels); +extern BOOL(WINAPI* BASS_SampleStop)(HSAMPLE handle); + +extern HSTREAM(WINAPI* BASS_StreamCreate)(DWORD freq, DWORD chans, DWORD flags, STREAMPROC* proc, void* user); +extern HSTREAM(WINAPI* BASS_StreamCreateFile)(BOOL mem, const void* file, QWORD offset, QWORD length, DWORD flags); +extern HSTREAM(WINAPI* BASS_StreamCreateURL)(const char* url, DWORD offset, DWORD flags, DOWNLOADPROC* proc, void* user); +extern HSTREAM(WINAPI* BASS_StreamCreateFileUser)(DWORD system, DWORD flags, const BASS_FILEPROCS* proc, void* user); +extern BOOL(WINAPI* BASS_StreamFree)(HSTREAM handle); +extern QWORD(WINAPI* BASS_StreamGetFilePosition)(HSTREAM handle, DWORD mode); +extern DWORD(WINAPI* BASS_StreamPutData)(HSTREAM handle, const void* buffer, DWORD length); +extern DWORD(WINAPI* BASS_StreamPutFileData)(HSTREAM handle, const void* buffer, DWORD length); + +extern HMUSIC(WINAPI* BASS_MusicLoad)(BOOL mem, const void* file, QWORD offset, DWORD length, DWORD flags, DWORD freq); +extern BOOL(WINAPI* BASS_MusicFree)(HMUSIC handle); + +extern BOOL(WINAPI* BASS_RecordGetDeviceInfo)(DWORD device, BASS_DEVICEINFO* info); +extern BOOL(WINAPI* BASS_RecordInit)(int device); +extern BOOL(WINAPI* BASS_RecordFree)(void); +extern BOOL(WINAPI* BASS_RecordSetDevice)(DWORD device); +extern DWORD(WINAPI* BASS_RecordGetDevice)(void); +extern BOOL(WINAPI* BASS_RecordGetInfo)(BASS_RECORDINFO* info); +extern const char* (WINAPI* BASS_RecordGetInputName)(int input); +extern BOOL(WINAPI* BASS_RecordSetInput)(int input, DWORD flags, float volume); +extern DWORD(WINAPI* BASS_RecordGetInput)(int input, float* volume); +extern HRECORD(WINAPI* BASS_RecordStart)(DWORD freq, DWORD chans, DWORD flags, RECORDPROC* proc, void* user); + +extern double (WINAPI* BASS_ChannelBytes2Seconds)(DWORD handle, QWORD pos); +extern QWORD(WINAPI* BASS_ChannelSeconds2Bytes)(DWORD handle, double pos); +extern DWORD(WINAPI* BASS_ChannelGetDevice)(DWORD handle); +extern BOOL(WINAPI* BASS_ChannelSetDevice)(DWORD handle, DWORD device); +extern DWORD(WINAPI* BASS_ChannelIsActive)(DWORD handle); +extern BOOL(WINAPI* BASS_ChannelGetInfo)(DWORD handle, BASS_CHANNELINFO* info); +extern const char* (WINAPI* BASS_ChannelGetTags)(DWORD handle, DWORD tags); +extern DWORD(WINAPI* BASS_ChannelFlags)(DWORD handle, DWORD flags, DWORD mask); +extern BOOL(WINAPI* BASS_ChannelLock)(DWORD handle, BOOL lock); +extern BOOL(WINAPI* BASS_ChannelFree)(DWORD handle); +extern BOOL(WINAPI* BASS_ChannelPlay)(DWORD handle, BOOL restart); +extern BOOL(WINAPI* BASS_ChannelStop)(DWORD handle); +extern BOOL(WINAPI* BASS_ChannelPause)(DWORD handle); +extern BOOL(WINAPI* BASS_ChannelUpdate)(DWORD handle, DWORD length); +extern BOOL(WINAPI* BASS_ChannelSetAttribute)(DWORD handle, DWORD attrib, float value); +extern BOOL(WINAPI* BASS_ChannelGetAttribute)(DWORD handle, DWORD attrib, float* value); +extern BOOL(WINAPI* BASS_ChannelSlideAttribute)(DWORD handle, DWORD attrib, float value, DWORD time); +extern BOOL(WINAPI* BASS_ChannelIsSliding)(DWORD handle, DWORD attrib); +extern BOOL(WINAPI* BASS_ChannelSetAttributeEx)(DWORD handle, DWORD attrib, void* value, DWORD size); +extern DWORD(WINAPI* BASS_ChannelGetAttributeEx)(DWORD handle, DWORD attrib, void* value, DWORD size); +extern BOOL(WINAPI* BASS_ChannelSet3DAttributes)(DWORD handle, int mode, float min, float max, int iangle, int oangle, float outvol); +extern BOOL(WINAPI* BASS_ChannelGet3DAttributes)(DWORD handle, DWORD* mode, float* min, float* max, DWORD* iangle, DWORD* oangle, float* outvol); +extern BOOL(WINAPI* BASS_ChannelSet3DPosition)(DWORD handle, const BASS_3DVECTOR* pos, const BASS_3DVECTOR* orient, const BASS_3DVECTOR* vel); +extern BOOL(WINAPI* BASS_ChannelGet3DPosition)(DWORD handle, BASS_3DVECTOR* pos, BASS_3DVECTOR* orient, BASS_3DVECTOR* vel); +extern QWORD(WINAPI* BASS_ChannelGetLength)(DWORD handle, DWORD mode); +extern BOOL(WINAPI* BASS_ChannelSetPosition)(DWORD handle, QWORD pos, DWORD mode); +extern QWORD(WINAPI* BASS_ChannelGetPosition)(DWORD handle, DWORD mode); +extern DWORD(WINAPI* BASS_ChannelGetLevel)(DWORD handle); +extern BOOL(WINAPI* BASS_ChannelGetLevelEx)(DWORD handle, float* levels, float length, DWORD flags); +extern DWORD(WINAPI* BASS_ChannelGetData)(DWORD handle, void* buffer, DWORD length); +extern HSYNC(WINAPI* BASS_ChannelSetSync)(DWORD handle, DWORD type, QWORD param, SYNCPROC* proc, void* user); +extern BOOL(WINAPI* BASS_ChannelRemoveSync)(DWORD handle, HSYNC sync); +extern BOOL(WINAPI* BASS_ChannelSetLink)(DWORD handle, DWORD chan); +extern BOOL(WINAPI* BASS_ChannelRemoveLink)(DWORD handle, DWORD chan); +extern HDSP(WINAPI* BASS_ChannelSetDSP)(DWORD handle, DSPPROC* proc, void* user, int priority); +extern BOOL(WINAPI* BASS_ChannelRemoveDSP)(DWORD handle, HDSP dsp); +extern HFX(WINAPI* BASS_ChannelSetFX)(DWORD handle, DWORD type, int priority); +extern BOOL(WINAPI* BASS_ChannelRemoveFX)(DWORD handle, HFX fx); + +extern BOOL(WINAPI* BASS_FXSetParameters)(HFX handle, const void* params); +extern BOOL(WINAPI* BASS_FXGetParameters)(HFX handle, void* params); +extern BOOL(WINAPI* BASS_FXSetPriority)(HFX handle, int priority); +extern BOOL(WINAPI* BASS_FXReset)(DWORD handle); + +#endif diff --git a/OmniMIDIv2/inc/bassmidi.h b/OmniMIDIv2/inc/bassmidi.h new file mode 100644 index 00000000..de75164d --- /dev/null +++ b/OmniMIDIv2/inc/bassmidi.h @@ -0,0 +1,369 @@ +/* + + OmniMIDI v15+ (Rewrite) for Windows NT + + This file contains the required code to run the driver under Windows 7 SP1 and later. + This file is useful only if you want to compile the driver under Windows, it's not needed for Linux/macOS porting. + This header has been modified to work properly with the new rewrite. + + Original header: BASSMIDI 2.4 C/C++ header file + Copyright (c) 2006-2022 Un4seen Developments Ltd. + + See the BASSMIDI.CHM file for more detailed documentation + +*/ + +#ifndef _BASSMIDI_H +#define _BASSMIDI_H + +#include "bass.h" + +#if BASSVERSION!=0x204 +#error conflicting BASS and BASSMIDI versions +#endif + +#ifdef __OBJC__ +typedef int BOOL32; +#define BOOL BOOL32 // override objc's BOOL +#endif + +typedef DWORD HSOUNDFONT; // soundfont handle + +// Additional error codes returned by BASS_ErrorGetCode +#define BASS_ERROR_MIDI_INCLUDE 7000 // SFZ include file could not be opened + +// Additional BASS_SetConfig options +#define BASS_CONFIG_MIDI_COMPACT 0x10400 +#define BASS_CONFIG_MIDI_VOICES 0x10401 +#define BASS_CONFIG_MIDI_AUTOFONT 0x10402 +#define BASS_CONFIG_MIDI_IN_PORTS 0x10404 +#define BASS_CONFIG_MIDI_SAMPLETHREADS 0x10406 +#define BASS_CONFIG_MIDI_SAMPLEMEM 0x10407 +#define BASS_CONFIG_MIDI_SAMPLEREAD 0x10408 +#define BASS_CONFIG_MIDI_SAMPLELOADING 0x1040a + +// Additional BASS_SetConfigPtr options +#define BASS_CONFIG_MIDI_DEFFONT 0x10403 +#define BASS_CONFIG_MIDI_SFZHEAD 0x10409 + +// Additional sync types +#define BASS_SYNC_MIDI_MARK 0x10000 +#define BASS_SYNC_MIDI_MARKER 0x10000 +#define BASS_SYNC_MIDI_CUE 0x10001 +#define BASS_SYNC_MIDI_LYRIC 0x10002 +#define BASS_SYNC_MIDI_TEXT 0x10003 +#define BASS_SYNC_MIDI_EVENT 0x10004 +#define BASS_SYNC_MIDI_TICK 0x10005 +#define BASS_SYNC_MIDI_TIMESIG 0x10006 +#define BASS_SYNC_MIDI_KEYSIG 0x10007 + +// Additional BASS_MIDI_StreamCreateFile/etc flags +#define BASS_MIDI_NODRUMPARAM 0x400 +#define BASS_MIDI_NOSYSRESET 0x800 +#define BASS_MIDI_DECAYEND 0x1000 +#define BASS_MIDI_NOFX 0x2000 +#define BASS_MIDI_DECAYSEEK 0x4000 +#define BASS_MIDI_NOCROP 0x8000 +#define BASS_MIDI_NOTEOFF1 0x10000 +#define BASS_MIDI_ASYNC 0x400000 +#define BASS_MIDI_SINCINTER 0x800000 + +// BASS_MIDI_FontInit flags +#define BASS_MIDI_FONT_MEM 0x10000 +#define BASS_MIDI_FONT_MMAP 0x20000 +#define BASS_MIDI_FONT_XGDRUMS 0x40000 +#define BASS_MIDI_FONT_NOFX 0x80000 +#define BASS_MIDI_FONT_LINATTMOD 0x100000 +#define BASS_MIDI_FONT_LINDECVOL 0x200000 +#define BASS_MIDI_FONT_NORAMPIN 0x400000 +#define BASS_MIDI_FONT_NOLIMITS 0x800000 +#define BASS_MIDI_FONT_MINFX 0x1000000 + +typedef struct { + HSOUNDFONT font; // soundfont + int preset; // preset number (-1=all) + int bank; +} BASS_MIDI_FONT; + +typedef struct { + HSOUNDFONT font; // soundfont + int spreset; // source preset number + int sbank; // source bank number + int dpreset; // destination preset/program number + int dbank; // destination bank number + int dbanklsb; // destination bank number LSB +} BASS_MIDI_FONTEX; + +typedef struct { + HSOUNDFONT font; // soundfont + int spreset; // source preset number + int sbank; // source bank number + int dpreset; // destination preset/program number + int dbank; // destination bank number + int dbanklsb; // destination bank number LSB + DWORD minchan; // minimum channel number + DWORD numchan; // number of channels from minchan +} BASS_MIDI_FONTEX2; + +// BASS_MIDI_StreamSet/GetFonts flag +#define BASS_MIDI_FONT_EX 0x1000000 // BASS_MIDI_FONTEX +#define BASS_MIDI_FONT_EX2 0x2000000 // BASS_MIDI_FONTEX2 + +typedef struct { + const char* name; + const char* copyright; + const char* comment; + DWORD presets; // number of presets/instruments + DWORD samsize; // total size (in bytes) of the sample data + DWORD samload; // amount of sample data currently loaded + DWORD samtype; // sample format (CTYPE) if packed +} BASS_MIDI_FONTINFO; + +typedef struct { + DWORD track; // track containing marker + DWORD pos; // marker position + const char* text; // marker text +} BASS_MIDI_MARK; + +// Marker types +#define BASS_MIDI_MARK_MARKER 0 // marker +#define BASS_MIDI_MARK_CUE 1 // cue point +#define BASS_MIDI_MARK_LYRIC 2 // lyric +#define BASS_MIDI_MARK_TEXT 3 // text +#define BASS_MIDI_MARK_TIMESIG 4 // time signature +#define BASS_MIDI_MARK_KEYSIG 5 // key signature +#define BASS_MIDI_MARK_COPY 6 // copyright notice +#define BASS_MIDI_MARK_TRACK 7 // track name +#define BASS_MIDI_MARK_INST 8 // instrument name +#define BASS_MIDI_MARK_TRACKSTART 9 // track start (SMF2) +#define BASS_MIDI_MARK_TICK 0x10000 // flag: get position in ticks (otherwise bytes) + +// MIDI events +#define MIDI_EVENT_NOTE 1 +#define MIDI_EVENT_PROGRAM 2 +#define MIDI_EVENT_CHANPRES 3 +#define MIDI_EVENT_PITCH 4 +#define MIDI_EVENT_PITCHRANGE 5 +#define MIDI_EVENT_DRUMS 6 +#define MIDI_EVENT_FINETUNE 7 +#define MIDI_EVENT_COARSETUNE 8 +#define MIDI_EVENT_MASTERVOL 9 +#define MIDI_EVENT_BANK 10 +#define MIDI_EVENT_MODULATION 11 +#define MIDI_EVENT_VOLUME 12 +#define MIDI_EVENT_PAN 13 +#define MIDI_EVENT_EXPRESSION 14 +#define MIDI_EVENT_SUSTAIN 15 +#define MIDI_EVENT_SOUNDOFF 16 +#define MIDI_EVENT_RESET 17 +#define MIDI_EVENT_NOTESOFF 18 +#define MIDI_EVENT_PORTAMENTO 19 +#define MIDI_EVENT_PORTATIME 20 +#define MIDI_EVENT_PORTANOTE 21 +#define MIDI_EVENT_MODE 22 +#define MIDI_EVENT_REVERB 23 +#define MIDI_EVENT_CHORUS 24 +#define MIDI_EVENT_CUTOFF 25 +#define MIDI_EVENT_RESONANCE 26 +#define MIDI_EVENT_RELEASE 27 +#define MIDI_EVENT_ATTACK 28 +#define MIDI_EVENT_DECAY 29 +#define MIDI_EVENT_REVERB_MACRO 30 +#define MIDI_EVENT_CHORUS_MACRO 31 +#define MIDI_EVENT_REVERB_TIME 32 +#define MIDI_EVENT_REVERB_DELAY 33 +#define MIDI_EVENT_REVERB_LOCUTOFF 34 +#define MIDI_EVENT_REVERB_HICUTOFF 35 +#define MIDI_EVENT_REVERB_LEVEL 36 +#define MIDI_EVENT_CHORUS_DELAY 37 +#define MIDI_EVENT_CHORUS_DEPTH 38 +#define MIDI_EVENT_CHORUS_RATE 39 +#define MIDI_EVENT_CHORUS_FEEDBACK 40 +#define MIDI_EVENT_CHORUS_LEVEL 41 +#define MIDI_EVENT_CHORUS_REVERB 42 +#define MIDI_EVENT_USERFX 43 +#define MIDI_EVENT_USERFX_LEVEL 44 +#define MIDI_EVENT_USERFX_REVERB 45 +#define MIDI_EVENT_USERFX_CHORUS 46 +#define MIDI_EVENT_DRUM_FINETUNE 50 +#define MIDI_EVENT_DRUM_COARSETUNE 51 +#define MIDI_EVENT_DRUM_PAN 52 +#define MIDI_EVENT_DRUM_REVERB 53 +#define MIDI_EVENT_DRUM_CHORUS 54 +#define MIDI_EVENT_DRUM_CUTOFF 55 +#define MIDI_EVENT_DRUM_RESONANCE 56 +#define MIDI_EVENT_DRUM_LEVEL 57 +#define MIDI_EVENT_DRUM_USERFX 58 +#define MIDI_EVENT_SOFT 60 +#define MIDI_EVENT_SYSTEM 61 +#define MIDI_EVENT_TEMPO 62 +#define MIDI_EVENT_SCALETUNING 63 +#define MIDI_EVENT_CONTROL 64 +#define MIDI_EVENT_CHANPRES_VIBRATO 65 +#define MIDI_EVENT_CHANPRES_PITCH 66 +#define MIDI_EVENT_CHANPRES_FILTER 67 +#define MIDI_EVENT_CHANPRES_VOLUME 68 +#define MIDI_EVENT_MOD_VIBRATO 69 +#define MIDI_EVENT_MODRANGE 69 +#define MIDI_EVENT_BANK_LSB 70 +#define MIDI_EVENT_KEYPRES 71 +#define MIDI_EVENT_KEYPRES_VIBRATO 72 +#define MIDI_EVENT_KEYPRES_PITCH 73 +#define MIDI_EVENT_KEYPRES_FILTER 74 +#define MIDI_EVENT_KEYPRES_VOLUME 75 +#define MIDI_EVENT_SOSTENUTO 76 +#define MIDI_EVENT_MOD_PITCH 77 +#define MIDI_EVENT_MOD_FILTER 78 +#define MIDI_EVENT_MOD_VOLUME 79 +#define MIDI_EVENT_VIBRATO_RATE 80 +#define MIDI_EVENT_VIBRATO_DEPTH 81 +#define MIDI_EVENT_VIBRATO_DELAY 82 +#define MIDI_EVENT_MASTER_FINETUNE 83 +#define MIDI_EVENT_MASTER_COARSETUNE 84 +#define MIDI_EVENT_MIXLEVEL 0x10000 +#define MIDI_EVENT_TRANSPOSE 0x10001 +#define MIDI_EVENT_SYSTEMEX 0x10002 +#define MIDI_EVENT_SPEED 0x10004 +#define MIDI_EVENT_DEFDRUMS 0x10006 + +#define MIDI_EVENT_END 0 +#define MIDI_EVENT_END_TRACK 0x10003 + +#define MIDI_EVENT_NOTES 0x20000 +#define MIDI_EVENT_VOICES 0x20001 + +#define MIDI_SYSTEM_DEFAULT 0 +#define MIDI_SYSTEM_GM1 1 +#define MIDI_SYSTEM_GM2 2 +#define MIDI_SYSTEM_XG 3 +#define MIDI_SYSTEM_GS 4 + +typedef struct { + DWORD event; // MIDI_EVENT_xxx + DWORD param; + DWORD chan; + DWORD tick; // event position (ticks) + DWORD pos; // event position (bytes) +} BASS_MIDI_EVENT; + +// BASS_MIDI_StreamEvents modes +#define BASS_MIDI_EVENTS_STRUCT 0 // BASS_MIDI_EVENT structures +#define BASS_MIDI_EVENTS_RAW 0x10000 // raw MIDI event data +#define BASS_MIDI_EVENTS_SYNC 0x1000000 // flag: trigger event syncs +#define BASS_MIDI_EVENTS_NORSTATUS 0x2000000 // flag: no running status +#define BASS_MIDI_EVENTS_CANCEL 0x4000000 // flag: cancel pending events +#define BASS_MIDI_EVENTS_TIME 0x8000000 // flag: delta-time info is present +#define BASS_MIDI_EVENTS_ABSTIME 0x10000000 // flag: absolute time info is present +#define BASS_MIDI_EVENTS_ASYNC 0x20000000 // flag: process asynchronously +#define BASS_MIDI_EVENTS_FILTER 0x40000000 // flag: apply filtering +#define BASS_MIDI_EVENTS_FLUSH 0x80000000 // flag: flush async events + +// BASS_MIDI_StreamGetChannel special channels +#define BASS_MIDI_CHAN_CHORUS (DWORD)-1 +#define BASS_MIDI_CHAN_REVERB (DWORD)-2 +#define BASS_MIDI_CHAN_USERFX (DWORD)-3 + +// BASS_CHANNELINFO type +#define BASS_CTYPE_STREAM_MIDI 0x10d00 + +// Additional attributes +#define BASS_ATTRIB_MIDI_PPQN 0x12000 +#define BASS_ATTRIB_MIDI_CPU 0x12001 +#define BASS_ATTRIB_MIDI_CHANS 0x12002 +#define BASS_ATTRIB_MIDI_VOICES 0x12003 +#define BASS_ATTRIB_MIDI_VOICES_ACTIVE 0x12004 +#define BASS_ATTRIB_MIDI_STATE 0x12005 +#define BASS_ATTRIB_MIDI_SRC 0x12006 +#define BASS_ATTRIB_MIDI_KILL 0x12007 +#define BASS_ATTRIB_MIDI_SPEED 0x12008 +#define BASS_ATTRIB_MIDI_REVERB 0x12009 +#define BASS_ATTRIB_MIDI_VOL 0x1200a +#define BASS_ATTRIB_MIDI_TRACK_VOL 0x12100 // + track # + +// Additional tag type +#define BASS_TAG_MIDI_TRACK 0x11000 // + track #, track text : array of null-terminated ANSI strings + +// BASS_ChannelGetLength/GetPosition/SetPosition mode +#define BASS_POS_MIDI_TICK 2 // tick position + +typedef BOOL(CALLBACK MIDIFILTERPROC)(HSTREAM handle, int track, BASS_MIDI_EVENT* event, BOOL seeking, void* user); +/* Event filtering callback function. +handle : MIDI stream handle +track : Track containing the event +event : The event +seeking: TRUE = the event is being processed while seeking, FALSE = it is being played +user : The 'user' parameter value given when calling BASS_MIDI_StreamSetFilter +RETURN : TRUE = process the event, FALSE = drop the event */ + +// BASS_MIDI_FontLoadEx flags +#define BASS_MIDI_FONTLOAD_NOWAIT 1 // don't want for the samples to load +#define BASS_MIDI_FONTLOAD_COMPACT 2 // compact samples +#define BASS_MIDI_FONTLOAD_NOLOAD 4 // don't load (only compact) +#define BASS_MIDI_FONTLOAD_TIME 8 // length is in milliseconds +#define BASS_MIDI_FONTLOAD_KEEPDEC 16 // keep decoders + +// BASS_MIDI_FontPack flags +#define BASS_MIDI_PACK_NOHEAD 1 // don't send a WAV header to the encoder +#define BASS_MIDI_PACK_16BIT 2 // discard low 8 bits of 24-bit sample data +#define BASS_MIDI_PACK_48KHZ 4 // set encoding rate to 48000 Hz (else 44100 Hz) + +typedef struct { + const char* name; // description + DWORD id; + DWORD flags; +} BASS_MIDI_DEVICEINFO; + +typedef void (CALLBACK MIDIINPROC)(DWORD device, double time, const BYTE* buffer, DWORD length, void* user); +/* MIDI input callback function. +device : MIDI input device +time : Timestamp +buffer : Buffer containing MIDI data +length : Number of bytes of data +user : The 'user' parameter value given when calling BASS_MIDI_InInit */ + +extern DWORD(WINAPI* BASS_MIDI_GetVersion)(void); + +extern HSTREAM(WINAPI* BASS_MIDI_StreamCreate)(DWORD channels, DWORD flags, DWORD freq); +extern HSTREAM(WINAPI* BASS_MIDI_StreamCreateFile)(BOOL mem, const void* file, QWORD offset, QWORD length, DWORD flags, DWORD freq); +extern HSTREAM(WINAPI* BASS_MIDI_StreamCreateURL)(const char* url, DWORD offset, DWORD flags, DOWNLOADPROC* proc, void* user, DWORD freq); +extern HSTREAM(WINAPI* BASS_MIDI_StreamCreateFileUser)(DWORD system, DWORD flags, const BASS_FILEPROCS* procs, void* user, DWORD freq); +extern HSTREAM(WINAPI* BASS_MIDI_StreamCreateEvents)(const BASS_MIDI_EVENT* events, DWORD ppqn, DWORD flags, DWORD freq); +extern BOOL(WINAPI* BASS_MIDI_StreamGetMark)(HSTREAM handle, DWORD type, DWORD index, BASS_MIDI_MARK* mark); +extern DWORD(WINAPI* BASS_MIDI_StreamGetMarks)(HSTREAM handle, int track, DWORD type, BASS_MIDI_MARK* marks); +extern BOOL(WINAPI* BASS_MIDI_StreamSetFonts)(HSTREAM handle, const void* fonts, DWORD count); +extern DWORD(WINAPI* BASS_MIDI_StreamGetFonts)(HSTREAM handle, void* fonts, DWORD count); +extern BOOL(WINAPI* BASS_MIDI_StreamLoadSamples)(HSTREAM handle); +extern BOOL(WINAPI* BASS_MIDI_StreamEvent)(HSTREAM handle, DWORD chan, DWORD event, DWORD param); +extern DWORD(WINAPI* BASS_MIDI_StreamEvents)(HSTREAM handle, DWORD mode, const void* events, DWORD length); +extern DWORD(WINAPI* BASS_MIDI_StreamGetEvent)(HSTREAM handle, DWORD chan, DWORD event); +extern DWORD(WINAPI* BASS_MIDI_StreamGetEvents)(HSTREAM handle, int track, DWORD filter, BASS_MIDI_EVENT* events); +extern DWORD(WINAPI* BASS_MIDI_StreamGetEventsEx)(HSTREAM handle, int track, DWORD filter, BASS_MIDI_EVENT* events, DWORD start, DWORD count); +extern BOOL(WINAPI* BASS_MIDI_StreamGetPreset)(HSTREAM handle, DWORD chan, BASS_MIDI_FONT* font); +extern HSTREAM(WINAPI* BASS_MIDI_StreamGetChannel)(HSTREAM handle, DWORD chan); +extern BOOL(WINAPI* BASS_MIDI_StreamSetFilter)(HSTREAM handle, BOOL seeking, MIDIFILTERPROC* proc, void* user); + +extern HSOUNDFONT(WINAPI* BASS_MIDI_FontInit)(const void* file, DWORD flags); +extern HSOUNDFONT(WINAPI* BASS_MIDI_FontInitUser)(const BASS_FILEPROCS* procs, void* user, DWORD flags); +extern BOOL(WINAPI* BASS_MIDI_FontFree)(HSOUNDFONT handle); +extern BOOL(WINAPI* BASS_MIDI_FontGetInfo)(HSOUNDFONT handle, BASS_MIDI_FONTINFO* info); +extern BOOL(WINAPI* BASS_MIDI_FontGetPresets)(HSOUNDFONT handle, DWORD* presets); +extern const char* (WINAPI* BASS_MIDI_FontGetPreset)(HSOUNDFONT handle, int preset, int bank); +extern BOOL(WINAPI* BASS_MIDI_FontLoad)(HSOUNDFONT handle, int preset, int bank); +extern BOOL(WINAPI* BASS_MIDI_FontLoadEx)(HSOUNDFONT handle, int preset, int bank, DWORD length, DWORD flags); +extern BOOL(WINAPI* BASS_MIDI_FontUnload)(HSOUNDFONT handle, int preset, int bank); +extern BOOL(WINAPI* BASS_MIDI_FontCompact)(HSOUNDFONT handle); +extern BOOL(WINAPI* BASS_MIDI_FontPack)(HSOUNDFONT handle, const void* outfile, const void* encoder, DWORD flags); +extern BOOL(WINAPI* BASS_MIDI_FontUnpack)(HSOUNDFONT handle, const void* outfile, DWORD flags); +extern DWORD(WINAPI* BASS_MIDI_FontFlags)(HSOUNDFONT handle, DWORD flags, DWORD mask); +extern BOOL(WINAPI* BASS_MIDI_FontSetVolume)(HSOUNDFONT handle, float volume); +extern float (WINAPI* BASS_MIDI_FontGetVolume)(HSOUNDFONT handle); + +extern DWORD(WINAPI* BASS_MIDI_ConvertEvents)(const BYTE* data, DWORD length, BASS_MIDI_EVENT* events, DWORD count, DWORD flags); + +extern BOOL(WINAPI* BASS_MIDI_InGetDeviceInfo)(DWORD device, BASS_MIDI_DEVICEINFO* info); +extern BOOL(WINAPI* BASS_MIDI_InInit)(DWORD device, MIDIINPROC* proc, void* user); +extern BOOL(WINAPI* BASS_MIDI_InFree)(DWORD device); +extern BOOL(WINAPI* BASS_MIDI_InStart)(DWORD device); +extern BOOL(WINAPI* BASS_MIDI_InStop)(DWORD device); + +#endif diff --git a/OmniMIDIv2/inc/cmmddk.h b/OmniMIDIv2/inc/cmmddk.h new file mode 100644 index 00000000..bac93b72 --- /dev/null +++ b/OmniMIDIv2/inc/cmmddk.h @@ -0,0 +1,481 @@ +/* +* Copyright 1998, Luiz Otavio L. Zorzella +* 1999, Eric Pouech +* +* Purpose: multimedia declarations (external to WINMM & MMSYSTEM DLLs +* for other DLLs (MCI, drivers...)) +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2.1 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA +*/ +#ifndef __MMDDK_H +#define __MMDDK_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define MAX_MIDIINDRV (16) + /* For now I'm making 16 the maximum number of midi devices one can + * have. This should be more than enough for everybody. But as a purist, + * I intend to make it unbounded in the future, as soon as I figure + * a good way to do so. + */ +#define MAX_MIDIOUTDRV (16) + + /* ================================== + * Multimedia DDK compatible part + * ================================== */ + +#include + +#define DRVM_INIT 100 +#define DRVM_EXIT 101 +#define DRVM_DISABLE 102 +#define DRVM_ENABLE 103 + + /* messages that have IOCTL format + * dw1 = NULL or handle + * dw2 = NULL or ptr to DRVM_IOCTL_DATA + * return is MMRESULT + */ +#define DRVM_IOCTL 0x100 +#define DRVM_ADD_THRU (DRVM_IOCTL+1) +#define DRVM_REMOVE_THRU (DRVM_IOCTL+2) +#define DRVM_IOCTL_LAST (DRVM_IOCTL+5) + typedef struct { + DWORD dwSize; /* size of this structure */ + DWORD dwCmd; /* IOCTL command code, 0x80000000 and above reserved for system */ + } DRVM_IOCTL_DATA, *LPDRVM_IOCTL_DATA; + + /* command code ranges for dwCmd field of DRVM_IOCTL message + * - codes from 0 to 0x7FFFFFFF are user defined + * - codes from 0x80000000 to 0xFFFFFFFF are reserved for future definition by microsoft + */ +#define DRVM_IOCTL_CMD_USER __MSABI_LONG(0x00000000) +#define DRVM_IOCTL_CMD_SYSTEM __MSABI_LONG(0x80000000) + +#define DRVM_MAPPER 0x2000 +#define DRVM_USER 0x4000 +#define DRVM_MAPPER_STATUS (DRVM_MAPPER+0) +#define DRVM_MAPPER_RECONFIGURE (DRVM_MAPPER+1) +#define DRVM_MAPPER_PREFERRED_GET (DRVM_MAPPER+21) +#define DRVM_MAPPER_CONSOLEVOICECOM_GET (DRVM_MAPPER+23) + +#define DRV_QUERYDRVENTRY (DRV_RESERVED + 1) +#define DRV_QUERYDEVNODE (DRV_RESERVED + 2) +#define DRV_QUERYNAME (DRV_RESERVED + 3) +#define DRV_QUERYDRIVERIDS (DRV_RESERVED + 4) +#define DRV_QUERYMAPPABLE (DRV_RESERVED + 5) +#define DRV_QUERYMODULE (DRV_RESERVED + 9) +#define DRV_PNPINSTALL (DRV_RESERVED + 11) +#define DRV_QUERYDEVICEINTERFACE (DRV_RESERVED + 12) +#define DRV_QUERYDEVICEINTERFACESIZE (DRV_RESERVED + 13) +#define DRV_QUERYSTRINGID (DRV_RESERVED + 14) +#define DRV_QUERYSTRINGIDSIZE (DRV_RESERVED + 15) +#define DRV_QUERYIDFROMSTRINGID (DRV_RESERVED + 16) +#define DRV_QUERYFUNCTIONINSTANCEID (DRV_RESERVED + 17) +#define DRV_QUERYFUNCTIONINSTANCEIDSIZE (DRV_RESERVED + 18) + +#define DRVM_MAPPER_PREFERRED_FLAGS_PREFERREDONLY 0x00000001 + +#define WODM_INIT DRVM_INIT +#define WODM_GETNUMDEVS 3 +#define WODM_GETDEVCAPS 4 +#define WODM_OPEN 5 +#define WODM_CLOSE 6 +#define WODM_PREPARE 7 +#define WODM_UNPREPARE 8 +#define WODM_WRITE 9 +#define WODM_PAUSE 10 +#define WODM_RESTART 11 +#define WODM_RESET 12 +#define WODM_GETPOS 13 +#define WODM_GETPITCH 14 +#define WODM_SETPITCH 15 +#define WODM_GETVOLUME 16 +#define WODM_SETVOLUME 17 +#define WODM_GETPLAYBACKRATE 18 +#define WODM_SETPLAYBACKRATE 19 +#define WODM_BREAKLOOP 20 +#define WODM_PREFERRED 21 + +#define WODM_MAPPER_STATUS (DRVM_MAPPER_STATUS + 0) +#define WAVEOUT_MAPPER_STATUS_DEVICE 0 +#define WAVEOUT_MAPPER_STATUS_MAPPED 1 +#define WAVEOUT_MAPPER_STATUS_FORMAT 2 + +#define WODM_BUSY 21 + +#define WIDM_INIT DRVM_INIT +#define WIDM_GETNUMDEVS 50 +#define WIDM_GETDEVCAPS 51 +#define WIDM_OPEN 52 +#define WIDM_CLOSE 53 +#define WIDM_PREPARE 54 +#define WIDM_UNPREPARE 55 +#define WIDM_ADDBUFFER 56 +#define WIDM_START 57 +#define WIDM_STOP 58 +#define WIDM_RESET 59 +#define WIDM_GETPOS 60 +#define WIDM_PREFERRED 61 +#define WIDM_MAPPER_STATUS (DRVM_MAPPER_STATUS + 0) +#define WAVEIN_MAPPER_STATUS_DEVICE 0 +#define WAVEIN_MAPPER_STATUS_MAPPED 1 +#define WAVEIN_MAPPER_STATUS_FORMAT 2 + +#define MODM_INIT DRVM_INIT +#define MODM_GETNUMDEVS 1 +#define MODM_GETDEVCAPS 2 +#define MODM_OPEN 3 +#define MODM_CLOSE 4 +#define MODM_PREPARE 5 +#define MODM_UNPREPARE 6 +#define MODM_DATA 7 +#define MODM_LONGDATA 8 +#define MODM_RESET 9 +#define MODM_GETVOLUME 10 +#define MODM_SETVOLUME 11 +#define MODM_CACHEPATCHES 12 +#define MODM_CACHEDRUMPATCHES 13 + +#if (WINVER >= 0x400) +#define MODM_STRMDATA 14 +#define MODM_GETPOS 17 +#define MODM_PAUSE 18 +#define MODM_RESTART 19 +#define MODM_STOP 20 +#define MODM_PROPERTIES 21 +#define MODM_PREFERRED 22 +#define MODM_RECONFIGURE (0x4000+0x0768) +#endif + +#define MIDM_INIT DRVM_INIT +#define MIDM_GETNUMDEVS 53 +#define MIDM_GETDEVCAPS 54 +#define MIDM_OPEN 55 +#define MIDM_CLOSE 56 +#define MIDM_PREPARE 57 +#define MIDM_UNPREPARE 58 +#define MIDM_ADDBUFFER 59 +#define MIDM_START 60 +#define MIDM_STOP 61 +#define MIDM_RESET 62 + + +#define AUXM_INIT DRVM_INIT +#define AUXDM_GETNUMDEVS 3 +#define AUXDM_GETDEVCAPS 4 +#define AUXDM_GETVOLUME 5 +#define AUXDM_SETVOLUME 6 + +#define MXDM_INIT DRVM_INIT +#define MXDM_USER DRVM_USER +#define MXDM_MAPPER DRVM_MAPPER + +#define MXDM_GETNUMDEVS 1 +#define MXDM_GETDEVCAPS 2 +#define MXDM_OPEN 3 +#define MXDM_CLOSE 4 +#define MXDM_GETLINEINFO 5 +#define MXDM_GETLINECONTROLS 6 +#define MXDM_GETCONTROLDETAILS 7 +#define MXDM_SETCONTROLDETAILS 8 + + /* pre-defined joystick types */ +#define JOY_HW_NONE 0 +#define JOY_HW_CUSTOM 1 +#define JOY_HW_2A_2B_GENERIC 2 +#define JOY_HW_2A_4B_GENERIC 3 +#define JOY_HW_2B_GAMEPAD 4 +#define JOY_HW_2B_FLIGHTYOKE 5 +#define JOY_HW_2B_FLIGHTYOKETHROTTLE 6 +#define JOY_HW_3A_2B_GENERIC 7 +#define JOY_HW_3A_4B_GENERIC 8 +#define JOY_HW_4B_GAMEPAD 9 +#define JOY_HW_4B_FLIGHTYOKE 10 +#define JOY_HW_4B_FLIGHTYOKETHROTTLE 11 +#define JOY_HW_LASTENTRY 12 + + /* calibration flags */ +#define JOY_ISCAL_XY __MSABI_LONG(0x00000001) /* XY are calibrated */ +#define JOY_ISCAL_Z __MSABI_LONG(0x00000002) /* Z is calibrated */ +#define JOY_ISCAL_R __MSABI_LONG(0x00000004) /* R is calibrated */ +#define JOY_ISCAL_U __MSABI_LONG(0x00000008) /* U is calibrated */ +#define JOY_ISCAL_V __MSABI_LONG(0x00000010) /* V is calibrated */ +#define JOY_ISCAL_POV __MSABI_LONG(0x00000020) /* POV is calibrated */ + + /* point of view constants */ +#define JOY_POV_NUMDIRS 4 +#define JOY_POVVAL_FORWARD 0 +#define JOY_POVVAL_BACKWARD 1 +#define JOY_POVVAL_LEFT 2 +#define JOY_POVVAL_RIGHT 3 + + /* Specific settings for joystick hardware */ +#define JOY_HWS_HASZ __MSABI_LONG(0x00000001) /* has Z info? */ +#define JOY_HWS_HASPOV __MSABI_LONG(0x00000002) /* point of view hat present */ +#define JOY_HWS_POVISBUTTONCOMBOS __MSABI_LONG(0x00000004) /* pov done through combo of buttons */ +#define JOY_HWS_POVISPOLL __MSABI_LONG(0x00000008) /* pov done through polling */ +#define JOY_HWS_ISYOKE __MSABI_LONG(0x00000010) /* joystick is a flight yoke */ +#define JOY_HWS_ISGAMEPAD __MSABI_LONG(0x00000020) /* joystick is a game pad */ +#define JOY_HWS_ISCARCTRL __MSABI_LONG(0x00000040) /* joystick is a car controller */ + /* X defaults to J1 X axis */ +#define JOY_HWS_XISJ1Y __MSABI_LONG(0x00000080) /* X is on J1 Y axis */ +#define JOY_HWS_XISJ2X __MSABI_LONG(0x00000100) /* X is on J2 X axis */ +#define JOY_HWS_XISJ2Y __MSABI_LONG(0x00000200) /* X is on J2 Y axis */ + /* Y defaults to J1 Y axis */ +#define JOY_HWS_YISJ1X __MSABI_LONG(0x00000400) /* Y is on J1 X axis */ +#define JOY_HWS_YISJ2X __MSABI_LONG(0x00000800) /* Y is on J2 X axis */ +#define JOY_HWS_YISJ2Y __MSABI_LONG(0x00001000) /* Y is on J2 Y axis */ + /* Z defaults to J2 Y axis */ +#define JOY_HWS_ZISJ1X __MSABI_LONG(0x00002000) /* Z is on J1 X axis */ +#define JOY_HWS_ZISJ1Y __MSABI_LONG(0x00004000) /* Z is on J1 Y axis */ +#define JOY_HWS_ZISJ2X __MSABI_LONG(0x00008000) /* Z is on J2 X axis */ + /* POV defaults to J2 Y axis, if it is not button based */ +#define JOY_HWS_POVISJ1X __MSABI_LONG(0x00010000) /* pov done through J1 X axis */ +#define JOY_HWS_POVISJ1Y __MSABI_LONG(0x00020000) /* pov done through J1 Y axis */ +#define JOY_HWS_POVISJ2X __MSABI_LONG(0x00040000) /* pov done through J2 X axis */ + /* R defaults to J2 X axis */ +#define JOY_HWS_HASR __MSABI_LONG(0x00080000) /* has R (4th axis) info */ +#define JOY_HWS_RISJ1X __MSABI_LONG(0x00100000) /* R done through J1 X axis */ +#define JOY_HWS_RISJ1Y __MSABI_LONG(0x00200000) /* R done through J1 Y axis */ +#define JOY_HWS_RISJ2Y __MSABI_LONG(0x00400000) /* R done through J2 X axis */ + /* U & V for future hardware */ +#define JOY_HWS_HASU __MSABI_LONG(0x00800000) /* has U (5th axis) info */ +#define JOY_HWS_HASV __MSABI_LONG(0x01000000) /* has V (6th axis) info */ + + /* Usage settings */ +#define JOY_US_HASRUDDER __MSABI_LONG(0x00000001) /* joystick configured with rudder */ +#define JOY_US_PRESENT __MSABI_LONG(0x00000002) /* is joystick actually present? */ +#define JOY_US_ISOEM __MSABI_LONG(0x00000004) /* joystick is an OEM defined type */ + + + /* struct for storing x,y, z, and rudder values */ + typedef struct joypos_tag { + DWORD dwX; + DWORD dwY; + DWORD dwZ; + DWORD dwR; + DWORD dwU; + DWORD dwV; + } JOYPOS, *LPJOYPOS; + + /* struct for storing ranges */ + typedef struct joyrange_tag { + JOYPOS jpMin; + JOYPOS jpMax; + JOYPOS jpCenter; + } JOYRANGE, *LPJOYRANGE; + + typedef struct joyreguservalues_tag { + DWORD dwTimeOut; /* value at which to timeout joystick polling */ + JOYRANGE jrvRanges; /* range of values app wants returned for axes */ + JOYPOS jpDeadZone; /* area around center to be considered + as "dead". specified as a percentage + (0-100). Only X & Y handled by system driver */ + } JOYREGUSERVALUES, *LPJOYREGUSERVALUES; + + typedef struct joyreghwsettings_tag { + DWORD dwFlags; + DWORD dwNumButtons; /* number of buttons */ + } JOYREGHWSETTINGS, *LPJOYHWSETTINGS; + + /* range of values returned by the hardware (filled in by calibration) */ + typedef struct joyreghwvalues_tag { + JOYRANGE jrvHardware; /* values returned by hardware */ + DWORD dwPOVValues[JOY_POV_NUMDIRS];/* POV values returned by hardware */ + DWORD dwCalFlags; /* what has been calibrated */ + } JOYREGHWVALUES, *LPJOYREGHWVALUES; + + /* hardware configuration */ + typedef struct joyreghwconfig_tag { + JOYREGHWSETTINGS hws; /* hardware settings */ + DWORD dwUsageSettings;/* usage settings */ + JOYREGHWVALUES hwv; /* values returned by hardware */ + DWORD dwType; /* type of joystick */ + DWORD dwReserved; /* reserved for OEM drivers */ + } JOYREGHWCONFIG, *LPJOYREGHWCONFIG; + + /* joystick calibration info structure */ + typedef struct joycalibrate_tag { + UINT wXbase; + UINT wXdelta; + UINT wYbase; + UINT wYdelta; + UINT wZbase; + UINT wZdelta; + } JOYCALIBRATE; + typedef JOYCALIBRATE *LPJOYCALIBRATE; + + /* prototype for joystick message function */ + typedef UINT(CALLBACK * JOYDEVMSGPROC)(DWORD dwID, UINT uMessage, LPARAM lParam1, LPARAM lParam2); + typedef JOYDEVMSGPROC *LPJOYDEVMSGPROC; + + /* messages sent to joystick driver's DriverProc() function */ +#define JDD_GETNUMDEVS (DRV_RESERVED + 0x0001) +#define JDD_GETDEVCAPS (DRV_RESERVED + 0x0002) +#define JDD_GETPOS (DRV_RESERVED + 0x0101) +#define JDD_SETCALIBRATION (DRV_RESERVED + 0x0102) +#define JDD_CONFIGCHANGED (DRV_RESERVED + 0x0103) +#define JDD_GETPOSEX (DRV_RESERVED + 0x0104) + +#define MCI_MAX_DEVICE_TYPE_LENGTH 80 + +#define MCI_FALSE (MCI_STRING_OFFSET + 19) +#define MCI_TRUE (MCI_STRING_OFFSET + 20) + +#define MCI_FORMAT_RETURN_BASE MCI_FORMAT_MILLISECONDS_S +#define MCI_FORMAT_MILLISECONDS_S (MCI_STRING_OFFSET + 21) +#define MCI_FORMAT_HMS_S (MCI_STRING_OFFSET + 22) +#define MCI_FORMAT_MSF_S (MCI_STRING_OFFSET + 23) +#define MCI_FORMAT_FRAMES_S (MCI_STRING_OFFSET + 24) +#define MCI_FORMAT_SMPTE_24_S (MCI_STRING_OFFSET + 25) +#define MCI_FORMAT_SMPTE_25_S (MCI_STRING_OFFSET + 26) +#define MCI_FORMAT_SMPTE_30_S (MCI_STRING_OFFSET + 27) +#define MCI_FORMAT_SMPTE_30DROP_S (MCI_STRING_OFFSET + 28) +#define MCI_FORMAT_BYTES_S (MCI_STRING_OFFSET + 29) +#define MCI_FORMAT_SAMPLES_S (MCI_STRING_OFFSET + 30) +#define MCI_FORMAT_TMSF_S (MCI_STRING_OFFSET + 31) + +#define MCI_VD_FORMAT_TRACK_S (MCI_VD_OFFSET + 5) + +#define WAVE_FORMAT_PCM_S (MCI_WAVE_OFFSET + 0) +#define WAVE_MAPPER_S (MCI_WAVE_OFFSET + 1) + +#define MCI_SEQ_MAPPER_S (MCI_SEQ_OFFSET + 5) +#define MCI_SEQ_FILE_S (MCI_SEQ_OFFSET + 6) +#define MCI_SEQ_MIDI_S (MCI_SEQ_OFFSET + 7) +#define MCI_SEQ_SMPTE_S (MCI_SEQ_OFFSET + 8) +#define MCI_SEQ_FORMAT_SONGPTR_S (MCI_SEQ_OFFSET + 9) +#define MCI_SEQ_NONE_S (MCI_SEQ_OFFSET + 10) +#define MIDIMAPPER_S (MCI_SEQ_OFFSET + 11) + +#define MCI_RESOURCE_RETURNED 0x00010000 /* resource ID */ +#define MCI_COLONIZED3_RETURN 0x00020000 /* colonized ID, 3 bytes data */ +#define MCI_COLONIZED4_RETURN 0x00040000 /* colonized ID, 4 bytes data */ +#define MCI_INTEGER_RETURNED 0x00080000 /* integer conversion needed */ +#define MCI_RESOURCE_DRIVER 0x00100000 /* driver owns returned resource */ + +#define MCI_NO_COMMAND_TABLE 0xFFFF + +#define MCI_COMMAND_HEAD 0 +#define MCI_STRING 1 +#define MCI_INTEGER 2 +#define MCI_END_COMMAND 3 +#define MCI_RETURN 4 +#define MCI_FLAG 5 +#define MCI_END_COMMAND_LIST 6 +#define MCI_RECT 7 +#define MCI_CONSTANT 8 +#define MCI_END_CONSTANT 9 +#define MCI_HWND 10 +#define MCI_HPAL 11 +#define MCI_HDC 12 + +#ifdef _WIN64 +#define MCI_INTEGER64 13 +#endif /* _WIN64 */ + +#define MAKEMCIRESOURCE(wRet, wRes) MAKELRESULT((wRet), (wRes)) + + typedef struct { + HWAVE hWave; + LPWAVEFORMATEX lpFormat; + DWORD_PTR dwCallback; + DWORD_PTR dwInstance; + UINT uMappedDeviceID; + DWORD_PTR dnDevNode; + } WAVEOPENDESC, *LPWAVEOPENDESC; + + typedef struct { + DWORD dwStreamID; + WORD wDeviceID; + } MIDIOPENSTRMID; + + typedef struct { + HMIDI hMidi; + DWORD_PTR dwCallback; + DWORD_PTR dwInstance; + DWORD_PTR dnDevNode; + DWORD cIds; + MIDIOPENSTRMID rgIds; + } MIDIOPENDESC, *LPMIDIOPENDESC; + + typedef struct tMIXEROPENDESC + { + HMIXEROBJ hmx; + LPVOID pReserved0; + DWORD_PTR dwCallback; + DWORD_PTR dwInstance; + DWORD_PTR dnDevNode; + } MIXEROPENDESC, *LPMIXEROPENDESC; + + typedef struct { + UINT wDeviceID; /* device ID */ + LPSTR lpstrParams; /* parameter string for entry in SYSTEM.INI */ + UINT wCustomCommandTable; /* custom command table (0xFFFF if none) * filled in by the driver */ + UINT wType; /* driver type (filled in by the driver) */ + } MCI_OPEN_DRIVER_PARMSA, *LPMCI_OPEN_DRIVER_PARMSA; + + typedef struct { + UINT wDeviceID; /* device ID */ + LPWSTR lpstrParams; /* parameter string for entry in SYSTEM.INI */ + UINT wCustomCommandTable; /* custom command table (0xFFFF if none) * filled in by the driver */ + UINT wType; /* driver type (filled in by the driver) */ + } MCI_OPEN_DRIVER_PARMSW, *LPMCI_OPEN_DRIVER_PARMSW; + + DWORD_PTR WINAPI mciGetDriverData(UINT uDeviceID); + BOOL WINAPI mciSetDriverData(UINT uDeviceID, DWORD_PTR dwData); + UINT WINAPI mciDriverYield(UINT uDeviceID); +#ifndef _MCIAPI_H_ + BOOL WINAPI mciDriverNotify(HWND hwndCallback, UINT uDeviceID, + UINT uStatus); + UINT WINAPI mciLoadCommandResource(HINSTANCE hInstance, + LPCWSTR lpResName, UINT uType); +#endif + BOOL WINAPI mciFreeCommandResource(UINT uTable); + +#define DCB_NULL 0x0000 +#define DCB_WINDOW 0x0001 /* dwCallback is a HWND */ +#define DCB_TASK 0x0002 /* dwCallback is a HTASK */ +#define DCB_FUNCTION 0x0003 /* dwCallback is a FARPROC */ +#define DCB_EVENT 0x0005 /* dwCallback is an EVENT Handler */ +#define DCB_TYPEMASK 0x0007 +#define DCB_NOSWITCH 0x0008 /* don't switch stacks for callback */ + + BOOL APIENTRY DriverCallback(DWORD_PTR dwCallback, DWORD dwFlags, + HDRVR hDevice, DWORD dwMsg, DWORD_PTR dwUser, DWORD_PTR dwParam1, DWORD_PTR dwParam2); + + typedef VOID(*LPTASKCALLBACK)(DWORD_PTR dwInst); + +#define TASKERR_NOTASKSUPPORT 1 +#define TASKERR_OUTOFMEMORY 2 + UINT WINAPI mmTaskCreate(LPTASKCALLBACK, HANDLE*, DWORD_PTR); + VOID WINAPI mmTaskBlock(DWORD); + BOOL WINAPI mmTaskSignal(DWORD); + VOID WINAPI mmTaskYield(VOID); + DWORD WINAPI mmGetCurrentTask(VOID); + +#include + +#ifdef __cplusplus +} +#endif + +#endif /* __MMDDK_H */ \ No newline at end of file diff --git a/OmniMIDIv2/pch.cpp b/OmniMIDIv2/pch.cpp new file mode 100644 index 00000000..64b7eef6 --- /dev/null +++ b/OmniMIDIv2/pch.cpp @@ -0,0 +1,5 @@ +// pch.cpp: source file corresponding to the pre-compiled header + +#include "pch.h" + +// When you are using pre-compiled headers, this source file is necessary for compilation to succeed. diff --git a/OmniMIDIv2/pch.h b/OmniMIDIv2/pch.h new file mode 100644 index 00000000..7f554852 --- /dev/null +++ b/OmniMIDIv2/pch.h @@ -0,0 +1,14 @@ +// pch.h: This is a precompiled header file. +// Files listed below are compiled only once, improving build performance for future builds. +// This also affects IntelliSense performance, including code completion and many code browsing features. +// However, files listed here are ALL re-compiled if any one of them is updated between builds. +// Do not add files here that you will be updating frequently as this negates the performance advantage. + +#ifndef PCH_H +#define PCH_H + +// add headers that you want to pre-compile here +#include "framework.h" +#include + +#endif //PCH_H