mirror of
https://github.com/LanZhan-Harmony/WindowsMusicPlayer-TheUntamedMusicPlayer.git
synced 2026-05-06 19:20:18 +08:00
初始化C++项目
This commit is contained in:
267
BassAudioEngine/BassAudioEngine.vcxproj
Normal file
267
BassAudioEngine/BassAudioEngine.vcxproj
Normal file
@@ -0,0 +1,267 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|ARM64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>ARM64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|ARM64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>ARM64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>18.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{ad06a049-a46d-4b45-ab74-471d5138a519}</ProjectGuid>
|
||||
<RootNamespace>BassAudioEngine</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v145</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v145</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v145</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v145</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v145</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v145</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<OutDir>$(Platform)\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<OutDir>$(Platform)\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
|
||||
<OutDir>$(Platform)\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
|
||||
<OutDir>$(Platform)\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(Platform)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(Platform)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;BASSAUDIOENGINE_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<LanguageStandard_C>stdclatest</LanguageStandard_C>
|
||||
<FloatingPointModel>Fast</FloatingPointModel>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<AdditionalDependencies>bass.lib;bass_fx.lib;basswasapi.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(ProjectDir)Libraries</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;BASSAUDIOENGINE_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<LanguageStandard_C>stdclatest</LanguageStandard_C>
|
||||
<FloatingPointModel>Fast</FloatingPointModel>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<AdditionalDependencies>bass.lib;bass_fx.lib;basswasapi.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(ProjectDir)Libraries</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;BASSAUDIOENGINE_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<LanguageStandard_C>stdclatest</LanguageStandard_C>
|
||||
<FloatingPointModel>Fast</FloatingPointModel>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<AdditionalDependencies>bass.lib;bass_fx.lib;basswasapi.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(ProjectDir)Libraries</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;BASSAUDIOENGINE_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<LanguageStandard_C>stdclatest</LanguageStandard_C>
|
||||
<FloatingPointModel>Fast</FloatingPointModel>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<AdditionalDependencies>bass.lib;bass_fx.lib;basswasapi.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(ProjectDir)Libraries</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;BASSAUDIOENGINE_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<LanguageStandard_C>stdclatest</LanguageStandard_C>
|
||||
<FloatingPointModel>Fast</FloatingPointModel>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<AdditionalDependencies>bass.lib;bass_fx.lib;basswasapi.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(ProjectDir)Libraries</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;BASSAUDIOENGINE_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpplatest</LanguageStandard>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<LanguageStandard_C>stdclatest</LanguageStandard_C>
|
||||
<FloatingPointModel>Fast</FloatingPointModel>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<AdditionalDependencies>bass.lib;bass_fx.lib;basswasapi.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(ProjectDir)Libraries</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="bass.h" />
|
||||
<ClInclude Include="basswasapi.h" />
|
||||
<ClInclude Include="bass_fx.h" />
|
||||
<ClInclude Include="framework.h" />
|
||||
<ClInclude Include="pch.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="dllmain.cpp" />
|
||||
<ClCompile Include="pch.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
42
BassAudioEngine/BassAudioEngine.vcxproj.filters
Normal file
42
BassAudioEngine/BassAudioEngine.vcxproj.filters
Normal file
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="源文件">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="头文件">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="资源文件">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="framework.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="pch.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="bass.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="bass_fx.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="basswasapi.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="dllmain.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="pch.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
1219
BassAudioEngine/bass.h
Normal file
1219
BassAudioEngine/bass.h
Normal file
File diff suppressed because it is too large
Load Diff
477
BassAudioEngine/bass_fx.h
Normal file
477
BassAudioEngine/bass_fx.h
Normal file
@@ -0,0 +1,477 @@
|
||||
/*===========================================================================
|
||||
BASS_FX 2.4 - Copyright (c) 2002-2018 (: JOBnik! :) [Arthur Aminov, ISRAEL]
|
||||
[http://www.jobnik.org]
|
||||
|
||||
bugs/suggestions/questions:
|
||||
forum : http://www.un4seen.com/forum/?board=1
|
||||
http://www.jobnik.org/forums
|
||||
e-mail : bass_fx@jobnik.org
|
||||
--------------------------------------------------
|
||||
|
||||
NOTE: This header will work only with BASS_FX version 2.4.12
|
||||
Check www.un4seen.com or www.jobnik.org for any later versions.
|
||||
|
||||
* Requires BASS 2.4 (available at http://www.un4seen.com)
|
||||
===========================================================================*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef BASS_FX_H
|
||||
#define BASS_FX_H
|
||||
|
||||
#include "bass.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#ifndef BASS_FXDEF
|
||||
#define BASS_FXDEF(f) WINAPI f
|
||||
#endif
|
||||
|
||||
// BASS_CHANNELINFO types
|
||||
#define BASS_CTYPE_STREAM_TEMPO 0x1f200
|
||||
#define BASS_CTYPE_STREAM_REVERSE 0x1f201
|
||||
|
||||
// Tempo / Reverse / BPM / Beat flag
|
||||
#define BASS_FX_FREESOURCE 0x10000 // Free the source handle as well?
|
||||
|
||||
// BASS_FX Version
|
||||
DWORD BASS_FXDEF(BASS_FX_GetVersion)();
|
||||
|
||||
/*===========================================================================
|
||||
DSP (Digital Signal Processing)
|
||||
===========================================================================*/
|
||||
|
||||
/*
|
||||
Multi-channel order of each channel is as follows:
|
||||
3 channels left-front, right-front, center.
|
||||
4 channels left-front, right-front, left-rear/side, right-rear/side.
|
||||
5 channels left-front, right-front, center, left-rear/side, right-rear/side.
|
||||
6 channels (5.1) left-front, right-front, center, LFE, left-rear/side, right-rear/side.
|
||||
8 channels (7.1) left-front, right-front, center, LFE, left-rear/side, right-rear/side, left-rear center, right-rear center.
|
||||
*/
|
||||
|
||||
// DSP channels flags
|
||||
#define BASS_BFX_CHANALL -1 // all channels at once (as by default)
|
||||
#define BASS_BFX_CHANNONE 0 // disable an effect for all channels
|
||||
#define BASS_BFX_CHAN1 1 // left-front channel
|
||||
#define BASS_BFX_CHAN2 2 // right-front channel
|
||||
#define BASS_BFX_CHAN3 4 // see above info
|
||||
#define BASS_BFX_CHAN4 8 // see above info
|
||||
#define BASS_BFX_CHAN5 16 // see above info
|
||||
#define BASS_BFX_CHAN6 32 // see above info
|
||||
#define BASS_BFX_CHAN7 64 // see above info
|
||||
#define BASS_BFX_CHAN8 128 // see above info
|
||||
|
||||
// if you have more than 8 channels (7.1), use this macro
|
||||
#define BASS_BFX_CHANNEL_N(n) (1 << ((n) - 1))
|
||||
|
||||
// DSP effects
|
||||
enum
|
||||
{
|
||||
BASS_FX_BFX_ROTATE = 0x10000, // A channels volume ping-pong / multi channel
|
||||
BASS_FX_BFX_ECHO, // Echo / 2 channels max (deprecated)
|
||||
BASS_FX_BFX_FLANGER, // Flanger / multi channel (deprecated)
|
||||
BASS_FX_BFX_VOLUME, // Volume / multi channel
|
||||
BASS_FX_BFX_PEAKEQ, // Peaking Equalizer / multi channel
|
||||
BASS_FX_BFX_REVERB, // Reverb / 2 channels max (deprecated)
|
||||
BASS_FX_BFX_LPF, // Low Pass Filter 24dB / multi channel (deprecated)
|
||||
BASS_FX_BFX_MIX, // Swap, remap and mix channels / multi channel
|
||||
BASS_FX_BFX_DAMP, // Dynamic Amplification / multi channel
|
||||
BASS_FX_BFX_AUTOWAH, // Auto Wah / multi channel
|
||||
BASS_FX_BFX_ECHO2, // Echo 2 / multi channel (deprecated)
|
||||
BASS_FX_BFX_PHASER, // Phaser / multi channel
|
||||
BASS_FX_BFX_ECHO3, // Echo 3 / multi channel (deprecated)
|
||||
BASS_FX_BFX_CHORUS, // Chorus/Flanger / multi channel
|
||||
BASS_FX_BFX_APF, // All Pass Filter / multi channel (deprecated)
|
||||
BASS_FX_BFX_COMPRESSOR, // Compressor / multi channel (deprecated)
|
||||
BASS_FX_BFX_DISTORTION, // Distortion / multi channel
|
||||
BASS_FX_BFX_COMPRESSOR2, // Compressor 2 / multi channel
|
||||
BASS_FX_BFX_VOLUME_ENV, // Volume envelope / multi channel
|
||||
BASS_FX_BFX_BQF, // BiQuad filters / multi channel
|
||||
BASS_FX_BFX_ECHO4, // Echo 4 / multi channel
|
||||
BASS_FX_BFX_PITCHSHIFT, // Pitch shift using FFT / multi channel (not available on mobile)
|
||||
BASS_FX_BFX_FREEVERB // Reverb using "Freeverb" algo / multi channel
|
||||
};
|
||||
|
||||
/*
|
||||
Deprecated effects in 2.4.10 version:
|
||||
------------------------------------
|
||||
BASS_FX_BFX_ECHO -> use BASS_FX_BFX_ECHO4
|
||||
BASS_FX_BFX_ECHO2 -> use BASS_FX_BFX_ECHO4
|
||||
BASS_FX_BFX_ECHO3 -> use BASS_FX_BFX_ECHO4
|
||||
BASS_FX_BFX_REVERB -> use BASS_FX_BFX_FREEVERB
|
||||
BASS_FX_BFX_FLANGER -> use BASS_FX_BFX_CHORUS
|
||||
BASS_FX_BFX_COMPRESSOR -> use BASS_FX_BFX_COMPRESSOR2
|
||||
BASS_FX_BFX_APF -> use BASS_FX_BFX_BQF with BASS_BFX_BQF_ALLPASS filter
|
||||
BASS_FX_BFX_LPF -> use 2x BASS_FX_BFX_BQF with BASS_BFX_BQF_LOWPASS filter and appropriate fQ values
|
||||
*/
|
||||
|
||||
// Rotate
|
||||
typedef struct
|
||||
{
|
||||
float fRate; // rotation rate/speed in Hz (A negative rate can be used for reverse direction)
|
||||
int lChannel; // BASS_BFX_CHANxxx flag/s (supported only even number of channels)
|
||||
} BASS_BFX_ROTATE;
|
||||
|
||||
// Echo (deprecated)
|
||||
typedef struct
|
||||
{
|
||||
float fLevel; // [0....1....n] linear
|
||||
int lDelay; // [1200..30000]
|
||||
} BASS_BFX_ECHO;
|
||||
|
||||
// Flanger (deprecated)
|
||||
typedef struct
|
||||
{
|
||||
float fWetDry; // [0....1....n] linear
|
||||
float fSpeed; // [0......0.09]
|
||||
int lChannel; // BASS_BFX_CHANxxx flag/s
|
||||
} BASS_BFX_FLANGER;
|
||||
|
||||
// Volume
|
||||
typedef struct
|
||||
{
|
||||
int lChannel; // BASS_BFX_CHANxxx flag/s or 0 for global volume control
|
||||
float fVolume; // [0....1....n] linear
|
||||
} BASS_BFX_VOLUME;
|
||||
|
||||
// Peaking Equalizer
|
||||
typedef struct
|
||||
{
|
||||
int lBand; // [0...............n] more bands means more memory & cpu usage
|
||||
float fBandwidth; // [0.1...........<10] in octaves - fQ is not in use (Bandwidth has a priority over fQ)
|
||||
float fQ; // [0...............1] the EE kinda definition (linear) (if Bandwidth is not in use)
|
||||
float fCenter; // [1Hz..<info.freq/2] in Hz
|
||||
float fGain; // [-15dB...0...+15dB] in dB (can be above/below these limits)
|
||||
int lChannel; // BASS_BFX_CHANxxx flag/s
|
||||
} BASS_BFX_PEAKEQ;
|
||||
|
||||
// Reverb (deprecated)
|
||||
typedef struct
|
||||
{
|
||||
float fLevel; // [0....1....n] linear
|
||||
int lDelay; // [1200..10000]
|
||||
} BASS_BFX_REVERB;
|
||||
|
||||
// Low Pass Filter (deprecated)
|
||||
typedef struct
|
||||
{
|
||||
float fResonance; // [0.01...........10]
|
||||
float fCutOffFreq; // [1Hz...info.freq/2] cutoff frequency
|
||||
int lChannel; // BASS_BFX_CHANxxx flag/s
|
||||
} BASS_BFX_LPF;
|
||||
|
||||
// Swap, remap and mix
|
||||
typedef struct
|
||||
{
|
||||
const int *lChannel; // an array of channels to mix using BASS_BFX_CHANxxx flag/s (lChannel[0] is left channel...)
|
||||
} BASS_BFX_MIX;
|
||||
|
||||
// Dynamic Amplification
|
||||
typedef struct
|
||||
{
|
||||
float fTarget; // target volume level [0<......1] linear
|
||||
float fQuiet; // quiet volume level [0.......1] linear
|
||||
float fRate; // amp adjustment rate [0.......1] linear
|
||||
float fGain; // amplification level [0...1...n] linear
|
||||
float fDelay; // delay in seconds before increasing level [0.......n] linear
|
||||
int lChannel; // BASS_BFX_CHANxxx flag/s
|
||||
} BASS_BFX_DAMP;
|
||||
|
||||
// Auto Wah
|
||||
typedef struct
|
||||
{
|
||||
float fDryMix; // dry (unaffected) signal mix [-2......2]
|
||||
float fWetMix; // wet (affected) signal mix [-2......2]
|
||||
float fFeedback; // output signal to feed back into input [-1......1]
|
||||
float fRate; // rate of sweep in cycles per second [0<....<10]
|
||||
float fRange; // sweep range in octaves [0<....<10]
|
||||
float fFreq; // base frequency of sweep Hz [0<...1000]
|
||||
int lChannel; // BASS_BFX_CHANxxx flag/s
|
||||
} BASS_BFX_AUTOWAH;
|
||||
|
||||
// Echo 2 (deprecated)
|
||||
typedef struct
|
||||
{
|
||||
float fDryMix; // dry (unaffected) signal mix [-2......2]
|
||||
float fWetMix; // wet (affected) signal mix [-2......2]
|
||||
float fFeedback; // output signal to feed back into input [-1......1]
|
||||
float fDelay; // delay sec [0<......n]
|
||||
int lChannel; // BASS_BFX_CHANxxx flag/s
|
||||
} BASS_BFX_ECHO2;
|
||||
|
||||
// Phaser
|
||||
typedef struct
|
||||
{
|
||||
float fDryMix; // dry (unaffected) signal mix [-2......2]
|
||||
float fWetMix; // wet (affected) signal mix [-2......2]
|
||||
float fFeedback; // output signal to feed back into input [-1......1]
|
||||
float fRate; // rate of sweep in cycles per second [0<....<10]
|
||||
float fRange; // sweep range in octaves [0<....<10]
|
||||
float fFreq; // base frequency of sweep [0<...1000]
|
||||
int lChannel; // BASS_BFX_CHANxxx flag/s
|
||||
} BASS_BFX_PHASER;
|
||||
|
||||
// Echo 3 (deprecated)
|
||||
typedef struct
|
||||
{
|
||||
float fDryMix; // dry (unaffected) signal mix [-2......2]
|
||||
float fWetMix; // wet (affected) signal mix [-2......2]
|
||||
float fDelay; // delay sec [0<......n]
|
||||
int lChannel; // BASS_BFX_CHANxxx flag/s
|
||||
} BASS_BFX_ECHO3;
|
||||
|
||||
// Chorus/Flanger
|
||||
typedef struct
|
||||
{
|
||||
float fDryMix; // dry (unaffected) signal mix [-2......2]
|
||||
float fWetMix; // wet (affected) signal mix [-2......2]
|
||||
float fFeedback; // output signal to feed back into input [-1......1]
|
||||
float fMinSweep; // minimal delay ms [0<...6000]
|
||||
float fMaxSweep; // maximum delay ms [0<...6000]
|
||||
float fRate; // rate ms/s [0<...1000]
|
||||
int lChannel; // BASS_BFX_CHANxxx flag/s
|
||||
} BASS_BFX_CHORUS;
|
||||
|
||||
// All Pass Filter (deprecated)
|
||||
typedef struct
|
||||
{
|
||||
float fGain; // reverberation time [-1=<..<=1]
|
||||
float fDelay; // delay sec [0<....<=n]
|
||||
int lChannel; // BASS_BFX_CHANxxx flag/s
|
||||
} BASS_BFX_APF;
|
||||
|
||||
// Compressor (deprecated)
|
||||
typedef struct
|
||||
{
|
||||
float fThreshold; // compressor threshold [0<=...<=1]
|
||||
float fAttacktime; // attack time ms [0<.<=1000]
|
||||
float fReleasetime; // release time ms [0<.<=5000]
|
||||
int lChannel; // BASS_BFX_CHANxxx flag/s
|
||||
} BASS_BFX_COMPRESSOR;
|
||||
|
||||
// Distortion
|
||||
typedef struct
|
||||
{
|
||||
float fDrive; // distortion drive [0<=...<=5]
|
||||
float fDryMix; // dry (unaffected) signal mix [-5<=..<=5]
|
||||
float fWetMix; // wet (affected) signal mix [-5<=..<=5]
|
||||
float fFeedback; // output signal to feed back into input [-1<=..<=1]
|
||||
float fVolume; // distortion volume [0=<...<=2]
|
||||
int lChannel; // BASS_BFX_CHANxxx flag/s
|
||||
} BASS_BFX_DISTORTION;
|
||||
|
||||
// Compressor 2
|
||||
typedef struct
|
||||
{
|
||||
float fGain; // output gain of signal after compression [-60....60] in dB
|
||||
float fThreshold; // point at which compression begins [-60.....0] in dB
|
||||
float fRatio; // compression ratio [1.......n]
|
||||
float fAttack; // attack time in ms [0.01.1000]
|
||||
float fRelease; // release time in ms [0.01.5000]
|
||||
int lChannel; // BASS_BFX_CHANxxx flag/s
|
||||
} BASS_BFX_COMPRESSOR2;
|
||||
|
||||
// Volume envelope
|
||||
typedef struct
|
||||
{
|
||||
int lChannel; // BASS_BFX_CHANxxx flag/s
|
||||
int lNodeCount; // number of nodes
|
||||
const struct BASS_BFX_ENV_NODE *pNodes; // the nodes
|
||||
BOOL bFollow; // follow source position
|
||||
} BASS_BFX_VOLUME_ENV;
|
||||
|
||||
#pragma pack(push, 4)
|
||||
typedef struct BASS_BFX_ENV_NODE
|
||||
{
|
||||
double pos; // node position in seconds (1st envelope node must be at position 0)
|
||||
float val; // node value
|
||||
} BASS_BFX_ENV_NODE;
|
||||
#pragma pack(pop)
|
||||
|
||||
// BiQuad Filters
|
||||
enum
|
||||
{
|
||||
BASS_BFX_BQF_LOWPASS,
|
||||
BASS_BFX_BQF_HIGHPASS,
|
||||
BASS_BFX_BQF_BANDPASS, // constant 0 dB peak gain
|
||||
BASS_BFX_BQF_BANDPASS_Q, // constant skirt gain, peak gain = Q
|
||||
BASS_BFX_BQF_NOTCH,
|
||||
BASS_BFX_BQF_ALLPASS,
|
||||
BASS_BFX_BQF_PEAKINGEQ,
|
||||
BASS_BFX_BQF_LOWSHELF,
|
||||
BASS_BFX_BQF_HIGHSHELF
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int lFilter; // BASS_BFX_BQF_xxx filter types
|
||||
float fCenter; // [1Hz..<info.freq/2] Cutoff (central) frequency in Hz
|
||||
float fGain; // [-15dB...0...+15dB] Used only for PEAKINGEQ and Shelving filters in dB (can be above/below these limits)
|
||||
float fBandwidth; // [0.1...........<10] Bandwidth in octaves (fQ is not in use (fBandwidth has a priority over fQ))
|
||||
// (between -3 dB frequencies for BANDPASS and NOTCH or between midpoint
|
||||
// (fGgain/2) gain frequencies for PEAKINGEQ)
|
||||
float fQ; // [0.1.............1] The EE kinda definition (linear) (if fBandwidth is not in use)
|
||||
float fS; // [0.1.............1] A "shelf slope" parameter (linear) (used only with Shelving filters)
|
||||
// when fS = 1, the shelf slope is as steep as you can get it and remain monotonically
|
||||
// increasing or decreasing gain with frequency.
|
||||
int lChannel; // BASS_BFX_CHANxxx flag/s
|
||||
} BASS_BFX_BQF;
|
||||
|
||||
// Echo 4
|
||||
typedef struct
|
||||
{
|
||||
float fDryMix; // dry (unaffected) signal mix [-2.......2]
|
||||
float fWetMix; // wet (affected) signal mix [-2.......2]
|
||||
float fFeedback; // output signal to feed back into input [-1.......1]
|
||||
float fDelay; // delay sec [0<.......n]
|
||||
BOOL bStereo; // echo adjoining channels to each other [TRUE/FALSE]
|
||||
int lChannel; // BASS_BFX_CHANxxx flag/s
|
||||
} BASS_BFX_ECHO4;
|
||||
|
||||
// Pitch shift (not available on mobile)
|
||||
typedef struct
|
||||
{
|
||||
float fPitchShift; // A factor value which is between 0.5 (one octave down) and 2 (one octave up) (1 won't change the pitch) [1 default]
|
||||
// (fSemitones is not in use, fPitchShift has a priority over fSemitones)
|
||||
float fSemitones; // Semitones (0 won't change the pitch) [0 default]
|
||||
long lFFTsize; // Defines the FFT frame size used for the processing. Typical values are 1024, 2048 and 4096 [2048 default]
|
||||
// It may be any value <= 8192 but it MUST be a power of 2
|
||||
long lOsamp; // Is the STFT oversampling factor which also determines the overlap between adjacent STFT frames [8 default]
|
||||
// It should at least be 4 for moderate scaling ratios. A value of 32 is recommended for best quality (better quality = higher CPU usage)
|
||||
int lChannel; // BASS_BFX_CHANxxx flag/s
|
||||
} BASS_BFX_PITCHSHIFT;
|
||||
|
||||
// Freeverb
|
||||
#define BASS_BFX_FREEVERB_MODE_FREEZE 1
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float fDryMix; // dry (unaffected) signal mix [0........1], def. 0
|
||||
float fWetMix; // wet (affected) signal mix [0........3], def. 1.0f
|
||||
float fRoomSize; // room size [0........1], def. 0.5f
|
||||
float fDamp; // damping [0........1], def. 0.5f
|
||||
float fWidth; // stereo width [0........1], def. 1
|
||||
DWORD lMode; // 0 or BASS_BFX_FREEVERB_MODE_FREEZE, def. 0 (no freeze)
|
||||
int lChannel; // BASS_BFX_CHANxxx flag/s
|
||||
} BASS_BFX_FREEVERB;
|
||||
|
||||
/*===========================================================================
|
||||
set dsp fx - BASS_ChannelSetFX
|
||||
remove dsp fx - BASS_ChannelRemoveFX
|
||||
set parameters - BASS_FXSetParameters
|
||||
retrieve parameters - BASS_FXGetParameters
|
||||
reset the state - BASS_FXReset
|
||||
===========================================================================*/
|
||||
|
||||
/*===========================================================================
|
||||
Tempo, Pitch scaling and Sample rate changers
|
||||
===========================================================================*/
|
||||
|
||||
// NOTE: Enable Tempo supported flags in BASS_FX_TempoCreate and the others to source handle.
|
||||
|
||||
// tempo attributes (BASS_ChannelSet/GetAttribute)
|
||||
enum
|
||||
{
|
||||
BASS_ATTRIB_TEMPO = 0x10000,
|
||||
BASS_ATTRIB_TEMPO_PITCH,
|
||||
BASS_ATTRIB_TEMPO_FREQ
|
||||
};
|
||||
|
||||
// tempo attributes options
|
||||
enum
|
||||
{
|
||||
BASS_ATTRIB_TEMPO_OPTION_USE_AA_FILTER = 0x10010, // TRUE (default) / FALSE (default for multi-channel on mobile devices for lower CPU usage)
|
||||
BASS_ATTRIB_TEMPO_OPTION_AA_FILTER_LENGTH, // 32 default (8 .. 128 taps)
|
||||
BASS_ATTRIB_TEMPO_OPTION_USE_QUICKALGO, // TRUE (default on mobile devices for lower CPU usage) / FALSE (default)
|
||||
BASS_ATTRIB_TEMPO_OPTION_SEQUENCE_MS, // 82 default, 0 = automatic
|
||||
BASS_ATTRIB_TEMPO_OPTION_SEEKWINDOW_MS, // 28 default, 0 = automatic
|
||||
BASS_ATTRIB_TEMPO_OPTION_OVERLAP_MS, // 8 default
|
||||
BASS_ATTRIB_TEMPO_OPTION_PREVENT_CLICK // TRUE / FALSE (default)
|
||||
};
|
||||
|
||||
// tempo algorithm flags
|
||||
#define BASS_FX_TEMPO_ALGO_LINEAR 0x200
|
||||
#define BASS_FX_TEMPO_ALGO_CUBIC 0x400 // default
|
||||
#define BASS_FX_TEMPO_ALGO_SHANNON 0x800
|
||||
|
||||
HSTREAM BASS_FXDEF(BASS_FX_TempoCreate)(DWORD chan, DWORD flags);
|
||||
DWORD BASS_FXDEF(BASS_FX_TempoGetSource)(HSTREAM chan);
|
||||
float BASS_FXDEF(BASS_FX_TempoGetRateRatio)(HSTREAM chan);
|
||||
|
||||
/*===========================================================================
|
||||
Reverse playback
|
||||
===========================================================================*/
|
||||
|
||||
// NOTES: 1. MODs won't load without BASS_MUSIC_PRESCAN flag.
|
||||
// 2. Enable Reverse supported flags in BASS_FX_ReverseCreate and the others to source handle.
|
||||
|
||||
// reverse attribute (BASS_ChannelSet/GetAttribute)
|
||||
#define BASS_ATTRIB_REVERSE_DIR 0x11000
|
||||
|
||||
// playback directions
|
||||
#define BASS_FX_RVS_REVERSE -1
|
||||
#define BASS_FX_RVS_FORWARD 1
|
||||
|
||||
HSTREAM BASS_FXDEF(BASS_FX_ReverseCreate)(DWORD chan, float dec_block, DWORD flags);
|
||||
DWORD BASS_FXDEF(BASS_FX_ReverseGetSource)(HSTREAM chan);
|
||||
|
||||
/*===========================================================================
|
||||
BPM (Beats Per Minute)
|
||||
===========================================================================*/
|
||||
|
||||
// bpm flags
|
||||
#define BASS_FX_BPM_BKGRND 1 // if in use, then you can do other processing while detection's in progress. Available only in Windows platforms (BPM/Beat)
|
||||
#define BASS_FX_BPM_MULT2 2 // if in use, then will auto multiply bpm by 2 (if BPM < minBPM*2)
|
||||
|
||||
// translation options (deprecated)
|
||||
enum
|
||||
{
|
||||
BASS_FX_BPM_TRAN_X2, // multiply the original BPM value by 2 (may be called only once & will change the original BPM as well!)
|
||||
BASS_FX_BPM_TRAN_2FREQ, // BPM value to Frequency
|
||||
BASS_FX_BPM_TRAN_FREQ2, // Frequency to BPM value
|
||||
BASS_FX_BPM_TRAN_2PERCENT, // BPM value to Percents
|
||||
BASS_FX_BPM_TRAN_PERCENT2 // Percents to BPM value
|
||||
};
|
||||
|
||||
typedef void(CALLBACK BPMPROC)(DWORD chan, float bpm, void *user);
|
||||
typedef void(CALLBACK BPMPROGRESSPROC)(DWORD chan, float percent, void *user);
|
||||
typedef BPMPROGRESSPROC BPMPROCESSPROC; // back-compatibility
|
||||
|
||||
float BASS_FXDEF(BASS_FX_BPM_DecodeGet)(DWORD chan, double startSec, double endSec, DWORD minMaxBPM, DWORD flags, BPMPROGRESSPROC *proc, void *user);
|
||||
BOOL BASS_FXDEF(BASS_FX_BPM_CallbackSet)(DWORD handle, BPMPROC *proc, double period, DWORD minMaxBPM, DWORD flags, void *user);
|
||||
BOOL BASS_FXDEF(BASS_FX_BPM_CallbackReset)(DWORD handle);
|
||||
float BASS_FXDEF(BASS_FX_BPM_Translate)(DWORD handle, float val2tran, DWORD trans); // deprecated
|
||||
BOOL BASS_FXDEF(BASS_FX_BPM_Free)(DWORD handle);
|
||||
|
||||
/*===========================================================================
|
||||
Beat position trigger
|
||||
===========================================================================*/
|
||||
|
||||
typedef void(CALLBACK BPMBEATPROC)(DWORD chan, double beatpos, void *user);
|
||||
|
||||
BOOL BASS_FXDEF(BASS_FX_BPM_BeatCallbackSet)(DWORD handle, BPMBEATPROC *proc, void *user);
|
||||
BOOL BASS_FXDEF(BASS_FX_BPM_BeatCallbackReset)(DWORD handle);
|
||||
BOOL BASS_FXDEF(BASS_FX_BPM_BeatDecodeGet)(DWORD chan, double startSec, double endSec, DWORD flags, BPMBEATPROC *proc, void *user);
|
||||
BOOL BASS_FXDEF(BASS_FX_BPM_BeatSetParameters)(DWORD handle, float bandwidth, float centerfreq, float beat_rtime);
|
||||
BOOL BASS_FXDEF(BASS_FX_BPM_BeatGetParameters)(DWORD handle, float *bandwidth, float *centerfreq, float *beat_rtime);
|
||||
BOOL BASS_FXDEF(BASS_FX_BPM_BeatFree)(DWORD handle);
|
||||
|
||||
/*===========================================================================
|
||||
Macros
|
||||
===========================================================================*/
|
||||
|
||||
// translate linear level to logarithmic dB
|
||||
#define BASS_BFX_Linear2dB(level) (20 * log10(level))
|
||||
|
||||
// translate logarithmic dB level to linear
|
||||
#define BASS_BFX_dB2Linear(dB) pow(10, (dB) / 20)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
166
BassAudioEngine/basswasapi.h
Normal file
166
BassAudioEngine/basswasapi.h
Normal file
@@ -0,0 +1,166 @@
|
||||
/*
|
||||
BASSWASAPI 2.4 C/C++ header file
|
||||
Copyright (c) 2009-2020 Un4seen Developments Ltd.
|
||||
|
||||
See the BASSWASAPI.CHM file for more detailed documentation
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef BASSWASAPI_H
|
||||
#define BASSWASAPI_H
|
||||
|
||||
#include "bass.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#ifndef BASSWASAPIDEF
|
||||
#define BASSWASAPIDEF(f) WINAPI f
|
||||
#endif
|
||||
|
||||
// Additional error codes returned by BASS_ErrorGetCode
|
||||
#define BASS_ERROR_WASAPI 5000 // no WASAPI
|
||||
#define BASS_ERROR_WASAPI_BUFFER 5001 // buffer size is invalid
|
||||
#define BASS_ERROR_WASAPI_CATEGORY 5002 // can't set category
|
||||
#define BASS_ERROR_WASAPI_DENIED 5003 // access denied
|
||||
|
||||
// Device info structure
|
||||
typedef struct
|
||||
{
|
||||
const char *name;
|
||||
const char *id;
|
||||
DWORD type;
|
||||
DWORD flags;
|
||||
float minperiod;
|
||||
float defperiod;
|
||||
DWORD mixfreq;
|
||||
DWORD mixchans;
|
||||
} BASS_WASAPI_DEVICEINFO;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DWORD initflags;
|
||||
DWORD freq;
|
||||
DWORD chans;
|
||||
DWORD format;
|
||||
DWORD buflen;
|
||||
float volmax;
|
||||
float volmin;
|
||||
float volstep;
|
||||
} BASS_WASAPI_INFO;
|
||||
|
||||
// BASS_WASAPI_DEVICEINFO "type"
|
||||
#define BASS_WASAPI_TYPE_NETWORKDEVICE 0
|
||||
#define BASS_WASAPI_TYPE_SPEAKERS 1
|
||||
#define BASS_WASAPI_TYPE_LINELEVEL 2
|
||||
#define BASS_WASAPI_TYPE_HEADPHONES 3
|
||||
#define BASS_WASAPI_TYPE_MICROPHONE 4
|
||||
#define BASS_WASAPI_TYPE_HEADSET 5
|
||||
#define BASS_WASAPI_TYPE_HANDSET 6
|
||||
#define BASS_WASAPI_TYPE_DIGITAL 7
|
||||
#define BASS_WASAPI_TYPE_SPDIF 8
|
||||
#define BASS_WASAPI_TYPE_HDMI 9
|
||||
#define BASS_WASAPI_TYPE_UNKNOWN 10
|
||||
|
||||
// BASS_WASAPI_DEVICEINFO flags
|
||||
#define BASS_DEVICE_ENABLED 1
|
||||
#define BASS_DEVICE_DEFAULT 2
|
||||
#define BASS_DEVICE_INIT 4
|
||||
#define BASS_DEVICE_LOOPBACK 8
|
||||
#define BASS_DEVICE_INPUT 16
|
||||
#define BASS_DEVICE_UNPLUGGED 32
|
||||
#define BASS_DEVICE_DISABLED 64
|
||||
|
||||
// BASS_WASAPI_Init flags
|
||||
#define BASS_WASAPI_EXCLUSIVE 1
|
||||
#define BASS_WASAPI_AUTOFORMAT 2
|
||||
#define BASS_WASAPI_BUFFER 4
|
||||
#define BASS_WASAPI_EVENT 16
|
||||
#define BASS_WASAPI_SAMPLES 32
|
||||
#define BASS_WASAPI_DITHER 64
|
||||
#define BASS_WASAPI_RAW 128
|
||||
#define BASS_WASAPI_ASYNC 0x100
|
||||
|
||||
#define BASS_WASAPI_CATEGORY_MASK 0xf000
|
||||
#define BASS_WASAPI_CATEGORY_OTHER 0x0000
|
||||
#define BASS_WASAPI_CATEGORY_FOREGROUNDONLYMEDIA 0x1000
|
||||
#define BASS_WASAPI_CATEGORY_BACKGROUNDCAPABLEMEDIA 0x2000
|
||||
#define BASS_WASAPI_CATEGORY_COMMUNICATIONS 0x3000
|
||||
#define BASS_WASAPI_CATEGORY_ALERTS 0x4000
|
||||
#define BASS_WASAPI_CATEGORY_SOUNDEFFECTS 0x5000
|
||||
#define BASS_WASAPI_CATEGORY_GAMEEFFECTS 0x6000
|
||||
#define BASS_WASAPI_CATEGORY_GAMEMEDIA 0x7000
|
||||
#define BASS_WASAPI_CATEGORY_GAMECHAT 0x8000
|
||||
#define BASS_WASAPI_CATEGORY_SPEECH 0x9000
|
||||
#define BASS_WASAPI_CATEGORY_MOVIE 0xa000
|
||||
#define BASS_WASAPI_CATEGORY_MEDIA 0xb000
|
||||
|
||||
// BASS_WASAPI_INFO "format"
|
||||
#define BASS_WASAPI_FORMAT_FLOAT 0
|
||||
#define BASS_WASAPI_FORMAT_8BIT 1
|
||||
#define BASS_WASAPI_FORMAT_16BIT 2
|
||||
#define BASS_WASAPI_FORMAT_24BIT 3
|
||||
#define BASS_WASAPI_FORMAT_32BIT 4
|
||||
|
||||
// BASS_WASAPI_Set/GetVolume modes
|
||||
#define BASS_WASAPI_CURVE_DB 0
|
||||
#define BASS_WASAPI_CURVE_LINEAR 1
|
||||
#define BASS_WASAPI_CURVE_WINDOWS 2
|
||||
#define BASS_WASAPI_VOL_SESSION 8
|
||||
|
||||
typedef DWORD(CALLBACK WASAPIPROC)(void *buffer, DWORD length, void *user);
|
||||
/* WASAPI callback function.
|
||||
buffer : Buffer containing the sample data
|
||||
length : Number of bytes
|
||||
user : The 'user' parameter given when calling BASS_WASAPI_Init
|
||||
RETURN : The number of bytes written (output devices), 0/1 = stop/continue (input devices) */
|
||||
|
||||
// Special WASAPIPROCs
|
||||
#define WASAPIPROC_PUSH (WASAPIPROC *)0 // push output
|
||||
#define WASAPIPROC_BASS (WASAPIPROC *)-1 // BASS channel
|
||||
|
||||
typedef void(CALLBACK WASAPINOTIFYPROC)(DWORD notify, DWORD device, void *user);
|
||||
/* WASAPI device notification callback function.
|
||||
notify : The notification (BASS_WASAPI_NOTIFY_xxx)
|
||||
device : Device that the notification applies to
|
||||
user : The 'user' parameter given when calling BASS_WASAPI_SetNotify */
|
||||
|
||||
// Device notifications
|
||||
#define BASS_WASAPI_NOTIFY_ENABLED 0
|
||||
#define BASS_WASAPI_NOTIFY_DISABLED 1
|
||||
#define BASS_WASAPI_NOTIFY_DEFOUTPUT 2
|
||||
#define BASS_WASAPI_NOTIFY_DEFINPUT 3
|
||||
#define BASS_WASAPI_NOTIFY_FAIL 0x100
|
||||
|
||||
DWORD BASSWASAPIDEF(BASS_WASAPI_GetVersion)();
|
||||
BOOL BASSWASAPIDEF(BASS_WASAPI_SetNotify)(WASAPINOTIFYPROC *proc, void *user);
|
||||
BOOL BASSWASAPIDEF(BASS_WASAPI_GetDeviceInfo)(DWORD device, BASS_WASAPI_DEVICEINFO *info);
|
||||
float BASSWASAPIDEF(BASS_WASAPI_GetDeviceLevel)(DWORD device, int chan);
|
||||
BOOL BASSWASAPIDEF(BASS_WASAPI_SetDevice)(DWORD device);
|
||||
DWORD BASSWASAPIDEF(BASS_WASAPI_GetDevice)();
|
||||
DWORD BASSWASAPIDEF(BASS_WASAPI_CheckFormat)(DWORD device, DWORD freq, DWORD chans, DWORD flags);
|
||||
BOOL BASSWASAPIDEF(BASS_WASAPI_Init)(int device, DWORD freq, DWORD chans, DWORD flags, float buffer, float period, WASAPIPROC *proc, void *user);
|
||||
BOOL BASSWASAPIDEF(BASS_WASAPI_Free)();
|
||||
BOOL BASSWASAPIDEF(BASS_WASAPI_GetInfo)(BASS_WASAPI_INFO *info);
|
||||
float BASSWASAPIDEF(BASS_WASAPI_GetCPU)();
|
||||
BOOL BASSWASAPIDEF(BASS_WASAPI_Lock)(BOOL lock);
|
||||
BOOL BASSWASAPIDEF(BASS_WASAPI_Start)();
|
||||
BOOL BASSWASAPIDEF(BASS_WASAPI_Stop)(BOOL reset);
|
||||
BOOL BASSWASAPIDEF(BASS_WASAPI_IsStarted)();
|
||||
BOOL BASSWASAPIDEF(BASS_WASAPI_SetVolume)(DWORD mode, float volume);
|
||||
float BASSWASAPIDEF(BASS_WASAPI_GetVolume)(DWORD mode);
|
||||
BOOL BASSWASAPIDEF(BASS_WASAPI_SetMute)(DWORD mode, BOOL mute);
|
||||
BOOL BASSWASAPIDEF(BASS_WASAPI_GetMute)(DWORD mode);
|
||||
DWORD BASSWASAPIDEF(BASS_WASAPI_PutData)(void *buffer, DWORD length);
|
||||
DWORD BASSWASAPIDEF(BASS_WASAPI_GetData)(void *buffer, DWORD length);
|
||||
DWORD BASSWASAPIDEF(BASS_WASAPI_GetLevel)();
|
||||
BOOL BASSWASAPIDEF(BASS_WASAPI_GetLevelEx)(float *levels, float length, DWORD flags);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
16
BassAudioEngine/dllmain.cpp
Normal file
16
BassAudioEngine/dllmain.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include "pch.h"
|
||||
|
||||
BOOL APIENTRY DllMain(HMODULE hModule,
|
||||
DWORD ul_reason_for_call,
|
||||
LPVOID lpReserved)
|
||||
{
|
||||
switch (ul_reason_for_call)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
case DLL_THREAD_ATTACH:
|
||||
case DLL_THREAD_DETACH:
|
||||
case DLL_PROCESS_DETACH:
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
5
BassAudioEngine/framework.h
Normal file
5
BassAudioEngine/framework.h
Normal file
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
|
||||
#include <windows.h>
|
||||
1
BassAudioEngine/pch.cpp
Normal file
1
BassAudioEngine/pch.cpp
Normal file
@@ -0,0 +1 @@
|
||||
#include "pch.h"
|
||||
6
BassAudioEngine/pch.h
Normal file
6
BassAudioEngine/pch.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef PCH_H
|
||||
#define PCH_H
|
||||
|
||||
#include "framework.h"
|
||||
|
||||
#endif // PCH_H
|
||||
@@ -5,6 +5,10 @@
|
||||
<Platform Name="x64" />
|
||||
<Platform Name="x86" />
|
||||
</Configurations>
|
||||
<Project Path="BassAudioEngine/BassAudioEngine.vcxproj" Id="ad06a049-a46d-4b45-ab74-471d5138a519">
|
||||
<Platform Solution="Debug|arm64" Project="ARM64" />
|
||||
<Platform Solution="Release|arm64" Project="x64" />
|
||||
</Project>
|
||||
<Project Path="UntamedMusicPlayer/UntamedMusicPlayer.csproj">
|
||||
<Platform Solution="*|Any CPU" Project="x64" />
|
||||
<Platform Solution="*|arm64" Project="arm64" />
|
||||
|
||||
@@ -43,22 +43,6 @@ public static class Settings
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否为独占模式下的低延迟模式
|
||||
/// </summary>
|
||||
public static bool IsLowLatencyMode
|
||||
{
|
||||
get;
|
||||
set
|
||||
{
|
||||
if (field != value)
|
||||
{
|
||||
field = value;
|
||||
_localSettingsService.SaveSettingAsync(nameof(IsLowLatencyMode), value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 仅添加歌曲所在文件夹
|
||||
/// </summary>
|
||||
@@ -278,9 +262,6 @@ public static class Settings
|
||||
IsExclusiveMode = await _localSettingsService.ReadSettingAsync<bool>(
|
||||
nameof(IsExclusiveMode)
|
||||
);
|
||||
IsLowLatencyMode = await _localSettingsService.ReadSettingAsync<bool>(
|
||||
nameof(IsLowLatencyMode)
|
||||
);
|
||||
IsOnlyAddSpecificFolder = await _localSettingsService.ReadSettingAsync<bool>(
|
||||
nameof(IsOnlyAddSpecificFolder)
|
||||
);
|
||||
|
||||
@@ -25,10 +25,6 @@ public sealed partial class AudioEngine : IDisposable
|
||||
private SyncProcedure? _syncFailCallback;
|
||||
private WasapiProcedure? _wasapiProc;
|
||||
|
||||
// GC 延迟模式控制
|
||||
private GCLatencyMode _originalGCLatencyMode;
|
||||
private bool _isGCLatencyModeChanged = false;
|
||||
|
||||
// 专用播放线程相关
|
||||
private readonly Thread _playbackThread;
|
||||
private readonly BlockingCollection<Action> _taskQueue;
|
||||
@@ -332,11 +328,9 @@ public sealed partial class AudioEngine : IDisposable
|
||||
}
|
||||
if (_isWasapiInitialized) // 从暂停恢复
|
||||
{
|
||||
EnableSustainedLowLatencyGC();
|
||||
if (!BassWasapi.Start())
|
||||
{
|
||||
_logger.ZLogInformation($"独占从暂停恢复播放失败: {Bass.LastError}");
|
||||
RestoreGCLatencyMode();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -346,17 +340,14 @@ public sealed partial class AudioEngine : IDisposable
|
||||
_logger.ZLogInformation($"无法获取流信息: {Bass.LastError}");
|
||||
return false;
|
||||
}
|
||||
var (buffer, period) = AudioPerformanceGuardian.GetRecommendedSettings();
|
||||
if (
|
||||
!BassWasapi.Init(
|
||||
-1,
|
||||
channelInfo.Frequency,
|
||||
channelInfo.Channels,
|
||||
_state.IsLowLatencyMode
|
||||
? WasapiInitFlags.Exclusive | WasapiInitFlags.EventDriven
|
||||
: WasapiInitFlags.Exclusive,
|
||||
_state.IsLowLatencyMode ? 0.1f : buffer,
|
||||
_state.IsLowLatencyMode ? 0.025f : period,
|
||||
WasapiInitFlags.Exclusive | WasapiInitFlags.EventDriven,
|
||||
0.1f,
|
||||
0.025f,
|
||||
_wasapiProc,
|
||||
nint.Zero
|
||||
)
|
||||
@@ -372,11 +363,9 @@ public sealed partial class AudioEngine : IDisposable
|
||||
return false;
|
||||
}
|
||||
_isWasapiInitialized = true;
|
||||
EnableSustainedLowLatencyGC();
|
||||
if (!BassWasapi.Start())
|
||||
{
|
||||
_logger.ZLogInformation($"独占播放失败: {Bass.LastError}");
|
||||
RestoreGCLatencyMode();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -415,7 +404,6 @@ public sealed partial class AudioEngine : IDisposable
|
||||
{
|
||||
BassWasapi.Stop(false);
|
||||
}
|
||||
RestoreGCLatencyMode();
|
||||
return;
|
||||
}
|
||||
Bass.ChannelPause(_fxHandle);
|
||||
@@ -429,7 +417,6 @@ public sealed partial class AudioEngine : IDisposable
|
||||
ExecuteOnPlaybackThread(() =>
|
||||
{
|
||||
FreeStreams();
|
||||
RestoreGCLatencyMode();
|
||||
});
|
||||
|
||||
/// <summary>
|
||||
@@ -485,34 +472,6 @@ public sealed partial class AudioEngine : IDisposable
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置低延迟模式
|
||||
/// </summary>
|
||||
/// <param name="isLowLatency"></param>
|
||||
/// <param name="isPlaying"></param>
|
||||
public async Task SetLowLatencyMode(bool isLowLatency, bool isPlaying)
|
||||
{
|
||||
await ExecuteOnPlaybackThread(async () =>
|
||||
{
|
||||
_state.IsLowLatencyMode = isLowLatency;
|
||||
if (!_state.IsExclusiveMode || _fxHandle == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var position = GetPositionSeconds();
|
||||
Stop();
|
||||
LoadSong();
|
||||
if (isPlaying)
|
||||
{
|
||||
if (!Play())
|
||||
{
|
||||
_dispatcher.TryEnqueue(() => _state.PlayState = MediaPlaybackState.Paused);
|
||||
}
|
||||
}
|
||||
await SetPositionInternal(position);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 随着计时器更新播放进度
|
||||
/// </summary>
|
||||
@@ -613,31 +572,6 @@ public sealed partial class AudioEngine : IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 启用持续低延迟 GC 模式
|
||||
/// </summary>
|
||||
private void EnableSustainedLowLatencyGC()
|
||||
{
|
||||
if (!_isGCLatencyModeChanged)
|
||||
{
|
||||
_originalGCLatencyMode = GCSettings.LatencyMode;
|
||||
GCSettings.LatencyMode = GCLatencyMode.SustainedLowLatency;
|
||||
_isGCLatencyModeChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 恢复原始 GC 延迟模式
|
||||
/// </summary>
|
||||
private void RestoreGCLatencyMode()
|
||||
{
|
||||
if (_isGCLatencyModeChanged)
|
||||
{
|
||||
GCSettings.LatencyMode = _originalGCLatencyMode;
|
||||
_isGCLatencyModeChanged = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_isDisposed)
|
||||
@@ -655,7 +589,6 @@ public sealed partial class AudioEngine : IDisposable
|
||||
Bass.Free();
|
||||
_syncEndCallback -= OnPlaybackEnded;
|
||||
_syncFailCallback -= OnPlaybackFailed;
|
||||
RestoreGCLatencyMode();
|
||||
});
|
||||
|
||||
// 停止播放线程
|
||||
|
||||
@@ -1,114 +0,0 @@
|
||||
namespace UntamedMusicPlayer.Playback;
|
||||
|
||||
public enum DevicePerformanceTier
|
||||
{
|
||||
Entry,
|
||||
Balanced,
|
||||
Pro,
|
||||
}
|
||||
|
||||
public static class AudioPerformanceGuardian
|
||||
{
|
||||
private static readonly int _processorCount = Environment.ProcessorCount;
|
||||
private static readonly long _totalMemoryGb = GetTotalMemoryGb();
|
||||
private static readonly DevicePerformanceTier _staticTier = AssessStaticTier();
|
||||
|
||||
private static long _lastGcIndex = -1;
|
||||
private static DateTime _lastGcTimestamp = DateTime.MinValue;
|
||||
private static double _lastGcPauseMs = 0;
|
||||
|
||||
private static float _recommendedBuffer;
|
||||
private static float _recommendedPeriod;
|
||||
private static readonly Timer _timer;
|
||||
|
||||
static AudioPerformanceGuardian()
|
||||
{
|
||||
RefreshSettings();
|
||||
_timer = new Timer(
|
||||
_ => RefreshSettings(),
|
||||
null,
|
||||
TimeSpan.FromSeconds(10),
|
||||
TimeSpan.FromSeconds(10)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取音频配置建议
|
||||
/// </summary>
|
||||
public static (float Buffer, float Period) GetRecommendedSettings() =>
|
||||
(_recommendedBuffer, _recommendedPeriod);
|
||||
|
||||
private static void RefreshSettings()
|
||||
{
|
||||
var (isUnderHeavyPressure, gcPauseMs) = GetRuntimePressure();
|
||||
|
||||
// 如果动态压力极大,强行降级
|
||||
if (isUnderHeavyPressure)
|
||||
{
|
||||
var period = ((float)gcPauseMs + 50) / 1000;
|
||||
_recommendedBuffer = period * 4;
|
||||
_recommendedPeriod = period;
|
||||
}
|
||||
else
|
||||
{
|
||||
(_recommendedBuffer, _recommendedPeriod) = _staticTier switch
|
||||
{
|
||||
DevicePerformanceTier.Pro => (0.16f, 0.04f),
|
||||
DevicePerformanceTier.Balanced => (0.25f, 0.0625f),
|
||||
_ => (0.4f, 0.1f),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private static DevicePerformanceTier AssessStaticTier()
|
||||
{
|
||||
if (_processorCount >= 12 && _totalMemoryGb >= 24)
|
||||
{
|
||||
return DevicePerformanceTier.Pro;
|
||||
}
|
||||
if (_processorCount >= 6 && _totalMemoryGb >= 8)
|
||||
{
|
||||
return DevicePerformanceTier.Balanced;
|
||||
}
|
||||
return DevicePerformanceTier.Entry;
|
||||
}
|
||||
|
||||
private static (bool IsUnderHeavyPressure, double GcPauseMs) GetRuntimePressure()
|
||||
{
|
||||
var info = GC.GetGCMemoryInfo();
|
||||
var now = DateTime.UtcNow;
|
||||
|
||||
// 1. 获取最后一次 GC 的总停顿时间
|
||||
var currentPause = 0d;
|
||||
foreach (var pause in info.PauseDurations)
|
||||
{
|
||||
currentPause += pause.TotalMilliseconds;
|
||||
}
|
||||
|
||||
// 2. 更新 GC 追踪状态
|
||||
if (info.Index > _lastGcIndex)
|
||||
{
|
||||
_lastGcIndex = info.Index;
|
||||
_lastGcPauseMs = currentPause;
|
||||
_lastGcTimestamp = now;
|
||||
}
|
||||
|
||||
// 3. 判定该停顿是否依然“有效”(例如 20 秒内)
|
||||
var isPauseRecent = (now - _lastGcTimestamp).TotalSeconds < 20;
|
||||
var effectivePause = isPauseRecent ? _lastGcPauseMs : 0;
|
||||
|
||||
// 4. 计算内存压力百分比
|
||||
var loadPercentage = (float)info.MemoryLoadBytes / info.TotalAvailableMemoryBytes * 100;
|
||||
|
||||
// 5. 判定标准
|
||||
// - 最近发生的停顿 > 100ms (音频断流风险)
|
||||
// - 或者内存占用 > 95% (系统交换压力)
|
||||
// - 或者全进程 GC 时间占比过高 (info.PauseTimePercentage > 5)
|
||||
var isHeavy = effectivePause > 100 || loadPercentage > 95 || info.PauseTimePercentage > 5;
|
||||
|
||||
return (isHeavy, effectivePause);
|
||||
}
|
||||
|
||||
private static long GetTotalMemoryGb() =>
|
||||
GC.GetGCMemoryInfo().TotalAvailableMemoryBytes / 1024 / 1024 / 1024;
|
||||
}
|
||||
@@ -382,24 +382,6 @@ public sealed partial class MusicPlayer : IDisposable
|
||||
_updatable = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置低延迟模式
|
||||
/// </summary>
|
||||
/// <param name="isLowLatency"></param>
|
||||
public async void SetLowLatencyMode(bool isLowLatency)
|
||||
{
|
||||
if (State.IsLowLatencyMode == isLowLatency)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_updatable = false;
|
||||
await _audioEngine.SetLowLatencyMode(
|
||||
isLowLatency,
|
||||
State.PlayState == MediaPlaybackState.Playing
|
||||
);
|
||||
_updatable = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 快退10秒
|
||||
/// </summary>
|
||||
|
||||
@@ -48,8 +48,6 @@ public sealed partial class SharedPlaybackState : ObservableObject
|
||||
|
||||
public bool IsExclusiveMode { get; set; } = false;
|
||||
|
||||
public bool IsLowLatencyMode { get; set; } = false;
|
||||
|
||||
public async Task LoadStateAsync()
|
||||
{
|
||||
try
|
||||
@@ -70,9 +68,6 @@ public sealed partial class SharedPlaybackState : ObservableObject
|
||||
IsExclusiveMode = await _localSettingsService.ReadSettingAsync<bool>(
|
||||
nameof(IsExclusiveMode)
|
||||
);
|
||||
IsLowLatencyMode = await _localSettingsService.ReadSettingAsync<bool>(
|
||||
nameof(IsLowLatencyMode)
|
||||
);
|
||||
if (Settings.NotFirstUsed)
|
||||
{
|
||||
Volume = await _localSettingsService.ReadSettingAsync<double>(nameof(Volume));
|
||||
|
||||
@@ -68,18 +68,6 @@ public sealed partial class SettingsViewModel
|
||||
Data.MusicPlayer.SetExclusiveMode(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否为独占模式下的低延迟模式
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
public partial bool IsLowLatencyMode { get; set; } = Settings.IsLowLatencyMode;
|
||||
|
||||
partial void OnIsLowLatencyModeChanged(bool value)
|
||||
{
|
||||
Settings.IsLowLatencyMode = value;
|
||||
Data.MusicPlayer.SetLowLatencyMode(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否为如果当前位于音乐库歌曲页面且使用文件夹排序方式,点击歌曲仅会将其所在文件夹内的歌曲加入播放队列
|
||||
/// </summary>
|
||||
|
||||
@@ -157,14 +157,9 @@
|
||||
<TextBlock x:Uid="Settings_Play"
|
||||
Margin="0,12,0,5"
|
||||
Style="{StaticResource BodyStrongTextBlockStyle}"/>
|
||||
<toolkit:SettingsExpander x:Uid="Settings_ExclusiveMode" HeaderIcon="{ui:FontIcon FontFamily={StaticResource UntamedFontFamily}, Glyph=}">
|
||||
<toolkit:SettingsCard x:Uid="Settings_ExclusiveMode" HeaderIcon="{ui:FontIcon FontFamily={StaticResource UntamedFontFamily}, Glyph=}">
|
||||
<ToggleSwitch IsOn="{x:Bind ViewModel.IsExclusiveMode, Mode=TwoWay}"/>
|
||||
<toolkit:SettingsExpander.Items>
|
||||
<toolkit:SettingsCard x:Uid="Settings_LowLatencyMode">
|
||||
<ToggleSwitch IsEnabled="{x:Bind ViewModel.IsExclusiveMode, Mode=OneWay}" IsOn="{x:Bind ViewModel.IsLowLatencyMode, Mode=TwoWay}"/>
|
||||
</toolkit:SettingsCard>
|
||||
</toolkit:SettingsExpander.Items>
|
||||
</toolkit:SettingsExpander>
|
||||
<toolkit:SettingsCard x:Uid="Settings_OnlyAddSpecificFolder" HeaderIcon="{ui:FontIcon FontFamily={StaticResource UntamedFontFamily}, Glyph=}">
|
||||
<ToggleSwitch IsOn="{x:Bind ViewModel.IsOnlyAddSpecificFolder, Mode=TwoWay}"/>
|
||||
</toolkit:SettingsCard>
|
||||
|
||||
Reference in New Issue
Block a user