Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Volume FX and BASSLoud #1

Open
wants to merge 27 commits into
base: fork
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
caf080d
Built-in BASS volume control through BASS_ChannelSetFX
Jun 23, 2023
bb69868
Revert "Use more correct boolean"
frenzibyte Jul 11, 2023
a6cbb7e
Merge pull request #118 from frenzibyte/fix-ios-issue
DustinBond Jul 11, 2023
415fb8f
Add bindings for bassloud
smallketchup82 Mar 19, 2024
0147fc7
Finish up
smallketchup82 Mar 20, 2024
10d8778
Fixes
smallketchup82 Mar 26, 2024
87ef2cf
BassEnc support
smallketchup82 Apr 3, 2024
f71ff3a
Merge branch 'volume-fx-support' into peppy-fork-smallketchup-edit
smallketchup82 Apr 3, 2024
b669943
Merge branch 'bassloud' into peppy-fork-smallketchup-edit
smallketchup82 Apr 3, 2024
1d579fb
Versioning
smallketchup82 Apr 3, 2024
ac470b2
Fixes
smallketchup82 Apr 3, 2024
5865dae
csproj
smallketchup82 Apr 3, 2024
025408f
Add custom patch for VolumeFx
smallketchup82 Apr 4, 2024
2ee8076
Fix indentation
smallketchup82 Apr 5, 2024
c303a19
Finish docs
smallketchup82 Apr 5, 2024
dcf2f8a
Make volume classes accessible
smallketchup82 Apr 9, 2024
fb68ef5
Remove redundant boolean comparison
smallketchup82 Apr 9, 2024
2bf94d5
Make access modifiers consistent
smallketchup82 Apr 9, 2024
f72b5d4
Merge branch 'volume-fx-fixup' into peppy-fork-smallketchup-edit
smallketchup82 Apr 9, 2024
ba7acb6
Reapply "Use more correct boolean"
smallketchup82 Apr 16, 2024
93b8298
Fix unnecessary dependency on BassEnc
smallketchup82 Apr 16, 2024
e446076
Revert changes to BassEnc
smallketchup82 Apr 16, 2024
d4153ce
Further revert BassEnc changes
smallketchup82 Apr 16, 2024
4d1a849
Rename methods
smallketchup82 May 10, 2024
cb0a742
Also rename version method
smallketchup82 May 10, 2024
348ee49
Undo versioning changes
smallketchup82 May 12, 2024
9dc2313
Fix capitalization in bassloud
smallketchup82 Jun 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/AddOns/BassFx/BassFx.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<AssemblyName>ppy.ManagedBass.Fx</AssemblyName>
<Version>3.0.0</Version>
<Version>2023.0.0</Version>
smallketchup82 marked this conversation as resolved.
Show resolved Hide resolved
<Authors>MathewSachin</Authors>
<Description>ManagedBass FX AddOn</Description>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand Down
77 changes: 77 additions & 0 deletions src/AddOns/BassFx/Effects/Objects/VolumeEffect.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ManagedBass.Fx
{
public sealed class Volume : Effect<VolumeParameters>
{
/// <summary>
/// The new volume level... 0 = silent, 1.0 = normal, above 1.0 = amplification. The default value is 1.
/// </summary>
public float Target
{
get => Parameters.fTarget;
set
{
Parameters.fTarget = value;
OnPropertyChanged();
}
}

/// <summary>
/// The current volume level... -1 = leave existing current level when setting parameters. The default value is 1.
/// </summary>
public float Current
{
get => Parameters.fCurrent;
set
{
Parameters.fCurrent = value;
OnPropertyChanged();
}
}

/// <summary>
/// The time to take to transition from the current level to the new level, in seconds. The default value is 0.
/// </summary>
public float Time
{
get => Parameters.fTime;
set
{
Parameters.fTime = value;
OnPropertyChanged();
}
}

/// <summary>
/// The curve to use in the transition... False for linear, true for logarithmic. The default value is false.
/// </summary>
public bool Curve
{
get => Convert.ToBoolean(Parameters.lCurve);
set
{
Parameters.lCurve = (uint)(value ? 1 : 0);
OnPropertyChanged();
}
}

/// <summary>
/// A <see cref="FXChannelFlags" /> flag to define on which channels to apply the effect. Default: <see cref="FXChannelFlags.All"/>
/// </summary>
public FXChannelFlags Channels
{
get => Parameters.lChannel;
set
{
Parameters.lChannel = value;

OnPropertyChanged();
}
}
}
}
38 changes: 38 additions & 0 deletions src/AddOns/BassFx/Effects/Structures/VolumeParameters.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System.Runtime.InteropServices;

