Decompiled source of Cyberpunk Custom Sounds and Hitmarkers v2.1.0
Mods/AudioImportLib.dll
Decompiled a year ago
The result has been truncated due to the large size, download it to view full contents!
#define DEBUG using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Net; using System.Net.Configuration; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.InteropServices.ComTypes; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Threading; using System.Threading.Tasks; using AudioImportLib; using CSCore; using CSCore.Codecs; using CSCore.Codecs.AAC; using CSCore.Codecs.AIFF; using CSCore.Codecs.FLAC; using CSCore.Codecs.FLAC.Metadata; using CSCore.Codecs.MP3; using CSCore.Codecs.OGG; using CSCore.Codecs.WAV; using CSCore.CoreAudioAPI; using CSCore.DMO; using CSCore.DMO.Effects; using CSCore.DSP; using CSCore.DirectSound; using CSCore.MediaFoundation; using CSCore.SoundIn; using CSCore.SoundOut; using CSCore.SoundOut.MMInterop; using CSCore.Streams; using CSCore.Streams.SampleConverter; using CSCore.Tags.ID3; using CSCore.Tags.ID3.Frames; using CSCore.Utils; using CSCore.Utils.Buffer; using CSCore.Win32; using Il2CppSystem; using MelonLoader; using NLayer; using NLayer.Decoder; using NVorbis; using NVorbis.Contracts; using NVorbis.Contracts.Ogg; using NVorbis.Ogg; using Un4seen.Bass; using UnhollowerBaseLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("AudioImportLib")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany(null)] [assembly: AssemblyProduct("AudioImportLib")] [assembly: AssemblyCopyright("Created by trev & zCubed")] [assembly: AssemblyTrademark(null)] [assembly: ComVisible(false)] [assembly: AssemblyFileVersion("1.0.0")] [assembly: NeutralResourcesLanguage("en")] [assembly: MelonInfo(typeof(Core), "AudioImportLib", "1.0.0", "trev & zCubed", null)] [assembly: MelonGame(null, null)] [assembly: MelonPriority(1000)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace Un4seen.Bass { [SuppressUnmanagedCodeSecurity] public sealed class Bass { private static object _mutex; private static bool _usesMF; private static bool _usesCA; public static string SupportedStreamExtensions; public static string SupportedStreamName; public static string SupportedMusicExtensions; internal static bool _configUTF8; public const int BASSVERSION = 516; public const int FALSE = 0; public const int TRUE = 1; public const int ERROR = -1; private static int _myModuleHandle; private const string _myModuleName = "bass"; public static bool UsesMediaFoundation => _usesMF; public static bool UsesCoreAudio => _usesCA; static Bass() { _mutex = new object(); _usesMF = false; _usesCA = false; SupportedStreamExtensions = "*.mp3;*.ogg;*.wav;*.mp2;*.mp1;*.aiff;*.m2a;*.mpa;*.m1a;*.mpg;*.mpeg;*.aif;*.mp3pro;*.bwf;*.mus"; SupportedStreamName = "WAV/AIFF/MP3/MP2/MP1/OGG"; SupportedMusicExtensions = "*.mod;*.mo3;*.s3m;*.xm;*.it;*.mtm;*.umx;*.mdz;*.s3z;*.itz;*.xmz"; _configUTF8 = false; _myModuleHandle = 0; string text = string.Empty; try { text = new StackFrame(1).GetMethod().Name; } catch { } if (!text.Equals("LoadMe")) { InitBass(); } } private static void InitBass() { if (!BassNet.OmitCheckVersion) { CheckVersion(); } _configUTF8 = BASS_SetConfig(BASSConfig.BASS_CONFIG_UNICODE, 1) || Environment.OSVersion.Platform > PlatformID.WinCE; try { if (BASS_GetVersion() >= 33818624 && Environment.OSVersion.Platform == PlatformID.MacOSX) { _usesCA = true; SupportedStreamExtensions += ";*.aac;*.adts;*.mp4;*.m4a;*.m4b;*.m4p;*.ac3;*.caf;*.mov"; SupportedStreamName += "/AAC/MP4/AC3/CAF"; } } catch { } try { if (BASS_GetVersion() >= 33818624 && Environment.OSVersion.Platform <= PlatformID.WinCE && File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "mfreadwrite.dll"))) { _usesMF = true; SupportedStreamExtensions += ";*.wma;*.wmv;*.aac;*.adts;*.mp4;*.m4a;*.m4b;*.m4p"; SupportedStreamName += "/WMA/AAC/MP4"; } else if (BASS_GetVersion() >= 33818624 && Environment.OSVersion.Platform == PlatformID.MacOSX) { _usesCA = true; SupportedStreamExtensions += ";*.aac;*.adts;*.mp4;*.m4a;*.m4b;*.m4p;*.ac3;*.caf;*.mov"; SupportedStreamName += "/AAC/MP4/AC3/CAF"; } } catch { } } [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool BASS_Init(int device, int freq, BASSInit flags, IntPtr win, IntPtr clsid); public static bool BASS_Init(int device, int freq, BASSInit flags, IntPtr win) { return BASS_Init(device, freq, flags, win, IntPtr.Zero); } [DllImport("bass", EntryPoint = "BASS_Init")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool BASS_InitGuid(int device, int freq, BASSInit flags, IntPtr win, [MarshalAs(UnmanagedType.LPStruct)] Guid clsid); public static bool BASS_Init(int device, int freq, BASSInit flags, IntPtr win, Guid clsid) { if (clsid == Guid.Empty) { return BASS_Init(device, freq, flags, win, IntPtr.Zero); } return BASS_InitGuid(device, freq, flags, win, clsid); } [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_IsStarted(); [DllImport("bass", EntryPoint = "BASS_GetDeviceInfo")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool BASS_GetDeviceInfoInternal([In] int device, [In][Out] ref BASS_DEVICEINFO_INTERNAL info); public unsafe static bool BASS_GetDeviceInfo(int device, BASS_DEVICEINFO info) { bool flag = BASS_GetDeviceInfoInternal(device, ref info._internal); if (flag) { if (_configUTF8) { info.name = Utils.IntPtrAsStringUtf8(info._internal.name, out var len); info.driver = Utils.IntPtrAsStringUtf8(info._internal.driver, out len); if (len > 0 && BASS_GetVersion() > 33818624 && Environment.OSVersion.Platform < PlatformID.WinCE) { try { info.id = Utils.IntPtrAsStringUtf8(new IntPtr((byte*)info._internal.driver.ToPointer() + len + 1), out len); } catch { } } } else { info.name = Utils.IntPtrAsStringAnsi(info._internal.name); info.driver = Utils.IntPtrAsStringAnsi(info._internal.driver); if (!string.IsNullOrEmpty(info.driver) && BASS_GetVersion() > 33818624 && Environment.OSVersion.Platform < PlatformID.WinCE) { try { info.id = Utils.IntPtrAsStringAnsi(new IntPtr((byte*)info._internal.driver.ToPointer() + info.driver.Length + 1)); } catch { } } } info.flags = info._internal.flags; } return flag; } public static BASS_DEVICEINFO BASS_GetDeviceInfo(int device) { BASS_DEVICEINFO bASS_DEVICEINFO = new BASS_DEVICEINFO(); if (BASS_GetDeviceInfo(device, bASS_DEVICEINFO)) { return bASS_DEVICEINFO; } return null; } public static BASS_DEVICEINFO[] BASS_GetDeviceInfos() { List<BASS_DEVICEINFO> list = new List<BASS_DEVICEINFO>(); int num = 0; BASS_DEVICEINFO item; while ((item = BASS_GetDeviceInfo(num)) != null) { list.Add(item); num++; } BASS_GetCPU(); return list.ToArray(); } public static int BASS_GetDeviceCount() { BASS_DEVICEINFO info = new BASS_DEVICEINFO(); int i; for (i = 0; BASS_GetDeviceInfo(i, info); i++) { } BASS_GetCPU(); return i; } [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_GetInfo([In][Out] BASS_INFO info); public static BASS_INFO BASS_GetInfo() { BASS_INFO bASS_INFO = new BASS_INFO(); if (BASS_GetInfo(bASS_INFO)) { return bASS_INFO; } return null; } [DllImport("bass")] public static extern BASSError BASS_ErrorGetCode(); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_Stop(); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_Free(); [DllImport("bass")] public static extern int BASS_GetVersion(); public static Version BASS_GetVersion(int fieldcount) { if (fieldcount < 1) { fieldcount = 1; } if (fieldcount > 4) { fieldcount = 4; } int num = BASS_GetVersion(); Version result = new Version(2, 3); switch (fieldcount) { case 1: result = new Version((num >> 24) & 0xFF, 0); break; case 2: result = new Version((num >> 24) & 0xFF, (num >> 16) & 0xFF); break; case 3: result = new Version((num >> 24) & 0xFF, (num >> 16) & 0xFF, (num >> 8) & 0xFF); break; case 4: result = new Version((num >> 24) & 0xFF, (num >> 16) & 0xFF, (num >> 8) & 0xFF, num & 0xFF); break; } return result; } [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_SetDevice(int device); [DllImport("bass")] public static extern int BASS_GetDevice(); [DllImport("bass")] public static extern IntPtr BASS_GetDSoundObject(int handle); [DllImport("bass")] public static extern IntPtr BASS_GetDSoundObject(BASSDirectSound dsobject); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_Update(int length); [DllImport("bass")] public static extern float BASS_GetCPU(); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_Start(); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_Pause(); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_SetVolume(float volume); [DllImport("bass")] public static extern float BASS_GetVolume(); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_SetConfig(BASSConfig option, int newvalue); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_SetConfig(BASSConfig option, [In][MarshalAs(UnmanagedType.Bool)] bool newvalue); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_SetConfigPtr(BASSConfig option, IntPtr newvalue); [DllImport("bass", EntryPoint = "BASS_SetConfigPtr")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool BASS_SetConfigStringUnicode(BASSConfig option, [In][MarshalAs(UnmanagedType.LPWStr)] string newvalue); public static bool BASS_SetConfigString(BASSConfig option, string newvalue) { return BASS_SetConfigStringUnicode(option | (BASSConfig)(-2147483648), newvalue); } [DllImport("bass")] public static extern int BASS_GetConfig(BASSConfig option); [DllImport("bass", EntryPoint = "BASS_GetConfig")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_GetConfigBool(BASSConfig option); [DllImport("bass")] public static extern IntPtr BASS_GetConfigPtr(BASSConfig option); public static string BASS_GetConfigString(BASSConfig option) { return Utils.IntPtrAsStringUnicode(BASS_GetConfigPtr(option | (BASSConfig)(-2147483648))); } [DllImport("bass", EntryPoint = "BASS_PluginLoad")] private static extern int BASS_PluginLoadUnicode([In][MarshalAs(UnmanagedType.LPWStr)] string file, BASSFlag flags); public static int BASS_PluginLoad(string file) { return BASS_PluginLoadUnicode(file, BASSFlag.BASS_UNICODE); } [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_PluginFree(int handle); public static Dictionary<int, string> BASS_PluginLoadDirectory(string dir) { return BASS_PluginLoadDirectory(dir, null); } public static Dictionary<int, string> BASS_PluginLoadDirectory(string dir, List<string> exclude) { Dictionary<int, string> dictionary = new Dictionary<int, string>(); string[] files = Directory.GetFiles(dir, "bass*.dll"); if (files == null || files.Length == 0) { files = Directory.GetFiles(dir, "libbass*.so"); } if (files == null || files.Length == 0) { files = Directory.GetFiles(dir, "libbass*.dylib"); } if (files != null) { string[] array = files; string[] array2 = array; foreach (string text in array2) { if (exclude != null) { string fn = Path.GetFileNameWithoutExtension(text); if (exclude.Find((string f) => f.ToLower().Contains(fn.ToLower())) != null) { continue; } } int num = BASS_PluginLoad(text); if (num != 0) { dictionary.Add(num, text); } } } BASS_GetCPU(); if (dictionary.Count > 0) { return dictionary; } return null; } [DllImport("bass", EntryPoint = "BASS_PluginGetInfo")] private static extern IntPtr BASS_PluginGetInfoPtr(int handle); public static BASS_PLUGININFO BASS_PluginGetInfo(int handle) { if (handle != 0) { IntPtr intPtr = BASS_PluginGetInfoPtr(handle); if (intPtr != IntPtr.Zero) { bass_plugininfo bass_plugininfo2 = (bass_plugininfo)Marshal.PtrToStructure(intPtr, typeof(bass_plugininfo)); return new BASS_PLUGININFO(bass_plugininfo2.version, bass_plugininfo2.formatc, bass_plugininfo2.formats); } return null; } if (_usesMF) { BASS_PLUGINFORM[] formats = new BASS_PLUGINFORM[16] { new BASS_PLUGINFORM("WAVE Audio", "*.wav", BASSChannelType.BASS_CTYPE_STREAM_WAV), new BASS_PLUGINFORM("Ogg Vorbis", "*.ogg", BASSChannelType.BASS_CTYPE_STREAM_OGG), new BASS_PLUGINFORM("MPEG Layer 1", "*.mp1;*.m1a", BASSChannelType.BASS_CTYPE_STREAM_MP1), new BASS_PLUGINFORM("MPEG Layer 2", "*.mp2;*.m2a;*.mpa;*.mus", BASSChannelType.BASS_CTYPE_STREAM_MP2), new BASS_PLUGINFORM("MPEG Layer 3", "*.mp3;*.mpg;*.mpeg;*.mp3pro", BASSChannelType.BASS_CTYPE_STREAM_MP3), new BASS_PLUGINFORM("Audio IFF", "*.aif;*.aiff", BASSChannelType.BASS_CTYPE_STREAM_AIFF), new BASS_PLUGINFORM("Broadcast Wave", "*.bwf", BASSChannelType.BASS_CTYPE_STREAM_WAV), new BASS_PLUGINFORM("Windows Media Audio", "*.wma;*.wmv", BASSChannelType.BASS_CTYPE_STREAM_WMA), new BASS_PLUGINFORM("Advanced Audio Codec", "*.aac;*.adts", BASSChannelType.BASS_CTYPE_STREAM_AAC), new BASS_PLUGINFORM("MPEG 4 Audio", "*.mp4;*.m4a;*.m4b;*.m4p", BASSChannelType.BASS_CTYPE_STREAM_MP4), new BASS_PLUGINFORM("MOD Music", "*.mod;*.mdz", BASSChannelType.BASS_CTYPE_MUSIC_MOD), new BASS_PLUGINFORM("MO3 Music", "*.mo3", BASSChannelType.BASS_CTYPE_MUSIC_MO3), new BASS_PLUGINFORM("S3M Music", "*.s3m;*.s3z", BASSChannelType.BASS_CTYPE_MUSIC_S3M), new BASS_PLUGINFORM("XM Music", "*.xm;*.xmz", BASSChannelType.BASS_CTYPE_MUSIC_XM), new BASS_PLUGINFORM("IT Music", "*.it;*.itz;*.umx", BASSChannelType.BASS_CTYPE_MUSIC_IT), new BASS_PLUGINFORM("MTM Music", "*.mtm", BASSChannelType.BASS_CTYPE_MUSIC_MTM) }; return new BASS_PLUGININFO(BASS_GetVersion(), formats); } if (_usesCA) { BASS_PLUGINFORM[] formats2 = new BASS_PLUGINFORM[18] { new BASS_PLUGINFORM("WAVE Audio", "*.wav", BASSChannelType.BASS_CTYPE_STREAM_WAV), new BASS_PLUGINFORM("Ogg Vorbis", "*.ogg", BASSChannelType.BASS_CTYPE_STREAM_OGG), new BASS_PLUGINFORM("MPEG Layer 1", "*.mp1;*.m1a", BASSChannelType.BASS_CTYPE_STREAM_MP1), new BASS_PLUGINFORM("MPEG Layer 2", "*.mp2;*.m2a;*.mpa;*.mus", BASSChannelType.BASS_CTYPE_STREAM_MP2), new BASS_PLUGINFORM("MPEG Layer 3", "*.mp3;*.mpg;*.mpeg;*.mp3pro", BASSChannelType.BASS_CTYPE_STREAM_MP3), new BASS_PLUGINFORM("Audio IFF", "*.aif;*.aiff", BASSChannelType.BASS_CTYPE_STREAM_AIFF), new BASS_PLUGINFORM("Broadcast Wave", "*.bwf", BASSChannelType.BASS_CTYPE_STREAM_WAV), new BASS_PLUGINFORM("Advanced Audio Codec", "*.aac;*.adts", BASSChannelType.BASS_CTYPE_STREAM_AAC), new BASS_PLUGINFORM("MPEG 4 Audio", "*.mp4;*.m4a;*.m4b;*.m4p", BASSChannelType.BASS_CTYPE_STREAM_MP4), new BASS_PLUGINFORM("AC-3 Dolby Digital", "*.ac3", BASSChannelType.BASS_CTYPE_STREAM_AC3), new BASS_PLUGINFORM("Apple Lossless Audio", "*.mp4;*.m4a;*.m4b;*.m4p;*.mov", BASSChannelType.BASS_CTYPE_STREAM_ALAC), new BASS_PLUGINFORM("Apple Core Audio", "*.caf", BASSChannelType.BASS_CTYPE_STREAM_CA), new BASS_PLUGINFORM("MOD Music", "*.mod;*.mdz", BASSChannelType.BASS_CTYPE_MUSIC_MOD), new BASS_PLUGINFORM("MO3 Music", "*.mo3", BASSChannelType.BASS_CTYPE_MUSIC_MO3), new BASS_PLUGINFORM("S3M Music", "*.s3m;*.s3z", BASSChannelType.BASS_CTYPE_MUSIC_S3M), new BASS_PLUGINFORM("XM Music", "*.xm;*.xmz", BASSChannelType.BASS_CTYPE_MUSIC_XM), new BASS_PLUGINFORM("IT Music", "*.it;*.itz;*.umx", BASSChannelType.BASS_CTYPE_MUSIC_IT), new BASS_PLUGINFORM("MTM Music", "*.mtm", BASSChannelType.BASS_CTYPE_MUSIC_MTM) }; return new BASS_PLUGININFO(BASS_GetVersion(), formats2); } BASS_PLUGINFORM[] formats3 = new BASS_PLUGINFORM[13] { new BASS_PLUGINFORM("WAVE Audio", "*.wav", BASSChannelType.BASS_CTYPE_STREAM_WAV), new BASS_PLUGINFORM("Ogg Vorbis", "*.ogg", BASSChannelType.BASS_CTYPE_STREAM_OGG), new BASS_PLUGINFORM("MPEG Layer 1", "*.mp1;*.m1a", BASSChannelType.BASS_CTYPE_STREAM_MP1), new BASS_PLUGINFORM("MPEG Layer 2", "*.mp2;*.m2a;*.mpa;*.mus", BASSChannelType.BASS_CTYPE_STREAM_MP2), new BASS_PLUGINFORM("MPEG Layer 3", "*.mp3;*.mpg;*.mpeg;*.mp3pro", BASSChannelType.BASS_CTYPE_STREAM_MP3), new BASS_PLUGINFORM("Audio IFF", "*.aif;*.aiff", BASSChannelType.BASS_CTYPE_STREAM_AIFF), new BASS_PLUGINFORM("Broadcast Wave", "*.bwf", BASSChannelType.BASS_CTYPE_STREAM_WAV), new BASS_PLUGINFORM("MOD Music", "*.mod;*.mdz", BASSChannelType.BASS_CTYPE_MUSIC_MOD), new BASS_PLUGINFORM("MO3 Music", "*.mo3", BASSChannelType.BASS_CTYPE_MUSIC_MO3), new BASS_PLUGINFORM("S3M Music", "*.s3m;*.s3z", BASSChannelType.BASS_CTYPE_MUSIC_S3M), new BASS_PLUGINFORM("XM Music", "*.xm;*.xmz", BASSChannelType.BASS_CTYPE_MUSIC_XM), new BASS_PLUGINFORM("IT Music", "*.it;*.itz;*.umx", BASSChannelType.BASS_CTYPE_MUSIC_IT), new BASS_PLUGINFORM("MTM Music", "*.mtm", BASSChannelType.BASS_CTYPE_MUSIC_MTM) }; return new BASS_PLUGININFO(BASS_GetVersion(), formats3); } [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_GetEAXParameters(ref EAXEnvironment env, ref float vol, ref float decay, ref float damp); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_GetEAXParameters([In][Out][MarshalAs(UnmanagedType.AsAny)] object env, [In][Out][MarshalAs(UnmanagedType.AsAny)] object vol, [In][Out][MarshalAs(UnmanagedType.AsAny)] object decay, [In][Out][MarshalAs(UnmanagedType.AsAny)] object damp); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_SetEAXParameters(EAXEnvironment env, float vol, float decay, float damp); public static bool BASS_SetEAXParameters(EAXPreset preset) { bool result = false; switch (preset) { case EAXPreset.EAX_PRESET_GENERIC: result = BASS_SetEAXParameters(EAXEnvironment.EAX_ENVIRONMENT_GENERIC, 0.5f, 1.493f, 0.5f); break; case EAXPreset.EAX_PRESET_PADDEDCELL: result = BASS_SetEAXParameters(EAXEnvironment.EAX_ENVIRONMENT_PADDEDCELL, 0.25f, 0.1f, 0f); break; case EAXPreset.EAX_PRESET_ROOM: result = BASS_SetEAXParameters(EAXEnvironment.EAX_ENVIRONMENT_ROOM, 0.417f, 0.4f, 0.666f); break; case EAXPreset.EAX_PRESET_BATHROOM: result = BASS_SetEAXParameters(EAXEnvironment.EAX_ENVIRONMENT_BATHROOM, 0.653f, 1.499f, 0.166f); break; case EAXPreset.EAX_PRESET_LIVINGROOM: result = BASS_SetEAXParameters(EAXEnvironment.EAX_ENVIRONMENT_LIVINGROOM, 0.208f, 0.478f, 0f); break; case EAXPreset.EAX_PRESET_STONEROOM: result = BASS_SetEAXParameters(EAXEnvironment.EAX_ENVIRONMENT_STONEROOM, 0.5f, 2.309f, 0.888f); break; case EAXPreset.EAX_PRESET_AUDITORIUM: result = BASS_SetEAXParameters(EAXEnvironment.EAX_ENVIRONMENT_AUDITORIUM, 0.403f, 4.279f, 0.5f); break; case EAXPreset.EAX_PRESET_CONCERTHALL: result = BASS_SetEAXParameters(EAXEnvironment.EAX_ENVIRONMENT_CONCERTHALL, 0.5f, 3.961f, 0.5f); break; case EAXPreset.EAX_PRESET_CAVE: result = BASS_SetEAXParameters(EAXEnvironment.EAX_ENVIRONMENT_CAVE, 0.5f, 2.886f, 1.304f); break; case EAXPreset.EAX_PRESET_ARENA: result = BASS_SetEAXParameters(EAXEnvironment.EAX_ENVIRONMENT_ARENA, 0.361f, 7.284f, 0.332f); break; case EAXPreset.EAX_PRESET_HANGAR: result = BASS_SetEAXParameters(EAXEnvironment.EAX_ENVIRONMENT_HANGAR, 0.5f, 10f, 0.3f); break; case EAXPreset.EAX_PRESET_CARPETEDHALLWAY: result = BASS_SetEAXParameters(EAXEnvironment.EAX_ENVIRONMENT_CARPETEDHALLWAY, 0.153f, 0.259f, 2f); break; case EAXPreset.EAX_PRESET_HALLWAY: result = BASS_SetEAXParameters(EAXEnvironment.EAX_ENVIRONMENT_HALLWAY, 0.361f, 1.493f, 0f); break; case EAXPreset.EAX_PRESET_STONECORRIDOR: result = BASS_SetEAXParameters(EAXEnvironment.EAX_ENVIRONMENT_STONECORRIDOR, 0.444f, 2.697f, 0.638f); break; case EAXPreset.EAX_PRESET_ALLEY: result = BASS_SetEAXParameters(EAXEnvironment.EAX_ENVIRONMENT_ALLEY, 0.25f, 1.752f, 0.776f); break; case EAXPreset.EAX_PRESET_FOREST: result = BASS_SetEAXParameters(EAXEnvironment.EAX_ENVIRONMENT_FOREST, 0.111f, 3.145f, 0.472f); break; case EAXPreset.EAX_PRESET_CITY: result = BASS_SetEAXParameters(EAXEnvironment.EAX_ENVIRONMENT_CITY, 0.111f, 2.767f, 0.224f); break; case EAXPreset.EAX_PRESET_MOUNTAINS: result = BASS_SetEAXParameters(EAXEnvironment.EAX_ENVIRONMENT_MOUNTAINS, 0.194f, 7.841f, 0.472f); break; case EAXPreset.EAX_PRESET_QUARRY: result = BASS_SetEAXParameters(EAXEnvironment.EAX_ENVIRONMENT_QUARRY, 1f, 1.499f, 0.5f); break; case EAXPreset.EAX_PRESET_PLAIN: result = BASS_SetEAXParameters(EAXEnvironment.EAX_ENVIRONMENT_PLAIN, 0.097f, 2.767f, 0.224f); break; case EAXPreset.EAX_PRESET_PARKINGLOT: result = BASS_SetEAXParameters(EAXEnvironment.EAX_ENVIRONMENT_PARKINGLOT, 0.208f, 1.652f, 1.5f); break; case EAXPreset.EAX_PRESET_SEWERPIPE: result = BASS_SetEAXParameters(EAXEnvironment.EAX_ENVIRONMENT_SEWERPIPE, 0.652f, 2.886f, 0.25f); break; case EAXPreset.EAX_PRESET_UNDERWATER: result = BASS_SetEAXParameters(EAXEnvironment.EAX_ENVIRONMENT_UNDERWATER, 1f, 1.499f, 0f); break; case EAXPreset.EAX_PRESET_DRUGGED: result = BASS_SetEAXParameters(EAXEnvironment.EAX_ENVIRONMENT_DRUGGED, 0.875f, 8.392f, 1.388f); break; case EAXPreset.EAX_PRESET_DIZZY: result = BASS_SetEAXParameters(EAXEnvironment.EAX_ENVIRONMENT_DIZZY, 0.139f, 17.234f, 0.666f); break; case EAXPreset.EAX_PRESET_PSYCHOTIC: result = BASS_SetEAXParameters(EAXEnvironment.EAX_ENVIRONMENT_PSYCHOTIC, 0.486f, 7.563f, 0.806f); break; } return result; } [DllImport("bass")] public static extern void BASS_Apply3D(); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_Set3DFactors(float distf, float rollf, float doppf); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_Get3DFactors(ref float distf, ref float rollf, ref float doppf); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_Get3DFactors([In][Out][MarshalAs(UnmanagedType.AsAny)] object distf, [In][Out][MarshalAs(UnmanagedType.AsAny)] object rollf, [In][Out][MarshalAs(UnmanagedType.AsAny)] object doppf); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_Set3DPosition([In] BASS_3DVECTOR pos, [In] BASS_3DVECTOR vel, [In] BASS_3DVECTOR front, [In] BASS_3DVECTOR top); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_Get3DPosition([In][Out] BASS_3DVECTOR pos, [In][Out] BASS_3DVECTOR vel, [In][Out] BASS_3DVECTOR front, [In][Out] BASS_3DVECTOR top); [DllImport("bass", EntryPoint = "BASS_SampleLoad")] private static extern int BASS_SampleLoadUnicode([MarshalAs(UnmanagedType.Bool)] bool mem, [In][MarshalAs(UnmanagedType.LPWStr)] string file, long offset, int length, int max, BASSFlag flags); public static int BASS_SampleLoad(string file, long offset, int length, int max, BASSFlag flags) { flags |= BASSFlag.BASS_UNICODE; return BASS_SampleLoadUnicode(mem: false, file, offset, length, max, flags); } [DllImport("bass", EntryPoint = "BASS_SampleLoad")] private static extern int BASS_SampleLoadMemory([MarshalAs(UnmanagedType.Bool)] bool mem, IntPtr memory, long offset, int length, int max, BASSFlag flags); public static int BASS_SampleLoad(IntPtr memory, long offset, int length, int max, BASSFlag flags) { return BASS_SampleLoadMemory(mem: true, memory, offset, length, max, flags); } [DllImport("bass", EntryPoint = "BASS_SampleLoad")] private static extern int BASS_SampleLoadMemory([MarshalAs(UnmanagedType.Bool)] bool mem, byte[] memory, long offset, int length, int max, BASSFlag flags); public static int BASS_SampleLoad(byte[] memory, long offset, int length, int max, BASSFlag flags) { return BASS_SampleLoadMemory(mem: true, memory, offset, length, max, flags); } [DllImport("bass")] public static extern int BASS_SampleCreate(int length, int freq, int chans, int max, BASSFlag flags); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_SampleSetData(int handle, IntPtr buffer); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_SampleSetData(int handle, float[] buffer); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_SampleSetData(int handle, int[] buffer); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_SampleSetData(int handle, short[] buffer); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_SampleSetData(int handle, byte[] buffer); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_SampleGetData(int handle, IntPtr buffer); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_SampleGetData(int handle, float[] buffer); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_SampleGetData(int handle, int[] buffer); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_SampleGetData(int handle, short[] buffer); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_SampleGetData(int handle, byte[] buffer); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_SampleFree(int handle); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_SampleGetInfo(int handle, [In][Out] BASS_SAMPLE info); public static BASS_SAMPLE BASS_SampleGetInfo(int handle) { BASS_SAMPLE bASS_SAMPLE = new BASS_SAMPLE(); if (BASS_SampleGetInfo(handle, bASS_SAMPLE)) { return bASS_SAMPLE; } return null; } [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_SampleSetInfo(int handle, [In] BASS_SAMPLE info); [DllImport("bass")] public static extern int BASS_SampleGetChannel(int handle, [MarshalAs(UnmanagedType.Bool)] bool onlynew); [DllImport("bass")] public static extern int BASS_SampleGetChannels(int handle, int[] channels); public static int[] BASS_SampleGetChannels(int handle) { int[] array = new int[BASS_SampleGetInfo(handle).max]; int num = BASS_SampleGetChannels(handle, array); if (num >= 0) { int[] array2 = new int[num]; Array.Copy(array, array2, num); return array2; } return null; } public static int BASS_SampleGetChannelCount(int handle) { return BASS_SampleGetChannels(handle, null); } [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_SampleStop(int handle); [DllImport("bass")] public static extern int BASS_StreamCreate(int freq, int chans, BASSFlag flags, STREAMPROC proc, IntPtr user); [DllImport("bass", EntryPoint = "BASS_StreamCreate")] private static extern int BASS_StreamCreatePtr(int freq, int chans, BASSFlag flags, IntPtr procPtr, IntPtr user); public static int BASS_StreamCreate(int freq, int chans, BASSFlag flags, BASSStreamProc proc) { return BASS_StreamCreatePtr(freq, chans, flags, new IntPtr((int)proc), IntPtr.Zero); } public static int BASS_StreamCreateDummy(int freq, int chans, BASSFlag flags, IntPtr user) { return BASS_StreamCreatePtr(freq, chans, flags, IntPtr.Zero, user); } public static int BASS_StreamCreatePush(int freq, int chans, BASSFlag flags, IntPtr user) { return BASS_StreamCreatePtr(freq, chans, flags, new IntPtr(-1), user); } public static int BASS_StreamCreateDevice(int freq, int chans, BASSFlag flags, IntPtr user) { return BASS_StreamCreatePtr(freq, chans, flags, new IntPtr(-2), user); } public static int BASS_StreamCreateDevice3D(int freq, int chans, BASSFlag flags, IntPtr user) { return BASS_StreamCreatePtr(freq, chans, flags, new IntPtr(-3), user); } [DllImport("bass")] public static extern int BASS_StreamCreateFileUser(BASSStreamSystem system, BASSFlag flags, BASS_FILEPROCS procs, IntPtr user); [DllImport("bass", EntryPoint = "BASS_StreamCreateFile")] private static extern int BASS_StreamCreateFileUnicode([MarshalAs(UnmanagedType.Bool)] bool mem, [In][MarshalAs(UnmanagedType.LPWStr)] string file, long offset, long length, BASSFlag flags); public static int BASS_StreamCreateFile(string file, long offset, long length, BASSFlag flags) { flags |= BASSFlag.BASS_UNICODE; return BASS_StreamCreateFileUnicode(mem: false, file, offset, length, flags); } [DllImport("bass", EntryPoint = "BASS_StreamCreateFile")] private static extern int BASS_StreamCreateFileMemory([MarshalAs(UnmanagedType.Bool)] bool mem, IntPtr memory, long offset, long length, BASSFlag flags); public static int BASS_StreamCreateFile(IntPtr memory, long offset, long length, BASSFlag flags) { return BASS_StreamCreateFileMemory(mem: true, memory, offset, length, flags); } [DllImport("bass", EntryPoint = "BASS_StreamCreateURL")] private static extern int BASS_StreamCreateURLUnicode([In][MarshalAs(UnmanagedType.LPWStr)] string url, int offset, BASSFlag flags, DOWNLOADPROC proc, IntPtr user); [DllImport("bass", CharSet = CharSet.Ansi, EntryPoint = "BASS_StreamCreateURL")] private static extern int BASS_StreamCreateURLAscii([In][MarshalAs(UnmanagedType.LPStr)] string url, int offset, BASSFlag flags, DOWNLOADPROC proc, IntPtr user); public static int BASS_StreamCreateURL(string url, int offset, BASSFlag flags, DOWNLOADPROC proc, IntPtr user) { flags |= BASSFlag.BASS_UNICODE; int num = BASS_StreamCreateURLUnicode(url, offset, flags, proc, user); if (num == 0) { flags &= BASSFlag.BASS_SPEAKER_PAIR15 | BASSFlag.BASS_SAMPLE_OVER_DIST | BASSFlag.BASS_AC3_DOWNMIX_DOLBY | BASSFlag.BASS_SAMPLE_8BITS | BASSFlag.BASS_SAMPLE_MONO | BASSFlag.BASS_SAMPLE_LOOP | BASSFlag.BASS_SAMPLE_3D | BASSFlag.BASS_SAMPLE_SOFTWARE | BASSFlag.BASS_SAMPLE_MUTEMAX | BASSFlag.BASS_SAMPLE_VAM | BASSFlag.BASS_SAMPLE_FX | BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_RECORD_PAUSE | BASSFlag.BASS_RECORD_ECHOCANCEL | BASSFlag.BASS_RECORD_AGC | BASSFlag.BASS_STREAM_AUTOFREE | BASSFlag.BASS_STREAM_RESTRATE | BASSFlag.BASS_STREAM_BLOCK | BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_STREAM_STATUS | BASSFlag.BASS_SPEAKER_LEFT | BASSFlag.BASS_SPEAKER_RIGHT | BASSFlag.BASS_ASYNCFILE | BASSFlag.BASS_WV_STEREO | BASSFlag.BASS_AC3_DYNAMIC_RANGE | BASSFlag.BASS_AAC_FRAME960; num = BASS_StreamCreateURLAscii(url, offset, flags, proc, user); } return num; } [DllImport("bass")] public static extern long BASS_StreamGetFilePosition(int handle, BASSStreamFilePosition mode); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_StreamFree(int handle); [DllImport("bass")] public static extern int BASS_StreamPutData(int handle, IntPtr buffer, int length); [DllImport("bass")] public static extern int BASS_StreamPutData(int handle, float[] buffer, int length); [DllImport("bass")] public static extern int BASS_StreamPutData(int handle, int[] buffer, int length); [DllImport("bass")] public static extern int BASS_StreamPutData(int handle, short[] buffer, int length); [DllImport("bass")] public static extern int BASS_StreamPutData(int handle, byte[] buffer, int length); public unsafe static int BASS_StreamPutData(int handle, byte[] buffer, int startIdx, int length) { fixed (byte* value = &buffer[startIdx]) { return BASS_StreamPutData(handle, new IntPtr(value), length); } } [DllImport("bass")] public static extern int BASS_StreamPutFileData(int handle, IntPtr buffer, int length); [DllImport("bass")] public static extern int BASS_StreamPutFileData(int handle, float[] buffer, int length); [DllImport("bass")] public static extern int BASS_StreamPutFileData(int handle, int[] buffer, int length); [DllImport("bass")] public static extern int BASS_StreamPutFileData(int handle, short[] buffer, int length); [DllImport("bass")] public static extern int BASS_StreamPutFileData(int handle, byte[] buffer, int length); [DllImport("bass", EntryPoint = "BASS_MusicLoad")] private static extern int BASS_MusicLoadUnicode([MarshalAs(UnmanagedType.Bool)] bool mem, [In][MarshalAs(UnmanagedType.LPWStr)] string file, long offset, int length, BASSFlag flags, int freq); public static int BASS_MusicLoad(string file, long offset, int length, BASSFlag flags, int freq) { flags |= BASSFlag.BASS_UNICODE; return BASS_MusicLoadUnicode(mem: false, file, offset, length, flags, freq); } [DllImport("bass", EntryPoint = "BASS_MusicLoad")] private static extern int BASS_MusicLoadMemory([MarshalAs(UnmanagedType.Bool)] bool mem, IntPtr memory, long offset, int length, BASSFlag flags, int freq); public static int BASS_MusicLoad(IntPtr memory, long offset, int length, BASSFlag flags, int freq) { return BASS_MusicLoadMemory(mem: true, memory, offset, length, flags, freq); } [DllImport("bass", EntryPoint = "BASS_MusicLoad")] private static extern int BASS_MusicLoadMemory([MarshalAs(UnmanagedType.Bool)] bool mem, byte[] memory, long offset, int length, BASSFlag flags, int freq); public static int BASS_MusicLoad(byte[] memory, long offset, int length, BASSFlag flags, int freq) { return BASS_MusicLoadMemory(mem: true, memory, offset, length, flags, freq); } [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_MusicFree(int handle); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_RecordInit(int device); [DllImport("bass")] public static extern int BASS_RecordStart(int freq, int chans, BASSFlag flags, RECORDPROC proc, IntPtr user); public static int BASS_RecordStart(int freq, int chans, BASSFlag flags, int period, RECORDPROC proc, IntPtr user) { return BASS_RecordStart(freq, chans, (BASSFlag)Utils.MakeLong((int)flags, period), proc, user); } [DllImport("bass", EntryPoint = "BASS_RecordGetDeviceInfo")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool BASS_RecordGetDeviceInfoInternal([In] int device, [In][Out] ref BASS_DEVICEINFO_INTERNAL info); public unsafe static bool BASS_RecordGetDeviceInfo(int device, BASS_DEVICEINFO info) { bool flag = BASS_RecordGetDeviceInfoInternal(device, ref info._internal); if (flag) { if (_configUTF8) { info.name = Utils.IntPtrAsStringUtf8(info._internal.name, out var len); info.driver = Utils.IntPtrAsStringUtf8(info._internal.driver, out len); if (len > 0 && BASS_GetVersion() > 33818624) { try { info.id = Utils.IntPtrAsStringUtf8(new IntPtr((byte*)info._internal.driver.ToPointer() + len + 1), out len); } catch { } } } else { info.name = Utils.IntPtrAsStringAnsi(info._internal.name); info.driver = Utils.IntPtrAsStringAnsi(info._internal.driver); if (!string.IsNullOrEmpty(info.driver) && BASS_GetVersion() > 33818624) { try { info.id = Utils.IntPtrAsStringAnsi(new IntPtr((byte*)info._internal.driver.ToPointer() + info.driver.Length + 1)); } catch { } } } info.flags = info._internal.flags; } return flag; } public static BASS_DEVICEINFO BASS_RecordGetDeviceInfo(int device) { BASS_DEVICEINFO bASS_DEVICEINFO = new BASS_DEVICEINFO(); if (BASS_RecordGetDeviceInfo(device, bASS_DEVICEINFO)) { return bASS_DEVICEINFO; } return null; } public static BASS_DEVICEINFO[] BASS_RecordGetDeviceInfos() { List<BASS_DEVICEINFO> list = new List<BASS_DEVICEINFO>(); int num = 0; BASS_DEVICEINFO item; while ((item = BASS_RecordGetDeviceInfo(num)) != null) { list.Add(item); num++; } BASS_GetCPU(); return list.ToArray(); } public static int BASS_RecordGetDeviceCount() { BASS_DEVICEINFO info = new BASS_DEVICEINFO(); int i; for (i = 0; BASS_RecordGetDeviceInfo(i, info); i++) { } BASS_GetCPU(); return i; } [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_RecordSetDevice(int device); [DllImport("bass")] public static extern int BASS_RecordGetDevice(); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_RecordGetInfo([In][Out] BASS_RECORDINFO info); public static BASS_RECORDINFO BASS_RecordGetInfo() { BASS_RECORDINFO bASS_RECORDINFO = new BASS_RECORDINFO(); if (BASS_RecordGetInfo(bASS_RECORDINFO)) { return bASS_RECORDINFO; } return null; } [DllImport("bass", EntryPoint = "BASS_RecordGetInputName")] private static extern IntPtr BASS_RecordGetInputNamePtr(int input); public static string BASS_RecordGetInputName(int input) { IntPtr intPtr = BASS_RecordGetInputNamePtr(input); if (intPtr != IntPtr.Zero) { if (_configUTF8 && BASS_GetVersion() >= 33819150) { return Utils.IntPtrAsStringUtf8(intPtr); } return Utils.IntPtrAsStringAnsi(intPtr); } return null; } public static string[] BASS_RecordGetInputNames() { List<string> list = new List<string>(); int num = 0; string item; while ((item = BASS_RecordGetInputName(num)) != null) { list.Add(item); num++; } BASS_GetCPU(); return list.ToArray(); } [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_RecordSetInput(int input, BASSInput setting, float volume); [DllImport("bass")] public static extern int BASS_RecordGetInput(int input, ref float volume); public static BASSInput BASS_RecordGetInput(int input) { int num = BASS_RecordGetInputPtr(input, IntPtr.Zero); if (num != -1) { return (BASSInput)(num & 0xFF0000); } return BASSInput.BASS_INPUT_NONE; } [DllImport("bass", EntryPoint = "BASS_RecordGetInput")] private static extern int BASS_RecordGetInputPtr(int input, IntPtr vol); public static BASSInputType BASS_RecordGetInputType(int input) { int num = BASS_RecordGetInputPtr(input, IntPtr.Zero); if (num != -1) { return (BASSInputType)(num & -16777216); } return BASSInputType.BASS_INPUT_TYPE_ERROR; } [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_RecordFree(); [DllImport("bass", EntryPoint = "BASS_ChannelGetInfo")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool BASS_ChannelGetInfoInternal(int handle, [In][Out] ref BASS_CHANNELINFO_INTERNAL info); public static bool BASS_ChannelGetInfo(int handle, BASS_CHANNELINFO info) { bool flag = BASS_ChannelGetInfoInternal(handle, ref info._internal); if (flag) { info.chans = info._internal.chans; info.ctype = info._internal.ctype; info.flags = info._internal.flags; info.freq = info._internal.freq; info.origres = info._internal.origres & 0xFFFF; info.origresIsFloat = (info._internal.origres & 0x10000) == 65536; info.plugin = info._internal.plugin; info.sample = info._internal.sample; if (((uint)info.flags & 0x80000000u) != 0) { info.filename = Marshal.PtrToStringUni(info._internal.filename); return flag; } if (_configUTF8 || Environment.OSVersion.Platform > PlatformID.WinCE) { info.filename = Utils.IntPtrAsStringUtf8(info._internal.filename); return flag; } info.filename = Utils.IntPtrAsStringAnsi(info._internal.filename); } return flag; } public static BASS_CHANNELINFO BASS_ChannelGetInfo(int handle) { BASS_CHANNELINFO bASS_CHANNELINFO = new BASS_CHANNELINFO(); if (BASS_ChannelGetInfo(handle, bASS_CHANNELINFO)) { return bASS_CHANNELINFO; } return null; } [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_ChannelPlay(int handle, [MarshalAs(UnmanagedType.Bool)] bool restart); [DllImport("bass")] public static extern int BASS_ChannelSetDSP(int handle, DSPPROC proc, IntPtr user, int priority); [DllImport("bass")] public static extern int BASS_ChannelGetData(int handle, IntPtr buffer, int length); [DllImport("bass")] public static extern int BASS_ChannelGetData(int handle, [In][Out] float[] buffer, int length); [DllImport("bass")] public static extern int BASS_ChannelGetData(int handle, [In][Out] short[] buffer, int length); [DllImport("bass")] public static extern int BASS_ChannelGetData(int handle, [In][Out] int[] buffer, int length); [DllImport("bass")] public static extern int BASS_ChannelGetData(int handle, [In][Out] byte[] buffer, int length); [DllImport("bass")] public static extern long BASS_ChannelSeconds2Bytes(int handle, double pos); [DllImport("bass")] public static extern double BASS_ChannelBytes2Seconds(int handle, long pos); [DllImport("bass")] public static extern BASSActive BASS_ChannelIsActive(int handle); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_ChannelLock(int handle, [MarshalAs(UnmanagedType.Bool)] bool state); [DllImport("bass")] public static extern long BASS_ChannelGetLength(int handle, BASSMode mode); public static long BASS_ChannelGetLength(int handle) { return BASS_ChannelGetLength(handle, BASSMode.BASS_POS_BYTE); } [DllImport("bass")] public static extern int BASS_ChannelSetSync(int handle, BASSSync type, long param, SYNCPROC proc, IntPtr user); [DllImport("bass")] public static extern int BASS_ChannelSetFX(int handle, BASSFXType type, int priority); [DllImport("bass")] public static extern int BASS_ChannelGetDevice(int handle); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_ChannelSetDevice(int handle, int device); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_ChannelStop(int handle); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_ChannelPause(int handle); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_ChannelSetAttribute(int handle, BASSAttribute attrib, float value); [DllImport("bass", EntryPoint = "BASS_ChannelSetAttributeEx")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_ChannelSetAttribute(int handle, BASSAttribute attrib, IntPtr value, int size); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_ChannelGetAttribute(int handle, BASSAttribute attrib, ref float value); [DllImport("bass", EntryPoint = "BASS_ChannelGetAttributeEx")] public static extern int BASS_ChannelGetAttribute(int handle, BASSAttribute attrib, IntPtr value, int size); [DllImport("bass")] public static extern BASSFlag BASS_ChannelFlags(int handle, BASSFlag flags, BASSFlag mask); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_ChannelUpdate(int handle, int length); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_ChannelIsSliding(int handle, BASSAttribute attrib); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_ChannelSlideAttribute(int handle, BASSAttribute attrib, float value, int time); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_ChannelSet3DAttributes(int handle, BASS3DMode mode, float min, float max, int iangle, int oangle, int outvol); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_ChannelGet3DAttributes(int handle, ref BASS3DMode mode, ref float min, ref float max, ref int iangle, ref int oangle, ref int outvol); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_ChannelGet3DAttributes(int handle, [In][Out][MarshalAs(UnmanagedType.AsAny)] object mode, [In][Out][MarshalAs(UnmanagedType.AsAny)] object min, [In][Out][MarshalAs(UnmanagedType.AsAny)] object max, [In][Out][MarshalAs(UnmanagedType.AsAny)] object iangle, [In][Out][MarshalAs(UnmanagedType.AsAny)] object oangle, [In][Out][MarshalAs(UnmanagedType.AsAny)] object outvol); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_ChannelSet3DPosition(int handle, [In] BASS_3DVECTOR pos, [In] BASS_3DVECTOR orient, [In] BASS_3DVECTOR vel); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_ChannelGet3DPosition(int handle, [In][Out] BASS_3DVECTOR pos, [In][Out] BASS_3DVECTOR orient, [In][Out] BASS_3DVECTOR vel); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_ChannelSetPosition(int handle, long pos, BASSMode mode); public static bool BASS_ChannelSetPosition(int handle, long pos) { return BASS_ChannelSetPosition(handle, pos, BASSMode.BASS_POS_BYTE); } public static bool BASS_ChannelSetPosition(int handle, double seconds) { return BASS_ChannelSetPosition(handle, BASS_ChannelSeconds2Bytes(handle, seconds), BASSMode.BASS_POS_BYTE); } public static bool BASS_ChannelSetPosition(int handle, int order, int row) { return BASS_ChannelSetPosition(handle, Utils.MakeLong(order, row), BASSMode.BASS_POS_MUSIC_ORDERS); } [DllImport("bass")] public static extern long BASS_ChannelGetPosition(int handle, BASSMode mode); public static long BASS_ChannelGetPosition(int handle) { return BASS_ChannelGetPosition(handle, BASSMode.BASS_POS_BYTE); } [DllImport("bass")] public static extern int BASS_ChannelGetLevel(int handle); [DllImport("bass", EntryPoint = "BASS_ChannelGetLevelEx")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_ChannelGetLevel(int handle, [In][Out] float[] levels, float length, BASSLevel flags); public static float[] BASS_ChannelGetLevels(int handle, float length = 0.02f, BASSLevel flags = BASSLevel.BASS_LEVEL_ALL) { BASS_CHANNELINFO bASS_CHANNELINFO = BASS_ChannelGetInfo(handle); if (bASS_CHANNELINFO != null) { int num = bASS_CHANNELINFO.chans; if ((flags & BASSLevel.BASS_LEVEL_MONO) == BASSLevel.BASS_LEVEL_MONO) { num = 1; } else if ((flags & BASSLevel.BASS_LEVEL_STEREO) == BASSLevel.BASS_LEVEL_STEREO) { num = 2; } float[] array = new float[num]; if (BASS_ChannelGetLevel(handle, array, length, flags)) { return array; } return null; } return null; } [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_ChannelRemoveSync(int handle, int sync); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_ChannelRemoveDSP(int handle, int dsp); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_ChannelRemoveFX(int handle, int fx); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_ChannelSetLink(int handle, int chan); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_ChannelRemoveLink(int handle, int chan); [DllImport("bass")] public static extern IntPtr BASS_ChannelGetTags(int handle, BASSTag tags); public static string[] BASS_ChannelGetTagsArrayNullTermAnsi(int handle, BASSTag format) { return Utils.IntPtrToArrayNullTermAnsi(BASS_ChannelGetTags(handle, format)); } public static string[] BASS_ChannelGetTagsArrayNullTermUtf8(int handle, BASSTag format) { return Utils.IntPtrToArrayNullTermUtf8(BASS_ChannelGetTags(handle, format)); } public static string[] BASS_ChannelGetTagsID3V1(int handle) { IntPtr intPtr = BASS_ChannelGetTags(handle, BASSTag.BASS_TAG_ID3); if (intPtr != IntPtr.Zero) { string[] array = new string[7]; try { BASS_TAG_ID3 bASS_TAG_ID = (BASS_TAG_ID3)Marshal.PtrToStructure(intPtr, typeof(BASS_TAG_ID3)); array[0] = bASS_TAG_ID.Title; array[1] = bASS_TAG_ID.Artist; array[2] = bASS_TAG_ID.Album; array[3] = bASS_TAG_ID.Year; array[4] = bASS_TAG_ID.Comment; array[5] = bASS_TAG_ID.Genre.ToString(); if (bASS_TAG_ID.Dummy == 0) { array[6] = bASS_TAG_ID.Track.ToString(); return array; } return array; } catch { return array; } } return null; } public static string[] BASS_ChannelGetTagsBWF(int handle) { IntPtr intPtr = BASS_ChannelGetTags(handle, BASSTag.BASS_TAG_RIFF_BEXT); if (intPtr != IntPtr.Zero) { string[] array = new string[9]; try { BASS_TAG_BEXT bASS_TAG_BEXT = (BASS_TAG_BEXT)Marshal.PtrToStructure(intPtr, typeof(BASS_TAG_BEXT)); array[0] = bASS_TAG_BEXT.Description; array[1] = bASS_TAG_BEXT.Originator; array[2] = bASS_TAG_BEXT.OriginatorReference; array[3] = bASS_TAG_BEXT.OriginationDate; array[4] = bASS_TAG_BEXT.OriginationTime; array[5] = bASS_TAG_BEXT.TimeReference.ToString(); array[6] = bASS_TAG_BEXT.Version.ToString(); array[7] = bASS_TAG_BEXT.UMID; array[8] = bASS_TAG_BEXT.GetCodingHistory(intPtr); return array; } catch { return array; } } return null; } public static BASS_TAG_CACODEC BASS_ChannelGetTagsCA(int handle) { IntPtr intPtr = BASS_ChannelGetTags(handle, BASSTag.BASS_TAG_WMA_META); if (intPtr != IntPtr.Zero) { return new BASS_TAG_CACODEC(intPtr); } return null; } public static string BASS_ChannelGetTagsDSDArtist(int handle) { return Utils.IntPtrAsStringAnsi(BASS_ChannelGetTags(handle, BASSTag.BASS_TAG_DSD_ARTIST)); } public static string BASS_ChannelGetTagsDSDTitle(int handle) { return Utils.IntPtrAsStringAnsi(BASS_ChannelGetTags(handle, BASSTag.BASS_TAG_DSD_TITLE)); } public static BASS_TAG_DSD_COMMENT[] BASS_ChannelGetTagsDSDComments(int handle) { List<BASS_TAG_DSD_COMMENT> list = new List<BASS_TAG_DSD_COMMENT>(); int num = 0; BASS_TAG_DSD_COMMENT tag; while ((tag = BASS_TAG_DSD_COMMENT.GetTag(handle, num)) != null) { list.Add(tag); num++; } if (list.Count > 0) { return list.ToArray(); } return null; } public static string[] BASS_ChannelGetTagsID3V2(int handle) { return null; } public static string[] BASS_ChannelGetTagsAPE(int handle) { return BASS_ChannelGetTagsArrayNullTermUtf8(handle, BASSTag.BASS_TAG_APE); } public static BASS_TAG_APE_BINARY[] BASS_ChannelGetTagsAPEBinary(int handle) { List<BASS_TAG_APE_BINARY> list = new List<BASS_TAG_APE_BINARY>(); int num = 0; BASS_TAG_APE_BINARY tag; while ((tag = BASS_TAG_APE_BINARY.GetTag(handle, num)) != null) { list.Add(tag); num++; } if (list.Count > 0) { return list.ToArray(); } return null; } public static string[] BASS_ChannelGetTagsWMA(int handle) { return BASS_ChannelGetTagsArrayNullTermUtf8(handle, BASSTag.BASS_TAG_WMA); } public static string[] BASS_ChannelGetTagsMP4(int handle) { return BASS_ChannelGetTagsArrayNullTermUtf8(handle, BASSTag.BASS_TAG_MP4); } public static string[] BASS_ChannelGetTagsMF(int handle) { return BASS_ChannelGetTagsArrayNullTermUtf8(handle, BASSTag.BASS_TAG_MF); } public static WAVEFORMATEXT BASS_ChannelGetTagsWAVEFORMAT(int handle) { IntPtr intPtr = BASS_ChannelGetTags(handle, BASSTag.BASS_TAG_WAVEFORMAT); if (intPtr != IntPtr.Zero) { return new WAVEFORMATEXT(intPtr); } return null; } public static BASS_TAG_FLAC_PICTURE[] BASS_ChannelGetTagsFLACPictures(int handle) { List<BASS_TAG_FLAC_PICTURE> list = new List<BASS_TAG_FLAC_PICTURE>(); int num = 0; BASS_TAG_FLAC_PICTURE tag; while ((tag = BASS_TAG_FLAC_PICTURE.GetTag(handle, num)) != null) { list.Add(tag); num++; } if (list.Count > 0) { return list.ToArray(); } return null; } public static BASS_TAG_FLAC_CUE BASS_ChannelGetTagsFLACCuesheet(int handle) { return BASS_TAG_FLAC_CUE.GetTag(handle); } public static string[] BASS_ChannelGetTagsHTTP(int handle) { return BASS_ChannelGetTagsArrayNullTermAnsi(handle, BASSTag.BASS_TAG_HTTP); } public static string[] BASS_ChannelGetTagsICY(int handle) { return BASS_ChannelGetTagsArrayNullTermAnsi(handle, BASSTag.BASS_TAG_ICY); } public static string[] BASS_ChannelGetTagsOGG(int handle) { return BASS_ChannelGetTagsArrayNullTermUtf8(handle, BASSTag.BASS_TAG_OGG); } public static string[] BASS_ChannelGetTagsRIFF(int handle) { return BASS_ChannelGetTagsArrayNullTermAnsi(handle, BASSTag.BASS_TAG_RIFF_INFO); } public static BASS_TAG_CUE BASS_ChannelGetTagsRIFFCUE(int handle) { return BASS_TAG_CUE.GetTag(handle); } public static string[] BASS_ChannelGetTagsMETA(int handle) { return Utils.IntPtrToArrayNullTermAnsi(BASS_ChannelGetTags(handle, BASSTag.BASS_TAG_META)); } public static string BASS_ChannelGetTagLyrics3v2(int handle) { IntPtr intPtr = BASS_ChannelGetTags(handle, BASSTag.BASS_TAG_LYRICS3); if (intPtr != IntPtr.Zero) { return Utils.IntPtrAsStringAnsi(intPtr); } return null; } public static string BASS_ChannelGetMusicName(int handle) { IntPtr intPtr = BASS_ChannelGetTags(handle, BASSTag.BASS_TAG_MUSIC_NAME); if (intPtr != IntPtr.Zero) { return Utils.IntPtrAsStringAnsi(intPtr); } return null; } public static string BASS_ChannelGetMusicMessage(int handle) { IntPtr intPtr = BASS_ChannelGetTags(handle, BASSTag.BASS_TAG_MUSIC_MESSAGE); if (intPtr != IntPtr.Zero) { return Utils.IntPtrAsStringAnsi(intPtr); } return null; } public static string BASS_ChannelGetMusicInstrument(int handle, int instrument) { IntPtr intPtr = BASS_ChannelGetTags(handle, (BASSTag)(65792 + instrument)); if (intPtr != IntPtr.Zero) { return Utils.IntPtrAsStringAnsi(intPtr); } return null; } public static string BASS_ChannelGetMusicSample(int handle, int sample) { IntPtr intPtr = BASS_ChannelGetTags(handle, (BASSTag)(66304 + sample)); if (intPtr != IntPtr.Zero) { return Utils.IntPtrAsStringAnsi(intPtr); } return null; } public static string[] BASS_ChannelGetMidiTrackText(int handle, int track) { if (track >= 0) { return Utils.IntPtrToArrayNullTermAnsi(BASS_ChannelGetTags(handle, (BASSTag)(69632 + track))); } List<string> list = new List<string>(); track = 0; while (true) { IntPtr intPtr = BASS_ChannelGetTags(handle, (BASSTag)(69632 + track)); if (!(intPtr != IntPtr.Zero)) { break; } string[] array = Utils.IntPtrToArrayNullTermAnsi(intPtr); if (array != null && array.Length != 0) { list.AddRange(array); } track++; } if (list.Count > 0) { return list.ToArray(); } return null; } [DllImport("bass", EntryPoint = "BASS_FXSetParameters")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool BASS_FXSetParametersExt(int handle, [In][MarshalAs(UnmanagedType.AsAny)] object par); public static bool BASS_FXSetParameters(int handle, object par) { return false; } [DllImport("bass", EntryPoint = "BASS_FXGetParameters")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool BASS_FXGetParametersExt(int handle, [In][Out] float[] par); [DllImport("bass", EntryPoint = "BASS_FXGetParameters")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool BASS_FXGetParametersExt(int handle, [In][Out][MarshalAs(UnmanagedType.AsAny)] object par); public static bool BASS_FXGetParameters(int handle, object par) { return false; } [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_FXReset(int handle); [DllImport("bass")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool BASS_FXSetPriority(int handle, int priority); public static bool LoadMe() { bool flag = Utils.LoadLib("bass", ref _myModuleHandle); if (flag) { InitBass(); } return flag; } public static bool LoadMe(string path) { bool flag = Utils.LoadLib(Path.Combine(path, "bass"), ref _myModuleHandle); if (flag) { InitBass(); } return flag; } public static bool FreeMe() { return Utils.FreeLib(ref _myModuleHandle); } private static void CheckVersion() { try { if (Utils.HighWord(BASS_GetVersion()) == 516) { return; } Version version = BASS_GetVersion(2); Version version2 = new Version(2, 4); FileVersionInfo fileVersionInfo = null; ProcessModuleCollection modules = Process.GetCurrentProcess().Modules; for (int num = modules.Count - 1; num >= 0; num--) { ProcessModule processModule = modules[num]; if (processModule.ModuleName.ToLower().Equals("bass".ToLower())) { fileVersionInfo = processModule.FileVersionInfo; break; } } if (fileVersionInfo != null) { Console.WriteLine(string.Format("An incorrect version of BASS was loaded!\r\n\r\nVersion loaded: {0}.{1}\r\nVersion expected: {2}.{3}\r\n\r\nFile: {4}\r\nFileVersion: {5}\r\nDescription: {6}\r\nCompany: {7}\r\nLanguage: {8}", version.Major, version.Minor, version2.Major, version2.Minor, fileVersionInfo.FileName, fileVersionInfo.FileVersion, fileVersionInfo.FileDescription, fileVersionInfo.CompanyName + " " + fileVersionInfo.LegalCopyright, fileVersionInfo.Language)); } else { Console.WriteLine($"An incorrect version of BASS was loaded!\r\n\r\nBASS Version loaded: {version.Major}.{version.Minor}\r\nBASS Version expected: {version2.Major}.{version2.Minor}"); } } catch { } } } public enum BASS3DAlgorithm { BASS_3DALG_DEFAULT, BASS_3DALG_OFF, BASS_3DALG_FULL, BASS_3DALG_LIGHT } public enum BASS3DMode { BASS_3DMODE_LEAVECURRENT = -1, BASS_3DMODE_NORMAL, BASS_3DMODE_RELATIVE, BASS_3DMODE_OFF } public enum BASSActive { BASS_ACTIVE_STOPPED, BASS_ACTIVE_PLAYING, BASS_ACTIVE_STALLED, BASS_ACTIVE_PAUSED, BASS_ACTIVE_PAUSED_DEVICE } public enum BASSAttribute { BASS_ATTRIB_FREQ = 1, BASS_ATTRIB_VOL = 2, BASS_ATTRIB_PAN = 3, BASS_ATTRIB_EAXMIX = 4, BASS_ATTRIB_NOBUFFER = 5, BASS_ATTRIB_CPU = 7, BASS_ATTRIB_SRC = 8, BASS_ATTRIB_NET_RESUME = 9, BASS_ATTRIB_SCANINFO = 10, BASS_ATTRIB_NORAMP = 11, BASS_ATTRIB_BITRATE = 12, BASS_ATTRIB_BUFFER = 13, BASS_ATTRIB_MUSIC_AMPLIFY = 256, BASS_ATTRIB_MUSIC_PANSEP = 257, BASS_ATTRIB_MUSIC_PSCALER = 258, BASS_ATTRIB_MUSIC_BPM = 259, BASS_ATTRIB_MUSIC_SPEED = 260, BASS_ATTRIB_MUSIC_VOL_GLOBAL = 261, BASS_ATTRIB_MUSIC_ACTIVE = 262, BASS_ATTRIB_MUSIC_VOL_CHAN = 512, BASS_ATTRIB_MUSIC_VOL_INST = 768, BASS_ATTRIB_TEMPO = 65536, BASS_ATTRIB_TEMPO_PITCH = 65537, BASS_ATTRIB_TEMPO_FREQ = 65538, BASS_ATTRIB_TEMPO_OPTION_USE_AA_FILTER = 65552, BASS_ATTRIB_TEMPO_OPTION_AA_FILTER_LENGTH = 65553, BASS_ATTRIB_TEMPO_OPTION_USE_QUICKALGO = 65554, BASS_ATTRIB_TEMPO_OPTION_SEQUENCE_MS = 65555, BASS_ATTRIB_TEMPO_OPTION_SEEKWINDOW_MS = 65556, BASS_ATTRIB_TEMPO_OPTION_OVERLAP_MS = 65557, BASS_ATTRIB_TEMPO_OPTION_PREVENT_CLICK = 65558, BASS_ATTRIB_REVERSE_DIR = 69632, BASS_ATTRIB_MIDI_PPQN = 73728, BASS_ATTRIB_MIDI_CPU = 73729, BASS_ATTRIB_MIDI_CHANS = 73730, BASS_ATTRIB_MIDI_VOICES = 73731, BASS_ATTRIB_MIDI_VOICES_ACTIVE = 73732, BASS_ATTRIB_MIDI_STATE = 73733, BASS_ATTRIB_MIDI_SRC = 73734, BASS_ATTRIB_MIDI_KILL = 73735, BASS_ATTRIB_MIDI_TRACK_VOL = 73984, BASS_ATTRIB_OPUS_ORIGFREQ = 77824, BASS_ATTRIB_DSD_GAIN = 81920, BASS_ATTRIB_DSD_RATE = 81921, BASS_ATTRIB_MIXER_LATENCY = 86016, BASS_ATTRIB_SPLIT_ASYNCBUFFER = 86032, BASS_ATTRIB_SPLIT_ASYNCPERIOD = 86033, BASS_ATTRIB_WEBM_TRACK = 90112, BASS_SLIDE_LOG = 16777216 } [SuppressUnmanagedCodeSecurity] public sealed class BASSBuffer : IDisposable { private bool disposed; private int _bufferlength = 352800; private int _bps = 2; private int _samplerate = 44100; private int _chans = 2; private byte[] _buffer; private int _bufferwritepos; private int _readers = 1; private int[] _bufferreadpos = new int[1]; public int BufferLength => _bufferlength; public int Bps => _bps; public int SampleRate => _samplerate; public int NumChans => _chans; public int Readers { get { return _readers; } set { if (value <= 0 || value == _readers) { return; } lock (_buffer) { int[] array = new int[value]; for (int i = 0; i < value; i++) { if (i < _readers) { array[i] = _bufferreadpos[i]; } else { array[i] = _bufferreadpos[_readers - 1]; } } _bufferreadpos = array; _readers = value; } } } public BASSBuffer() { Initialize(); } public BASSBuffer(float seconds, int samplerate, int chans, int bps) { if (seconds <= 0f) { seconds = 2f; } _samplerate = samplerate; if (_samplerate <= 0) { _samplerate = 44100; } _chans = chans; if (_chans <= 0) { _chans = 2; } _bps = bps; if (_bps > 4) { switch (_bps) { case 32: _bps = 4; break; case 8: _bps = 1; break; default: _bps = 2; break; } } if (_bps <= 0 || _bps == 3) { _bps = 2; } _bufferlength = (int)Math.Ceiling((double)seconds * (double)_samplerate * (double)_chans * (double)_bps); if (_bufferlength % _bps > 0) { _bufferlength -= _bufferlength % _bps; } Initialize(); } private void Initialize() { _buffer = new byte[_bufferlength]; Clear(); } public void Dispose() { Dispose(disposing: true); GC.SuppressFinalize(this); } private void Dispose(bool disposing) { if (!disposed) { } disposed = true; } ~BASSBuffer() { Dispose(disposing: false); } public void Clear() { lock (_buffer) { Array.Clear(_buffer, 0, _bufferlength); _bufferwritepos = 0; for (int i = 0; i < _readers; i++) { _bufferreadpos[i] = 0; } } } public void Resize(float factor) { if (factor <= 1f) { return; } lock (_buffer) { _bufferlength = (int)Math.Ceiling((double)factor * (double)_bufferlength); if (_bufferlength % _bps > 0) { _bufferlength -= _bufferlength % _bps; } byte[] array = new byte[_bufferlength]; Array.Clear(array, 0, _bufferlength); Array.Copy(_buffer, array, _buffer.Length); _buffer = array; } } public int Space(int reader) { int num = _bufferlength; lock (_buffer) { if (reader < 0 || reader >= _readers) { int num2 = 0; for (int i = 0; i < _readers; i++) { num2 = _bufferlength - (_bufferwritepos - _bufferreadpos[reader]); if (num2 > _bufferlength) { num2 -= _bufferlength; } if (num2 < num) { num = num2; } } return num; } num = _bufferlength - (_bufferwritepos - _bufferreadpos[reader]); if (num > _bufferlength) { return num - _bufferlength; } return num; } } public int Count(int reader) { int num = -1; lock (_buffer) { if (reader < 0 || reader >= _readers) { int num2 = 0; for (int i = 0; i < _readers; i++) { num2 = _bufferwritepos - _bufferreadpos[i]; if (num2 < 0) { num2 += _bufferlength; } if (num2 > num) { num = num2; } } return num; } num = _bufferwritepos - _bufferreadpos[reader]; if (num < 0) { return num + _bufferlength; } return num; } } public unsafe int Write(IntPtr buffer, int length) { lock (_buffer) { if (length > _bufferlength) { length = _bufferlength; } int num = 0; int num2 = _bufferlength - _bufferwritepos; if (length >= num2) { Marshal.Copy(buffer, _buffer, _bufferwritepos, num2); num += num2; buffer = new IntPtr((byte*)buffer.ToPointer() + num2); length -= num2; _bufferwritepos = 0; } Marshal.Copy(buffer, _buffer, _bufferwritepos, length); num += length; _bufferwritepos += length; return num; } } public int Write(byte[] buffer, int length) { lock (_buffer) { if (length > _bufferlength) { length = _bufferlength; } int num = 0; int num2 = _bufferlength - _bufferwritepos; if (length >= num2) { Array.Copy(buffer, num, _buffer, _bufferwritepos, num2); num += num2; length -= num2; _bufferwritepos = 0; } Array.Copy(buffer, num, _buffer, _bufferwritepos, length); num += length; _bufferwritepos += length; return num; } } public unsafe int Read(IntPtr buffer, int length, int reader) { lock (_buffer) { int num = 0; if (reader < 0 || reader >= _readers) { reader = 0; } int num2 = _bufferwritepos - _bufferreadpos[reader]; if (num2 < 0) { num2 += _bufferlength; } if (length > num2) { length = num2; } num2 = _bufferlength - _bufferreadpos[reader]; if (length >= num2) { Marshal.Copy(_buffer, _bufferreadpos[reader], buffer, num2); num += num2; buffer = new IntPtr((byte*)buffer.ToPointer() + num2); length -= num2; _bufferreadpos[reader] = 0; } Marshal.Copy(_buffer, _bufferreadpos[reader], buffer, length); _bufferreadpos[reader] += length; return num + length; } } public int Read(byte[] buffer, int length, int reader) { lock (_buffer) { int num = 0; if (reader < 0 || reader >= _readers) { reader = 0; } int num2 = _bufferwritepos - _bufferreadpos[reader]; if (num2 < 0) { num2 += _bufferlength; } if (length > num2) { length = num2; } num2 = _bufferlength - _bufferreadpos[reader]; if (length >= num2) { Array.Copy(_buffer, _bufferreadpos[reader], buffer, num, num2); num += num2; length -= num2; _bufferreadpos[reader] = 0; } Array.Copy(_buffer, _bufferreadpos[reader], buffer, num, length); _bufferreadpos[reader] += length; return num + length; } } } [Flags] public enum BASSChannelType { BASS_CTYPE_UNKNOWN = 0, BASS_CTYPE_SAMPLE = 1, BASS_CTYPE_RECORD = 2, BASS_CTYPE_MUSIC_MO3 = 0x100, BASS_CTYPE_STREAM = 0x10000, BASS_CTYPE_STREAM_OGG = 0x10002, BASS_CTYPE_STREAM_MP1 = 0x10003, BASS_CTYPE_STREAM_MP2 = 0x10004, BASS_CTYPE_STREAM_MP3 = 0x10005, BASS_CTYPE_STREAM_AIFF = 0x10006, BASS_CTYPE_STREAM_CA = 0x10007, BASS_CTYPE_STREAM_MF = 0x10008, BASS_CTYPE_STREAM_AM = 0x10009, BASS_CTYPE_STREAM_DUMMY = 0x18000, BASS_CTYPE_STREAM_DEVICE = 0x18001, BASS_CTYPE_STREAM_MIXER = 0x10800, BASS_CTYPE_STREAM_SPLIT = 0x10801, BASS_CTYPE_STREAM_WAV = 0x40000, BASS_CTYPE_STREAM_WAV_PCM = 0x50001, BASS_CTYPE_STREAM_WAV_FLOAT = 0x50003, BASS_CTYPE_MUSIC_MOD = 0x20000, BASS_CTYPE_MUSIC_MTM = 0x20001, BASS_CTYPE_MUSIC_S3M = 0x20002, BASS_CTYPE_MUSIC_XM = 0x20003, BASS_CTYPE_MUSIC_IT = 0x20004, BASS_CTYPE_STREAM_WV = 0x10500, BASS_CTYPE_STREAM_WV_H = 0x10501, BASS_CTYPE_STREAM_WV_L = 0x10502, BASS_CTYPE_STREAM_WV_LH = 0x10503, BASS_CTYPE_STREAM_CD = 0x10200, BASS_CTYPE_STREAM_WMA = 0x10300, BASS_CTYPE_STREAM_WMA_MP3 = 0x10301, BASS_CTYPE_STREAM_FLAC = 0x10900, BASS_CTYPE_STREAM_FLAC_OGG = 0x10901, BASS_CTYPE_STREAM_OFR = 0x10600, BASS_CTYPE_STREAM_APE = 0x10700, BASS_CTYPE_STREAM_MPC = 0x10A00, BASS_CTYPE_STREAM_AAC = 0x10B00, BASS_CTYPE_STREAM_MP4 = 0x10B01, BASS_CTYPE_STREAM_SPX = 0x10C00, BASS_CTYPE_STREAM_ALAC = 0x10E00, BASS_CTYPE_STREAM_TTA = 0x10F00, BASS_CTYPE_STREAM_AC3 = 0x11000, BASS_CTYPE_STREAM_OPUS = 0x11200, BASS_CTYPE_STREAM_WINAMP = 0x10400, BASS_CTYPE_STREAM_DSD = 0x11700, BASS_CTYPE_STREAM_MIDI = 0x10D00, BASS_CTYPE_STREAM_ADX = 0x1F000, BASS_CTYPE_STREAM_AIX = 0x1F001, BASS_CTYPE_STREAM_TEMPO = 0x1F200, BASS_CTYPE_STREAM_REVERSE = 0x1F201, BASS_CTYPE_STREAM_VIDEO = 0x11100 } public enum BASSConfig { BASS_CONFIG_BUFFER = 0, BASS_CONFIG_UPDATEPERIOD = 1, BASS_CONFIG_GVOL_SAMPLE = 4, BASS_CONFIG_GVOL_STREAM = 5, BASS_CONFIG_GVOL_MUSIC = 6, BASS_CONFIG_CURVE_VOL = 7, BASS_CONFIG_CURVE_PAN = 8, BASS_CONFIG_FLOATDSP = 9, BASS_CONFIG_3DALGORITHM = 10, BASS_CONFIG_NET_TIMEOUT = 11, BASS_CONFIG_NET_BUFFER = 12, BASS_CONFIG_PAUSE_NOPLAY = 13, BASS_CONFIG_NET_PREBUF = 15, BASS_CONFIG_NET_AGENT = 16, BASS_CONFIG_NET_PROXY = 17, BASS_CONFIG_NET_PASSIVE = 18, BASS_CONFIG_REC_BUFFER = 19, BASS_CONFIG_NET_PLAYLIST = 21, BASS_CONFIG_MUSIC_VIRTUAL = 22, BASS_CONFIG_VERIFY = 23, BASS_CONFIG_UPDATETHREADS = 24, BASS_CONFIG_DEV_BUFFER = 27, BASS_CONFIG_VISTA_TRUEPOS = 30, BASS_CONFIG_MP3_ERRORS = 35, BASS_CONFIG_DEV_DEFAULT = 36, BASS_CONFIG_NET_READTIMEOUT = 37, BASS_CONFIG_VISTA_SPEAKERS = 38, BASS_CONFIG_MF_DISABLE = 40, BASS_CONFIG_HANDLES = 41, BASS_CONFIG_UNICODE = 42, BASS_CONFIG_SRC = 43, BASS_CONFIG_SRC_SAMPLE = 44, BASS_CONFIG_ASYNCFILE_BUFFER = 45, BASS_CONFIG_OGG_PRESCAN = 47, BASS_CONFIG_MF_VIDEO = 48, BASS_CONFIG_DEV_NONSTOP = 50, BASS_CONFIG_VERIFY_NET = 52, BASS_CONFIG_NET_SEEK = 56, BASS_CONFIG_NET_PLAYLIST_DEPTH = 59, BASS_CONFIG_NET_PREBUF_WAIT = 60, BASS_CONFIG_LIBSSL = 64, BASS_CONFIG_WASAPI_PERSIST = 65, BASS_CONFIG_AC3_DYNRNG = 65537, BASS_CONFIG_WMA_PREBUF = 65793, BASS_CONFIG_WMA_BASSFILE = 65795, BASS_CONFIG_WMA_NETSEEK = 65796, BASS_CONFIG_WMA_VIDEO = 65797, BASS_CONFIG_WMA_ASYNC = 65807, BASS_CONFIG_CD_FREEOLD = 66048, BASS_CONFIG_CD_RETRY = 66049, BASS_CONFIG_CD_AUTOSPEED = 66050, BASS_CONFIG_CD_SKIPERROR = 66051, BASS_CONFIG_CD_CDDB_SERVER = 66052, BASS_CONFIG_CD_READ = 66053, BASS_CONFIG_CD_TIMEOUT = 66054, BASS_CONFIG_ENCODE_PRIORITY = 66304, BASS_CONFIG_ENCODE_QUEUE = 66305, BASS_CONFIG_ENCODE_ACM_LOAD = 66306, BASS_CONFIG_ENCODE_CAST_TIMEOUT = 66320, BASS_CONFIG_ENCODE_CAST_PROXY = 66321, BASS_CONFIG_MIDI_COMPACT = 66560, BASS_CONFIG_MIDI_VOICES = 66561, BASS_CONFIG_MIDI_AUTOFONT = 66562, BASS_CONFIG_MIDI_DEFFONT = 66563, BASS_CONFIG_MIDI_IN_PORTS = 66564, BASS_CONFIG_MIXER_FILTER = 67072, BASS_CONFIG_MIXER_BUFFER = 67073, BASS_CONFIG_MIXER_POSEX = 67074, BASS_CONFIG_SPLIT_BUFFER = 67088, BASS_CONFIG_MP4_VIDEO = 67328, BASS_CONFIG_AAC_PRESCAN = 67330, BASS_CONFIG_AAC_MP4 = 67329, BASS_CONFIG_WINAMP_INPUT_TIMEOUT = 67584, BASS_CONFIG_DSD_FREQ = 67584, BASS_CONFIG_DSD_GAIN = 67585 } [Flags] public enum BASSData { BASS_DATA_AVAILABLE = 0, BASS_DATA_FFT_INDIVIDUAL = 0x10, BASS_DATA_FFT_NOWINDOW = 0x20, BASS_DATA_FFT_REMOVEDC = 0x40, BASS_DATA_FFT_COMPLEX = 0x80, BASS_DATA_FFT_NYQUIST = 0x100, BASS_DATA_FIXED = 0x20000000, BASS_DATA_FLOAT = 0x40000000, BASS_DATA_FFT256 = int.MinValue, BASS_DATA_FFT512 = -2147483647, BASS_DATA_FFT1024 = -2147483646, BASS_DATA_FFT2048 = -2147483645, BASS_DATA_FFT4096 = -2147483644, BASS_DATA_FFT8192 = -2147483643, BASS_DATA_FFT16384 = -2147483642, BASS_DATA_FFT32768 = -2147483641 } [Flags] public enum BASSDeviceInfo { BASS_DEVICE_NONE = 0, BASS_DEVICE_ENABLED = 1, BASS_DEVICE_DEFAULT = 2, BASS_DEVICE_INIT = 4, BASS_DEVICE_LOOPBACK = 8, BASS_DEVICE_INPUT = 0x10, BASS_DEVICE_UNPLUGGED = 0x20, BASS_DEVICE_DISABLED = 0x40, BASS_DEVICE_TYPE_NETWORK = 0x1000000, BASS_DEVICE_TYPE_SPEAKERS = 0x2000000, BASS_DEVICE_TYPE_LINE = 0x3000000, BASS_DEVICE_TYPE_HEADPHONES = 0x4000000, BASS_DEVICE_TYPE_MICROPHONE = 0x5000000, BASS_DEVICE_TYPE_HEADSET = 0x6000000, BASS_DEVICE_TYPE_HANDSET = 0x7000000, BASS_DEVICE_TYPE_DIGITAL = 0x8000000, BASS_DEVICE_TYPE_SPDIF = 0x9000000, BASS_DEVICE_TYPE_HDMI = 0xA000000, BASS_DEVICE_TYPE_DISPLAYPORT = 0x40000000, BASS_DEVICE_TYPE_MASK = -16777216 } public enum BASSDirectSound { BASS_OBJECT_DS = 1, BASS_OBJECT_DS3DL } public enum BASSError { BASS_OK = 0, BASS_ERROR_MEM = 1, BASS_ERROR_FILEOPEN = 2, BASS_ERROR_DRIVER = 3, BASS_ERROR_BUFLOST = 4, BASS_ERROR_HANDLE = 5, BASS_ERROR_FORMAT = 6, BASS_ERROR_POSITION = 7, BASS_ERROR_INIT = 8, BASS_ERROR_START = 9, BASS_ERROR_NOCD = 12, BASS_ERROR_CDTRACK = 13, BASS_ERROR_ALREADY = 14, BASS_ERROR_NOPAUSE = 16, BASS_ERROR_NOTAUDIO = 17, BASS_ERROR_NOCHAN = 18, BASS_ERROR_ILLTYPE = 19, BASS_ERROR_ILLPARAM = 20, BASS_ERROR_NO3D = 21, BASS_ERROR_NOEAX = 22, BASS_ERROR_DEVICE = 23, BASS_ERROR_NOPLAY = 24, BASS_ERROR_FREQ = 25, BASS_ERROR_NOTFILE = 27, BASS_ERROR_NOHW = 29, BASS_ERROR_EMPTY = 31, BASS_ERROR_NONET = 32, BASS_ERROR_CREATE = 33, BASS_ERROR_NOFX = 34, BASS_ERROR_PLAYING = 35, BASS_ERROR_NOTAVAIL = 37, BASS_ERROR_DECODE = 38, BASS_ERROR_DX = 39, BASS_ERROR_TIMEOUT = 40, BASS_ERROR_FILEFORM = 41, BASS_ERROR_SPEAKER = 42, BASS_ERROR_VERSION = 43, BASS_ERROR_CODEC = 44, BASS_ERROR_ENDED = 45, BASS_ERROR_BUSY = 46, BASS_ERROR_UNKNOWN = -1, BASS_ERROR_WMA_LICENSE = 1000, BASS_ERROR_WMA_WM9 = 1001, BASS_ERROR_WMA_DENIED = 1002, BASS_ERROR_WMA_CODEC = 1003, BASS_ERROR_WMA_INDIVIDUAL = 1004, BASS_ERROR_ACM_CANCEL = 2000, BASS_ERROR_CAST_DENIED = 2100, BASS_VST_ERROR_NOINPUTS = 3000, BASS_VST_ERROR_NOOUTPUTS = 3001, BASS_VST_ERROR_NOREALTIME = 3002, BASS_ERROR_WASAPI = 5000, BASS_ERROR_WASAPI_BUFFER = 5001, BASS_ERROR_WASAPI_CATEGORY = 5002, BASS_ERROR_MP4_NOSTREAM = 6000, BASS_ERROR_WEBM_NOTAUDIO = 8000, BASS_ERROR_WEBM_TRACK = 8001 } [Flags] public enum BASSFlag { BASS_DEFAULT = 0, BASS_SAMPLE_8BITS = 1, BASS_SAMPLE_MONO = 2, BASS_SAMPLE_LOOP = 4, BASS_SAMPLE_3D = 8, BASS_SAMPLE_SOFTWARE = 0x10, BASS_SAMPLE_MUTEMAX = 0x20, BASS_SAMPLE_VAM = 0x40, BASS_SAMPLE_FX = 0x80, BASS_SAMPLE_FLOAT = 0x100, BASS_RECORD_PAUSE = 0x8000, BASS_RECORD_ECHOCANCEL = 0x2000, BASS_RECORD_AGC = 0x4000, BASS_STREAM_PRESCAN = 0x20000, BASS_STREAM_AUTOFREE = 0x40000, BASS_STREAM_RESTRATE = 0x80000, BASS_STREAM_BLOCK = 0x100000, BASS_STREAM_DECODE = 0x200000, BASS_STREAM_STATUS = 0x800000, BASS_SPEAKER_FRONT = 0x1000000, BASS_SPEAKER_REAR = 0x2000000, BASS_SPEAKER_CENLFE = 0x3000000, BASS_SPEAKER_REAR2 = 0x4000000, BASS_SPEAKER_LEFT = 0x10000000, BASS_SPEAKER_RIGHT = 0x20000000, BASS_SPEAKER_FRONTLEFT = 0x11000000, BASS_SPEAKER_FRONTRIGHT = 0x21000000, BASS_SPEAKER_REARLEFT = 0x12000000, BASS_SPEAKER_REARRIGHT = 0x22000000, BASS_SPEAKER_CENTER = 0x13000000, BASS_SPEAKER_LFE = 0x23000000, BASS_SPEAKER_REAR2LEFT = 0x14000000, BASS_SPEAKER_REAR2RIGHT = 0x24000000, BASS_SPEAKER_PAIR1 = 0x1000000, BASS_SPEAKER_PAIR2 = 0x2000000, BASS_SPEAKER_PAIR3 = 0x3000000, BASS_SPEAKER_PAIR4 = 0x4000000, BASS_SPEAKER_PAIR5 = 0x5000000, BASS_SPEAKER_PAIR6 = 0x6000000, BASS_SPEAKER_PAIR7 = 0x7000000, BASS_SPEAKER_PAIR8 = 0x8000000, BASS_SPEAKER_PAIR9 = 0x9000000, BASS_SPEAKER_PAIR10 = 0xA000000, BASS_SPEAKER_PAIR11 = 0xB000000, BASS_SPEAKER_PAIR12 = 0xC000000, BASS_SPEAKER_PAIR13 = 0xD000000, BASS_SPEAKER_PAIR14 = 0xE000000, BASS_SPEAKER_PAIR15 = 0xF000000, BASS_ASYNCFILE = 0x40000000, BASS_UNICODE = int.MinValue, BASS_SAMPLE_OVER_VOL = 0x10000, BASS_SAMPLE_OVER_POS = 0x20000, BASS_SAMPLE_OVER_DIST = 0x30000, BASS_WV_STEREO = 0x400000, BASS_AC3_DOWNMIX_2 = 0x200, BASS_AC3_DOWNMIX_4 = 0x400, BASS_DSD_RAW = 0x200, BASS_DSD_DOP = 0x400, BASS_AC3_DOWNMIX_DOLBY = 0x600, BASS_AC3_DYNAMIC_RANGE = 0x800, BASS_AAC_FRAME960 = 0x1000, BASS_AAC_STEREO = 0x400000, BASS_MIXER_END = 0x10000, BASS_MIXER_PAUSE = 0x20000, BASS_MIXER_NONSTOP = 0x20000, BASS_MIXER_RESUME = 0x1000, BASS_MIXER_POSEX = 0x2000, BASS_MIXER_LIMIT = 0x4000, BASS_MIXER_MATRIX = 0x10000, BASS_MIXER_DOWNMIX = 0x400000, BASS_MIXER_NORAMPIN = 0x800000, BASS_SPLIT_SLAVE = 0x1000, BASS_MIXER_BUFFER = 0x2000, BASS_SPLIT_POS = 0x2000, BASS_CD_SUBCHANNEL = 0x200, BASS_CD_SUBCHANNEL_NOHW = 0x400, BASS_CD_C2ERRORS = 0x800, BASS_MIDI_NOSYSRESET = 0x800, BASS_MIDI_DECAYEND = 0x1000, BASS_MIDI_NOFX = 0x2000, BASS_MIDI_DECAYSEEK = 0x4000, BASS_MIDI_NOCROP = 0x8000, BASS_MIDI_NOTEOFF1 = 0x10000, BASS_MIDI_SINCINTER = 0x800000, BASS_MIDI_FONT_MMAP = 0x20000, BASS_MIDI_FONT_XGDRUMS = 0x40000, BASS_MIDI_FONT_NOFX = 0x80000, BASS_MIDI_PACK_NOHEAD = 1, BASS_MIDI_PACK_16BIT = 2, BASS_FX_FREESOURCE = 0x10000, BASS_FX_BPM_BKGRND = 1, BASS_FX_BPM_MULT2 = 2, BASS_FX_TEMPO_ALGO_LINEAR = 0x200, BASS_FX_TEMPO_ALGO_CUBIC = 0x400, BASS_FX_TEMPO_ALGO_SHANNON = 0x800, BASS_MUSIC_FLOAT = 0x100, BASS_MUSIC_MONO = 2, BASS_MUSIC_LOOP = 4, BASS_MUSIC_3D = 8, BASS_MUSIC_FX = 0x80, BASS_MUSIC_AUTOFREE = 0x40000, BASS_MUSIC_DECODE = 0x200000, BASS_MUSIC_PRESCAN = 0x20000, BASS_MUSIC_RAMP = 0x200, BASS_MUSIC_RAMPS = 0x400, BASS_MUSIC_SURROUND = 0x800, BASS_MUSIC_SURROUND2 = 0x1000, BASS_MUSIC_FT2PAN = 0x2000, BASS_MUSIC_FT2MOD = 0x2000, BASS_MUSIC_PT1MOD = 0x4000, BASS_MUSIC_NONINTER = 0x10000, BASS_MUSIC_SINCINTER = 0x800000, BASS_MUSIC_POSRESET = 0x8000, BASS_MUSIC_POSRESETEX = 0x400000, BASS_MUSIC_STOPBACK = 0x80000, BASS_MUSIC_NOSAMPLE = 0x100000 } public enum BASSFXPhase { BASS_FX_PHASE_NEG_180, BASS_FX_PHASE_NEG_90, BASS_FX_PHASE_ZERO, BASS_FX_PHASE_90, BASS_FX_PHASE_180 } public enum BASSFXType { BASS_FX_DX8_CHORUS = 0, BASS_FX_DX8_COMPRESSOR = 1, BASS_FX_DX8_DISTORTION = 2, BASS_FX_DX8_ECHO = 3, BASS_FX_DX8_FLANGER = 4, BASS_FX_DX8_GARGLE = 5, BASS_FX_DX8_I3DL2REVERB = 6, BASS_FX_DX8_PARAMEQ = 7, BASS_FX_DX8_REVERB = 8, BASS_FX_VOLUME = 9, BASS_FX_BFX_ROTATE = 65536, [Obsolete("This effect is obsolete; use BASS_FX_BFX_ECHO4 instead")] BASS_FX_BFX_ECHO = 65537, [Obsolete("This effect is obsolete; use BASS_FX_BFX_CHORUS instead")] BASS_FX_BFX_FLANGER = 65538, BASS_FX_BFX_VOLUME = 65539, BASS_FX_BFX_PEAKEQ = 65540, [Obsolete("This effect is obsolete; use BASS_FX_BFX_FREEVERB instead")] BASS_FX_BFX_REVERB = 65541, [Obsolete("This effect is obsolete; use 2x BASS_FX_BFX_BQF with BASS_BFX_BQF_LOWPASS filter and appropriate fQ values instead")] BASS_FX_BFX_LPF = 65542, BASS_FX_BFX_MIX = 65543, BASS_FX_BFX_DAMP = 65544, BASS_FX_BFX_AUTOWAH = 65545, [Obsolete("This effect is obsolete; use BASS_FX_BFX_ECHO4 instead")] BASS_FX_BFX_ECHO2 = 65546, BASS_FX_BFX_PHASER = 65547, [Obsolete("This effect is obsolete; use BASS_FX_BFX_ECHO4 instead")] BASS_FX_BFX_ECHO3 = 65548, BASS_FX_BFX_CHORUS = 65549, [Obsolete("This effect is obsolete; use BASS_FX_BFX_BQF with BASS_BFX_BQF_ALLPASS filter instead")] BASS_FX_BFX_APF = 65550, [Obsolete("This effect is obsolete; use BASS_FX_BFX_COMPRESSOR2 instead")] BASS_FX_BFX_COMPRESSOR = 65551, BASS_FX_BFX_DISTORTION = 65552, BASS_FX_BFX_COMPRESSOR2 = 65553, BASS_FX_BFX_VOLUME_ENV = 65554, BASS_FX_BFX_BQF = 65555, BASS_FX_BFX_ECHO4 = 65556, BASS_FX_BFX_PITCHSHIFT = 65557, BASS_FX_BFX_FREEVERB = 65558 } [Flags] public enum BASSInfo { DSCAPS_NONE = 0, DSCAPS_CONTINUOUSRATE = 0x10, DSCAPS_EMULDRIVER = 0x20, DSCAPS_CERTIFIED = 0x40, DSCAPS_SECONDARYMONO = 0x100, DSCAPS_SECONDARYSTEREO = 0x200, DSCAPS_SECONDARY8BIT = 0x400, DSCAPS_SECONDARY16BIT = 0x800 } [Flags] public enum BASSInit { BASS_DEVICE_DEFAULT = 0, BASS_DEVICE_8BITS = 1, BASS_DEVICE_MONO = 2, BASS_DEVICE_3D = 4, BASS_DEVICE_LATENCY = 0x100, BASS_DEVICE_CPSPEAKERS = 0x400, BASS_DEVICE_SPEAKERS = 0x800, BASS_DEVICE_NOSPEAKER = 0x1000, BASS_DEVIDE_DMIX = 0x2000, BASS_DEVICE_FREQ = 0x4000, BASS_DEVICE_STEREO = 0x8000, BASS_DEVICE_HOG = 0x10000, BASS_DEVICE_DSOUND = 0x40000 } [Flags] public enum BASSInput { BASS_INPUT_NONE = 0, BASS_INPUT_OFF = 0x10000, BASS_INPUT_ON = 0x20000 } [Flags] public enum BASSInputType { BASS_INPUT_TYPE_ERROR = -1, BASS_INPUT_TYPE_MASK = -16777216, BASS_INPUT_TYPE_UNDEF = 0, BASS_INPUT_TYPE_DIGITAL = 0x1000000, BASS_INPUT_TYPE_LINE = 0x2000000, BASS_INPUT_TYPE_MIC = 0x3000000, BASS_INPUT_TYPE_SYNTH = 0x4000000, BASS_INPUT_TYPE_CD = 0x5000000, BASS_INPUT_TYPE_PHONE = 0x6000000, BASS_INPUT_TYPE_SPEAKER = 0x7000000, BASS_INPUT_TYPE_WAVE = 0x8000000, BASS_INPUT_TYPE_AUX = 0x9000000, BASS_INPUT_TYPE_ANALOG = 0xA000000 } [Flags] public enum BASSLevel { BASS_LEVEL_ALL = 0, BASS_LEVEL_MONO = 1, BASS_LEVEL_STEREO = 2, BASS_LEVEL_RMS = 4, BASS_LEVEL_VOLPAN = 8 } [Flags] public enum BASSMode { BASS_POS_BYTE = 0, BASS_POS_BYTES = 0, BASS_POS_MUSIC_ORDERS = 1, BASS_POS_MIDI_TICK = 2, BASS_POS_OGG = 3, BASS_POS_CD_TRACK = 4, BASS_POS_RESET = 0x2000000, BASS_POS_RELATIVE = 0x4000000, BASS_POS_INEXACT = 0x8000000, BASS_MUSIC_POSRESET = 0x8000, BASS_MUSIC_POSRESETEX = 0x400000, BASS_MIXER_NORAMPIN = 0x800000, BASS_POS_MIXER_RESET = 0x10000, BASS_POS_DECODE = 0x10000000, BASS_POS_DECODETO = 0x20000000, BASS_POS_SCAN = 0x40000000, BASS_MIDI_DECAYSEEK = 0x4000 } [SuppressUnmanagedCodeSecurity] public sealed class BassNet { internal static string _eMail; internal static string _registrationKey; internal static string _internalName; public static bool OmitCheckVersion; private static bool _useBrokenLatin1; private static bool _useRiffInfoUTF8; public static string InternalName => _internalName; public static bool UseBrokenLatin1Behavior { get { return _useBrokenLatin1; } set { _useBrokenLatin1 = value; } } public static bool UseRiffInfoUTF8 { get { return _useRiffInfoUTF8; } set { _useRiffInfoUTF8 = value; } } private BassNet() { } static BassNet() { _eMail = string.Empty; _registrationKey = string.Empty; _internalName = "BASS.NET"; OmitCheckVersion = false; _useBrokenLatin1 = false; _useRiffInfoUTF8 = false; AssemblyName name = Assembly.GetExecutingAssembly().GetName(); _internalName = $"{name.Name} v{name.Version}"; } public static void Registration(string eMail, string registrationKey) { _eMail = eMail; _registrationKey = registrationKey; } } [Flags] public enum BASSRecordFormat { WAVE_FORMAT_UNKNOWN = 0, WAVE_FORMAT_1M08 = 1, WAVE_FORMAT_1S08 = 2, WAVE_FORMAT_1M16 = 4, WAVE_FORMAT_1S16 = 8, WAVE_FORMAT_2M08 = 0x10, WAVE_FORMAT_2S08 = 0x20, WAVE_FORMAT_2M16 = 0x40, WAVE_FORMAT_2S16 = 0x80, WAVE_FORMAT_4M08 = 0x100, WAVE_FORMAT_4S08 = 0x200, WAVE_FORMAT_4M16 = 0x400, WAVE_FORMAT_4S16 = 0x800, WAVE_FORMAT_48M08 = 0x1000, WAVE_FORMAT_48S08 = 0x2000, WAVE_FORMAT_48M16 = 0x4000, WAVE_FORMAT_48S16 = 0x8000, WAVE_FORMAT_96M08 = 0x10000, WAVE_FORMAT_96S08 = 0x20000, WAVE_FORMAT_96M16 = 0x40000, WAVE_FORMAT_96S16 = 0x80000 } [Flags] public enum BASSRecordInfo { DSCAPS_NONE = 0, DSCAPS_EMULDRIVER = 0x20, DSCAPS_CERTIFIED = 0x40 } public enum BASSStreamFilePosition { BASS_FILEPOS_CURRENT = 0, BASS_FILEPOS_DOWNLOAD = 1, BASS_FILEPOS_END = 2, BASS_FILEPOS_START = 3, BASS_FILEPOS_CONNECTED = 4, BASS_FILEPOS_BUFFER = 5, BASS_FILEPOS_SOCKET = 6, BASS_FILEPOS_ASYNCBUF = 7, BASS_FILEPOS_SIZE = 8, BASS_FILEPOS_BUFFERING = 9, BASS_FILEPOS_WMA_BUFFER = 1000, BASS_FILEPOS_HLS_SEGMENT = 65536 } public enum BASSStreamProc { STREAMPROC_DUMMY = 0, STREAMPROC_PUSH = -1, BASS_STREAMPROC_END = int.MinValue } public enum BASSStreamSystem { STREAMFILE_NOBUFFER, STREAMFILE_BUFFER, STREAMFILE_BUFFERPUSH } [Flags] public enum BASSSync { BASS_SYNC_POS = 0, BASS_SYNC_MUSICINST = 1, BASS_SYNC_END = 2, BASS_SYNC_MUSICFX = 3, BASS_SYNC_META = 4, BASS_SYNC_SLIDE = 5, BASS_SYNC_STALL = 6, BASS_SYNC_DOWNLOAD = 7, BASS_SYNC_FREE = 8, BASS_SYNC_MUSICPOS = 0xA, BASS_SYNC_SETPOS = 0xB, BASS_SYNC_OGG_CHANGE = 0xC, BASS_SYNC_DEV_FAIL = 0xE, BASS_SYNC_DEV_FORMAT = 0xF, BASS_SYNC_MIXTIME = 0x40000000, BASS_SYNC_ONETIME = int.MinValue, BASS_SYNC_MIXER_ENVELOPE = 0x10200, BASS_SYNC_MIXER_ENVELOPE_NODE = 0x10201, BASS_SYNC_WMA_CHANGE = 0x10100, BASS_SYNC_WMA_META = 0x10101, BASS_SYNC_CD_ERROR = 0x3E8, BASS_SYNC_CD_SPEED = 0x3EA, BASS_WINAMP_SYNC_BITRATE = 0x64, BASS_SYNC_MIDI_MARKER = 0x10000, BASS_SYNC_MIDI_CUE = 0x10001, BASS_SYNC_MIDI_LYRIC = 0x10002, BASS_SYNC_MIDI_TEXT = 0x10003, BASS_SYNC_MIDI_EVENT = 0x10004, BASS_SYNC_MIDI_TICK = 0x10005, BASS_SYNC_MIDI_TIMESIG = 0x10006, BASS_SYNC_MIDI_KEYSIG = 0x10007, BASS_SYNC_HLS_SEGMENT = 0x10300 } public enum BASSTag { BASS_TAG_ID3 = 0, BASS_TAG_ID3V2 = 1, BASS_TAG_OGG = 2, BASS_TAG_HTTP = 3, BASS_TAG_ICY = 4, BASS_TAG_META = 5, BASS_TAG_APE = 6, BASS_TAG_MP4 = 7, BASS_TAG_WMA = 8, BASS_TAG_VENDOR = 9, BASS_TAG_LYRICS3 = 10, BASS_TAG_WMA_META = 11, BASS_TAG_CA_CODEC = 11, BASS_TAG_FLAC_CUE = 12, BASS_TAG_WMA_CODEC = 12, BASS_TAG_MF = 13, BASS_TAG_WAVEFORMAT = 14, BASS_TAG_AM_MIME = 15, BASS_TAG_AM_NAME = 16, BASS_TAG_RIFF_INFO = 256, BASS_TAG_RIFF_BEXT = 257, BASS_TAG_RIFF_CART = 258, BASS_TAG_RIFF_DISP = 259, BASS_TAG_RIFF_CUE = 260, BASS_TAG_RIFF_SMPL = 261, BASS_TAG_APE_BINARY = 4096, BASS_TAG_MUSIC_NAME = 65536, BASS_TAG_MUSIC_MESSAGE = 65537, BASS_TAG_MUSIC_ORDERS = 65538, BASS_TAG_MUSIC_AUTH = 65539, BASS_TAG_MUSIC_INST = 65792, BASS_TAG_MUSIC_SAMPLE = 66304, BASS_TAG_MIDI_TRACK = 69632, BASS_TAG_ADX_LOOP = 73728, BASS_TAG_FLAC_PICTURE = 73728, BASS_TAG_DSD_ARTIST = 77824, BASS_TAG_DSD_TITLE = 77825, BASS_TAG_DSD_COMMENT = 78080, BASS_TAG_HLS_EXTINF = 81920, BASS_TAG_HLS_STREAMINF = 81921, BASS_TAG_HLS_DATE = 81922, BASS_TAG_UNKNOWN = -1 } [SuppressUnmanagedCodeSecurity] public sealed class BASSTimer : IDisposable { private bool disposed; private Timer _timer; private int _interval = 50; private TimerCallback _timerDelegate; private bool _enabled; public int Interval { get { return _interval; } set { if (value <= 0) { _interval = -1; } else { _interval = value; } if (Enabled) { lock (_timer) { _timer.Change(_interval, _interval); } } } } public bool Enabled { get { if (_enabled) { return _timer != null; } return false; } set { if (value == _enabled) { return; } if (value) { if (_timer != null) { lock (_timer) { _timer.Change(_interval, _interval); _enabled = true; return; } } Start(); return; } if (_timer != null) { lock (_timer) { _timer.Change(-1, -1); _enabled = false; return; } } Stop(); } } public event EventHandler Tick; public BASSTimer() { _timerDelegate = timer_Tick; } public BASSTimer(int interval) { _interval = interval; _timerDelegate = timer_Tick; } public void Dispose() { Dispose(disposing: true); GC.SuppressFinalize(this); } private void Dispose(bool disposing) { if (!disposed) { try { Stop(); } catch { } } disposed = true; } ~BASSTimer() { Dispose(disposing: false); } private void timer_Tick(object state) { if (this.Tick != null) { ProcessDelegate(this.Tick, this, EventArgs.Empty); } } private void ProcessDelegate(Delegate del, params object[] args) { if ((object)del == null || _timer == null) { return; } lock (_timer) { Delegate[] invocationList = del.GetInvocationList(); Delegate[] array = invocationList; foreach (Delegate del2 in array) { InvokeDelegate(del2, args); } } } private void InvokeDelegate(Delegate del, object[] args) { if (del.Target is ISynchronizeInvoke synchronizeInvoke) { if (synchronizeInvoke.InvokeRequired) { try { synchronizeInvoke.BeginInvoke(del, args); return; } catch { return; } } del.DynamicInvoke(args); } else { del.DynamicInvoke(args); } } public void Start() { if (_timer == null) { _timer = new Timer(_timerDelegate, null, _interval, _interval); _enabled = true; return; } lock (_timer) { _timer.Change(_interval, _interval); _enabled = true; } } public void Stop() { if (_timer != null) { lock (_timer) { _timer.Change(-1, -1); _timer.Dispose(); _enabled = false; } _timer = null; } else { _enabled = false; } } } [Flags] public enum BASSVam { BASS_VAM_HARDWARE = 1, BASS_VAM_SOFTWARE = 2, BASS_VAM_TERM_TIME = 4, BASS_VAM_TERM_DIST = 8, BASS_VAM_TERM_PRIO = 0x10 } [Serializable] [StructLayout(LayoutKind.Sequential)] public sealed class BASS_3DVECTOR { public float x; public float y; public float z; public BASS_3DVECTOR() { } public BASS_3DVECTOR(float X, float Y, float Z) { x = X; y = Y; z = Z; } public override string ToString() { return $"X={x}, Y={y}, Z={z}"; } } [Serializable] public sealed class BASS_CHANNELINFO { internal BASS_CHANNELINFO_INTERNAL _internal; public int freq; public int chans; public BASSFlag flags; public BASSChannelType ctype; public int origres; public int plugin; public int sample; public string filename = string.Empty; public bool origresIsFloat; public bool IsDecodingChannel => (flags & BASSFlag.BASS_STREAM_DECODE) != 0; public bool Is32bit => (flags & BASSFlag.BASS_SAMPLE_FLOAT) != 0; public bool Is8bit => (flags & BASSFlag.BASS_SAMPLE_8BITS) != 0; public override string ToString() { return string.Format("{0}, {1}Hz, {2}, {3}bit{4}", Utils.BASSChannelTypeToString(ctype), freq, Utils.ChannelNumberToString(chans), (origres != 0) ? origres : (Is32bit ? 32 : (Is8bit ? 8 : 16)), origresIsFloat ? "-float" : ""); } } [Serializable] internal struct BASS_CHANNELINFO_INTERNAL { public int freq; public int chans; public BASSFlag flags; public BASSChannelType ctype; public int origres; public int plugin; public int sample; public IntPtr filename; } [Serializable] public sealed class BASS_DEVICEINFO { internal BASS_DEVICEINFO_INTERNAL _internal; public string name = string.Empty; public string driver = string.Empty; public string id; public BASSDeviceInfo flags; public BASSDeviceInfo status => flags & (BASSDeviceInfo)16777215; public BASSDeviceInfo type => flags & BASSDeviceInfo.BASS_DEVICE_TYPE_MASK; public bool IsEnabled => (flags & BASSDeviceInfo.BASS_DEVICE_ENABLED) != 0; public bool IsDefault => (flags & BASSDeviceInfo.BASS_DEVICE_DEFAULT) != 0; public bool IsInitialized => (flags & BASSDeviceInfo.BASS_DEVICE_INIT) != 0; public override string ToString() { return name; } } [Serializable] internal struct BASS_DEVICEINFO_INTERNAL { public IntPtr name; public IntPtr driver; public BASSDeviceInfo flags; } [Serializable] [StructLayout(LayoutKind.Sequential)] public sealed class BASS_DX8_CHORUS { public float fWetDryMix; public float fDepth = 25f; public float fFeedback; public float fFrequency; public int lWaveform = 1; public float fDelay; public BASSFXPhase lPhase = BASSFXPhase.BASS_FX_PHASE_ZERO; public BASS_DX8_CHORUS() { } public BASS_DX8_CHORUS(float WetDryMix, float Depth, float Feedback, float Frequency, int Waveform, float Delay, BASSFXPhase Phase) { fWetDryMix = WetDryMix; fDepth = Depth; fFeedback = Feedback; fFrequency = Frequency; lWaveform = Waveform; fDelay = Delay; lPhase = Phase; } public void Preset_Default() { fWetDryMix = 50f; fDepth = 25f; fFeedback = 0f; fFrequency = 0f; lWaveform = 1; fDelay = 0f; lPhase = BASSFXPhase.BASS_FX_PHASE_ZERO; } public void Preset_A() { fWetDryMix = 60f; fDepth = 60f; fFeedback = 25f; fFrequency = 5f; lWaveform = 1; fDelay = 8f; lPhase = BASSFXPhase.BASS_FX_PHASE_90; } public void Preset_B() { fWetDryMix = 75f; fDepth = 80f; fFeedback = 50f; fFrequency = 7f; lWaveform = 0; fDelay = 15f; lPhase = BASSFXPhase.BASS_FX_PHASE_NEG_90; } } [Serializable] [StructLayout(LayoutKind.Sequential)] public sealed class BASS_DX8_COMPRESSOR { public float fGain; public float fAttack = 10f; public float fRelease = 200f; public float fThreshold = -20f; public float fRatio = 3f; public float fPredelay = 4f; public BASS_DX8_COMPRESSOR() { } public BASS_DX8_COMPRESSOR(float Gain, float Attack, float Release, float Threshold, float Ratio, float Predelay) { fGain = Gain; fAttack = Attack; fRelease = Release; fThreshold = Threshold; fRatio = Ratio; fPredelay = Predelay; } public void Preset_Default() { fGain = 0f; fAttack = 10f; fRelease = 200f; fThreshold = -20f; fRatio = 3f; fPredelay = 4f; } public void Preset_Soft() { fGain = 0f; fAttack = 12f; fRelease = 800f; fThreshold = -20f; fRatio = 3f; fPredelay = 4f; } public void Preset_Soft2() { fGain = 2f; fAttack = 20f; fRelease = 800f; fThreshold = -20f; fRatio = 4f; fPredelay = 4f; } public void Preset_Medium() { fGain = 4f; fAttack = 5f; fRelease = 600f; fThreshold = -20f; fRatio = 5f; fPredelay = 3f; } public void Preset_Hard() { fGain = 2f; fAttack = 2f; fRelease = 400f; fThreshold = -20f; fRatio = 8f; fPredelay = 2f; } public void Preset_Hard2() { fGain = 6f; fAttack = 2f; fRelease = 200f; fThreshold = -20f; fRatio = 10f; fPredelay = 2f; } public void Preset_HardCommercial() { fGain = 4f; fAttack = 5f; fRelease = 300f; fThreshold = -16f; fRatio = 9f; fPredelay = 2f; } } [Serializable] [StructLayout(LayoutKind.Sequential)] public sealed class BASS_DX8_DISTORTION { public float fGain; public float fEdge = 50f; public float fPostEQCenterFrequency = 4000f; public float fPostEQBandwidth = 4000f; public float fPreLowpassCutoff = 4000f; public BASS_DX8_DISTORTION() { } public BASS_DX8_DISTORTION(float Gain, float Edge, float PostEQCenterFrequency, float PostEQBandwidth, float PreLowpassCutoff) { fGain = Gain; fEdge = Edge; fPostEQCenterFrequency = PostEQCenterFrequency; fPostEQBandwidth = PostEQBandwidth; fPreLowpassCutoff = PreLowpassCutoff; } public void Preset_Default() { fGain = 0f; fEdge = 50f; fPostEQCenterFrequency = 4000f; fPostEQBandwidth = 4000f; fPreLowpassCutoff = 4000f; } } [Serializable] [StructLayout(LayoutKind.Sequential)] public sealed class BASS_DX8_ECHO { public float fWetDryMix; public float fFeedback; public float fLeftDelay = 333f; public float fRightDelay = 333f; [MarshalAs(UnmanagedType.Bool)] public bool lPanDelay; public BASS_DX8_ECHO() { } public BASS_DX8_ECHO(float WetDryMix, float Feedback, float LeftDelay, float RightDelay, bool PanDelay) { fWetDryMix = WetDryMix; fFeedback = Feedback; fLeftDelay = LeftDelay; fRightDelay = RightDelay; lPanDelay = PanDelay; } public void Preset_Default() { fWetDryMix = 50f; fFeedback = 0f; fLeftDelay = 333f; fRightDelay = 333f; lPanDelay = false; } public void Preset_Small() { fWetDryMix = 50f; fFeedback = 20f; fLeftDelay = 100f; fRightDelay = 100f; lPanDelay = false; } public void Preset_Long() { fWetDryMix = 50f; fFeedback = 20f; fLeftDelay = 700f; fRightDelay = 700f; lPanDelay = false; } } [Serializable] [StructLayout(LayoutKind.Sequential)] public sealed class BASS_DX8_FLANGER { public float fWetDryMix; public float fDepth = 25f; public float fFeedback; public float fFrequency; public int lWaveform = 1; public float fDelay; public BASSFXPhase lPhase = BASSFXPhase.BASS_FX_PHASE_ZERO; public BASS_DX8_FLANGER() { } public BASS_DX8_FLANGER(float WetDryMix, float Depth, float Feedback, float Frequency, int Waveform, float Delay, BASSFXPhase Phase) { fWetDryMix = WetDryMix; fDepth = Depth; fFeedback = Feedback; fFrequency = Frequency; lWaveform = Waveform; fDelay = Delay; lPhase = Phase; } public void Preset_Default() { fWetDryMix = 50f; fDepth = 25f; fFeedback = 0f; fFrequency = 0f; lWaveform = 1; fDelay = 0f; lPhase = BASSFXPhase.BASS_FX_PHASE_ZERO; } public void Preset_A() { fWetDryMix = 60f; fDepth = 60f; fFeedback = 25f; fFrequency = 5f; lWaveform = 1; fDelay = 1f; lPhase = BASSFXPhase.BASS_FX_PHASE_90; } public void Preset_B() { fWetDryMix = 75f; fDepth = 80f; fFeedback = 50f; fFrequency = 7f; lWaveform = 0; fDelay = 3f; lPhase = BASSFXPhase.BASS_FX_PHASE_NEG_90; } } [Serializable] [StructLayout(LayoutKind.Sequential)] public sealed class BASS_DX8_GARGLE { public int dwRateHz = 500; public int dwWaveShape = 1; public BASS_DX8_GARGLE() { } public BASS_DX8_GARGLE(int RateHz, int WaveShape) { dwRateHz = RateHz; dwWaveShape = WaveShape; } public void Preset_Default() { dwRateHz = 100; dwWaveShape = 1; } } [Serializable] [StructLayout(LayoutKind.Sequential)] public sealed class BASS_DX8_I3DL2REVERB { public int lRoom = -1000; public int lRoomHF; public float flRoomRolloffFactor; public float flDecayTime = 1.49f; public float flDecayHFRatio = 0.83f; public int lReflections = -2602; public float flReflectionsDelay = 0.007f; public int lReverb = 200; public float flReverbDelay = 0.011f; public float flDiffusion = 100f; public float flDensity = 100f; public float flHFReference = 5000f; public BASS_DX8_I3DL2REVERB() { } public BASS_DX8_I3DL2REVERB(int Room, int RoomHF, float RoomRolloffFactor, float DecayTime, float DecayHFRatio, int Reflections, float ReflectionsDelay, int Reverb, float ReverbDelay, float Diffusion, float Density, float HFReference) { lRoom = Room; lRoomHF = RoomHF; flRoomRolloffFactor = RoomRolloffFactor; flDecayTime = DecayTime; flDecayHFRatio = DecayHFRatio; lReflections = Reflections; flReflectionsDelay = ReflectionsDelay; lReverb = Reverb; flReverbDelay = ReverbDelay; flDiffusion = Diffusion; flDensity = Density; flHFReference = HFReference; } public void Preset_Default() { lRoom = -1000; lRoomHF = 0; flRoomRolloffFactor = 0f; flDecayTime = 1.49f; flDecayHFRatio = 0.83f; lReflections = -2602; flReflectionsDelay = 0.007f; lReverb = 200; flReverbDelay = 0.011f; flDiffusion = 100f; flDensity = 100f; flHFReference = 5000f; } } [Serializable] [StructLayout(LayoutKind.Sequential)] public sealed class BASS_DX8_PARAMEQ { public float fCenter = 100f; public float fBandwidth = 18f; public float fGain; public BASS_DX8_PARAMEQ() { } public BASS_DX8_PARAMEQ(float Center, float Bandwidth, float Gain) { fCenter = Center; fBandwidth = Bandwidth; fGain = Gain; } public void Preset_Default() { fCenter = 100f; fBandwidth = 18f; fGain = 0f; } public void Preset_Low() { fCenter = 125f; fBandwidth = 18f; fGain = 0f; } public void Preset_Mid() { fCenter = 1000f; fBandwidth = 18f; fGain = 0f; } public void Preset_High() { fCenter = 8000f; fBandwidth = 18f; fGain = 0f; } } [Serializable] [StructLayout(LayoutKind.Sequential)] public sealed class BASS_DX8_REVERB { public float fInGain; public float fReverbMix; public float fReverbTime = 1000f; public float fHighFreq
Mods/AudioReplacer.dll
Decompiled a year agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using AudioImportLib; using AudioReplacer; using HarmonyLib; using MelonLoader; using MelonLoader.Preferences; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("AudioReplacer")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany(null)] [assembly: AssemblyProduct("AudioReplacer")] [assembly: AssemblyCopyright("Created by trev")] [assembly: AssemblyTrademark(null)] [assembly: ComVisible(false)] [assembly: AssemblyFileVersion("1.3.0")] [assembly: NeutralResourcesLanguage("en")] [assembly: MelonInfo(typeof(Core), "AudioReplacer", "1.3.0", "trev", null)] [assembly: MelonGame(null, null)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.3.0.0")] namespace AudioReplacer; public static class BuildInfo { public const string Name = "AudioReplacer"; public const string Author = "trev"; public const string Company = null; public const string Version = "1.3.0"; public const string DownloadLink = null; } public class Core : MelonMod { public static Dictionary<string, AudioClip> AudioClips = new Dictionary<string, AudioClip>(); public static bool LogSounds; private static bool overrideEnabled; private readonly string customAudioPath = Path.Combine(MelonUtils.UserDataDirectory, "CustomAudio"); private readonly string[] allowedExts = new string[2] { ".wav", ".mp3" }; public override void OnInitializeMelon() { //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Expected O, but got Unknown //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Expected O, but got Unknown if (!Directory.Exists(customAudioPath)) { Directory.CreateDirectory(customAudioPath); } MelonPreferences_Category val = MelonPreferences.CreateCategory("AudioReplacer", ""); val.CreateEntry<bool>("LogSounds", false, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); LogSounds = val.GetEntry<bool>("LogSounds").Value; MelonPreferences.Save(); string[] files = Directory.GetFiles(customAudioPath, "*", SearchOption.AllDirectories); string text = files.SingleOrDefault((string f) => Path.GetFileNameWithoutExtension(f) == "REPLACE_ALL"); if (text == null) { string[] array = files; foreach (string text2 in array) { if (allowedExts.Contains<string>(Path.GetExtension(text2))) { AudioClip val2 = API.LoadAudioClip(text2, true); AudioClips.Add(((Object)val2).name, val2); ((MelonBase)this).LoggerInstance.Msg("Added: " + ((Object)val2).name); } } } else { AudioClip val3 = API.LoadAudioClip(text, true); AudioClips.Add(((Object)val3).name, val3); overrideEnabled = true; ((MelonBase)this).LoggerInstance.Msg("Added override: " + ((Object)val3).name); } ((MelonBase)this).HarmonyInstance.Patch((MethodBase)AccessTools.Method(typeof(AudioSource), "Play", new Type[0], (Type[])null), new HarmonyMethod(typeof(Core).GetMethod("AudioPlayPatch")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ((MelonBase)this).HarmonyInstance.Patch((MethodBase)AccessTools.Method(typeof(AudioSource), "Play", new Type[1] { typeof(ulong) }, (Type[])null), new HarmonyMethod(typeof(Core).GetMethod("AudioPlayPatch")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } public static void AudioPlayPatch(AudioSource __instance) { if (!((Object)(object)__instance.clip == (Object)null)) { if (LogSounds) { MelonLogger.Msg("Playing \"" + ((Object)__instance.clip).name + "\" from object \"" + ((Object)((Component)__instance).gameObject).name + "\""); } string key = (overrideEnabled ? "REPLACE_ALL" : ((Object)__instance.clip).name); if (AudioClips.TryGetValue(key, out var value)) { __instance.pitch = 1f; __instance.clip = value; } } } }
Mods/Hitmarkers.dll
Decompiled a year agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using AudioImportLib; using BoneLib; using BoneLib.BoneMenu; using BoneLib.BoneMenu.Elements; using HarmonyLib; using Il2CppSystem; using MelonLoader; using MelonLoader.Preferences; using NEP.Hitmarkers; using NEP.Hitmarkers.Audio; using NEP.Hitmarkers.Data; using PuppetMasta; using SLZ.AI; using SLZ.Combat; using SLZ.Marrow.Utilities; using SLZ.Rig; using UnhollowerBaseLib; using UnityEngine; using UnityEngine.Events; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Simple hitmarkers mod for BONELAB.")] [assembly: AssemblyDescription("Simple hitmarkers mod for BONELAB.")] [assembly: AssemblyCompany("Not Enough Photons")] [assembly: AssemblyProduct("Hitmarkers")] [assembly: AssemblyCopyright("Created by Not Enough Photons")] [assembly: AssemblyTrademark("Not Enough Photons")] [assembly: AssemblyFileVersion("2.1.0")] [assembly: MelonInfo(typeof(Main), "Hitmarkers", "2.1.0", "Not Enough Photons", null)] [assembly: MelonColor] [assembly: MelonGame("Stress Level Zero", "BONELAB")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.1.0.0")] [module: UnverifiableCode] namespace NEP.Hitmarkers { public struct HitData { public Projectile projectile; public Vector3 worldHit; public Collider collider; public BehaviourBaseNav behaviour; public AIBrain brain; } public static class HitDirector { public static Action<HitData> OnHit; public static Action<PuppetMaster> OnKill; public static RigManager lastHitManager; public static void Initialize() { OnHit = (Action<HitData>)Delegate.Combine(OnHit, new Action<HitData>(OnProjectileHit)); PuppetMaster.OnDeathStatsEvent += Action<PuppetMaster>.op_Implicit((Action<PuppetMaster>)OnPuppetDeath); } public static bool EvaluateHit(HitData data) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) if (((Object)data.projectile._proxy.root).name != "[RigManager (Blank)]") { return false; } if ((int)data.projectile._proxy.triggerType != 0) { return true; } if ((Object)(object)data.brain != (Object)null && data.brain.isDead) { return false; } if (((Component)data.collider).gameObject.layer == LayerMask.NameToLayer("EnemyColliders")) { return true; } return false; } public static void OnProjectileHit(HitData data) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (EvaluateHit(data)) { HitmarkerManager.Instance.SpawnMarker(data.worldHit); } } public static void OnPuppetDeath(PuppetMaster puppet) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) Il2CppReferenceArray<BehaviourBase> behaviours = puppet.behaviours; object obj; if (behaviours == null) { obj = null; } else { BehaviourBase? obj2 = ((IEnumerable<BehaviourBase>)behaviours).FirstOrDefault(); obj = ((obj2 != null) ? ((Il2CppObjectBase)obj2).TryCast<BehaviourBaseNav>() : null); } BehaviourBaseNav val = (BehaviourBaseNav)obj; if (!((Object)(object)val == (Object)null)) { OnKill?.Invoke(puppet); HitmarkerManager.Instance.SpawnMarker(val.eyeTran.position, finisher: true); } } } [HarmonyPatch(typeof(Projectile))] [HarmonyPatch("Awake")] public static class ProjectilePatch { public static void Postfix(Projectile __instance) { ((UnityEvent<Collider, Vector3, Vector3>)(object)__instance.onCollision).AddListener(UnityAction<Collider, Vector3, Vector3>.op_Implicit((Action<Collider, Vector3, Vector3>)delegate(Collider hitCol, Vector3 world, Vector3 normal) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) HitData hitData = default(HitData); hitData.projectile = __instance; hitData.worldHit = world; hitData.collider = hitCol; hitData.brain = ((Component)hitCol).GetComponentInParent<AIBrain>(); HitData obj = hitData; HitDirector.OnHit?.Invoke(obj); })); } } [HarmonyPatch(typeof(PuppetMaster))] [HarmonyPatch("Awake")] public static class PuppetMasterPatch { public static void Postfix(PuppetMaster __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) StateSettings stateSettings = __instance.stateSettings; stateSettings.killDuration = 0f; __instance.stateSettings = stateSettings; } } [RegisterTypeInIl2Cpp] public class Hitmarker : MonoBehaviour { private bool _isFinisher; private AudioClip[] _hitAudio; private AudioClip[] _finisherAudio; private Animator _markerAnimator; private Animator _finisherAnimator; private GameObject _markerObject; private GameObject _finisherObject; private AudioSource _source; private float _timerHide; private float _timeUntilHide = 1f; public AudioClip[] HitAudio => _hitAudio; public AudioClip[] FinisherAudio => _finisherAudio; public bool IsFinisher { get { return _isFinisher; } set { _isFinisher = value; } } public Hitmarker(IntPtr ptr) : base(ptr) { } private void Awake() { _hitAudio = DataManager.HitClips; _finisherAudio = DataManager.FinisherClips; _markerObject = ((Component)((Component)this).transform.Find("Marker")).gameObject; _finisherObject = ((Component)((Component)this).transform.Find("Finisher")).gameObject; _markerAnimator = _markerObject.GetComponent<Animator>(); _finisherAnimator = _finisherObject.GetComponent<Animator>(); _source = ((Component)((Component)this).transform.Find("Source")).GetComponent<AudioSource>(); SetTextures(); _markerObject.SetActive(false); _finisherObject.SetActive(false); } private void OnEnable() { PlayAnimation(); PlayAudio(); } private void PlayAnimation() { if (_isFinisher) { _finisherObject.SetActive(true); _markerObject.SetActive(false); int num = Random.Range(1, 2); _finisherAnimator.Play($"finisher_appear_{num}"); } else { _finisherObject.SetActive(false); _markerObject.SetActive(true); int num2 = Random.Range(1, 2); _markerAnimator.Play($"marker_appear_{num2}"); } } private void Update() { if (((Component)this).gameObject.activeInHierarchy) { ((Component)this).transform.LookAt(Player.playerHead); _timerHide += Time.deltaTime; if (_timerHide > _timeUntilHide) { ((Component)this).gameObject.SetActive(false); _timerHide = 0f; } } } private void PlayAudio() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) AudioClip[] array = ((!_isFinisher) ? _hitAudio : _finisherAudio); HitmarkerAudio.PlayAtPoint(array[Random.Range(0, array.Length)], ((Component)this).transform.position); } private void SetTextures() { Material material = ((Renderer)_markerObject.GetComponent<MeshRenderer>()).material; Material material2 = ((Renderer)_finisherObject.GetComponent<MeshRenderer>()).material; Material material3 = ((Renderer)((Component)_finisherObject.transform.Find("DeathSkull")).GetComponent<MeshRenderer>()).material; material.mainTexture = (Texture)(object)DataManager.GetTexture("marker.png"); material2.mainTexture = (Texture)(object)DataManager.GetTexture("finisher_marker.png"); material3.mainTexture = (Texture)(object)DataManager.GetTexture("finisher_feedback.png"); } } [RegisterTypeInIl2Cpp] public class HitmarkerManager : MonoBehaviour { public static HitmarkerManager Instance; private List<Hitmarker> _hitmarkers; private List<Hitmarker> _finishers; private int _markerCount = 64; private Transform _poolHitmarker; private Transform _poolFinisher; public HitmarkerManager(IntPtr ptr) : base(ptr) { } private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } Object.DontDestroyOnLoad((Object)(object)Instance); BuildPools(); _hitmarkers = new List<Hitmarker>(); _finishers = new List<Hitmarker>(); for (int i = 0; i < _markerCount; i++) { _hitmarkers.Add(BuildHitmarker(isFinisher: false)); _finishers.Add(BuildHitmarker(isFinisher: true)); } } private void BuildPools() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) _poolHitmarker = new GameObject("Hitmarker Pool").transform; _poolFinisher = new GameObject("Finisher Pool").transform; ((Component)_poolHitmarker).transform.SetParent(((Component)this).transform); ((Component)_poolFinisher).transform.SetParent(((Component)this).transform); } private Hitmarker BuildHitmarker(bool isFinisher) { string name = ((!isFinisher) ? "Hitmarker" : "Finisher"); GameObject obj = Object.Instantiate<GameObject>(DataManager.GetGameObject("Hitmarker")); ((Object)obj).name = name; ((Object)obj).hideFlags = (HideFlags)32; obj.transform.parent = ((!isFinisher) ? _poolHitmarker : _poolFinisher); obj.gameObject.SetActive(false); return obj.AddComponent<Hitmarker>(); } private Hitmarker GetInactiveMarker(bool finisher) { List<Hitmarker> list = ((!finisher) ? _hitmarkers : _finishers); for (int i = 0; i < list.Count; i++) { if (!((Component)list[i]).gameObject.activeInHierarchy) { return list[i]; } } return null; } public void SpawnMarker(Vector3 position, bool finisher = false) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) if (Options.EnableHitmarkers) { Hitmarker inactiveMarker = GetInactiveMarker(finisher); inactiveMarker.IsFinisher = finisher; ((Component)inactiveMarker).transform.position = position; ((Component)inactiveMarker).gameObject.SetActive(true); float num = Vector3.Distance(((Component)inactiveMarker).transform.position, Player.playerHead.position); if (num < 5f) { ((Component)inactiveMarker).transform.localScale = Vector3.one; } else { ((Component)inactiveMarker).transform.localScale = Vector3.one * Mathf.Pow(2f, 1f + num / 50f); } } } } public static class BuildInfo { public const string Name = "Hitmarkers"; public const string Description = "Simple hitmarkers mod for BONELAB."; public const string Author = "Not Enough Photons"; public const string Company = "Not Enough Photons"; public const string Version = "2.1.0"; public const string DownloadLink = null; } public class Main : MelonMod { internal const string EmbeddedModule = "NEP.Hitmarkers.Resources.HitmarkersFusionModule.dll"; public override void OnInitializeMelon() { Assembly.Load(DataManager.Internal_LoadFromAssembly(Assembly.GetExecutingAssembly(), "NEP.Hitmarkers.Resources.HitmarkersFusionModule.dll")); Options.Init(); SetupBoneMenu(); DataManager.Initialize(); MarrowGame.RegisterOnReadyAction(Action.op_Implicit((Action)delegate { OnMarrowGameStart(); })); } public void OnMarrowGameStart() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) new GameObject("Hitmarker Manager").AddComponent<HitmarkerManager>(); new GameObject("Hitmarker Audio").AddComponent<HitmarkerAudio>(); HitDirector.Initialize(); } private void SetupBoneMenu() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) MenuCategory val = null; val = ((MenuManager.GetCategory("Not Enough Photons") == null) ? MenuManager.CreateCategory("Not Enough Photons", "#08104d") : MenuManager.GetCategory("Not Enough Photons")); MenuCategory obj = val.CreateCategory("Hitmarkers", Color.white); obj.CreateBoolElement("Enable Hitmarkers", Color.white, Options.EnableHitmarkers, (Action<bool>)delegate(bool value) { Options.SetEnableHitmarkers(value); }); obj.CreateFloatElement("Hitmarker SFX", Color.white, Options.HitmarkerSFX, 10f, 0f, 100f, (Action<float>)delegate(float value) { Options.SetHitmarkerSFX(value); }); obj.CreateFloatElement("Hitmarker Pitch", Color.white, Options.HitmarkerPitch, 0.25f, 0f, 2f, (Action<float>)delegate(float value) { Options.SetHitmarkerPitch(value); }); } } } namespace NEP.Hitmarkers.Data { public static class DataManager { private static readonly string path_UserData = MelonUtils.UserDataDirectory; private static readonly string path_Developer = path_UserData + "/Not Enough Photons"; private static readonly string path_Mod = path_Developer + "/Hitmarkers"; private static readonly string path_Resources = path_Mod + "/resources.pack"; private static readonly string path_Audio = path_Mod + "/Audio"; private static readonly string path_Textures = path_Mod + "/Textures"; private static AssetBundle _bundle; private static Object[] _bundleObjects; private static List<GameObject> _gameObjects; private static List<AnimationClip> _animations; private static List<AudioClip> _clipHitmarkers; private static List<AudioClip> _clipFinishers; private static List<Texture2D> _textures; public static AssetBundle Bundle => _bundle; public static Object[] BundleObjects => _bundleObjects; public static GameObject[] GameObjects => _gameObjects.ToArray(); public static AnimationClip[] Animations => _animations.ToArray(); public static Texture2D[] Textures => _textures.ToArray(); public static AudioClip[] HitClips => _clipHitmarkers.ToArray(); public static AudioClip[] FinisherClips => _clipFinishers.ToArray(); public static void Initialize() { GenerateFolders(); _gameObjects = new List<GameObject>(); _animations = new List<AnimationClip>(); _textures = new List<Texture2D>(); _clipHitmarkers = new List<AudioClip>(); _clipFinishers = new List<AudioClip>(); _bundle = GetEmbeddedBundle(); _bundleObjects = Il2CppArrayBase<Object>.op_Implicit((Il2CppArrayBase<Object>)(object)_bundle.LoadAllAssets()); GetGameObjects(); GetAnimations(); GetAudio(); GetTextures(); } public static GameObject GetGameObject(string name) { return _gameObjects.Find((GameObject match) => ((Object)match).name == name); } public static Texture2D GetTexture(string name) { return _textures.Find((Texture2D match) => ((Object)match).name == name); } private static void GenerateFolders() { Directory.CreateDirectory(path_Mod); Directory.CreateDirectory(path_Textures); Directory.CreateDirectory(path_Audio); } private static void GetGameObjects() { Object[] bundleObjects = _bundleObjects; for (int i = 0; i < bundleObjects.Length; i++) { GameObject val = ((Il2CppObjectBase)bundleObjects[i]).TryCast<GameObject>(); if ((Object)(object)val != (Object)null) { ((Object)val).hideFlags = (HideFlags)32; _gameObjects.Add(val); } } } private static void GetAnimations() { Object[] bundleObjects = _bundleObjects; for (int i = 0; i < bundleObjects.Length; i++) { AnimationClip val = ((Il2CppObjectBase)bundleObjects[i]).TryCast<AnimationClip>(); if ((Object)(object)val != (Object)null) { ((Object)val).hideFlags = (HideFlags)32; _animations.Add(val); } } } private static void GetAudio() { string[] files = Directory.GetFiles(path_Audio); foreach (string text in files) { string text2 = text.Substring(path_Audio.Length + 1); Melon<Main>.Logger.Msg("Loading Clip " + text2 + "..."); if (text2.StartsWith("marker_")) { _clipHitmarkers.Add(API.LoadAudioClip(text, true)); } else if (text2.StartsWith("finisher_")) { _clipFinishers.Add(API.LoadAudioClip(text, true)); } Melon<Main>.Logger.Msg("Successfully Loaded " + text2 + "!"); } } private static void GetTextures() { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown string[] files = Directory.GetFiles(path_Textures); foreach (string text in files) { string text2 = text.Substring(path_Textures.Length + 1); Melon<Main>.Logger.Msg("Loading Texture " + text2 + "..."); Texture2D val = new Texture2D(2, 2); if (!File.Exists(text)) { Melon<Main>.Logger.Warning("Couldn't load " + text2 + "! Going to use a white square instead."); } else { byte[] array = File.ReadAllBytes(text); ImageConversion.LoadImage(val, Il2CppStructArray<byte>.op_Implicit(array)); } ((Object)val).hideFlags = (HideFlags)32; ((Object)val).name = text2; Melon<Main>.Logger.Msg("Successfully loaded " + ((Object)val).name + "!"); _textures.Add(val); } } internal static AssetBundle GetEmbeddedBundle() { Assembly executingAssembly = Assembly.GetExecutingAssembly(); string text = (HelperMethods.IsAndroid() ? "resources_quest.pack" : "resources_pcvr.pack"); using Stream stream = executingAssembly.GetManifestResourceStream("NEP.Hitmarkers.Resources." + text); using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); return AssetBundle.LoadFromMemory(Il2CppStructArray<byte>.op_Implicit(memoryStream.ToArray())); } internal static byte[] Internal_LoadFromAssembly(Assembly assembly, string name) { if (assembly.GetManifestResourceNames().Contains(name)) { using (Stream stream = assembly.GetManifestResourceStream(name)) { using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); return memoryStream.ToArray(); } } return null; } } public static class Options { private static MelonPreferences_Category category = MelonPreferences.CreateCategory("Hitmarkers"); private static MelonPreferences_Entry<bool> enableHitmarkers_Entry; private static MelonPreferences_Entry<float> hitmarkerVolume_Entry; private static MelonPreferences_Entry<float> hitmarkerPitch_Entry; public static bool EnableHitmarkers { get; private set; } public static float HitmarkerSFX { get; private set; } public static float HitmarkerPitch { get; private set; } public static void Init() { if (category.GetEntry("Enable Hitmarkers") != null) { enableHitmarkers_Entry = category.GetEntry<bool>("Enable Hitmarkers"); EnableHitmarkers = enableHitmarkers_Entry.Value; } else { EnableHitmarkers = true; enableHitmarkers_Entry = category.CreateEntry<bool>("Enable Hitmarkers", EnableHitmarkers, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); } if (category.GetEntry("Hitmarker Volume") != null) { hitmarkerVolume_Entry = category.GetEntry<float>("Hitmarker Volume"); HitmarkerSFX = hitmarkerVolume_Entry.Value; } else { HitmarkerSFX = 100f; hitmarkerVolume_Entry = category.CreateEntry<float>("Hitmarker Volume", HitmarkerSFX, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); } if (category.GetEntry("Hitmarker Pitch") != null) { hitmarkerPitch_Entry = category.GetEntry<float>("Hitmarker Pitch"); HitmarkerPitch = hitmarkerPitch_Entry.Value; } else { HitmarkerPitch = 1f; hitmarkerPitch_Entry = category.CreateEntry<float>("Hitmarker Pitch", HitmarkerPitch, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); } } public static void SetEnableHitmarkers(bool value) { EnableHitmarkers = value; enableHitmarkers_Entry.Value = EnableHitmarkers; } public static void SetHitmarkerSFX(float volume) { HitmarkerSFX = volume; hitmarkerVolume_Entry.Value = HitmarkerSFX; } public static void SetHitmarkerPitch(float pitch) { HitmarkerPitch = pitch; hitmarkerPitch_Entry.Value = HitmarkerPitch; } } } namespace NEP.Hitmarkers.Audio { [RegisterTypeInIl2Cpp] public class HitmarkerAudio : MonoBehaviour { public static HitmarkerAudio Instance; public static AudioClip[] HitAudio; public static AudioClip[] FinisherAudio; private static List<GameObject> pooledAudioObjects; public HitmarkerAudio(IntPtr ptr) : base(ptr) { } private void Awake() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown if ((Object)(object)Instance == (Object)null) { Instance = this; } Object.DontDestroyOnLoad((Object)(object)Instance); pooledAudioObjects = new List<GameObject>(); GameObject val = new GameObject("Pooled Audio List"); val.transform.parent = ((Component)this).transform; for (int i = 0; i < 64; i++) { GameObject val2 = new GameObject("Poolee Audio"); val2.transform.parent = val.transform; AudioSource obj = val2.AddComponent<AudioSource>(); obj.playOnAwake = true; obj.volume = 5f; val2.AddComponent<PooledAudio>(); val2.SetActive(false); pooledAudioObjects.Add(val2); } HitAudio = DataManager.HitClips; FinisherAudio = DataManager.FinisherClips; } public static void PlayAtPoint(AudioClip clip, Vector3 position) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) GameObject val = ((IEnumerable<GameObject>)pooledAudioObjects).FirstOrDefault((Func<GameObject, bool>)((GameObject inactive) => !inactive.activeInHierarchy)); AudioSource component = val.GetComponent<AudioSource>(); if ((Object)(object)val != (Object)null) { component.volume = Options.HitmarkerSFX / 100f; component.pitch = Options.HitmarkerPitch; component.clip = clip; val.transform.position = position; val.SetActive(true); } } } [RegisterTypeInIl2Cpp] public class PooledAudio : MonoBehaviour { private AudioSource source; private float time; public PooledAudio(IntPtr ptr) : base(ptr) { } private void Start() { source = ((Component)this).GetComponent<AudioSource>(); } private void Update() { time += Time.deltaTime; if (time >= source.clip.length) { ((Component)this).gameObject.SetActive(false); time = 0f; } } } }
Mods/Quicksilver.dll
Decompiled a year agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BoneLib; using BoneLib.BoneMenu; using BoneLib.BoneMenu.Elements; using HarmonyLib; using Il2CppSystem; using MelonLoader; using MelonLoader.Preferences; using Quicksilver; using SLZ.Interaction; using SLZ.Marrow.Warehouse; using SLZ.Props.Weapons; using SLZ.Rig; using SLZ.SFX; using SLZ.VRMK; using UnhollowerBaseLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Quicksilver")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Quicksilver")] [assembly: AssemblyCopyright("Copyright © 2022")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("945622a5-4786-4c52-87f3-624bc6542a09")] [assembly: AssemblyFileVersion("1.6.0")] [assembly: MelonInfo(typeof(QuicksilverMod), "Quicksilver", "1.6.0", "Lakatrazz", null)] [assembly: MelonGame("Stress Level Zero", "BONELAB")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.6.0.0")] [module: UnverifiableCode] namespace Quicksilver { public class QuicksilverMod : MelonMod { public struct RigidbodyState { public float drag; public float angularDrag; public RigidbodyState(Rigidbody rb) { drag = rb.drag; angularDrag = rb.angularDrag; } } public const string Version = "1.6.0"; private static bool _previousIsEnabled; public RigManager rigManager; public float lastTimeScale; public float lastCheckedTimeScale; public float timeOfLastAvatarUpdate; public bool checkForUpdate; public Dictionary<Rigidbody, RigidbodyState> rigidbodies = new Dictionary<Rigidbody, RigidbodyState>(); private static bool _registeredPrefs = false; public static QuicksilverMod Instance { get; private set; } public static bool IsEnabled { get; private set; } public static float TargetTimeScale { get; private set; } = 1f; public static MelonPreferences_Category MelonPrefCategory { get; private set; } public static MelonPreferences_Entry<bool> MelonPrefEnabled { get; private set; } public static MenuCategory BoneMenuCategory { get; private set; } public static BoolElement BoneMenuEnabledElement { get; private set; } public override void OnInitializeMelon() { Instance = this; Hooking.OnLevelInitialized += OnLevelInitialized; SetupMelonPrefs(); SetupBoneMenu(); } public static void SetupMelonPrefs() { MelonPrefCategory = MelonPreferences.CreateCategory("Quicksilver"); MelonPrefEnabled = MelonPrefCategory.CreateEntry<bool>("IsEnabled", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); IsEnabled = MelonPrefEnabled.Value; _previousIsEnabled = IsEnabled; _registeredPrefs = true; } public static void SetupBoneMenu() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) BoneMenuCategory = MenuManager.CreateCategory("Quicksilver", new Color(0.75f, 0.75f, 0.75f)); BoneMenuEnabledElement = BoneMenuCategory.CreateBoolElement("Mod Toggle", Color.yellow, IsEnabled, (Action<bool>)OnSetEnabled); } public static void OnSetEnabled(bool value) { IsEnabled = value; MelonPrefEnabled.Value = value; MelonPrefCategory.SaveToFile(false); } public override void OnPreferencesLoaded() { if (_registeredPrefs) { IsEnabled = MelonPrefEnabled.Value; ((GenericElement<bool>)(object)BoneMenuEnabledElement).SetValue(IsEnabled); } } public void OnLevelInitialized(LevelInfo info) { rigManager = Player.rigManager; TargetTimeScale = Time.timeScale; lastTimeScale = Time.timeScale; lastCheckedTimeScale = lastTimeScale; rigidbodies.Clear(); foreach (Rigidbody componentsInChild in ((Component)rigManager).GetComponentsInChildren<Rigidbody>(true)) { rigidbodies.Add(componentsInChild, new RigidbodyState(componentsInChild)); } } public void ResetPlayer() { if (rigManager.physicsRig.torso.spineInternalMult > 0f) { rigManager.physicsRig.torso.spineInternalMult = 1f; } rigManager.SwapAvatarCrate(Barcode.op_Implicit(((CrateReference)rigManager.AvatarCrate).Barcode), false, (Action<bool>)null); rigManager.bodyVitals.ApplyControlInputSettings((ControllerRig)(object)rigManager.openControllerRig); OnUpdateAnimationRig(1f); OnUpdateRigidbodies(1f); } public bool HasRigManager() { if (rigManager != null && !((Object)(object)rigManager == (Object)null)) { return !((Il2CppObjectBase)rigManager).WasCollected; } return false; } public override void OnFixedUpdate() { //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) float timeScale = Time.timeScale; if (!(timeScale > 0f) || !HasRigManager() || !(rigManager.physicsRig.torso.spineInternalMult > 0f)) { return; } if (IsEnabled) { if (Mathf.Round(timeScale * 1000f) != Mathf.Round(lastCheckedTimeScale * 1000f)) { OnUpdateVelocities(timeScale, lastCheckedTimeScale); timeOfLastAvatarUpdate = Time.realtimeSinceStartup; checkForUpdate = true; lastCheckedTimeScale = timeScale; } if (!_previousIsEnabled || (checkForUpdate && Time.realtimeSinceStartup - timeOfLastAvatarUpdate > 0.015f)) { checkForUpdate = false; rigManager.SwapAvatarCrate(Barcode.op_Implicit(((CrateReference)rigManager.AvatarCrate).Barcode), false, (Action<bool>)null); rigManager.bodyVitals.ApplyControlInputSettings((ControllerRig)(object)rigManager.openControllerRig); OnUpdateAnimationRig(timeScale); OnUpdateRigidbodies(timeScale); lastTimeScale = timeScale; TargetTimeScale = timeScale; } float num = rigManager.avatar.massTotal * 0.35f; float num2 = 1f / Mathf.Pow(timeScale, 0.2f); Vector3 val = Physics.gravity * num; Vector3 val2 = val * num2 - val; Rigidbody feetRb = rigManager.physicsRig._feetRb; Rigidbody kneeRb = rigManager.physicsRig._kneeRb; Vector3 val3 = val2; float num3 = 0f; if (feetRb.useGravity) { feetRb.AddForce(val2, (ForceMode)5); num3 += feetRb.mass; } if (kneeRb.useGravity) { kneeRb.AddForce(val2, (ForceMode)5); num3 += kneeRb.mass; } Collider groundedCollider = rigManager.physicsRig.physG._groundedCollider; if (Object.op_Implicit((Object)(object)groundedCollider) && Object.op_Implicit((Object)(object)groundedCollider.attachedRigidbody)) { groundedCollider.attachedRigidbody.AddForceAtPosition(-val3 * Mathf.Min(groundedCollider.attachedRigidbody.mass, num3), feetRb.worldCenterOfMass, (ForceMode)0); } if (rigManager.physicsRig.torso.spineInternalMult > 0f) { rigManager.physicsRig.torso.spineInternalMult = 1f / Mathf.Pow(timeScale, 3f); } } else if (_previousIsEnabled) { ResetPlayer(); } _previousIsEnabled = IsEnabled; } public void OnUpdateAnimationRig(float timeScale) { if (!(timeScale <= 0f)) { SLZ_Body body = rigManager.animationRig.body; body.spine.accelLeanWeight = 0.35f * timeScale; body.spine.dragWeight = 0.35f * timeScale; body.spine.pACdProduct = 0.35f * timeScale; } } public void OnUpdateVelocities(float timeScale, float lastTimeScale) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) if (timeScale <= 0f || lastTimeScale <= 0f) { return; } float num = lastTimeScale / timeScale; for (int i = 0; i < rigidbodies.Keys.Count; i++) { Rigidbody val = rigidbodies.Keys.ElementAt(i); if (val != null && !((Object)(object)val == (Object)null) && !((Il2CppObjectBase)val).WasCollected) { val.velocity *= num; val.angularVelocity *= num; } } } public void OnUpdateRigidbodies(float timeScale) { if (timeScale <= 0f) { return; } for (int i = 0; i < rigidbodies.Keys.Count; i++) { Rigidbody val = rigidbodies.Keys.ElementAt(i); if (val != null && !((Object)(object)val == (Object)null) && !((Il2CppObjectBase)val).WasCollected) { RigidbodyState rigidbodyState = rigidbodies[val]; val.drag = rigidbodyState.drag * timeScale; val.angularDrag = rigidbodyState.angularDrag * timeScale; } } } public static bool IsMainRig(Avatar avatar) { bool result = false; try { if ((Object)(object)Instance.rigManager.avatar == (Object)(object)avatar) { result = true; } } catch { } return result; } public static bool IsMainRig(Rig rig) { bool result = false; try { if ((Object)(object)rig.manager == (Object)(object)Instance.rigManager) { result = true; } } catch { } return result; } } } namespace Quicksilver.Patching { [HarmonyPatch(typeof(ArtRig))] public static class ArtRigPatches { [HarmonyPrefix] [HarmonyPatch("OnUpdate")] public static void OnUpdatePrefix(ArtRig __instance) { if (QuicksilverMod.IsEnabled && QuicksilverMod.TargetTimeScale > 0f && QuicksilverMod.IsMainRig((Rig)(object)__instance)) { TimePatches.ReturnScaled = true; } } [HarmonyPostfix] [HarmonyPatch("OnUpdate")] public static void OnUpdatePostfix() { TimePatches.ReturnScaled = false; } } [HarmonyPatch(typeof(OpenController))] public static class OpenControllerPatches { [HarmonyPostfix] [HarmonyPatch("GetThumbStickAxis")] public static void GetThumbStickAxis(OpenController __instance, ref Vector2 __result) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Invalid comparison between Unknown and I4 //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Invalid comparison between Unknown and I4 if (!QuicksilverMod.IsEnabled || !(QuicksilverMod.TargetTimeScale > 0f) || !QuicksilverMod.IsMainRig((Rig)(object)((BaseController)__instance).manager)) { return; } float num = 1f / QuicksilverMod.TargetTimeScale; if (((BaseController)__instance).manager.isRightHanded) { if ((int)((BaseController)__instance).handedness != 2) { __result.x *= num; } } else if ((int)((BaseController)__instance).handedness != 1) { __result.x *= num; } __result.y *= num; } } [HarmonyPatch(typeof(RemapRig))] public static class RemapRigPatches { private const float CrouchPow = 0.01f; private const float JumpPow = 0.5f; private const float RotationPow = 0.4f; [HarmonyPrefix] [HarmonyPatch("ApplyRotation")] public static void ApplyRotation(RemapRig __instance, ref float deltaTime, float smoothTwist) { if (QuicksilverMod.IsEnabled && QuicksilverMod.TargetTimeScale > 0f && QuicksilverMod.IsMainRig((Rig)(object)__instance)) { deltaTime /= Mathf.Pow(QuicksilverMod.TargetTimeScale, 0.4f); } } [HarmonyPrefix] [HarmonyPatch("JumpCharge")] public static void JumpCharge(RemapRig __instance, ref float deltaTime, bool chargeInput = true) { if (QuicksilverMod.IsEnabled && QuicksilverMod.TargetTimeScale > 0f && QuicksilverMod.IsMainRig((Rig)(object)__instance)) { deltaTime /= Mathf.Pow(QuicksilverMod.TargetTimeScale, 0.5f); } } [HarmonyPrefix] [HarmonyPatch("Jumping")] public static void Jumping(RemapRig __instance, ref float deltaTime) { if (QuicksilverMod.IsEnabled && QuicksilverMod.TargetTimeScale > 0f && QuicksilverMod.IsMainRig((Rig)(object)__instance)) { deltaTime /= Mathf.Pow(QuicksilverMod.TargetTimeScale, 0.5f); } } [HarmonyPrefix] [HarmonyPatch("CrouchHold")] public static void CrouchHold(RemapRig __instance, ref float deltaTime, float crouchRate = -1f, bool crouchInput = true) { if (QuicksilverMod.IsEnabled && QuicksilverMod.TargetTimeScale > 0f && QuicksilverMod.IsMainRig((Rig)(object)__instance)) { deltaTime /= Mathf.Pow(QuicksilverMod.TargetTimeScale, 0.01f); } } [HarmonyPrefix] [HarmonyPatch("MoveSpineCrouchOffTowards")] public static void MoveSpineCrouchOffTowards(RemapRig __instance, float target, ref float deltaTime, float rate = 6.5f) { if (QuicksilverMod.IsEnabled && QuicksilverMod.TargetTimeScale > 0f && QuicksilverMod.IsMainRig((Rig)(object)__instance)) { deltaTime /= Mathf.Pow(QuicksilverMod.TargetTimeScale, 0.01f); } } [HarmonyPrefix] [HarmonyPatch("ApplyMovement")] public static void ApplyMovementPrefix(RemapRig __instance, Vector2 axis, bool inputPressed, ref float deltaTime) { if (QuicksilverMod.IsEnabled && QuicksilverMod.TargetTimeScale > 0f && QuicksilverMod.IsMainRig((Rig)(object)__instance)) { deltaTime /= Mathf.Lerp(1f, QuicksilverMod.TargetTimeScale, 0.95f); TimePatches.ForceDefaultTimescale = true; } } [HarmonyPostfix] [HarmonyPatch("ApplyMovement")] public static void ApplyMovementPostfix(Vector2 axis, bool inputPressed, float deltaTime) { TimePatches.ForceDefaultTimescale = false; } } [HarmonyPatch(typeof(ControllerRig))] public static class ControllerRigPatches { private const float RotationPow = 0.4f; [HarmonyPrefix] [HarmonyPatch("OnFixedUpdate")] public static void OnFixedUpdatePrefix(ControllerRig __instance, float deltaTime, out float __state) { __state = __instance.degreesPerSnap; if (QuicksilverMod.IsEnabled && QuicksilverMod.TargetTimeScale > 0f && QuicksilverMod.IsMainRig((Rig)(object)__instance)) { __instance.degreesPerSnap /= Mathf.Pow(QuicksilverMod.TargetTimeScale, 0.4f); TimePatches.ReturnScaled = true; } } [HarmonyPostfix] [HarmonyPatch("OnFixedUpdate")] public static void OnFixedUpdatePostfix(ControllerRig __instance, float deltaTime, float __state) { __instance.degreesPerSnap = __state; TimePatches.ReturnScaled = false; } } [HarmonyPatch(typeof(PhysicsRig))] public static class PhysicsRigPatches { [HarmonyPrefix] [HarmonyPatch("UpdateKnee")] public static void UpdateKneePrefix(PhysicsRig __instance, float feetTar, out float __state) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) __state = ((Rig)__instance).manager.avatar._massTotal; if (QuicksilverMod.IsEnabled && QuicksilverMod.TargetTimeScale > 0f && QuicksilverMod.IsMainRig((Rig)(object)__instance)) { JointDrive yDrive = __instance.kneePelvisJoint.yDrive; float num = 1f / QuicksilverMod.TargetTimeScale; ((JointDrive)(ref yDrive)).positionSpring = 7500f * num; ((JointDrive)(ref yDrive)).positionDamper = 1200f * num; ((JointDrive)(ref yDrive)).maximumForce = 6750f * num; __instance.kneePelvisJoint.yDrive = yDrive; Avatar avatar = ((Rig)__instance).manager.avatar; avatar._massTotal *= num; } } [HarmonyPostfix] [HarmonyPatch("UpdateKnee")] public static void UpdateKneePostfix(PhysicsRig __instance, float feetTar, float __state) { ((Rig)__instance).manager.avatar._massTotal = __state; } } [HarmonyPatch(typeof(AlignPlug))] public static class AlignPlugPatches { [HarmonyPrefix] [HarmonyPatch("Update")] public static void UpdatePrefix() { if (QuicksilverMod.IsEnabled && QuicksilverMod.TargetTimeScale > 0f) { TimePatches.ReturnScaled = true; } } [HarmonyPostfix] [HarmonyPatch("Update")] public static void UpdatePostfix() { TimePatches.ReturnScaled = false; } } [HarmonyPatch(typeof(Gun))] public static class GunPatches { [HarmonyPrefix] [HarmonyPatch("Update")] public static void UpdatePrefix(Gun __instance) { if (QuicksilverMod.TargetTimeScale > 0f && Object.op_Implicit((Object)(object)__instance.triggerGrip) && Object.op_Implicit((Object)(object)__instance.triggerGrip.GetHand()) && (Object)(object)__instance.triggerGrip.GetHand().manager == (Object)(object)QuicksilverMod.Instance.rigManager) { if (QuicksilverMod.IsEnabled) { __instance.fireDuration = 60f / __instance.roundsPerMinute * QuicksilverMod.TargetTimeScale; } else { __instance.fireDuration = 60f / __instance.roundsPerMinute; } } TimePatches.ReturnScaled = true; } [HarmonyPostfix] [HarmonyPatch("Update")] public static void UpdatePostfix() { TimePatches.ReturnScaled = false; } } [HarmonyPatch(typeof(HandJointConfiguration))] public static class HandJointConfigurationPatches { [HarmonyPostfix] [HarmonyPatch("LockConfiguration")] public static void LockConfiguration(ConfigurableJoint joint) { float targetTimeScale = QuicksilverMod.TargetTimeScale; if (QuicksilverMod.IsEnabled && targetTimeScale > 0f) { float num = targetTimeScale * targetTimeScale; ((Joint)joint).breakForce = ((Joint)joint).breakForce / num; ((Joint)joint).breakTorque = ((Joint)joint).breakTorque / num; } } [HarmonyPostfix] [HarmonyPatch("ApplyConfiguration", new Type[] { typeof(ConfigurableJoint) })] public static void ApplyConfiguration(ConfigurableJoint joint) { if (QuicksilverMod.IsEnabled && QuicksilverMod.TargetTimeScale > 0f) { ((Joint)joint).breakForce = ((Joint)joint).breakForce / (QuicksilverMod.TargetTimeScale * QuicksilverMod.TargetTimeScale); ((Joint)joint).breakTorque = ((Joint)joint).breakTorque / (QuicksilverMod.TargetTimeScale * QuicksilverMod.TargetTimeScale); } } [HarmonyPostfix] [HarmonyPatch("ApplyConfiguration", new Type[] { typeof(Quaternion), typeof(ConfigurableJoint) })] public static void ApplyConfiguration(Quaternion localRotation, ConfigurableJoint joint) { if (QuicksilverMod.IsEnabled && QuicksilverMod.TargetTimeScale > 0f) { ((Joint)joint).breakForce = ((Joint)joint).breakForce / (QuicksilverMod.TargetTimeScale * QuicksilverMod.TargetTimeScale); ((Joint)joint).breakTorque = ((Joint)joint).breakTorque / (QuicksilverMod.TargetTimeScale * QuicksilverMod.TargetTimeScale); } } } [HarmonyPatch(typeof(Footstep))] public static class FootstepPatches { [HarmonyPrefix] [HarmonyPatch("UpdateStepping")] public static void UpdateStepping(Vector3 p, Vector3 comVelGrndVector, Vector3 accel, float angularVel, Quaternion rootRotation, ref float stepSpeedUpdate, float stepLZ, Vector3 rootUp, float deltaTime) { if (QuicksilverMod.IsEnabled && QuicksilverMod.TargetTimeScale > 0f) { stepSpeedUpdate /= Mathf.Lerp(1f, QuicksilverMod.TargetTimeScale, 0.95f); } } } [HarmonyPatch(typeof(ForcePullGrip), "OnFarHandHoverUpdate")] public static class ForcePullPatches { public static void Prefix(ForcePullGrip __instance, Hand hand) { if (QuicksilverMod.IsEnabled && QuicksilverMod.TargetTimeScale > 0f) { __instance.maxForce = 250f / QuicksilverMod.TargetTimeScale; } } } [HarmonyPatch(typeof(RealtimeSkeletonRig))] public static class RealtimeSkeletonRigPatches { [HarmonyPrefix] [HarmonyPatch("UpdateHeptaBody")] public static void UpdateHeptaBody(RealtimeSkeletonRig __instance, ControllerRig inRig, ref float deltaTime) { if (QuicksilverMod.IsEnabled && QuicksilverMod.TargetTimeScale > 0f && QuicksilverMod.IsMainRig((Rig)(object)__instance)) { deltaTime /= QuicksilverMod.TargetTimeScale; } } [HarmonyPrefix] [HarmonyPatch("OnFixedUpdate")] public static void OnFixedUpdate(RealtimeSkeletonRig __instance, ref float deltaTime) { if (QuicksilverMod.IsEnabled && QuicksilverMod.TargetTimeScale > 0f && QuicksilverMod.IsMainRig((Rig)(object)__instance)) { deltaTime /= QuicksilverMod.TargetTimeScale; } } } [HarmonyPatch(typeof(GameWorldSkeletonRig))] public static class GameworldRigPatches { [HarmonyPrefix] [HarmonyPatch("OnFixedUpdate")] public static void OnFixedUpdatePrefix(GameWorldSkeletonRig __instance, float deltaTime) { if (QuicksilverMod.IsEnabled && QuicksilverMod.TargetTimeScale > 0f && QuicksilverMod.IsMainRig((Rig)(object)__instance)) { TimePatches.ReturnScaled = true; } } [HarmonyPostfix] [HarmonyPatch("OnFixedUpdate")] public static void OnFixedUpdatePostfix(float deltaTime) { TimePatches.ReturnScaled = false; } [HarmonyPrefix] [HarmonyPatch("UpdateHeptaBody2")] public static void UpdateHeptaBody2(GameWorldSkeletonRig __instance, Rig inRig, ref float deltaTime, ref Vector2 velocity, ref Vector2 accel) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) if (QuicksilverMod.IsEnabled) { float targetTimeScale = QuicksilverMod.TargetTimeScale; if (targetTimeScale > 0f && QuicksilverMod.IsMainRig((Rig)(object)__instance)) { float num = targetTimeScale * targetTimeScale; float num2 = num * num; deltaTime /= num; velocity *= num2; accel *= num2 * num2; } } } } [HarmonyPatch(typeof(Avatar))] public static class AvatarPatches { [HarmonyPostfix] [HarmonyPatch("ComputeMass")] public static void ComputeMass(Avatar __instance, float normalizeTo82) { if (!(QuicksilverMod.TargetTimeScale <= 0f) && QuicksilverMod.IsMainRig(__instance) && QuicksilverMod.IsEnabled) { float num = 1f / QuicksilverMod.TargetTimeScale; float num2 = 1f / Mathf.Lerp(1f, QuicksilverMod.TargetTimeScale, 0.9f); __instance._massChest *= num; __instance._massHead *= num; __instance._massPelvis *= num; __instance._massArm *= num; __instance._massLeg *= num; __instance._massTotal *= num2; } } [HarmonyPostfix] [HarmonyPatch("ComputeBaseStats")] public static void ComputeBaseStats(Avatar __instance) { if (!(QuicksilverMod.TargetTimeScale <= 0f) && QuicksilverMod.IsMainRig(__instance) && QuicksilverMod.IsEnabled) { float num = 1f / QuicksilverMod.TargetTimeScale; float num2 = num * num; __instance._strengthUpper *= num2; __instance._strengthLower *= num2 * num2; __instance._strengthGrip *= num; __instance._speed *= num; __instance._agility *= num2; } } } [HarmonyPatch(typeof(FootstepSFX))] public static class FootstepSFXPatches { [HarmonyPrefix] [HarmonyPatch("PlayStep")] public static void PlayStepPrefix(float velocitySqr) { TimePatches.ForceDefaultTimescale = true; } [HarmonyPostfix] [HarmonyPatch("PlayStep")] public static void PlayStepPostfix(float velocitySqr) { TimePatches.ForceDefaultTimescale = false; } } [HarmonyPatch(typeof(HeadSFX))] public static class HeadSFXPatches { [HarmonyPrefix] [HarmonyPatch("SmallDamageVocal")] public static void SmallDamageVocalPrefix(float damage) { TimePatches.ForceDefaultTimescale = true; } [HarmonyPostfix] [HarmonyPatch("SmallDamageVocal")] public static void SmallDamageVocalPostfix(float damage) { TimePatches.ForceDefaultTimescale = false; } [HarmonyPrefix] [HarmonyPatch("BigDamageVocal")] public static void BigDamageVocalPrefix() { TimePatches.ForceDefaultTimescale = true; } [HarmonyPostfix] [HarmonyPatch("BigDamageVocal")] public static void BigDamageVocalPostfix() { TimePatches.ForceDefaultTimescale = false; } [HarmonyPrefix] [HarmonyPatch("DyingVocal")] public static void DyingVocalPrefix() { TimePatches.ForceDefaultTimescale = true; } [HarmonyPostfix] [HarmonyPatch("DyingVocal")] public static void DyingVocalPostfix() { TimePatches.ForceDefaultTimescale = false; } [HarmonyPrefix] [HarmonyPatch("DeathVocal")] public static void DeathVocalPrefix() { TimePatches.ForceDefaultTimescale = true; } [HarmonyPostfix] [HarmonyPatch("DeathVocal")] public static void DeathVocalPostfix() { TimePatches.ForceDefaultTimescale = false; } [HarmonyPrefix] [HarmonyPatch("RecoveryVocal")] public static void RecoveryVocalPrefix() { TimePatches.ForceDefaultTimescale = true; } [HarmonyPostfix] [HarmonyPatch("RecoveryVocal")] public static void RecoveryVocalPostfix() { TimePatches.ForceDefaultTimescale = false; } [HarmonyPrefix] [HarmonyPatch("JumpEffort")] public static void JumpEffortPrefix() { TimePatches.ForceDefaultTimescale = true; } [HarmonyPostfix] [HarmonyPatch("JumpEffort")] public static void JumpEffortPostfix() { TimePatches.ForceDefaultTimescale = false; } [HarmonyPrefix] [HarmonyPatch("DoubleJump")] public static void DoubleJumpPrefix() { TimePatches.ForceDefaultTimescale = true; } [HarmonyPostfix] [HarmonyPatch("DoubleJump")] public static void DoubleJumpPostfix() { TimePatches.ForceDefaultTimescale = false; } [HarmonyPrefix] [HarmonyPatch("OnCollisionEnter")] public static void OnCollisionEnterPrefix(Collision c) { TimePatches.ForceDefaultTimescale = true; } [HarmonyPostfix] [HarmonyPatch("OnCollisionEnter")] public static void OnCollisionEnterPostfix(Collision c) { TimePatches.ForceDefaultTimescale = false; } } [HarmonyPatch(typeof(HandSFX))] public static class HandSFXPatches { [HarmonyPrefix] [HarmonyPatch("Grab")] public static void GrabPrefix() { TimePatches.ForceDefaultTimescale = true; } [HarmonyPostfix] [HarmonyPatch("Grab")] public static void GrabPostfix() { TimePatches.ForceDefaultTimescale = false; } [HarmonyPrefix] [HarmonyPatch("BodySlot")] public static void BodySlotPrefix() { TimePatches.ForceDefaultTimescale = true; } [HarmonyPostfix] [HarmonyPatch("BodySlot")] public static void BodySlotPostfix() { TimePatches.ForceDefaultTimescale = false; } [HarmonyPrefix] [HarmonyPatch("Drop")] public static void DropPrefix() { TimePatches.ForceDefaultTimescale = true; } [HarmonyPostfix] [HarmonyPatch("Drop")] public static void DropPostfix() { TimePatches.ForceDefaultTimescale = false; } [HarmonyPrefix] [HarmonyPatch("ForcePull")] public static void ForcePullPrefix(float massDistance) { TimePatches.ForceDefaultTimescale = true; } [HarmonyPostfix] [HarmonyPatch("ForcePull")] public static void ForcePullPostfix(float massDistance) { TimePatches.ForceDefaultTimescale = false; } [HarmonyPrefix] [HarmonyPatch("OnCollisionEnter")] public static void OnCollisionEnterPrefix(Collision c) { TimePatches.ForceDefaultTimescale = true; } [HarmonyPostfix] [HarmonyPatch("OnCollisionEnter")] public static void OnCollisionEnterPostfix(Collision c) { TimePatches.ForceDefaultTimescale = false; } } [HarmonyPatch(typeof(Rigidbody))] public static class RigidbodyPatches { [HarmonyPrefix] [HarmonyPatch("AddForceAtPosition", new Type[] { typeof(Vector3), typeof(Vector3), typeof(ForceMode) })] public static void AddForceAtPosition(Rigidbody __instance, ref Vector3 force, Vector3 position, ForceMode mode) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) if (QuicksilverMod.IsEnabled) { Gun val = Gun.Cache.Get(((Component)__instance).gameObject); if (!(QuicksilverMod.TargetTimeScale <= 0f) && Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.triggerGrip) && Object.op_Implicit((Object)(object)val.triggerGrip.GetHand()) && (Object)(object)val.triggerGrip.GetHand().manager == (Object)(object)QuicksilverMod.Instance.rigManager) { force /= QuicksilverMod.TargetTimeScale; } } } } [HarmonyPatch(typeof(Time))] public static class TimePatches { public static bool ReturnScaled; public static bool ForceDefaultTimescale; public static bool ReturnInversed; [HarmonyPostfix] [HarmonyPatch(/*Could not decode attribute arguments.*/)] public static void GetDeltaTime(ref float __result) { if (QuicksilverMod.IsEnabled && Time.timeScale > 0f) { if (ReturnScaled) { __result /= Time.timeScale; } else if (ReturnInversed) { __result *= Time.timeScale; } } } [HarmonyPostfix] [HarmonyPatch(/*Could not decode attribute arguments.*/)] public static void GetFixedDeltaTime(ref float __result) { if (QuicksilverMod.IsEnabled && Time.timeScale > 0f) { if (ReturnScaled) { __result /= Time.timeScale; } else if (ReturnInversed) { __result *= Time.timeScale; } } } [HarmonyPostfix] [HarmonyPatch(/*Could not decode attribute arguments.*/)] public static void GetTimeScale(ref float __result) { if (QuicksilverMod.IsEnabled && ForceDefaultTimescale) { __result = 1f; } } } [HarmonyPatch(typeof(HandgunVirtualController))] public static class HandgunVirtualControllerPatches { [HarmonyPrefix] [HarmonyPatch("OnVirtualControllerSolve")] public static void OnVirtualControllerSolvePrefix(VirtualControlerPayload p) { TimePatches.ReturnScaled = true; } [HarmonyPostfix] [HarmonyPatch("OnVirtualControllerSolve")] public static void OnVirtualControllerSolvePostfix(VirtualControlerPayload p) { TimePatches.ReturnScaled = false; } } [HarmonyPatch(typeof(RifleVirtualController))] public static class RifleVirtualControllerPatches { [HarmonyPrefix] [HarmonyPatch("OnVirtualControllerSolve")] public static void OnVirtualControllerSolvePrefix(VirtualControlerPayload payload) { TimePatches.ReturnScaled = true; } [HarmonyPostfix] [HarmonyPatch("OnVirtualControllerSolve")] public static void OnVirtualControllerSolvePostfix(VirtualControlerPayload payload) { TimePatches.ReturnScaled = false; } } [HarmonyPatch(typeof(WindBuffetSFX))] public static class WindBuffetPatches { [HarmonyPrefix] [HarmonyPatch("Update")] public static void UpdatePrefix(WindBuffetSFX __instance) { if (QuicksilverMod.IsEnabled) { if (QuicksilverMod.TargetTimeScale > 0f) { __instance.minSpeed = 5f / QuicksilverMod.TargetTimeScale; __instance.maxSpeed = 40f / QuicksilverMod.TargetTimeScale; } TimePatches.ForceDefaultTimescale = true; } else { __instance.minSpeed = 5f; __instance.maxSpeed = 40f; } } [HarmonyPostfix] [HarmonyPatch("Update")] public static void UpdatePostfix(WindBuffetSFX __instance) { TimePatches.ForceDefaultTimescale = false; } } }