diff --git a/Examples/Examples.csproj b/Examples/Examples.csproj
index 6fc42f2..cd05201 100644
--- a/Examples/Examples.csproj
+++ b/Examples/Examples.csproj
@@ -5,7 +5,7 @@
true
Examples.Program
$(MSBuildThisFileDirectory)
- 10
+ 12
enable
diff --git a/Raylib-cs.Tests/Raylib-cs.Tests.csproj b/Raylib-cs.Tests/Raylib-cs.Tests.csproj
index c6c27ee..fa9d3a9 100644
--- a/Raylib-cs.Tests/Raylib-cs.Tests.csproj
+++ b/Raylib-cs.Tests/Raylib-cs.Tests.csproj
@@ -2,6 +2,7 @@
net6.0
true
+ 12
diff --git a/Raylib-cs/Raylib-cs.csproj b/Raylib-cs/Raylib-cs.csproj
index 48c59a0..9969b12 100644
--- a/Raylib-cs/Raylib-cs.csproj
+++ b/Raylib-cs/Raylib-cs.csproj
@@ -1,13 +1,13 @@
- net5.0;net6.0
+ net6.0
false
Raylib-cs
Raylib_cs
true
false
$(NoWarn);1591
- 10.0
+ 12
diff --git a/Raylib-cs/interop/Raylib.cs b/Raylib-cs/interop/Raylib.cs
index cebd3a8..662ee7d 100644
--- a/Raylib-cs/interop/Raylib.cs
+++ b/Raylib-cs/interop/Raylib.cs
@@ -2350,7 +2350,7 @@ public static unsafe partial class Raylib
/// Unload mesh from memory (RAM and/or VRAM)
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
- public static extern void UnloadMesh(Mesh* mesh);
+ public static extern void UnloadMesh(Mesh mesh);
/// Draw a 3d mesh with material and transform
[DllImport(NativeLibName, CallingConvention = CallingConvention.Cdecl)]
diff --git a/Raylib-cs/types/AudioCallback.cs b/Raylib-cs/types/AudioCallback.cs
new file mode 100644
index 0000000..2f7b372
--- /dev/null
+++ b/Raylib-cs/types/AudioCallback.cs
@@ -0,0 +1,10 @@
+using System;
+
+namespace Raylib_cs;
+
+///
+/// Audio stream processor.
+/// Used with Raylib.AttachAudioMixedProcessor()
+/// and Raylib.DetachAudioMixedProcessor()
+///
+public delegate void AudioCallback(Span buffer);
diff --git a/Raylib-cs/types/AudioMixed.cs b/Raylib-cs/types/AudioMixed.cs
new file mode 100644
index 0000000..bf98491
--- /dev/null
+++ b/Raylib-cs/types/AudioMixed.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+namespace Raylib_cs;
+
+internal static unsafe class AudioMixed
+{
+ public static AudioCallback Callback = null;
+
+ [UnmanagedCallersOnly(CallConvs = new[]
+ {
+ typeof(CallConvCdecl),
+ })]
+ public static void Processor(void* buffer, uint frames)
+ {
+ // The buffer is stereo audio, so we need to double our frame count.
+ frames = Math.Min(frames * 2, int.MaxValue);
+
+ Span floats = new(buffer, (int)frames);
+ Callback?.Invoke(floats);
+ }
+}
diff --git a/Raylib-cs/types/Raylib.Utils.cs b/Raylib-cs/types/Raylib.Utils.cs
index c3b2f1d..1b83b66 100644
--- a/Raylib-cs/types/Raylib.Utils.cs
+++ b/Raylib-cs/types/Raylib.Utils.cs
@@ -911,15 +911,6 @@ public static unsafe partial class Raylib
}
}
- /// Unload mesh from memory (RAM and/or VRAM)
- public static void UnloadMesh(ref Mesh mesh)
- {
- fixed (Mesh* p = &mesh)
- {
- UnloadMesh(p);
- }
- }
-
/// Set texture for a material map type (MAP_DIFFUSE, MAP_SPECULAR...)
public static void SetMaterialTexture(ref Material material, MaterialMapIndex mapType, Texture2D texture)
{
@@ -1261,6 +1252,30 @@ public static unsafe partial class Raylib
}
}
+ ///
+ /// Attach audio stream processor to the entire audio pipeline
+ ///
+ public static void AttachAudioMixedProcessor(AudioCallback processor)
+ {
+ if (AudioMixed.Callback == null)
+ {
+ AudioMixed.Callback = processor;
+ AttachAudioMixedProcessor(&AudioMixed.Processor);
+ }
+ }
+
+ ///
+ /// Detach audio stream processor from the entire audio pipeline
+ ///
+ public static void DetachAudioMixedProcessor(AudioCallback processor)
+ {
+ if (AudioMixed.Callback == processor)
+ {
+ DetachAudioMixedProcessor(&AudioMixed.Processor);
+ AudioMixed.Callback = null;
+ }
+ }
+
public static string SubText(this string input, int position, int length)
{
return input.Substring(position, Math.Min(length, input.Length));