namespace ManagedBass.Fx
{
[StructLayout(LayoutKind.Sequential)]
public class VolumeParameters : IEffectParameter
{
/// <summary>
/// The new volume level... 0 = silent, 1.0 = normal, above 1.0 = amplification. The default value is 1.
/// </summary>
public float fTarget = 1.0f;

/// <summary>
/// The current volume level... -1 = leave existing current level when setting parameters. The default value is 1.
/// </summary>
public float fCurrent = 1.0f;

/// <summary>
/// The time to take to transition from the current level to the new level, in seconds. The default value is 0.
/// </summary>
public float fTime = 0;

/// <summary>
/// The curve to use in the transition... 0 = linear, 1 = logarithmic. The default value is 0.
/// </summary>
public uint lCurve = 0;

/// <summary>
/// A <see cref="FXChannelFlags" /> flag to define on which channels to apply the effect. Default: <see cref="FXChannelFlags.All"/>
/// </summary>
public FXChannelFlags lChannel = FXChannelFlags.All;

/// <summary>
/// Gets the <see cref="EffectType"/>.
/// </summary>
public EffectType FXType => EffectType.Volume;
}
}
63 changes: 63 additions & 0 deletions src/AddOns/Bassloud/Bassloud.cs
smallketchup82 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using System;
using System.Runtime.InteropServices;

namespace ManagedBass.Loud
{
public static class BassLoud
{
const string DllName = "bassloud";

#region Version
[DllImport(DllName)]
static extern int BASS_Loudness_GetVersion();

/// <summary>
/// Gets the Version of BassFx that is loaded.
/// </summary>
public static Version Version => Extensions.GetVersion(BASS_Loudness_GetVersion());
#endregion

/// <summary>
/// Retrieves the channel that a loudness measurement is set on.
/// </summary>
/// <param name="Handle">The loudness measurement.</param>
/// <returns>If successful, the loudness measurement's channel handle is returned, else 0 is returned. Use <see cref="Bass.LastError" /> to get the error code.</returns>
/// <exception cref="Errors.Handle"><paramref name="Handle"/> is not valid.</exception>
[DllImport(DllName, EntryPoint = "BASS_Loudness_GetChannel")]
public static extern int BASS_Loudness_GetChannel(int Handle);

/// <summary>
/// Retrieves the level of a loudness measurement.
/// </summary>
/// <param name="Handle">The loudness measurement handle.</param>
/// <param name="Mode">The measurement type to retrieve. One of the following. BassFlags.BassLoudnessCurrent, BassFlags.BassLoudnessIntegrated, BassFlags.BassLoudnessRange, BassFlags.BassLoudnessPeak, BassFlags.BassLoudnessTruePeak.</param>
/// <param name="Level">Pointer to a variable to receive the measurement level.</param>
/// <returns>If successful, TRUE is returned, else FALSE is returned. Use <see cref="Bass.LastError"/> to get the error code.</returns>
/// <exception cref="Errors.Handle"><paramref name="Handle"/> is not valid.</exception>
/// <exception cref="Errors.Parameter"><paramref name="Mode"/> is not valid. If requesting a duration with BASS_LOUDNESS_CURRENT then it exceeds what has been enabled.</exception>
/// <exception cref="Errors.NotAvailable">The requested measurement has not been enabled.</exception>
[DllImport(DllName, EntryPoint = "BASS_Loudness_GetLevel")]
public static extern bool BASS_Loudness_GetLevel(int Handle, BassFlags Mode, ref float Level);

/// <summary>
/// Starts loudness measurement on a channel.
/// </summary>
/// <param name="Handle">The channel handle</param>
/// <param name="Flags">The measurement mode & flags</param>
/// <param name="Priority">The DSP priority of the measurements.</param>
/// <returns>The loudness measurement handle is returned if it is successfully started, else 0 is returned. Use <see cref="Bass.LastError"/> to get the error code.</returns>
/// <exception cref="Errors.Handle"><paramref name="Handle"/> is not valid.</exception>
/// <exception cref="Errors.Memory">There is insufficient memory.</exception>
[DllImport(DllName, EntryPoint = "BASS_Loudness_Start", CharSet = CharSet.Unicode)]
public static extern int BASS_Loudness_Start(int Handle, BassFlags Flags, int Priority);

/// <summary>
/// Stops a loudness measurement or all loudness measurements on a channel.
/// </summary>
/// <param name="Handle">The channel handle</param>
/// <returns>If successful, TRUE is returned, else FALSE is returned. Use <see cref="Bass.LastError"/> to get the error code.</returns>
/// <exception cref="Errors.Handle"><paramref name="Handle"/> is not valid.</exception>
[DllImport(DllName, EntryPoint = "BASS_Loudness_Stop")]
public static extern bool BASS_Loudness_Stop(int Handle);
}
}
36 changes: 36 additions & 0 deletions src/AddOns/Bassloud/Bassloud.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Nullable>disable</Nullable>
<LangVersion>8</LangVersion>
<AssemblyName>ppy.ManagedBass.Loud</AssemblyName>
<PackageId>ppy.ManagedBass.Loud</PackageId>
<Authors>MathewSachin</Authors>
<Version>3.0.5</Version>
<Description>ManagedBass BASSLoud AddOn</Description>
<PackageProjectUrl>https://github.com/ManagedBass/ManagedBass</PackageProjectUrl>
<PackageIcon>icon.png</PackageIcon>
<RepositoryUrl>https://github.com/ManagedBass/ManagedBass</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<TargetFramework>netstandard2.1</TargetFramework>
<Product>ppy.ManagedBass.Loud</Product>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\Bass\Portable\Bass.csproj" />
</ItemGroup>

