com.shinolab.autd3-sdk.pattern 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Ops.cs CHANGED
@@ -16,8 +16,14 @@ namespace AUTD3
16
16
 
17
17
  public static class PatternCompressionExt
18
18
  {
19
- public static int PerFrame(this PatternCompression format) =>
20
- (int)NativePattern.autd3_pattern_compression_per_frame((byte)format);
19
+ public static int PerFrame(this PatternCompression format)
20
+ {
21
+ if (NativePattern.autd3_pattern_compression_per_frame((byte)format, out var perFrame) != 0)
22
+ {
23
+ throw new Autd3Exception($"unknown pattern compression format {format}");
24
+ }
25
+ return (int)perFrame;
26
+ }
21
27
  }
22
28
 
23
29
  public sealed class WritePatternCompressed : ICommand
package/Pattern.cs CHANGED
@@ -1,4 +1,5 @@
1
1
  using System;
2
+ using System.Threading;
2
3
  using System.Collections;
3
4
  using System.Collections.Generic;
4
5
  using System.Numerics;
@@ -81,6 +82,20 @@ namespace AUTD3
81
82
  {
82
83
  private const string Lib = "autd3_pattern";
83
84
 
85
+ private const string ClientLib = "autd3capi";
86
+
87
+ static NativePattern()
88
+ {
89
+ NativeAbi.Verify(Lib, autd3_abi_version());
90
+ NativeAbi.Verify(ClientLib, autd3capi_abi_version());
91
+ }
92
+
93
+ [DllImport(Lib)]
94
+ private static extern uint autd3_abi_version();
95
+
96
+ [DllImport(ClientLib, EntryPoint = "autd3_abi_version")]
97
+ private static extern uint autd3capi_abi_version();
98
+
84
99
  [DllImport(Lib)]
85
100
  internal static extern float autd3_pattern_wavelength(float soundSpeedMmPerS);
86
101
 
@@ -139,26 +154,26 @@ namespace AUTD3
139
154
  internal static extern void autd3_pattern_null(IntPtr buffer);
140
155
 
141
156
 
142
- [DllImport("autd3capi")]
157
+ [DllImport(ClientLib)]
143
158
  internal static extern IntPtr autd3_op_pattern(byte bank, IntPtr patternBuffer, byte transitionMode, ulong transitionValue, uint transitionMarginNs);
144
159
 
145
- [DllImport("autd3capi")]
160
+ [DllImport(ClientLib)]
146
161
  internal static extern IntPtr autd3_op_write_pattern_buffer(byte bank, ushort index, IntPtr patternBuffer);
147
162
 
148
- [DllImport("autd3capi")]
163
+ [DllImport(ClientLib)]
149
164
  internal static extern IntPtr autd3_op_write_pattern_compressed(byte bank, uint index, byte format, IntPtr[] patterns, UIntPtr numPatterns);
150
165
 
151
- [DllImport("autd3capi")]
166
+ [DllImport(ClientLib)]
152
167
  internal static extern IntPtr autd3_op_config_pattern(byte bank, IntPtr samplingConfig, uint size, ushort rep);
153
168
 
154
- [DllImport("autd3capi")]
169
+ [DllImport(ClientLib)]
155
170
  internal static extern IntPtr autd3_op_config_foci_stm(byte bank, IntPtr samplingConfig, uint size, byte numFoci, float soundSpeedMPerS, ushort rep);
156
171
 
157
- [DllImport("autd3capi")]
172
+ [DllImport(ClientLib)]
158
173
  internal static extern IntPtr autd3_op_change_pattern_bank(byte bank, byte transitionMode, ulong transitionValue, uint transitionMarginNs);
159
174
 
160
- [DllImport("autd3capi")]
161
- internal static extern UIntPtr autd3_pattern_compression_per_frame(byte format);
175
+ [DllImport(ClientLib)]
176
+ internal static extern int autd3_pattern_compression_per_frame(byte format, out UIntPtr @out);
162
177
  }
163
178
 
164
179
  public readonly struct DevicePattern : IEnumerable<Emission>
