Watch
2
0
Fork
You've already forked raylib-cs
0
raylib-cs/Raylib-cs/types/AudioMixed.cs
Matorio 762641e296 Updating calls and docs
Moved the "AudioCallback" delegate into the "AudioMixed.cs" File.
Added a "Update" method to AudioStream.
Added "LoadAnim" static method to Image.
Added a "Update" method to Music.
Explicit constructors on the "Mesh.cs" file.
Properties and structs marked as read-only on the "Model.cs" file.
Updated the "README.md" to mentions Raylib-cs targets net6.0 and net8.0 (and also explicitly added that the "STAThread" attribute comes from the "System" namespace).
Changed redundant calls on some "Draw" methods from Texture2D.
2025-07-18 14:02:01 -05:00

28 lines
861 B
C#

using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System;
namespace Raylib_cs;
/// <summary>
/// Audio stream processor.
/// Used with <see cref="Raylib.AttachAudioMixedProcessor(AudioCallback{float})"/>
/// and <see cref="Raylib.DetachAudioMixedProcessor(AudioCallback{float})"/>
/// </summary>
public delegate void AudioCallback<T>(Span<T> buffer);
internal static unsafe class AudioMixed
{
public static AudioCallback<float> Callback = null;
[UnmanagedCallersOnly(CallConvs = new Type[]
{ 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<float> floats = new(buffer, (int)frames);
Callback?.Invoke(floats);
}
}