com.shinolab.autd3-sdk.modulation 0.6.0 → 0.7.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/Modulation.cs CHANGED
@@ -27,79 +27,92 @@ namespace AUTD3
27
27
  NativeAbi.Verify(ClientLib, autd3capi_abi_version());
28
28
  }
29
29
 
30
- [DllImport(Lib)]
30
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
31
31
  private static extern uint autd3_abi_version();
32
32
 
33
- [DllImport(ClientLib, EntryPoint = "autd3_abi_version")]
33
+ [DllImport(ClientLib, EntryPoint = "autd3_abi_version", CallingConvention = CallingConvention.Cdecl)]
34
34
  private static extern uint autd3capi_abi_version();
35
35
 
36
- [DllImport(Lib)]
36
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
37
37
  internal static extern IntPtr autd3_modulation_buffer_new();
38
38
 
39
- [DllImport(Lib)]
39
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
40
40
  internal static extern IntPtr autd3_modulation_buffer_from_bytes(byte[] data, UIntPtr len);
41
41
 
42
- [DllImport(Lib)]
43
- internal static extern UIntPtr autd3_modulation_buffer_len(IntPtr buffer);
42
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
43
+ internal static extern UIntPtr autd3_modulation_buffer_len(ModulationBufferHandle buffer);
44
44
 
45
- [DllImport(Lib)]
46
- internal static extern int autd3_modulation_buffer_get(IntPtr buffer, UIntPtr index, out byte @out);
45
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
46
+ internal static extern int autd3_modulation_buffer_get(ModulationBufferHandle buffer, UIntPtr index, out byte @out);
47
47
 
48
- [DllImport(Lib)]
49
- internal static extern int autd3_modulation_buffer_set(IntPtr buffer, UIntPtr index, byte value);
48
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
49
+ internal static extern int autd3_modulation_buffer_set(ModulationBufferHandle buffer, UIntPtr index, byte value);
50
50
 
51
- [DllImport(Lib)]
51
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
52
52
  internal static extern void autd3_modulation_buffer_free(IntPtr buffer);
53
53
 
54
- [DllImport(Lib)]
54
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
55
55
  [return: MarshalAs(UnmanagedType.I1)]
56
56
  internal static extern bool autd3_modulation_samples_per_period(ushort divider, uint freqHz, out uint outValue);
57
57
 
58
- [DllImport(Lib)]
58
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
59
59
  internal static extern IntPtr autd3_modulation_sine_option_new(byte amplitude, byte offset, float phase, [MarshalAs(UnmanagedType.I1)] bool clamp, IntPtr samplingConfig);
60
60
 
61
- [DllImport(Lib)]
61
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
62
62
  internal static extern void autd3_modulation_sine_option_free(IntPtr option);
63
63
 
64
- [DllImport(Lib)]
65
- internal static extern int autd3_modulation_sine(byte mode, float freq, uint freqInt, IntPtr option, IntPtr buffer, byte[] outErr, UIntPtr outErrLen);
64
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
65
+ internal static extern int autd3_modulation_sine(byte mode, float freq, uint freqInt, IntPtr option, ModulationBufferHandle buffer, byte[] outErr, UIntPtr outErrLen);
66
66
 
67
- [DllImport(Lib)]
67
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
68
68
  internal static extern IntPtr autd3_modulation_square_option_new(byte low, byte high, float duty, IntPtr samplingConfig);
69
69
 
70
- [DllImport(Lib)]
70
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
71
71
  internal static extern void autd3_modulation_square_option_free(IntPtr option);
72
72
 
73
- [DllImport(Lib)]
74
- internal static extern int autd3_modulation_square(byte mode, float freq, uint freqInt, IntPtr option, IntPtr buffer, byte[] outErr, UIntPtr outErrLen);
73
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
74
+ internal static extern int autd3_modulation_square(byte mode, float freq, uint freqInt, IntPtr option, ModulationBufferHandle buffer, byte[] outErr, UIntPtr outErrLen);
75
75
 
76
- [DllImport(Lib)]
76
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
77
77
  internal static extern IntPtr autd3_modulation_fourier_option_new([MarshalAs(UnmanagedType.I1)] bool hasScaleFactor, float scaleFactor, [MarshalAs(UnmanagedType.I1)] bool clamp, byte offset);
78
78
 
79
- [DllImport(Lib)]
79
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
80
80
  internal static extern void autd3_modulation_fourier_option_free(IntPtr option);
81
81
 
