com.shinolab.autd3-sdk.pattern 0.9.0 → 0.13.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 +40 -72
- package/Pattern.cs +324 -444
- 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 +53 -239
- package/package.json +2 -2
package/Ops.cs
CHANGED
|
@@ -9,44 +9,49 @@ namespace AUTD3
|
|
|
9
9
|
B1 = 1,
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
public enum
|
|
12
|
+
public enum PhaseDepth : byte
|
|
13
13
|
{
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
Bits8 = 0,
|
|
15
|
+
Bits4 = 1,
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
public static class
|
|
18
|
+
public static class PhaseDepthExt
|
|
19
19
|
{
|
|
20
|
-
public static int
|
|
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
|
|
24
|
+
throw new Autd3Exception($"unknown phase depth {depth}", Autd3ErrorCode.InvalidArgument);
|
|
25
25
|
}
|
|
26
|
-
return (int)
|
|
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
|
-
public sealed class
|
|
37
|
+
public sealed class WritePatternPhase : ICommand
|
|
31
38
|
{
|
|
32
39
|
private readonly PatternBank _bank;
|
|
33
|
-
private readonly
|
|
34
|
-
private readonly
|
|
35
|
-
private readonly
|
|
40
|
+
private readonly ushort _startIndex;
|
|
41
|
+
private readonly PhaseDepth _depth;
|
|
42
|
+
private readonly Intensity _intensity;
|
|
43
|
+
private readonly PhaseBuffer[] _patterns;
|
|
36
44
|
|
|
37
|
-
public
|
|
45
|
+
public WritePatternPhase(PatternBank bank, ushort startIndex, PhaseDepth depth, Intensity intensity, PhaseBuffer[] patterns)
|
|
38
46
|
{
|
|
39
|
-
if (patterns.Length == 0 || patterns.Length > 4)
|
|
40
|
-
{
|
|
41
|
-
throw new Autd3Exception("WritePatternCompressed expects 1..=4 pattern buffers");
|
|
42
|
-
}
|
|
43
47
|
_bank = bank;
|
|
44
|
-
|
|
45
|
-
|
|
48
|
+
_startIndex = startIndex;
|
|
49
|
+
_depth = depth;
|
|
50
|
+
_intensity = intensity;
|
|
46
51
|
_patterns = patterns;
|
|
47
52
|
}
|
|
48
53
|
|
|
49
|
-
IntPtr ICommand.CreateOp()
|
|
54
|
+
IntPtr ICommand.CreateOp(Geometry geometry)
|
|
50
55
|
{
|
|
51
56
|
var handles = new SafeHandle[_patterns.Length];
|
|
52
57
|
for (var i = 0; i < _patterns.Length; i++)
|
|
@@ -54,27 +59,10 @@ namespace AUTD3
|
|
|
54
59
|
handles[i] = _patterns[i].Handle;
|
|
55
60
|
}
|
|
56
61
|
using var lease = new HandleArray(handles);
|
|
57
|
-
return
|
|
62
|
+
return NativePatternOp.autd3_op_write_pattern_phase((byte)_bank, _startIndex, _depth.ToBits(), _intensity.Value, lease.Pointers, (UIntPtr)lease.Pointers.Length);
|
|
58
63
|
}
|
|
59
64
|
}
|
|
60
65
|
|
|
61
|
-
public sealed class WritePatternBuffer : ICommand
|
|
62
|
-
{
|
|
63
|
-
private readonly PatternBank _bank;
|
|
64
|
-
private readonly ushort _index;
|
|
65
|
-
private readonly PatternBuffer _buffer;
|
|
66
|
-
|
|
67
|
-
public WritePatternBuffer(PatternBank bank, ushort index, PatternBuffer emissions)
|
|
68
|
-
{
|
|
69
|
-
_bank = bank;
|
|
70
|
-
_index = index;
|
|
71
|
-
_buffer = emissions;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
IntPtr ICommand.CreateOp() =>
|
|
75
|
-
NativePattern.autd3_op_write_pattern_buffer((byte)_bank, _index, _buffer.Handle);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
66
|
public sealed class ConfigPattern : ICommand
|
|
79
67
|
{
|
|
80
68
|
private readonly PatternBank _bank;
|
|
@@ -82,26 +70,16 @@ namespace AUTD3
|
|
|
82
70
|
private readonly uint _size;
|
|
83
71
|
private readonly LoopBehavior _loopBehavior;
|
|
84
72
|
|
|
85
|
-
public ConfigPattern(PatternBank bank, SamplingConfig config, uint size, LoopBehavior
|
|
73
|
+
public ConfigPattern(PatternBank bank, SamplingConfig config, uint size, LoopBehavior loopBehavior)
|
|
86
74
|
{
|
|
87
75
|
_bank = bank;
|
|
88
76
|
_config = config;
|
|
89
77
|
_size = size;
|
|
90
|
-
_loopBehavior = loopBehavior
|
|
78
|
+
_loopBehavior = loopBehavior;
|
|
91
79
|
}
|
|
92
80
|
|
|
93
|
-
IntPtr ICommand.CreateOp()
|
|
94
|
-
|
|
95
|
-
var sampling = _config.CreateHandle();
|
|
96
|
-
try
|
|
97
|
-
{
|
|
98
|
-
return NativePattern.autd3_op_config_pattern((byte)_bank, sampling, _size, _loopBehavior.Rep);
|
|
99
|
-
}
|
|
100
|
-
finally
|
|
101
|
-
{
|
|
102
|
-
NativeCore.autd3_core_sampling_config_free(sampling);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
81
|
+
IntPtr ICommand.CreateOp(Geometry geometry) =>
|
|
82
|
+
NativePatternOp.autd3_op_config_pattern((byte)_bank, _config.DivideForNative(), _size, _loopBehavior.Rep);
|
|
105
83
|
}
|
|
106
84
|
|
|
107
85
|
public sealed class ConfigFociStm : ICommand
|
|
@@ -113,42 +91,32 @@ namespace AUTD3
|
|
|
113
91
|
private readonly Velocity _soundSpeed;
|
|
114
92
|
private readonly LoopBehavior _loopBehavior;
|
|
115
93
|
|
|
116
|
-
public ConfigFociStm(PatternBank bank, SamplingConfig config, uint size, byte numFoci, Velocity
|
|
94
|
+
public ConfigFociStm(PatternBank bank, SamplingConfig config, uint size, byte numFoci, Velocity soundSpeed, LoopBehavior loopBehavior)
|
|
117
95
|
{
|
|
118
96
|
_bank = bank;
|
|
119
97
|
_config = config;
|
|
120
98
|
_size = size;
|
|
121
99
|
_numFoci = numFoci;
|
|
122
|
-
_soundSpeed = soundSpeed
|
|
123
|
-
_loopBehavior = loopBehavior
|
|
100
|
+
_soundSpeed = soundSpeed;
|
|
101
|
+
_loopBehavior = loopBehavior;
|
|
124
102
|
}
|
|
125
103
|
|
|
126
|
-
IntPtr ICommand.CreateOp()
|
|
127
|
-
|
|
128
|
-
var sampling = _config.CreateHandle();
|
|
129
|
-
try
|
|
130
|
-
{
|
|
131
|
-
return NativePattern.autd3_op_config_foci_stm((byte)_bank, sampling, _size, _numFoci, _soundSpeed.MS, _loopBehavior.Rep);
|
|
132
|
-
}
|
|
133
|
-
finally
|
|
134
|
-
{
|
|
135
|
-
NativeCore.autd3_core_sampling_config_free(sampling);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
104
|
+
IntPtr ICommand.CreateOp(Geometry geometry) =>
|
|
105
|
+
NativePatternOp.autd3_op_config_foci_stm((byte)_bank, _config.DivideForNative(), _size, _numFoci, _soundSpeed.MS, _loopBehavior.Rep);
|
|
138
106
|
}
|
|
139
107
|
|
|
140
|
-
public sealed class
|
|
108
|
+
public sealed class ActivatePatternBank : ICommand
|
|
141
109
|
{
|
|
142
110
|
private readonly PatternBank _bank;
|
|
143
111
|
private readonly TransitionMode _transitionMode;
|
|
144
112
|
|
|
145
|
-
public
|
|
113
|
+
public ActivatePatternBank(PatternBank bank, TransitionMode transitionMode)
|
|
146
114
|
{
|
|
147
115
|
_bank = bank;
|
|
148
|
-
_transitionMode = transitionMode
|
|
116
|
+
_transitionMode = transitionMode;
|
|
149
117
|
}
|
|
150
118
|
|
|
151
|
-
IntPtr ICommand.CreateOp() =>
|
|
152
|
-
|
|
119
|
+
IntPtr ICommand.CreateOp(Geometry geometry) =>
|
|
120
|
+
NativePatternOp.autd3_op_activate_pattern_bank((byte)_bank, _transitionMode.Mode, _transitionMode.Value);
|
|
153
121
|
}
|
|
154
122
|
}
|