@@ -206,7 +221,9 @@ namespace AUTD3
206
221
  {
207
222
  internal const int NumTransducers = 249;
208
223
 
209
- internal IntPtr Handle { get; private set; }
224
+ private IntPtr _handle;
225
+
226
+ internal IntPtr Handle => _handle;
210
227
 
211
228
  internal PatternBuffer(IntPtr handle)
212
229
  {
@@ -214,7 +231,7 @@ namespace AUTD3
214
231
  {
215
232
  throw new Autd3Exception("failed to create pattern buffer");
216
233
  }
217
- Handle = handle;
234
+ _handle = handle;
218
235
  }
219
236
 
220
237
  public static PatternBuffer FromArray(Emission[][] emissions)
@@ -264,19 +281,20 @@ namespace AUTD3
264
281
 
265
282
  public void Dispose()
266
283
  {
267
- if (Handle != IntPtr.Zero)
284
+ var handle = Interlocked.Exchange(ref _handle, IntPtr.Zero);
285
+ if (handle != IntPtr.Zero)
268
286
  {
269
- NativePattern.autd3_pattern_buffer_free(Handle);
270
- Handle = IntPtr.Zero;
287
+ NativePattern.autd3_pattern_buffer_free(handle);
271
288
  }
272
289
  GC.SuppressFinalize(this);
273
290
  }
274
291
 
275
292
  ~PatternBuffer()
276
293
  {
277
- if (Handle != IntPtr.Zero)
294
+ var handle = Interlocked.Exchange(ref _handle, IntPtr.Zero);
295
+ if (handle != IntPtr.Zero)
278
296
  {
279
- NativePattern.autd3_pattern_buffer_free(Handle);
297
+ NativePattern.autd3_pattern_buffer_free(handle);
280
298
  }
281
299
  }
282
300
  }
Binary file
@@ -854,11 +854,41 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
854
854
 
855
855
  Used by:
856
856
 
857
- - autd3-ffi-abi 0.5.0 — https://github.com/shinolab/autd3-sdk
858
- - autd3-ffi-pattern 0.5.0 — https://github.com/shinolab/autd3-sdk
859
- - autd3-rs-core 0.5.0 — https://github.com/shinolab/autd3-sdk
860
- - autd3-rs-pattern 0.5.0 — https://github.com/shinolab/autd3-sdk
861
- - autd3-cpu-wire 0.4.0 — https://github.com/shinolab/autd3-sdk
857
+ - autd3-rs-core 0.6.0 — https://github.com/shinolab/autd3-sdk
858
+ - autd3-rs-pattern 0.6.0 — https://github.com/shinolab/autd3-sdk
859
+ - autd3-cpu-wire 0.6.0 — https://github.com/shinolab/autd3-sdk
860
+
861
+ ```
862
+ MIT License
863
+
864
+ Copyright (c) 2026 Shun Suzuki
865
+
866
+ Permission is hereby granted, free of charge, to any person obtaining a copy
867
+ of this software and associated documentation files (the "Software"), to deal
868
+ in the Software without restriction, including without limitation the rights
869
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
870
+ copies of the Software, and to permit persons to whom the Software is
871
+ furnished to do so, subject to the following conditions:
872
+
873
+ The above copyright notice and this permission notice shall be included in all
874
+ copies or substantial portions of the Software.
875
+
876
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
877
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
878
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
879
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
880
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
881
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
882
+ SOFTWARE.
883
+
884
+ ```
885
+
886
+ ## MIT License
887
+
888
+ Used by:
889
+
890
+ - autd3-ffi-abi 0.6.0 — https://github.com/shinolab/autd3-sdk
891
+ - autd3-ffi-pattern 0.6.0 — https://github.com/shinolab/autd3-sdk
862
892
  - chrono 0.4.45 — https://github.com/chronotope/chrono
863
893
  - wide 1.5.0 — https://github.com/Lokathor/wide
864
894
  - winapi-i686-pc-windows-gnu 0.4.0 — https://github.com/retep998/winapi-rs
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "url": "git+https://github.com/shinolab/autd3-sdk.git",
6
6
  "directory": "bindings/unity/com.shinolab.autd3-sdk.pattern"
7
7
  },
8
- "version": "0.5.0",
8
+ "version": "0.6.0",
9
9
  "displayName": "AUTD3 Pattern",
10
10
  "description": "AUTD3 emission patterns: Focus, Plane, Bessel (Unity binding).",
11
11
  "unity": "6000.0",
@@ -15,6 +15,6 @@
15
15
  "url": "https://github.com/shinolab"
16
16
  },
17
17
  "dependencies": {
18
- "com.shinolab.autd3-sdk.core": "0.5.0"
18
+ "com.shinolab.autd3-sdk.core": "0.6.0"
19
19
  }
20
20
  }