<ItemGroup>
<None Include="..\..\..\icon.png">
<Pack>true</Pack>
<PackagePath></PackagePath>
<Link>icon.png</Link>
</None>
<None Include="..\..\..\LICENSE.md">
<Pack>true</Pack>
<PackagePath></PackagePath>
<Link>LICENSE.md</Link>
</None>
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/Bass/Desktop/Desktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<DefineConstants>__DESKTOP__</DefineConstants>
<Version>3.0.0</Version>
<Version>2023.0.1</Version>
smallketchup82 marked this conversation as resolved.
Show resolved Hide resolved
</PropertyGroup>

<Import Project="..\Shared\Shared.projitems" Label="Shared" />
Expand Down
33 changes: 33 additions & 0 deletions src/Bass/Shared/Bass/Enumerations/BassFlags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,39 @@ public enum BassFlags : uint
DShowVideoProcessing = 0x20000,
#endregion

#region BassLoud

/// <summary>
/// BassLoud add-on: Loudness in LUFS of the last 400ms or the duration (in milliseconds) specified in the HIWORD
/// </summary>
BassLoudnessCurrent = 0,

/// <summary>
/// BassLoud add-on: Integrated loudness in LUFS. This is the average since measurement started.
/// </summary>
BassLoudnessIntegrated = 1,

/// <summary>
/// BassLoud add-on: Loudness range in LU.
/// </summary>
BassLoudnessRange = 2,

/// <summary>
/// BassLoud add-on: Peak level in linear scale.
/// </summary>
BassLoudnessPeak = 4,

/// <summary>
/// BassLoud add-on: True peak level in linear scale.
/// </summary>
BassLoudnessTruePeak = 8,

/// <summary>
/// BassLoud add-on: Automatically free the measurement when the channel is freed.
/// </summary>
BassLoudnessAutofree = 0x8000,
#endregion

/// <summary>
/// BassWV add-on: Limit to stereo
/// </summary>
Expand Down
9 changes: 8 additions & 1 deletion src/Bass/Shared/Bass/Enumerations/EffectType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ public enum EffectType
DXReverb,
#endregion

#region Bass
/// <summary>
/// Bass: Volume control (built into Bass itself).
/// </summary>
Volume,
#endregion

#region BassFx
/// <summary>
/// BassFx: Channel Volume Ping-Pong (multi channel).
Expand All @@ -61,7 +68,7 @@ public enum EffectType
/// <summary>
/// BassFx: Volume control (multi channel).
/// </summary>
Volume = 0x10003,
VolumeBfx = 0x10003,

