com.shinolab.autd3-sdk.pattern 0.10.0 → 0.14.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 +26 -61
- package/Pattern.cs +51 -410
- package/Plugins/linux-x64/libautd3_pattern.so +0 -0
- package/Plugins/osx-arm64/libautd3_pattern.dylib +0 -0
- package/Plugins/win-x64/autd3_pattern.dll +0 -0
- package/THIRD-PARTY-LICENSES.md +51 -88
- package/package.json +2 -2
package/Ops.cs
CHANGED
|
@@ -11,34 +11,41 @@ namespace AUTD3
|
|
|
11
11
|
|
|
12
12
|
public enum PhaseDepth : byte
|
|
13
13
|
{
|
|
14
|
-
Bits8 =
|
|
15
|
-
Bits4 =
|
|
14
|
+
Bits8 = 0,
|
|
15
|
+
Bits4 = 1,
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
public static class PhaseDepthExt
|
|
19
19
|
{
|
|
20
20
|
public static int MaxCount(this PhaseDepth depth)
|
|
21
21
|
{
|
|
22
|
-
if (
|
|
22
|
+
if (NativePatternOp.autd3_phase_depth_max_count(depth.ToBits(), out var maxCount) != 0)
|
|
23
23
|
{
|
|
24
|
-
throw new Autd3Exception($"unknown phase depth {depth}");
|
|
24
|
+
throw new Autd3Exception($"unknown phase depth {depth}", Autd3ErrorCode.InvalidArgument);
|
|
25
25
|
}
|
|
26
26
|
return (int)maxCount;
|
|
27
27
|
}
|
|
28
|
+
|
|
29
|
+
internal static byte ToBits(this PhaseDepth depth) => depth switch
|
|
30
|
+
{
|
|
31
|
+
PhaseDepth.Bits8 => 8,
|
|
32
|
+
PhaseDepth.Bits4 => 4,
|
|
33
|
+
_ => 0,
|
|
34
|
+
};
|
|
28
35
|
}
|
|
29
36
|
|
|
30
37
|
public sealed class WritePatternPhase : ICommand
|
|
31
38
|
{
|
|
32
39
|
private readonly PatternBank _bank;
|
|
33
|
-
private readonly ushort
|
|
40
|
+
private readonly ushort _startIndex;
|
|
34
41
|
private readonly PhaseDepth _depth;
|
|
35
42
|
private readonly Intensity _intensity;
|
|
36
43
|
private readonly PhaseBuffer[] _patterns;
|
|
37
44
|
|
|
38
|
-
public WritePatternPhase(PatternBank bank, ushort
|
|
45
|
+
public WritePatternPhase(PatternBank bank, ushort startIndex, PhaseDepth depth, Intensity intensity, PhaseBuffer[] patterns)
|
|
39
46
|
{
|
|
40
47
|
_bank = bank;
|
|
41
|
-
|
|
48
|
+
_startIndex = startIndex;
|
|
42
49
|
_depth = depth;
|
|
43
50
|
_intensity = intensity;
|
|
44
51
|
_patterns = patterns;
|
|
@@ -52,29 +59,7 @@ namespace AUTD3
|
|
|
52
59
|
handles[i] = _patterns[i].Handle;
|
|
53
60
|
}
|
|
54
61
|
using var lease = new HandleArray(handles);
|
|
55
|
-
return
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
public sealed class WritePatternBuffer : ICommand
|
|
60
|
-
{
|
|
61
|
-
private readonly PatternBank _bank;
|
|
62
|
-
private readonly ushort _index;
|
|
63
|
-
private readonly PhaseBuffer _phases;
|
|
64
|
-
private readonly PatternIntensity _intensities;
|
|
65
|
-
|
|
66
|
-
public WritePatternBuffer(PatternBank bank, ushort index, PhaseBuffer phases, PatternIntensity intensities)
|
|
67
|
-
{
|
|
68
|
-
_bank = bank;
|
|
69
|
-
_index = index;
|
|
70
|
-
_phases = phases;
|
|
71
|
-
_intensities = intensities;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
IntPtr ICommand.CreateOp(Geometry geometry)
|
|
75
|
-
{
|
|
76
|
-
using var intensityLease = new HandleLease(_intensities.Buffer?.Handle);
|
|
77
|
-
return NativePattern.autd3_op_write_pattern_buffer((byte)_bank, _index, _phases.Handle, intensityLease.Pointer, _intensities.Uniform);
|
|
62
|
+
return NativePatternOp.autd3_op_write_pattern_phase((byte)_bank, _startIndex, _depth.ToBits(), _intensity.Value, lease.Pointers, (UIntPtr)lease.Pointers.Length);
|
|
78
63
|
}
|
|
79
64
|
}
|
|
80
65
|
|
|
@@ -85,26 +70,16 @@ namespace AUTD3
|
|
|
85
70
|
private readonly uint _size;
|
|
86
71
|
private readonly LoopBehavior _loopBehavior;
|
|
87
72
|
|
|
88
|
-
public ConfigPattern(PatternBank bank, SamplingConfig config, uint size, LoopBehavior
|
|
73
|
+
public ConfigPattern(PatternBank bank, SamplingConfig config, uint size, LoopBehavior loopBehavior)
|
|
89
74
|
{
|
|
90
75
|
_bank = bank;
|
|
91
76
|
_config = config;
|
|
92
77
|
_size = size;
|
|
93
|
-
_loopBehavior = loopBehavior
|
|
78
|
+
_loopBehavior = loopBehavior;
|
|
94
79
|
}
|
|
95
80
|
|
|
96
|
-
IntPtr ICommand.CreateOp(Geometry geometry)
|
|
97
|
-
|
|
98
|
-
var sampling = _config.CreateHandle();
|
|
99
|
-
try
|
|
100
|
-
{
|
|
101
|
-
return NativePattern.autd3_op_config_pattern((byte)_bank, sampling, _size, _loopBehavior.Rep);
|
|
102
|
-
}
|
|
103
|
-
finally
|
|
104
|
-
{
|
|
105
|
-
NativeCore.autd3_core_sampling_config_free(sampling);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
81
|
+
IntPtr ICommand.CreateOp(Geometry geometry) =>
|
|
82
|
+
NativePatternOp.autd3_op_config_pattern((byte)_bank, _config.DivideForNative(), _size, _loopBehavior.Rep);
|
|
108
83
|
}
|
|
109
84
|
|
|
110
85
|
public sealed class ConfigFociStm : ICommand
|
|
@@ -116,28 +91,18 @@ namespace AUTD3
|
|
|
116
91
|
private readonly Velocity _soundSpeed;
|
|
117
92
|
private readonly LoopBehavior _loopBehavior;
|
|
118
93
|
|
|
119
|
-
public ConfigFociStm(PatternBank bank, SamplingConfig config, uint size, byte numFoci, Velocity soundSpeed, LoopBehavior
|
|
94
|
+
public ConfigFociStm(PatternBank bank, SamplingConfig config, uint size, byte numFoci, Velocity soundSpeed, LoopBehavior loopBehavior)
|
|
120
95
|
{
|
|
121
96
|
_bank = bank;
|
|
122
97
|
_config = config;
|
|
123
98
|
_size = size;
|
|
124
99
|
_numFoci = numFoci;
|
|
125
100
|
_soundSpeed = soundSpeed;
|
|
126
|
-
_loopBehavior = loopBehavior
|
|
101
|
+
_loopBehavior = loopBehavior;
|
|
127
102
|
}
|
|
128
103
|
|
|
129
|
-
IntPtr ICommand.CreateOp(Geometry geometry)
|
|
130
|
-
|
|
131
|
-
var sampling = _config.CreateHandle();
|
|
132
|
-
try
|
|
133
|
-
{
|
|
134
|
-
return NativePattern.autd3_op_config_foci_stm((byte)_bank, sampling, _size, _numFoci, _soundSpeed.MS, _loopBehavior.Rep);
|
|
135
|
-
}
|
|
136
|
-
finally
|
|
137
|
-
{
|
|
138
|
-
NativeCore.autd3_core_sampling_config_free(sampling);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
104
|
+
IntPtr ICommand.CreateOp(Geometry geometry) =>
|
|
105
|
+
NativePatternOp.autd3_op_config_foci_stm((byte)_bank, _config.DivideForNative(), _size, _numFoci, _soundSpeed.MS, _loopBehavior.Rep);
|
|
141
106
|
}
|
|
142
107
|
|
|
143
108
|
public sealed class ActivatePatternBank : ICommand
|
|
@@ -145,13 +110,13 @@ namespace AUTD3
|
|
|
145
110
|
private readonly PatternBank _bank;
|
|
146
111
|
private readonly TransitionMode _transitionMode;
|
|
147
112
|
|
|
148
|
-
public ActivatePatternBank(PatternBank bank, TransitionMode
|
|
113
|
+
public ActivatePatternBank(PatternBank bank, TransitionMode transitionMode)
|
|
149
114
|
{
|
|
150
115
|
_bank = bank;
|
|
151
|
-
_transitionMode = transitionMode
|
|
116
|
+
_transitionMode = transitionMode;
|
|
152
117
|
}
|
|
153
118
|
|
|
154
119
|
IntPtr ICommand.CreateOp(Geometry geometry) =>
|
|
155
|
-
|
|
120
|
+
NativePatternOp.autd3_op_activate_pattern_bank((byte)_bank, _transitionMode.Mode, _transitionMode.Value);
|
|
156
121
|
}
|
|
157
122
|
}
|
package/Pattern.cs
CHANGED
|
@@ -97,148 +97,15 @@ namespace AUTD3
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
public sealed class TransducerGroups<TKey> where TKey : notnull
|
|
101
|
-
{
|
|
102
|
-
private readonly int[] _numTransducers;
|
|
103
|
-
private readonly List<TKey> _keys = new List<TKey>();
|
|
104
|
-
private readonly Dictionary<TKey, int> _lookup = new Dictionary<TKey, int>();
|
|
105
|
-
|
|
106
|
-
internal int[] FlatIndices { get; }
|
|
107
|
-
|
|
108
|
-
public IReadOnlyList<TKey> Keys => _keys;
|
|
109
|
-
|
|
110
|
-
public int NumDevices => _numTransducers.Length;
|
|
111
|
-
|
|
112
|
-
public TransducerGroups(Geometry geometry, Func<Device, int, TKey> key)
|
|
113
|
-
{
|
|
114
|
-
_numTransducers = new int[geometry.NumDevices];
|
|
115
|
-
FlatIndices = new int[geometry.NumTransducers];
|
|
116
|
-
var k = 0;
|
|
117
|
-
var dev = 0;
|
|
118
|
-
foreach (var device in geometry)
|
|
119
|
-
{
|
|
120
|
-
var numTransducers = device.NumTransducers;
|
|
121
|
-
_numTransducers[dev++] = numTransducers;
|
|
122
|
-
for (var tr = 0; tr < numTransducers; tr++)
|
|
123
|
-
{
|
|
124
|
-
var value = key(device, tr);
|
|
125
|
-
if (!_lookup.TryGetValue(value, out var index))
|
|
126
|
-
{
|
|
127
|
-
index = _keys.Count;
|
|
128
|
-
_lookup.Add(value, index);
|
|
129
|
-
_keys.Add(value);
|
|
130
|
-
}
|
|
131
|
-
FlatIndices[k++] = index;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
public TKey Key(int device, int transducer)
|
|
137
|
-
{
|
|
138
|
-
if (device < 0 || device >= _numTransducers.Length)
|
|
139
|
-
{
|
|
140
|
-
throw new ArgumentOutOfRangeException(nameof(device));
|
|
141
|
-
}
|
|
142
|
-
if (transducer < 0 || transducer >= _numTransducers[device])
|
|
143
|
-
{
|
|
144
|
-
throw new ArgumentOutOfRangeException(nameof(transducer));
|
|
145
|
-
}
|
|
146
|
-
return _keys[FlatIndices[Offset(device) + transducer]];
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
public int Index(int device, int transducer)
|
|
150
|
-
{
|
|
151
|
-
if (transducer < 0 || transducer >= NumTransducers(device))
|
|
152
|
-
{
|
|
153
|
-
throw new ArgumentOutOfRangeException(nameof(transducer));
|
|
154
|
-
}
|
|
155
|
-
return FlatIndices[Offset(device) + transducer];
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
public IReadOnlyList<int> Indices(int device) =>
|
|
159
|
-
new ArraySegment<int>(FlatIndices, Offset(device), NumTransducers(device));
|
|
160
|
-
|
|
161
|
-
public int NumTransducers(int device)
|
|
162
|
-
{
|
|
163
|
-
if (device < 0 || device >= _numTransducers.Length)
|
|
164
|
-
{
|
|
165
|
-
throw new ArgumentOutOfRangeException(nameof(device));
|
|
166
|
-
}
|
|
167
|
-
return _numTransducers[device];
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
public int NumTransducersIn(TKey key)
|
|
171
|
-
{
|
|
172
|
-
if (!_lookup.TryGetValue(key, out var index))
|
|
173
|
-
{
|
|
174
|
-
return 0;
|
|
175
|
-
}
|
|
176
|
-
var count = 0;
|
|
177
|
-
foreach (var i in FlatIndices)
|
|
178
|
-
{
|
|
179
|
-
if (i == index)
|
|
180
|
-
{
|
|
181
|
-
count++;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
return count;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
public IEnumerable<(TKey Key, TransducerMask Mask)> Masks()
|
|
188
|
-
{
|
|
189
|
-
foreach (var key in _keys)
|
|
190
|
-
{
|
|
191
|
-
yield return (key, MaskOf(_lookup[key]));
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
private int Offset(int device)
|
|
196
|
-
{
|
|
197
|
-
var offset = 0;
|
|
198
|
-
for (var dev = 0; dev < device; dev++)
|
|
199
|
-
{
|
|
200
|
-
offset += _numTransducers[dev];
|
|
201
|
-
}
|
|
202
|
-
return offset;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
public TransducerMask? Mask(TKey key) =>
|
|
206
|
-
_lookup.TryGetValue(key, out var index) ? MaskOf(index) : null;
|
|
207
|
-
|
|
208
|
-
internal TransducerMask MaskOf(int index)
|
|
209
|
-
{
|
|
210
|
-
var mask = new bool[_numTransducers.Length][];
|
|
211
|
-
var k = 0;
|
|
212
|
-
for (var dev = 0; dev < mask.Length; dev++)
|
|
213
|
-
{
|
|
214
|
-
mask[dev] = new bool[_numTransducers[dev]];
|
|
215
|
-
for (var tr = 0; tr < mask[dev].Length; tr++)
|
|
216
|
-
{
|
|
217
|
-
mask[dev][tr] = FlatIndices[k++] == index;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
return TransducerMask.Masked(mask);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
|
|
224
100
|
internal static class NativePattern
|
|
225
101
|
{
|
|
226
102
|
private const string Lib = "autd3_pattern";
|
|
227
103
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
static NativePattern()
|
|
231
|
-
{
|
|
232
|
-
NativeAbi.Verify(Lib, autd3_abi_version());
|
|
233
|
-
NativeAbi.Verify(ClientLib, autd3capi_abi_version());
|
|
234
|
-
}
|
|
104
|
+
static NativePattern() => NativeAbi.Verify(Lib, autd3_abi_version());
|
|
235
105
|
|
|
236
106
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
237
107
|
private static extern uint autd3_abi_version();
|
|
238
108
|
|
|
239
|
-
[DllImport(ClientLib, EntryPoint = "autd3_abi_version", CallingConvention = CallingConvention.Cdecl)]
|
|
240
|
-
private static extern uint autd3capi_abi_version();
|
|
241
|
-
|
|
242
109
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
243
110
|
internal static extern float autd3_pattern_wavelength(float soundSpeedMmPerS);
|
|
244
111
|
|
|
@@ -263,6 +130,9 @@ namespace AUTD3
|
|
|
263
130
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
264
131
|
internal static extern int autd3_phase_buffer_copy_to(PhaseBufferHandle buffer, [Out] byte[] dst, UIntPtr len);
|
|
265
132
|
|
|
133
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
134
|
+
internal static extern int autd3_phase_buffer_copy_from(PhaseBufferHandle buffer, ref byte src, UIntPtr len);
|
|
135
|
+
|
|
266
136
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
267
137
|
internal static extern void autd3_phase_buffer_free(IntPtr buffer);
|
|
268
138
|
|
|
@@ -288,13 +158,13 @@ namespace AUTD3
|
|
|
288
158
|
internal static extern int autd3_intensity_buffer_copy_to(IntensityBufferHandle buffer, [Out] byte[] dst, UIntPtr len);
|
|
289
159
|
|
|
290
160
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
291
|
-
internal static extern
|
|
161
|
+
internal static extern int autd3_intensity_buffer_copy_from(IntensityBufferHandle buffer, ref byte src, UIntPtr len);
|
|
292
162
|
|
|
293
163
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
294
|
-
internal static extern
|
|
164
|
+
internal static extern void autd3_intensity_buffer_free(IntPtr buffer);
|
|
295
165
|
|
|
296
166
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
297
|
-
internal static extern int
|
|
167
|
+
internal static extern int autd3_pattern_focus(GeometryHandle geometry, float[] target, float wavelengthMm, PhaseBufferHandle buffer);
|
|
298
168
|
|
|
299
169
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
300
170
|
internal static extern int autd3_pattern_focus_transducer(float[] position, float[] target, float wavelengthMm, out byte @out);
|
|
@@ -302,92 +172,59 @@ namespace AUTD3
|
|
|
302
172
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
303
173
|
internal static extern int autd3_pattern_plane(GeometryHandle geometry, float[] dir, float wavelengthMm, PhaseBufferHandle buffer);
|
|
304
174
|
|
|
305
|
-
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
306
|
-
internal static extern int autd3_pattern_plane_device(GeometryHandle geometry, UIntPtr dev, float[] dir, float wavelengthMm, [In, Out] byte[] dst);
|
|
307
|
-
|
|
308
175
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
309
176
|
internal static extern int autd3_pattern_plane_transducer(float[] position, float[] dir, float wavelengthMm, out byte @out);
|
|
310
177
|
|
|
311
178
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
312
179
|
internal static extern int autd3_pattern_bessel(GeometryHandle geometry, float[] apex, float[] dir, float thetaRad, float wavelengthMm, PhaseBufferHandle buffer);
|
|
313
180
|
|
|
314
|
-
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
315
|
-
internal static extern int autd3_pattern_bessel_device(GeometryHandle geometry, UIntPtr dev, float[] apex, float[] dir, float thetaRad, float wavelengthMm, [In, Out] byte[] dst);
|
|
316
|
-
|
|
317
181
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
318
182
|
internal static extern int autd3_pattern_bessel_transducer(float[] position, float[] apex, float[] dir, float thetaRad, float wavelengthMm, out byte @out);
|
|
319
183
|
|
|
320
184
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
321
185
|
internal static extern int autd3_pattern_laguerre_gaussian_phase(GeometryHandle geometry, float[] target, float[] axis, uint p, int l, float waistMm, float wavelengthMm, PhaseBufferHandle buffer);
|
|
322
186
|
|
|
323
|
-
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
324
|
-
internal static extern int autd3_pattern_laguerre_gaussian_phase_device(GeometryHandle geometry, UIntPtr dev, float[] target, float[] axis, uint p, int l, float waistMm, float wavelengthMm, [In, Out] byte[] dst);
|
|
325
|
-
|
|
326
187
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
327
188
|
internal static extern int autd3_pattern_laguerre_gaussian_phase_transducer(float[] position, float[] target, float[] axis, uint p, int l, float waistMm, float wavelengthMm, out byte @out);
|
|
328
189
|
|
|
329
190
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
330
191
|
internal static extern int autd3_pattern_laguerre_gaussian_intensity(GeometryHandle geometry, float[] target, float[] axis, uint p, int l, float waistMm, float wavelengthMm, IntensityBufferHandle buffer);
|
|
331
192
|
|
|
332
|
-
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
333
|
-
internal static extern int autd3_pattern_laguerre_gaussian_intensity_device(GeometryHandle geometry, UIntPtr dev, float[] target, float[] axis, uint p, int l, float waistMm, float wavelengthMm, [In, Out] byte[] dst);
|
|
334
|
-
|
|
335
193
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
336
194
|
internal static extern int autd3_pattern_hermite_gaussian_phase(GeometryHandle geometry, float[] target, float[] axis, float[] xDir, uint m, uint n, float waistMm, float wavelengthMm, PhaseBufferHandle buffer);
|
|
337
195
|
|
|
338
|
-
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
339
|
-
internal static extern int autd3_pattern_hermite_gaussian_phase_device(GeometryHandle geometry, UIntPtr dev, float[] target, float[] axis, float[] xDir, uint m, uint n, float waistMm, float wavelengthMm, [In, Out] byte[] dst);
|
|
340
|
-
|
|
341
196
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
342
197
|
internal static extern int autd3_pattern_hermite_gaussian_phase_transducer(float[] position, float[] target, float[] axis, float[] xDir, uint m, uint n, float waistMm, float wavelengthMm, out byte @out);
|
|
343
198
|
|
|
344
199
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
345
200
|
internal static extern int autd3_pattern_hermite_gaussian_intensity(GeometryHandle geometry, float[] target, float[] axis, float[] xDir, uint m, uint n, float waistMm, float wavelengthMm, IntensityBufferHandle buffer);
|
|
201
|
+
}
|
|
346
202
|
|
|
347
|
-
|
|
348
|
-
|
|
203
|
+
internal static class NativePatternOp
|
|
204
|
+
{
|
|
205
|
+
private const string Lib = "autd3capi";
|
|
349
206
|
|
|
350
|
-
|
|
351
|
-
internal static extern int autd3_pattern_set_intensity(byte intensity, IntensityBufferHandle buffer);
|
|
207
|
+
static NativePatternOp() => NativeAbi.Verify(Lib, autd3_abi_version());
|
|
352
208
|
|
|
353
209
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
354
|
-
|
|
210
|
+
private static extern uint autd3_abi_version();
|
|
355
211
|
|
|
356
212
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
357
|
-
internal static extern
|
|
213
|
+
internal static extern IntPtr autd3_op_pattern(byte bank, PhaseBufferHandle phases, IntPtr intensities, byte uniformIntensity, byte transitionMode, ulong transitionValue);
|
|
358
214
|
|
|
359
215
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
360
|
-
internal static extern
|
|
216
|
+
internal static extern IntPtr autd3_op_write_pattern_phase(byte bank, ushort startIndex, byte depth, byte intensity, IntPtr[] patterns, UIntPtr numPatterns);
|
|
361
217
|
|
|
362
218
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
363
|
-
internal static extern
|
|
219
|
+
internal static extern IntPtr autd3_op_config_pattern(byte bank, ushort samplingDivide, uint size, ushort rep);
|
|
364
220
|
|
|
365
221
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
366
|
-
internal static extern
|
|
222
|
+
internal static extern IntPtr autd3_op_config_foci_stm(byte bank, ushort samplingDivide, uint size, byte numFoci, float soundSpeedMPerS, ushort rep);
|
|
367
223
|
|
|
368
224
|
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
369
|
-
internal static extern int autd3_pattern_group_copy_intensity(GeometryHandle geometry, int[] indices, int index, IntensityBufferHandle source, IntensityBufferHandle buffer);
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
[DllImport(ClientLib, CallingConvention = CallingConvention.Cdecl)]
|
|
373
|
-
internal static extern IntPtr autd3_op_pattern(byte bank, PhaseBufferHandle phases, IntPtr intensities, byte uniformIntensity, byte transitionMode, ulong transitionValue);
|
|
374
|
-
|
|
375
|
-
[DllImport(ClientLib, CallingConvention = CallingConvention.Cdecl)]
|
|
376
|
-
internal static extern IntPtr autd3_op_write_pattern_buffer(byte bank, ushort index, PhaseBufferHandle phases, IntPtr intensities, byte uniformIntensity);
|
|
377
|
-
|
|
378
|
-
[DllImport(ClientLib, CallingConvention = CallingConvention.Cdecl)]
|
|
379
|
-
internal static extern IntPtr autd3_op_write_pattern_phase(byte bank, ushort index, byte depth, byte intensity, IntPtr[] patterns, UIntPtr numPatterns);
|
|
380
|
-
|
|
381
|
-
[DllImport(ClientLib, CallingConvention = CallingConvention.Cdecl)]
|
|
382
|
-
internal static extern IntPtr autd3_op_config_pattern(byte bank, IntPtr samplingConfig, uint size, ushort rep);
|
|
383
|
-
|
|
384
|
-
[DllImport(ClientLib, CallingConvention = CallingConvention.Cdecl)]
|
|
385
|
-
internal static extern IntPtr autd3_op_config_foci_stm(byte bank, IntPtr samplingConfig, uint size, byte numFoci, float soundSpeedMPerS, ushort rep);
|
|
386
|
-
|
|
387
|
-
[DllImport(ClientLib, CallingConvention = CallingConvention.Cdecl)]
|
|
388
225
|
internal static extern IntPtr autd3_op_activate_pattern_bank(byte bank, byte transitionMode, ulong transitionValue);
|
|
389
226
|
|
|
390
|
-
[DllImport(
|
|
227
|
+
[DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
|
|
391
228
|
internal static extern int autd3_phase_depth_max_count(byte depth, out UIntPtr @out);
|
|
392
229
|
}
|
|
393
230
|
|
|
@@ -566,6 +403,14 @@ namespace AUTD3
|
|
|
566
403
|
|
|
567
404
|
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
|
568
405
|
|
|
406
|
+
public void CopyFrom(ReadOnlySpan<byte> src)
|
|
407
|
+
{
|
|
408
|
+
if (NativePattern.autd3_phase_buffer_copy_from(Handle, ref MemoryMarshal.GetReference(src), (UIntPtr)src.Length) != 0)
|
|
409
|
+
{
|
|
410
|
+
throw new Autd3Exception("the source must hold one value for every transducer of the buffer", Autd3ErrorCode.InvalidArgument);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
569
414
|
public void Dispose() => _handle.Dispose();
|
|
570
415
|
}
|
|
571
416
|
|
|
@@ -638,6 +483,14 @@ namespace AUTD3
|
|
|
638
483
|
|
|
639
484
|
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
|
640
485
|
|
|
486
|
+
public void CopyFrom(ReadOnlySpan<byte> src)
|
|
487
|
+
{
|
|
488
|
+
if (NativePattern.autd3_intensity_buffer_copy_from(Handle, ref MemoryMarshal.GetReference(src), (UIntPtr)src.Length) != 0)
|
|
489
|
+
{
|
|
490
|
+
throw new Autd3Exception("the source must hold one value for every transducer of the buffer", Autd3ErrorCode.InvalidArgument);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
|
|
641
494
|
public void Dispose() => _handle.Dispose();
|
|
642
495
|
}
|
|
643
496
|
|
|
@@ -654,7 +507,7 @@ namespace AUTD3
|
|
|
654
507
|
{
|
|
655
508
|
if (src[d] == null || src[d].Length != Autd3.NumTransducers)
|
|
656
509
|
{
|
|
657
|
-
throw new Autd3Exception($"each device requires {Autd3.NumTransducers} {name}");
|
|
510
|
+
throw new Autd3Exception($"each device requires {Autd3.NumTransducers} {name}", Autd3ErrorCode.InvalidArgument);
|
|
658
511
|
}
|
|
659
512
|
for (var t = 0; t < Autd3.NumTransducers; t++)
|
|
660
513
|
{
|
|
@@ -707,23 +560,23 @@ namespace AUTD3
|
|
|
707
560
|
private readonly PatternIntensity _intensities;
|
|
708
561
|
private readonly TransitionMode _transitionMode;
|
|
709
562
|
|
|
710
|
-
public Pattern(PhaseBuffer phases, PatternIntensity intensities, TransitionMode
|
|
563
|
+
public Pattern(PhaseBuffer phases, PatternIntensity intensities, TransitionMode transitionMode = default)
|
|
711
564
|
: this(PatternBank.B0, phases, intensities, transitionMode)
|
|
712
565
|
{
|
|
713
566
|
}
|
|
714
567
|
|
|
715
|
-
public Pattern(PatternBank bank, PhaseBuffer phases, PatternIntensity intensities, TransitionMode
|
|
568
|
+
public Pattern(PatternBank bank, PhaseBuffer phases, PatternIntensity intensities, TransitionMode transitionMode = default)
|
|
716
569
|
{
|
|
717
570
|
_bank = bank;
|
|
718
571
|
_phases = phases;
|
|
719
572
|
_intensities = intensities;
|
|
720
|
-
_transitionMode = transitionMode
|
|
573
|
+
_transitionMode = transitionMode;
|
|
721
574
|
}
|
|
722
575
|
|
|
723
576
|
IntPtr ICommand.CreateOp(Geometry geometry)
|
|
724
577
|
{
|
|
725
578
|
using var intensityLease = new HandleLease(_intensities.Buffer?.Handle);
|
|
726
|
-
return
|
|
579
|
+
return NativePatternOp.autd3_op_pattern((byte)_bank, _phases.Handle, intensityLease.Pointer, _intensities.Uniform, _transitionMode.Mode, _transitionMode.Value);
|
|
727
580
|
}
|
|
728
581
|
|
|
729
582
|
|
|
@@ -735,19 +588,8 @@ namespace AUTD3
|
|
|
735
588
|
{
|
|
736
589
|
if (NativePattern.autd3_pattern_focus(geometry.Handle, Coords.PointArray(target), wavelength.Mm, dst.Handle) != 0)
|
|
737
590
|
{
|
|
738
|
-
throw new Autd3Exception("focus failed (buffer device count must match geometry)");
|
|
739
|
-
}
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
public static void FocusDevice(Device device, Vector3 target, Length wavelength, Phase[] dst)
|
|
743
|
-
{
|
|
744
|
-
var native = ToNative(dst);
|
|
745
|
-
if (NativePattern.autd3_pattern_focus_device(device.GeometryHandle, device.DeviceIndex,
|
|
746
|
-
Coords.PointArray(target), wavelength.Mm, native) != 0)
|
|
747
|
-
{
|
|
748
|
-
throw new Autd3Exception("focus_device failed");
|
|
591
|
+
throw new Autd3Exception("focus failed (buffer device count must match geometry)", Autd3ErrorCode.InvalidArgument);
|
|
749
592
|
}
|
|
750
|
-
FromNative(native, dst);
|
|
751
593
|
}
|
|
752
594
|
|
|
753
595
|
public static Phase FocusTransducer(Vector3 position, Vector3 target, Length wavelength)
|
|
@@ -756,7 +598,7 @@ namespace AUTD3
|
|
|
756
598
|
Coords.PointArray(position),
|
|
757
599
|
Coords.PointArray(target), wavelength.Mm, out var p) != 0)
|
|
758
600
|
{
|
|
759
|
-
throw new Autd3Exception("focus_transducer failed");
|
|
601
|
+
throw new Autd3Exception("focus_transducer failed", Autd3ErrorCode.InvalidArgument);
|
|
760
602
|
}
|
|
761
603
|
return new Phase(p);
|
|
762
604
|
}
|
|
@@ -765,28 +607,17 @@ namespace AUTD3
|
|
|
765
607
|
{
|
|
766
608
|
if (NativePattern.autd3_pattern_plane(geometry.Handle, Coords.DirArray(dir), wavelength.Mm, dst.Handle) != 0)
|
|
767
609
|
{
|
|
768
|
-
throw new Autd3Exception("plane failed (buffer device count must match geometry)");
|
|
610
|
+
throw new Autd3Exception("plane failed (buffer device count must match geometry)", Autd3ErrorCode.InvalidArgument);
|
|
769
611
|
}
|
|
770
612
|
}
|
|
771
613
|
|
|
772
|
-
public static void PlaneDevice(Device device, Vector3 dir, Length wavelength, Phase[] dst)
|
|
773
|
-
{
|
|
774
|
-
var native = ToNative(dst);
|
|
775
|
-
if (NativePattern.autd3_pattern_plane_device(device.GeometryHandle, device.DeviceIndex,
|
|
776
|
-
Coords.DirArray(dir), wavelength.Mm, native) != 0)
|
|
777
|
-
{
|
|
778
|
-
throw new Autd3Exception("plane_device failed");
|
|
779
|
-
}
|
|
780
|
-
FromNative(native, dst);
|
|
781
|
-
}
|
|
782
|
-
|
|
783
614
|
public static Phase PlaneTransducer(Vector3 position, Vector3 dir, Length wavelength)
|
|
784
615
|
{
|
|
785
616
|
if (NativePattern.autd3_pattern_plane_transducer(
|
|
786
617
|
Coords.PointArray(position),
|
|
787
618
|
Coords.DirArray(dir), wavelength.Mm, out var p) != 0)
|
|
788
619
|
{
|
|
789
|
-
throw new Autd3Exception("plane_transducer failed");
|
|
620
|
+
throw new Autd3Exception("plane_transducer failed", Autd3ErrorCode.InvalidArgument);
|
|
790
621
|
}
|
|
791
622
|
return new Phase(p);
|
|
792
623
|
}
|
|
@@ -795,22 +626,10 @@ namespace AUTD3
|
|
|
795
626
|
{
|
|
796
627
|
if (NativePattern.autd3_pattern_bessel(geometry.Handle, Coords.PointArray(apex), Coords.DirArray(dir), theta.Rad, wavelength.Mm, dst.Handle) != 0)
|
|
797
628
|
{
|
|
798
|
-
throw new Autd3Exception("bessel failed (buffer device count must match geometry)");
|
|
629
|
+
throw new Autd3Exception("bessel failed (buffer device count must match geometry)", Autd3ErrorCode.InvalidArgument);
|
|
799
630
|
}
|
|
800
631
|
}
|
|
801
632
|
|
|
802
|
-
public static void BesselDevice(Device device, Vector3 apex, Vector3 dir, Angle theta, Length wavelength, Phase[] dst)
|
|
803
|
-
{
|
|
804
|
-
var native = ToNative(dst);
|
|
805
|
-
if (NativePattern.autd3_pattern_bessel_device(device.GeometryHandle, device.DeviceIndex,
|
|
806
|
-
Coords.PointArray(apex),
|
|
807
|
-
Coords.DirArray(dir), theta.Rad, wavelength.Mm, native) != 0)
|
|
808
|
-
{
|
|
809
|
-
throw new Autd3Exception("bessel_device failed");
|
|
810
|
-
}
|
|
811
|
-
FromNative(native, dst);
|
|
812
|
-
}
|
|
813
|
-
|
|
814
633
|
public static Phase BesselTransducer(Vector3 position, Vector3 apex, Vector3 dir, Angle theta, Length wavelength)
|
|
815
634
|
{
|
|
816
635
|
if (NativePattern.autd3_pattern_bessel_transducer(
|
|
@@ -818,7 +637,7 @@ namespace AUTD3
|
|
|
818
637
|
Coords.PointArray(apex),
|
|
819
638
|
Coords.DirArray(dir), theta.Rad, wavelength.Mm, out var p) != 0)
|
|
820
639
|
{
|
|
821
|
-
throw new Autd3Exception("bessel_transducer failed");
|
|
640
|
+
throw new Autd3Exception("bessel_transducer failed", Autd3ErrorCode.InvalidArgument);
|
|
822
641
|
}
|
|
823
642
|
return new Phase(p);
|
|
824
643
|
}
|
|
@@ -828,21 +647,10 @@ namespace AUTD3
|
|
|
828
647
|
if (NativePattern.autd3_pattern_laguerre_gaussian_phase(geometry.Handle, Coords.PointArray(target), Coords.DirArray(axis),
|
|
829
648
|
option.P, option.L, option.Waist.Mm, wavelength.Mm, dst.Handle) != 0)
|
|
830
649
|
{
|
|
831
|
-
throw new Autd3Exception("laguerre_gaussian_phase failed (waist must be positive and buffer device count must match geometry)");
|
|
650
|
+
throw new Autd3Exception("laguerre_gaussian_phase failed (waist must be a positive finite length and buffer device count must match geometry)", Autd3ErrorCode.InvalidArgument);
|
|
832
651
|
}
|
|
833
652
|
}
|
|
834
653
|
|
|
835
|
-
public static void LaguerreGaussianPhaseDevice(Device device, Vector3 target, Vector3 axis, LaguerreGaussianOption option, Length wavelength, Phase[] dst)
|
|
836
|
-
{
|
|
837
|
-
var native = ToNative(dst);
|
|
838
|
-
if (NativePattern.autd3_pattern_laguerre_gaussian_phase_device(device.GeometryHandle, device.DeviceIndex,
|
|
839
|
-
Coords.PointArray(target), Coords.DirArray(axis), option.P, option.L, option.Waist.Mm, wavelength.Mm, native) != 0)
|
|
840
|
-
{
|
|
841
|
-
throw new Autd3Exception("laguerre_gaussian_phase_device failed (waist must be positive)");
|
|
842
|
-
}
|
|
843
|
-
FromNative(native, dst);
|
|
844
|
-
}
|
|
845
|
-
|
|
846
654
|
public static Phase LaguerreGaussianPhaseTransducer(Vector3 position, Vector3 target, Vector3 axis, LaguerreGaussianOption option, Length wavelength)
|
|
847
655
|
{
|
|
848
656
|
if (NativePattern.autd3_pattern_laguerre_gaussian_phase_transducer(
|
|
@@ -850,7 +658,7 @@ namespace AUTD3
|
|
|
850
658
|
Coords.PointArray(target),
|
|
851
659
|
Coords.DirArray(axis), option.P, option.L, option.Waist.Mm, wavelength.Mm, out var p) != 0)
|
|
852
660
|
{
|
|
853
|
-
throw new Autd3Exception("laguerre_gaussian_phase_transducer failed (waist must be positive)");
|
|
661
|
+
throw new Autd3Exception("laguerre_gaussian_phase_transducer failed (waist must be a positive finite length)", Autd3ErrorCode.InvalidArgument);
|
|
854
662
|
}
|
|
855
663
|
return new Phase(p);
|
|
856
664
|
}
|
|
@@ -860,19 +668,8 @@ namespace AUTD3
|
|
|
860
668
|
if (NativePattern.autd3_pattern_laguerre_gaussian_intensity(geometry.Handle, Coords.PointArray(target), Coords.DirArray(axis),
|
|
861
669
|
option.P, option.L, option.Waist.Mm, wavelength.Mm, dst.Handle) != 0)
|
|
862
670
|
{
|
|
863
|
-
throw new Autd3Exception("laguerre_gaussian_intensity failed (waist must be positive and buffer device count must match geometry)");
|
|
864
|
-
}
|
|
865
|
-
}
|
|
866
|
-
|
|
867
|
-
public static void LaguerreGaussianIntensityDevice(Device device, Vector3 target, Vector3 axis, LaguerreGaussianOption option, Length wavelength, Intensity[] dst)
|
|
868
|
-
{
|
|
869
|
-
var native = ToNative(dst);
|
|
870
|
-
if (NativePattern.autd3_pattern_laguerre_gaussian_intensity_device(device.GeometryHandle, device.DeviceIndex,
|
|
871
|
-
Coords.PointArray(target), Coords.DirArray(axis), option.P, option.L, option.Waist.Mm, wavelength.Mm, native) != 0)
|
|
872
|
-
{
|
|
873
|
-
throw new Autd3Exception("laguerre_gaussian_intensity_device failed (waist must be positive)");
|
|
671
|
+
throw new Autd3Exception("laguerre_gaussian_intensity failed (waist must be a positive finite length and buffer device count must match geometry)", Autd3ErrorCode.InvalidArgument);
|
|
874
672
|
}
|
|
875
|
-
FromNative(native, dst);
|
|
876
673
|
}
|
|
877
674
|
|
|
878
675
|
public static void HermiteGaussianPhase(Geometry geometry, Vector3 target, Vector3 axis, Vector3 xDir, HermiteGaussianOption option, Length wavelength, PhaseBuffer dst)
|
|
@@ -880,21 +677,10 @@ namespace AUTD3
|
|
|
880
677
|
if (NativePattern.autd3_pattern_hermite_gaussian_phase(geometry.Handle, Coords.PointArray(target), Coords.DirArray(axis), Coords.DirArray(xDir),
|
|
881
678
|
option.M, option.N, option.Waist.Mm, wavelength.Mm, dst.Handle) != 0)
|
|
882
679
|
{
|
|
883
|
-
throw new Autd3Exception("hermite_gaussian_phase failed (waist must be positive and buffer device count must match geometry)");
|
|
680
|
+
throw new Autd3Exception("hermite_gaussian_phase failed (waist must be a positive finite length and buffer device count must match geometry)", Autd3ErrorCode.InvalidArgument);
|
|
884
681
|
}
|
|
885
682
|
}
|
|
886
683
|
|
|
887
|
-
public static void HermiteGaussianPhaseDevice(Device device, Vector3 target, Vector3 axis, Vector3 xDir, HermiteGaussianOption option, Length wavelength, Phase[] dst)
|
|
888
|
-
{
|
|
889
|
-
var native = ToNative(dst);
|
|
890
|
-
if (NativePattern.autd3_pattern_hermite_gaussian_phase_device(device.GeometryHandle, device.DeviceIndex,
|
|
891
|
-
Coords.PointArray(target), Coords.DirArray(axis), Coords.DirArray(xDir), option.M, option.N, option.Waist.Mm, wavelength.Mm, native) != 0)
|
|
892
|
-
{
|
|
893
|
-
throw new Autd3Exception("hermite_gaussian_phase_device failed (waist must be positive)");
|
|
894
|
-
}
|
|
895
|
-
FromNative(native, dst);
|
|
896
|
-
}
|
|
897
|
-
|
|
898
684
|
public static Phase HermiteGaussianPhaseTransducer(Vector3 position, Vector3 target, Vector3 axis, Vector3 xDir, HermiteGaussianOption option, Length wavelength)
|
|
899
685
|
{
|
|
900
686
|
if (NativePattern.autd3_pattern_hermite_gaussian_phase_transducer(
|
|
@@ -903,7 +689,7 @@ namespace AUTD3
|
|
|
903
689
|
Coords.DirArray(axis),
|
|
904
690
|
Coords.DirArray(xDir), option.M, option.N, option.Waist.Mm, wavelength.Mm, out var p) != 0)
|
|
905
691
|
{
|
|
906
|
-
throw new Autd3Exception("hermite_gaussian_phase_transducer failed (waist must be positive)");
|
|
692
|
+
throw new Autd3Exception("hermite_gaussian_phase_transducer failed (waist must be a positive finite length)", Autd3ErrorCode.InvalidArgument);
|
|
907
693
|
}
|
|
908
694
|
return new Phase(p);
|
|
909
695
|
}
|
|
@@ -913,152 +699,7 @@ namespace AUTD3
|
|
|
913
699
|
if (NativePattern.autd3_pattern_hermite_gaussian_intensity(geometry.Handle, Coords.PointArray(target), Coords.DirArray(axis), Coords.DirArray(xDir),
|
|
914
700
|
option.M, option.N, option.Waist.Mm, wavelength.Mm, dst.Handle) != 0)
|
|
915
701
|
{
|
|
916
|
-
throw new Autd3Exception("hermite_gaussian_intensity failed (waist must be positive and buffer device count must match geometry)");
|
|
917
|
-
}
|
|
918
|
-
}
|
|
919
|
-
|
|
920
|
-
public static void HermiteGaussianIntensityDevice(Device device, Vector3 target, Vector3 axis, Vector3 xDir, HermiteGaussianOption option, Length wavelength, Intensity[] dst)
|
|
921
|
-
{
|
|
922
|
-
var native = ToNative(dst);
|
|
923
|
-
if (NativePattern.autd3_pattern_hermite_gaussian_intensity_device(device.GeometryHandle, device.DeviceIndex,
|
|
924
|
-
Coords.PointArray(target), Coords.DirArray(axis), Coords.DirArray(xDir), option.M, option.N, option.Waist.Mm, wavelength.Mm, native) != 0)
|
|
925
|
-
{
|
|
926
|
-
throw new Autd3Exception("hermite_gaussian_intensity_device failed (waist must be positive)");
|
|
927
|
-
}
|
|
928
|
-
FromNative(native, dst);
|
|
929
|
-
}
|
|
930
|
-
|
|
931
|
-
public static void SetIntensity(Intensity intensity, IntensityBuffer dst)
|
|
932
|
-
{
|
|
933
|
-
if (NativePattern.autd3_pattern_set_intensity(intensity.Value, dst.Handle) != 0)
|
|
934
|
-
{
|
|
935
|
-
throw new Autd3Exception("set_intensity failed");
|
|
936
|
-
}
|
|
937
|
-
}
|
|
938
|
-
|
|
939
|
-
public static void SetPhase(Phase phase, PhaseBuffer dst)
|
|
940
|
-
{
|
|
941
|
-
if (NativePattern.autd3_pattern_set_phase(phase.Value, dst.Handle) != 0)
|
|
942
|
-
{
|
|
943
|
-
throw new Autd3Exception("set_phase failed");
|
|
944
|
-
}
|
|
945
|
-
}
|
|
946
|
-
|
|
947
|
-
public static void AddPhase(Phase phase, PhaseBuffer dst)
|
|
948
|
-
{
|
|
949
|
-
if (NativePattern.autd3_pattern_add_phase(phase.Value, dst.Handle) != 0)
|
|
950
|
-
{
|
|
951
|
-
throw new Autd3Exception("add_phase failed");
|
|
952
|
-
}
|
|
953
|
-
}
|
|
954
|
-
|
|
955
|
-
public static void Group<TKey>(Geometry geometry, TransducerGroups<TKey> groups, Func<TKey, PhaseBuffer> source, PhaseBuffer dst) where TKey : notnull
|
|
956
|
-
{
|
|
957
|
-
using var lease = GroupSources(geometry, groups, key => source(key)?.Handle, dst.Handle);
|
|
958
|
-
if (NativePattern.autd3_pattern_group_phase(geometry.Handle, groups.FlatIndices, lease.Pointers, (UIntPtr)groups.Keys.Count, dst.Handle) != 0)
|
|
959
|
-
{
|
|
960
|
-
throw new Autd3Exception("group failed (every buffer must match the geometry)");
|
|
961
|
-
}
|
|
962
|
-
}
|
|
963
|
-
|
|
964
|
-
public static void Group<TKey>(Geometry geometry, TransducerGroups<TKey> groups, Func<TKey, IntensityBuffer> source, IntensityBuffer dst) where TKey : notnull
|
|
965
|
-
{
|
|
966
|
-
using var lease = GroupSources(geometry, groups, key => source(key)?.Handle, dst.Handle);
|
|
967
|
-
if (NativePattern.autd3_pattern_group_intensity(geometry.Handle, groups.FlatIndices, lease.Pointers, (UIntPtr)groups.Keys.Count, dst.Handle) != 0)
|
|
968
|
-
{
|
|
969
|
-
throw new Autd3Exception("group failed (every buffer must match the geometry)");
|
|
970
|
-
}
|
|
971
|
-
}
|
|
972
|
-
|
|
973
|
-
private static HandleArray GroupSources<TKey>(Geometry geometry, TransducerGroups<TKey> groups, Func<TKey, SafeHandle?> source, SafeHandle dst) where TKey : notnull
|
|
974
|
-
{
|
|
975
|
-
if (groups.FlatIndices.Length != geometry.NumTransducers)
|
|
976
|
-
{
|
|
977
|
-
throw new Autd3Exception("groups must be built from the same geometry");
|
|
978
|
-
}
|
|
979
|
-
var keys = groups.Keys;
|
|
980
|
-
var handles = new SafeHandle[keys.Count];
|
|
981
|
-
for (var i = 0; i < keys.Count; i++)
|
|
982
|
-
{
|
|
983
|
-
var handle = source(keys[i]);
|
|
984
|
-
if (handle == null)
|
|
985
|
-
{
|
|
986
|
-
throw new Autd3Exception($"no source was given for the key {keys[i]}");
|
|
987
|
-
}
|
|
988
|
-
if (ReferenceEquals(handle, dst))
|
|
989
|
-
{
|
|
990
|
-
throw new Autd3Exception("dst must not be one of the sources");
|
|
991
|
-
}
|
|
992
|
-
handles[i] = handle;
|
|
993
|
-
}
|
|
994
|
-
return new HandleArray(handles);
|
|
995
|
-
}
|
|
996
|
-
|
|
997
|
-
public static void GroupCompute<TKey>(Geometry geometry, TransducerGroups<TKey> groups, Action<TKey, TransducerMask, PhaseBuffer, IntensityBuffer> compute, PhaseBuffer phases, IntensityBuffer intensities) where TKey : notnull
|
|
998
|
-
{
|
|
999
|
-
if (compute == null)
|
|
1000
|
-
{
|
|
1001
|
-
throw new ArgumentNullException(nameof(compute));
|
|
1002
|
-
}
|
|
1003
|
-
if (groups.FlatIndices.Length != geometry.NumTransducers)
|
|
1004
|
-
{
|
|
1005
|
-
throw new Autd3Exception("groups must be built from the same geometry");
|
|
1006
|
-
}
|
|
1007
|
-
if (phases.NumDevices != geometry.NumDevices || intensities.NumDevices != geometry.NumDevices)
|
|
1008
|
-
{
|
|
1009
|
-
throw new Autd3Exception("group_compute failed (dst must match the geometry)");
|
|
1010
|
-
}
|
|
1011
|
-
using var scratchPhases = geometry.PhaseBuffer();
|
|
1012
|
-
using var scratchIntensities = geometry.IntensityBuffer();
|
|
1013
|
-
var keys = groups.Keys;
|
|
1014
|
-
for (var i = 0; i < keys.Count; i++)
|
|
1015
|
-
{
|
|
1016
|
-
SetPhase(Phase.Zero, scratchPhases);
|
|
1017
|
-
SetIntensity(Intensity.Max, scratchIntensities);
|
|
1018
|
-
compute(keys[i], groups.MaskOf(i), scratchPhases, scratchIntensities);
|
|
1019
|
-
if (NativePattern.autd3_pattern_group_copy_phase(geometry.Handle, groups.FlatIndices, i, scratchPhases.Handle, phases.Handle) != 0
|
|
1020
|
-
|| NativePattern.autd3_pattern_group_copy_intensity(geometry.Handle, groups.FlatIndices, i, scratchIntensities.Handle, intensities.Handle) != 0)
|
|
1021
|
-
{
|
|
1022
|
-
throw new Autd3Exception("group_compute failed (dst must match the geometry)");
|
|
1023
|
-
}
|
|
1024
|
-
}
|
|
1025
|
-
}
|
|
1026
|
-
|
|
1027
|
-
private static byte[] ToNative(Phase[] dst) => ToNative(dst, p => p.Value);
|
|
1028
|
-
|
|
1029
|
-
private static byte[] ToNative(Intensity[] dst) => ToNative(dst, i => i.Value);
|
|
1030
|
-
|
|
1031
|
-
private static byte[] ToNative<T>(T[] dst, Func<T, byte> value)
|
|
1032
|
-
{
|
|
1033
|
-
if (dst == null)
|
|
1034
|
-
{
|
|
1035
|
-
throw new ArgumentNullException(nameof(dst));
|
|
1036
|
-
}
|
|
1037
|
-
if (dst.Length != Autd3.NumTransducers)
|
|
1038
|
-
{
|
|
1039
|
-
throw new Autd3Exception($"dst requires {Autd3.NumTransducers} elements");
|
|
1040
|
-
}
|
|
1041
|
-
var native = new byte[dst.Length];
|
|
1042
|
-
for (var i = 0; i < dst.Length; i++)
|
|
1043
|
-
{
|
|
1044
|
-
native[i] = value(dst[i]);
|
|
1045
|
-
}
|
|
1046
|
-
return native;
|
|
1047
|
-
}
|
|
1048
|
-
|
|
1049
|
-
private static void FromNative(byte[] native, Phase[] dst)
|
|
1050
|
-
{
|
|
1051
|
-
for (var i = 0; i < dst.Length; i++)
|
|
1052
|
-
{
|
|
1053
|
-
dst[i] = new Phase(native[i]);
|
|
1054
|
-
}
|
|
1055
|
-
}
|
|
1056
|
-
|
|
1057
|
-
private static void FromNative(byte[] native, Intensity[] dst)
|
|
1058
|
-
{
|
|
1059
|
-
for (var i = 0; i < dst.Length; i++)
|
|
1060
|
-
{
|
|
1061
|
-
dst[i] = new Intensity(native[i]);
|
|
702
|
+
throw new Autd3Exception("hermite_gaussian_intensity failed (waist must be a positive finite length and buffer device count must match geometry)", Autd3ErrorCode.InvalidArgument);
|
|
1062
703
|
}
|
|
1063
704
|
}
|
|
1064
705
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/THIRD-PARTY-LICENSES.md
CHANGED
|
@@ -5,7 +5,7 @@ The following is a list of those components and the full text of their licenses.
|
|
|
5
5
|
|
|
6
6
|
## Overview
|
|
7
7
|
|
|
8
|
-
- MIT License (
|
|
8
|
+
- MIT License (27)
|
|
9
9
|
- Apache License 2.0 (3)
|
|
10
10
|
- Unicode License v3 (1)
|
|
11
11
|
|
|
@@ -226,7 +226,7 @@ Used by:
|
|
|
226
226
|
Used by:
|
|
227
227
|
|
|
228
228
|
- nalgebra 0.35.0 — https://github.com/dimforge/nalgebra
|
|
229
|
-
- simba 0.10.
|
|
229
|
+
- simba 0.10.2 — https://github.com/dimforge/simba
|
|
230
230
|
|
|
231
231
|
```
|
|
232
232
|
Apache License
|
|
@@ -511,7 +511,7 @@ DEALINGS IN THE SOFTWARE.
|
|
|
511
511
|
|
|
512
512
|
Used by:
|
|
513
513
|
|
|
514
|
-
- matrixmultiply 0.3.
|
|
514
|
+
- matrixmultiply 0.3.11 — https://github.com/bluss/matrixmultiply/
|
|
515
515
|
|
|
516
516
|
```
|
|
517
517
|
Copyright (c) 2016 - 2023 Ulrik Sverdrup "bluss"
|
|
@@ -548,44 +548,8 @@ DEALINGS IN THE SOFTWARE.
|
|
|
548
548
|
|
|
549
549
|
Used by:
|
|
550
550
|
|
|
551
|
-
-
|
|
552
|
-
-
|
|
553
|
-
|
|
554
|
-
```
|
|
555
|
-
Copyright (c) 2019 Tokio Contributors
|
|
556
|
-
|
|
557
|
-
Permission is hereby granted, free of charge, to any
|
|
558
|
-
person obtaining a copy of this software and associated
|
|
559
|
-
documentation files (the "Software"), to deal in the
|
|
560
|
-
Software without restriction, including without
|
|
561
|
-
limitation the rights to use, copy, modify, merge,
|
|
562
|
-
publish, distribute, sublicense, and/or sell copies of
|
|
563
|
-
the Software, and to permit persons to whom the Software
|
|
564
|
-
is furnished to do so, subject to the following
|
|
565
|
-
conditions:
|
|
566
|
-
|
|
567
|
-
The above copyright notice and this permission notice
|
|
568
|
-
shall be included in all copies or substantial portions
|
|
569
|
-
of the Software.
|
|
570
|
-
|
|
571
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
|
572
|
-
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
573
|
-
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
574
|
-
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
|
|
575
|
-
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
576
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
577
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
|
|
578
|
-
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
579
|
-
DEALINGS IN THE SOFTWARE.
|
|
580
|
-
|
|
581
|
-
```
|
|
582
|
-
|
|
583
|
-
## MIT License
|
|
584
|
-
|
|
585
|
-
Used by:
|
|
586
|
-
|
|
587
|
-
- zerocopy-derive 0.8.52 — https://github.com/google/zerocopy
|
|
588
|
-
- zerocopy 0.8.52 — https://github.com/google/zerocopy
|
|
551
|
+
- zerocopy-derive 0.8.63 — https://github.com/google/zerocopy
|
|
552
|
+
- zerocopy 0.8.63 — https://github.com/google/zerocopy
|
|
589
553
|
|
|
590
554
|
```
|
|
591
555
|
Copyright 2023 The Fuchsia Authors
|
|
@@ -683,7 +647,7 @@ SOFTWARE.
|
|
|
683
647
|
|
|
684
648
|
Used by:
|
|
685
649
|
|
|
686
|
-
- bytemuck 1.25.
|
|
650
|
+
- bytemuck 1.25.2 — https://github.com/Lokathor/bytemuck
|
|
687
651
|
|
|
688
652
|
```
|
|
689
653
|
MIT License
|
|
@@ -702,7 +666,38 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
702
666
|
|
|
703
667
|
Used by:
|
|
704
668
|
|
|
705
|
-
-
|
|
669
|
+
- wide 1.7.1 — https://github.com/Lokathor/wide
|
|
670
|
+
|
|
671
|
+
```
|
|
672
|
+
MIT License
|
|
673
|
+
|
|
674
|
+
Copyright (c) 2020 Daniel "Lokathor" Gee
|
|
675
|
+
|
|
676
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
677
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
678
|
+
in the Software without restriction, including without limitation the rights
|
|
679
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
680
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
681
|
+
furnished to do so, subject to the following conditions:
|
|
682
|
+
|
|
683
|
+
The above copyright notice and this permission notice shall be included in all
|
|
684
|
+
copies or substantial portions of the Software.
|
|
685
|
+
|
|
686
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
687
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
688
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
689
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
690
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
691
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
692
|
+
SOFTWARE.
|
|
693
|
+
|
|
694
|
+
```
|
|
695
|
+
|
|
696
|
+
## MIT License
|
|
697
|
+
|
|
698
|
+
Used by:
|
|
699
|
+
|
|
700
|
+
- safe_arch 1.2.0 — https://github.com/Lokathor/safe_arch
|
|
706
701
|
|
|
707
702
|
```
|
|
708
703
|
MIT License
|
|
@@ -721,9 +716,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
721
716
|
|
|
722
717
|
Used by:
|
|
723
718
|
|
|
724
|
-
- autd3-rs-core 0.
|
|
725
|
-
- autd3-rs-pattern 0.
|
|
726
|
-
- autd3-cpu-wire 0.
|
|
719
|
+
- autd3-rs-core 0.14.0 — https://github.com/shinolab/autd3-sdk
|
|
720
|
+
- autd3-rs-pattern 0.14.0 — https://github.com/shinolab/autd3-sdk
|
|
721
|
+
- autd3-cpu-wire 0.14.0 — https://github.com/shinolab/autd3-sdk
|
|
727
722
|
|
|
728
723
|
```
|
|
729
724
|
MIT License
|
|
@@ -754,9 +749,8 @@ SOFTWARE.
|
|
|
754
749
|
|
|
755
750
|
Used by:
|
|
756
751
|
|
|
757
|
-
- autd3-ffi-abi 0.
|
|
758
|
-
- autd3-ffi-pattern 0.
|
|
759
|
-
- wide 1.5.0 — https://github.com/Lokathor/wide
|
|
752
|
+
- autd3-ffi-abi 0.14.0 — https://github.com/shinolab/autd3-sdk
|
|
753
|
+
- autd3-ffi-pattern 0.14.0 — https://github.com/shinolab/autd3-sdk
|
|
760
754
|
|
|
761
755
|
```
|
|
762
756
|
MIT License
|
|
@@ -784,13 +778,13 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
784
778
|
|
|
785
779
|
Used by:
|
|
786
780
|
|
|
787
|
-
-
|
|
788
|
-
-
|
|
789
|
-
-
|
|
790
|
-
- syn
|
|
791
|
-
- thiserror-impl 2.0.
|
|
792
|
-
- thiserror 2.0.
|
|
793
|
-
- unicode-ident 1.0.
|
|
781
|
+
- proc-macro2 1.0.107 — https://github.com/dtolnay/proc-macro2
|
|
782
|
+
- quote 1.0.47 — https://github.com/dtolnay/quote
|
|
783
|
+
- syn 2.0.119 — https://github.com/dtolnay/syn
|
|
784
|
+
- syn 3.0.9 — https://github.com/dtolnay/syn
|
|
785
|
+
- thiserror-impl 2.0.21 — https://github.com/dtolnay/thiserror
|
|
786
|
+
- thiserror 2.0.21 — https://github.com/dtolnay/thiserror
|
|
787
|
+
- unicode-ident 1.0.27 — https://github.com/dtolnay/unicode-ident
|
|
794
788
|
|
|
795
789
|
```
|
|
796
790
|
Permission is hereby granted, free of charge, to any
|
|
@@ -823,37 +817,6 @@ DEALINGS IN THE SOFTWARE.
|
|
|
823
817
|
|
|
824
818
|
Used by:
|
|
825
819
|
|
|
826
|
-
- tracing-core 0.1.36 — https://github.com/tokio-rs/tracing
|
|
827
|
-
|
|
828
|
-
```
|
|
829
|
-
The MIT License (MIT)
|
|
830
|
-
|
|
831
|
-
Copyright (c) 2014 Mathijs van de Nes
|
|
832
|
-
|
|
833
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
834
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
835
|
-
in the Software without restriction, including without limitation the rights
|
|
836
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
837
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
838
|
-
furnished to do so, subject to the following conditions:
|
|
839
|
-
|
|
840
|
-
The above copyright notice and this permission notice shall be included in all
|
|
841
|
-
copies or substantial portions of the Software.
|
|
842
|
-
|
|
843
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
844
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
845
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
846
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
847
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
848
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
849
|
-
SOFTWARE.
|
|
850
|
-
|
|
851
|
-
```
|
|
852
|
-
|
|
853
|
-
## MIT License
|
|
854
|
-
|
|
855
|
-
Used by:
|
|
856
|
-
|
|
857
820
|
- typenum 1.20.1 — https://github.com/paholg/typenum
|
|
858
821
|
|
|
859
822
|
```
|
|
@@ -885,7 +848,7 @@ SOFTWARE.
|
|
|
885
848
|
|
|
886
849
|
Used by:
|
|
887
850
|
|
|
888
|
-
- unicode-ident 1.0.
|
|
851
|
+
- unicode-ident 1.0.27 — https://github.com/dtolnay/unicode-ident
|
|
889
852
|
|
|
890
853
|
```
|
|
891
854
|
UNICODE LICENSE V3
|
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.
|
|
8
|
+
"version": "0.14.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.
|
|
18
|
+
"com.shinolab.autd3-sdk.core": "0.14.0"
|
|
19
19
|
}
|
|
20
20
|
}
|