Skip to content

Commit

Permalink
chore: bump native
Browse files Browse the repository at this point in the history
  • Loading branch information
lmichaelis committed Apr 30, 2024
1 parent cf001fb commit 26d5ac8
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 36 deletions.
7 changes: 5 additions & 2 deletions DirectMusic/Native.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,14 @@ internal static class Native
public static extern void DmPerformance_release(IntPtr slf);

[DllImport(DllName)]
public static extern DmResult DmPerformance_playSegment(IntPtr slf, IntPtr sgt, PlaybackFlags flags);
public static extern DmResult DmPerformance_playSegment(IntPtr slf, IntPtr sgt, Timing flags);

[DllImport(DllName)]
public static extern DmResult DmPerformance_playTransition(IntPtr slf, IntPtr sgt, Embellishment embellishment,
PlaybackFlags flags);
Timing flags);

[DllImport(DllName)]
public static extern void DmPerformance_setVolume(IntPtr slf, float vol);

[DllImport(DllName)]
public static extern DmResult DmPerformance_renderPcm(IntPtr slf, short[] buf, ulong len, DmRenderOptions opts);
Expand Down
62 changes: 28 additions & 34 deletions DirectMusic/Performance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,30 @@
namespace DirectMusic
{
[Flags]
public enum PlaybackFlags
public enum Timing
{
Secondary = 1 << 7,
Queue = 1 << 8,
Control = 1 << 9,
AfterPrepareTime = 1 << 10,
Grid = 1 << 11,
Beat = 1 << 12,
Measure = 1 << 13,
Default = 1 << 14,
NoInvalidate = 1 << 15,
Align = 1 << 16,
ValidStartBeat = 1 << 17,
ValidStartGrid = 1 << 18,
ValidStartTick = 1 << 19,
AutoTransition = 1 << 20,
AfterQueueTime = 1 << 21,
AfterLatencyTime = 1 << 22,
SegmentEnd = 1 << 23,
Marker = 1 << 24,
TimeSigAlways = 1 << 25,
UseAudiopath = 1 << 26,
ValidStartMeasure = 1 << 27,
InvalidatePri = 1 << 28
Instant = 1,
Grid = 2,
Beat = 3,
Measure = 4,
}

public enum Embellishment
{
None = 0,
Fill = 1,
Intro = 2,
Break = 3,
End = 4
Groove = 1,
Fill = 2,
Intro = 3,
Break = 4,
End = 5,
EndAndIntro = 5,
}

public class Performance
{
private readonly IntPtr _handle;

public Performance(IntPtr handle)
private Performance(IntPtr handle)
{
_handle = handle;
}
Expand All @@ -52,30 +36,40 @@ public Performance(IntPtr handle)
Native.DmPerformance_release(_handle);
}

public void PlaySegment(Segment segment, PlaybackFlags flags)
public void PlaySegment(Segment segment, Timing timing)
{
Native.DmPerformance_playSegment(_handle, segment.Handle, flags);
Native.DmPerformance_playSegment(_handle, segment.Handle, timing).Check();
}

public void PlayTransition(Segment segment, Embellishment embellishment, PlaybackFlags flags)
public void PlayTransition(Segment segment, Embellishment embellishment, Timing timing)
{
Native.DmPerformance_playTransition(_handle, segment.Handle, embellishment, flags);
Native.DmPerformance_playTransition(_handle, segment.Handle, embellishment, timing).Check();
}

public void StopSegment(Timing timing)
{
Native.DmPerformance_playSegment(_handle, IntPtr.Zero, timing).Check();
}

public void SetVolume(float volume)
{
Native.DmPerformance_setVolume(_handle, volume);
}

public void RenderPcm(short[] pcm, bool stereo)
{
var opts = DmRenderOptions.Short;
if (stereo) opts |= DmRenderOptions.Stereo;

Native.DmPerformance_renderPcm(_handle, pcm, (ulong)pcm.Length, opts);
Native.DmPerformance_renderPcm(_handle, pcm, (ulong)pcm.Length, opts).Check();
}

public void RenderPcm(float[] pcm, bool stereo)
{
var opts = DmRenderOptions.Float;
if (stereo) opts |= DmRenderOptions.Stereo;

Native.DmPerformance_renderPcm(_handle, pcm, (ulong)pcm.Length, opts);
Native.DmPerformance_renderPcm(_handle, pcm, (ulong)pcm.Length, opts).Check();
}

public static Performance Create()
Expand Down
Binary file modified DirectMusic/runtimes/android-arm64/native/libdmusic.so
Binary file not shown.
Binary file modified DirectMusic/runtimes/linux-x64/native/libdmusic.so
Binary file not shown.
Binary file modified DirectMusic/runtimes/win-x64/native/dmusic.dll
Binary file not shown.

0 comments on commit 26d5ac8

Please sign in to comment.