82
- [DllImport(Lib)]
83
- internal static extern int autd3_modulation_fourier(SineComponentNative[] components, UIntPtr numComponents, IntPtr option, IntPtr buffer, byte[] outErr, UIntPtr outErrLen);
82
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
83
+ internal static extern int autd3_modulation_fourier(SineComponentNative[] components, UIntPtr numComponents, IntPtr option, ModulationBufferHandle buffer, byte[] outErr, UIntPtr outErrLen);
84
84
 
85
- [DllImport(Lib)]
86
- internal static extern int autd3_modulation_constant(byte intensity, IntPtr buffer);
85
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
86
+ internal static extern int autd3_modulation_constant(byte intensity, ModulationBufferHandle buffer);
87
87
 
88
- [DllImport(Lib)]
89
- internal static extern int autd3_modulation_radiation_pressure(IntPtr src, IntPtr dst);
88
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
89
+ internal static extern int autd3_modulation_radiation_pressure(ModulationBufferHandle src, ModulationBufferHandle dst);
90
90
 
91
- [DllImport(Lib)]
92
- internal static extern int autd3_modulation_radiation_pressure_inplace(IntPtr buffer);
91
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
92
+ internal static extern int autd3_modulation_radiation_pressure_inplace(ModulationBufferHandle buffer);
93
93
 
94
- [DllImport(ClientLib)]
95
- internal static extern IntPtr autd3_op_modulation(byte bank, IntPtr samplingConfig, IntPtr modulationBuffer, ushort loopRep, byte transitionMode, ulong transitionValue, uint transitionMarginNs);
94
+ [DllImport(ClientLib, CallingConvention = CallingConvention.Cdecl)]
95
+ internal static extern IntPtr autd3_op_modulation(byte bank, IntPtr samplingConfig, ModulationBufferHandle modulationBuffer, ushort loopRep, byte transitionMode, ulong transitionValue, uint transitionMarginNs);
96
+ }
97
+
98
+ internal sealed class ModulationBufferHandle : Autd3SafeHandle
99
+ {
100
+ internal ModulationBufferHandle(IntPtr handle) : base(handle)
101
+ {
102
+ }
103
+
104
+ protected override bool ReleaseHandle()
105
+ {
106
+ NativeModulation.autd3_modulation_buffer_free(handle);
107
+ return true;
108
+ }
96
109
  }
97
110
 
98
111
  public sealed class ModulationBuffer : IDisposable, IEnumerable<byte>
99
112
  {
100
- private IntPtr _handle;
113
+ private readonly ModulationBufferHandle _handle;
101
114
 
102
- internal IntPtr Handle => _handle;
115
+ internal ModulationBufferHandle Handle => _handle;
103
116
 
104
117
  private ModulationBuffer(IntPtr handle)
105
118
  {
@@ -107,7 +120,7 @@ namespace AUTD3
107
120
  {
108
121
  throw new Autd3Exception("failed to create modulation buffer");
109
122
  }
110
- _handle = handle;
123
+ _handle = new ModulationBufferHandle(handle);
111
124
  }
112
125
 
113
126
  internal ModulationBuffer() : this(NativeModulation.autd3_modulation_buffer_new())
@@ -151,24 +164,7 @@ namespace AUTD3
151
164
 
152
165
  IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
153
166
 
154
- public void Dispose()
155
- {
156
- var handle = Interlocked.Exchange(ref _handle, IntPtr.Zero);
157
- if (handle != IntPtr.Zero)
158
- {
159
- NativeModulation.autd3_modulation_buffer_free(handle);
160
- }
161
- GC.SuppressFinalize(this);
162
- }
163
-
164
- ~ModulationBuffer()
165
- {
166
- var handle = Interlocked.Exchange(ref _handle, IntPtr.Zero);
167
- if (handle != IntPtr.Zero)
168
- {
169
- NativeModulation.autd3_modulation_buffer_free(handle);
170
- }
171
- }
167
+ public void Dispose() => _handle.Dispose();
172
168
  }
173
169
 
174
170
  public readonly struct SineOption
@@ -309,7 +305,7 @@ namespace AUTD3
309
305
  try
310
306
  {
311
307
  var optionHandle = NativeModulation.autd3_modulation_sine_option_new(
312
- option.Amplitude, option.Offset, option.Phase.Radian, option.Clamp, sampling);
308
+ option.Amplitude, option.Offset, option.Phase.Rad, option.Clamp, sampling);
313
309
  try
314
310
  {
315
311
  var err = new byte[NativeAbi.ErrorBufferLength];
@@ -382,7 +378,7 @@ namespace AUTD3
382
378
  var sampling = c.Option.SamplingConfig.CreateHandle();
383
379
  samplingHandles.Add(sampling);
384
380
  var optionHandle = NativeModulation.autd3_modulation_sine_option_new(
385
- c.Option.Amplitude, c.Option.Offset, c.Option.Phase.Radian, c.Option.Clamp, sampling);
381
+ c.Option.Amplitude, c.Option.Offset, c.Option.Phase.Rad, c.Option.Clamp, sampling);
386
382
  optionHandles.Add(optionHandle);