/// <summary>
/// BassFx: Peaking Equalizer (multi channel).
Expand Down
36 changes: 23 additions & 13 deletions src/ManagedBass.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29709.97
# Visual Studio Version 17
VisualStudioVersion = 17.5.33627.172
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Bass", "Bass", "{2F77A940-A236-4FCB-950C-03600F1F4EDC}"
EndProject
Expand Down Expand Up @@ -102,18 +102,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Items", "Items", "{B5C0D018
..\README.md = ..\README.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BassLoud", "AddOns\BassLoud\BassLoud.csproj", "{390A135A-A966-4F3A-B420-3FF4CCD86098}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
AddOns\BassMidi\Shared\Shared.projitems*{1fb51416-f915-4dbb-9ac2-120333c73ff8}*SharedItemsImports = 13
Bass\Shared\Shared.projitems*{2128ef61-f422-439a-beb2-be39bac713ee}*SharedItemsImports = 4
AddOns\BassEnc\Shared\Shared.projitems*{3ba4ff0c-458a-44da-b267-3409151598d7}*SharedItemsImports = 4
Bass\Shared\Shared.projitems*{78ebb66c-05cb-4a2d-94a7-5eb29c5f02ed}*SharedItemsImports = 4
AddOns\BassMidi\Shared\Shared.projitems*{794cfb9c-8bac-48b8-abe6-b1003eae0766}*SharedItemsImports = 4
AddOns\BassMidi\Shared\Shared.projitems*{a4d1f1ce-73e9-4f5f-b399-e69d7bf998aa}*SharedItemsImports = 4
AddOns\BassEnc\Shared\Shared.projitems*{a885cf43-1f88-4ec7-af35-4c73776b1c42}*SharedItemsImports = 13
Bass\Shared\Shared.projitems*{cd4e203e-c152-4914-93f8-59010befcb52}*SharedItemsImports = 13
AddOns\BassEnc\Shared\Shared.projitems*{d7a05b65-f427-4d11-a156-5f5459044b22}*SharedItemsImports = 4
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Expand Down Expand Up @@ -271,6 +262,10 @@ Global
{B74875B2-2AE0-4665-BC80-33EDC955C381}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B74875B2-2AE0-4665-BC80-33EDC955C381}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B74875B2-2AE0-4665-BC80-33EDC955C381}.Release|Any CPU.Build.0 = Release|Any CPU
{390A135A-A966-4F3A-B420-3FF4CCD86098}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{390A135A-A966-4F3A-B420-3FF4CCD86098}.Debug|Any CPU.Build.0 = Debug|Any CPU
{390A135A-A966-4F3A-B420-3FF4CCD86098}.Release|Any CPU.ActiveCfg = Release|Any CPU
{390A135A-A966-4F3A-B420-3FF4CCD86098}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -317,8 +312,23 @@ Global
{AA72E426-627B-497C-8219-F344577D4DE0} = {27976565-211B-4A18-8501-89D534534BF4}
{8E11E61B-F8DB-44A1-B30E-140A46B9D6D4} = {32C0B6FE-4187-44E4-8F10-453FB1BB6287}
{B74875B2-2AE0-4665-BC80-33EDC955C381} = {46E48BCB-C105-4049-A64B-DFC1621B5A2D}
{390A135A-A966-4F3A-B420-3FF4CCD86098} = {27976565-211B-4A18-8501-89D534534BF4}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2963EB56-09D6-4AFD-863A-6DAF38D4955A}
EndGlobalSection
GlobalSection(SharedMSBuildProjectFiles) = preSolution
AddOns\BassMidi\Shared\Shared.projitems*{1fb51416-f915-4dbb-9ac2-120333c73ff8}*SharedItemsImports = 13
Bass\Shared\Shared.projitems*{2128ef61-f422-439a-beb2-be39bac713ee}*SharedItemsImports = 5
AddOns\BassEnc\Shared\Shared.projitems*{3ba4ff0c-458a-44da-b267-3409151598d7}*SharedItemsImports = 5
Bass\Shared\Shared.projitems*{78ebb66c-05cb-4a2d-94a7-5eb29c5f02ed}*SharedItemsImports = 5
AddOns\BassMidi\Shared\Shared.projitems*{794cfb9c-8bac-48b8-abe6-b1003eae0766}*SharedItemsImports = 5
AddOns\BassEnc\Shared\Shared.projitems*{8e11e61b-f8db-44a1-b30e-140a46b9d6d4}*SharedItemsImports = 5
AddOns\BassMidi\Shared\Shared.projitems*{a4d1f1ce-73e9-4f5f-b399-e69d7bf998aa}*SharedItemsImports = 5
AddOns\BassEnc\Shared\Shared.projitems*{a885cf43-1f88-4ec7-af35-4c73776b1c42}*SharedItemsImports = 13
AddOns\BassMidi\Shared\Shared.projitems*{b74875b2-2ae0-4665-bc80-33edc955c381}*SharedItemsImports = 5
Bass\Shared\Shared.projitems*{cd4e203e-c152-4914-93f8-59010befcb52}*SharedItemsImports = 13
AddOns\BassEnc\Shared\Shared.projitems*{d7a05b65-f427-4d11-a156-5f5459044b22}*SharedItemsImports = 5
Bass\Shared\Shared.projitems*{e29cfa86-e31d-4694-9cc0-7337502c7746}*SharedItemsImports = 5
EndGlobalSection
EndGlobal