387
383
  native[i] = new SineComponentNative
388
384
  {
package/ModulationOps.cs CHANGED
@@ -15,16 +15,16 @@ namespace AUTD3
15
15
 
16
16
  static NativeModulationOp() => NativeAbi.Verify(Lib, autd3_abi_version());
17
17
 
18
- [DllImport(Lib)]
18
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
19
19
  private static extern uint autd3_abi_version();
20
20
 
21
- [DllImport(Lib)]
22
- internal static extern IntPtr autd3_op_write_modulation_buffer(byte bank, uint offset, IntPtr modulationBuffer);
21
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
22
+ internal static extern IntPtr autd3_op_write_modulation_buffer(byte bank, uint offset, ModulationBufferHandle modulationBuffer);
23
23
 
24
- [DllImport(Lib)]
24
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
25
25
  internal static extern IntPtr autd3_op_config_modulation(byte bank, IntPtr samplingConfig, uint size, ushort rep);
26
26
 
27
- [DllImport(Lib)]
27
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
28
28
  internal static extern IntPtr autd3_op_change_modulation_bank(byte bank, byte transitionMode, ulong transitionValue, uint transitionMarginNs);
29
29
  }
30
30
 
@@ -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 (50)
8
+ - MIT License (51)
9
9
  - Apache License 2.0 (3)
10
10
  - Unicode License v3 (1)
11
11
 
@@ -854,8 +854,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
854
854
 
855
855
  Used by:
856
856
 
857
- - autd3-rs-core 0.6.0 — https://github.com/shinolab/autd3-sdk
858
- - autd3-rs-modulation 0.6.0 — https://github.com/shinolab/autd3-sdk
857
+ - autd3-rs-core 0.7.0 — https://github.com/shinolab/autd3-sdk
858
+ - autd3-rs-modulation 0.7.0 — https://github.com/shinolab/autd3-sdk
859
859
  - autd3-cpu-wire 0.6.0 — https://github.com/shinolab/autd3-sdk
860
860
 
861
861
  ```
@@ -887,8 +887,8 @@ SOFTWARE.
887
887
 
888
888
  Used by:
889
889
 
890
- - autd3-ffi-abi 0.6.0 — https://github.com/shinolab/autd3-sdk
891
- - autd3-ffi-modulation 0.6.0 — https://github.com/shinolab/autd3-sdk
890
+ - autd3-ffi-abi 0.7.0 — https://github.com/shinolab/autd3-sdk
891
+ - autd3-ffi-modulation 0.7.0 — https://github.com/shinolab/autd3-sdk
892
892
  - chrono 0.4.45 — https://github.com/chronotope/chrono
893
893
  - wide 1.5.0 — https://github.com/Lokathor/wide
894
894
  - winapi-i686-pc-windows-gnu 0.4.0 — https://github.com/retep998/winapi-rs
@@ -972,6 +972,37 @@ DEALINGS IN THE SOFTWARE.
972
972
 
973
973
  Used by:
974
974
 
975
+ - tracing-core 0.1.36 — https://github.com/tokio-rs/tracing
976
+
977
+ ```
978
+ The MIT License (MIT)
979
+
980
+ Copyright (c) 2014 Mathijs van de Nes
981
+
982
+ Permission is hereby granted, free of charge, to any person obtaining a copy
983
+ of this software and associated documentation files (the "Software"), to deal
984
+ in the Software without restriction, including without limitation the rights
985
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
986
+ copies of the Software, and to permit persons to whom the Software is
987
+ furnished to do so, subject to the following conditions:
988
+
989
+ The above copyright notice and this permission notice shall be included in all
990
+ copies or substantial portions of the Software.
991
+
992
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
993
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
994
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
995
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
996
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
997
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
998
+ SOFTWARE.
999
+
1000
+ ```
1001
+
1002
+ ## MIT License
1003
+
1004
+ Used by:
1005
+
975
1006
  - typenum 1.20.1 — https://github.com/paholg/typenum
976
1007
 
977
1008
  ```
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.modulation"
7
7
  },
8
- "version": "0.6.0",
8
+ "version": "0.7.0",
9
9
  "displayName": "AUTD3 Modulation",
10
10
  "description": "AUTD3 amplitude modulation waveforms (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.6.0"
18
+ "com.shinolab.autd3-sdk.core": "0.7.0"
19
19
  }
20
20
  }