-
Notifications
You must be signed in to change notification settings - Fork 9
/
CVec.cs
126 lines (95 loc) · 3.37 KB
/
CVec.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
using System;
using System.Runtime.InteropServices;
using JetBrains.Annotations;
namespace Aubio.NET.Collections
{
public sealed class CVec : AubioObject
{
#region Fields
private readonly unsafe CVec__* _cVec;
#endregion
#region Constructors
internal unsafe CVec([NotNull] CVec__* cVec)
{
if (cVec == null)
throw new ArgumentNullException(nameof(cVec));
_cVec = cVec;
Norm = new CVecBufferNorm(this, cVec->Norm, cVec->Length.ToInt32());
Phas = new CVecBufferNorm(this, cVec->Norm, cVec->Length.ToInt32());
}
[PublicAPI]
public unsafe CVec(int length)
: this(new_cvec(length.ToUInt32()))
{
}
#endregion
#region AubioObject members
protected override void DisposeNative()
{
del_cvec(this);
}
internal override unsafe IntPtr ToPointer()
{
return new IntPtr(_cVec);
}
#endregion
#region Public members
[PublicAPI]
public unsafe int Length => _cVec->Length.ToInt32();
[PublicAPI]
public CVecBuffer Norm { get; }
[PublicAPI]
public CVecBuffer Phas { get; }
[PublicAPI]
public void Copy([NotNull] CVec target)
{
if (target == null)
throw new ArgumentNullException(nameof(target));
cvec_copy(this, target);
}
[PublicAPI]
public void LogMag(float lambda)
{
cvec_logmag(this, lambda);
}
[PublicAPI]
public void Print()
{
cvec_print(this);
}
[PublicAPI]
public void Zeros()
{
cvec_zeros(this);
}
#endregion
#region Native methods
[DllImport("aubio", CallingConvention = CallingConvention.Cdecl)]
private static extern unsafe CVec__* new_cvec(
uint length
);
[DllImport("aubio", CallingConvention = CallingConvention.Cdecl)]
private static extern void del_cvec(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(AubioObjectMarshaler))] CVec cVec
);
[DllImport("aubio", CallingConvention = CallingConvention.Cdecl)]
private static extern void cvec_copy(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(AubioObjectMarshaler))] CVec cVec,
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(AubioObjectMarshaler))] CVec target
);
[DllImport("aubio", CallingConvention = CallingConvention.Cdecl)]
private static extern void cvec_logmag(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(AubioObjectMarshaler))] CVec cVec,
float lambda
);
[DllImport("aubio", CallingConvention = CallingConvention.Cdecl)]
private static extern void cvec_print(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(AubioObjectMarshaler))] CVec cVec
);
[DllImport("aubio", CallingConvention = CallingConvention.Cdecl)]
private static extern void cvec_zeros(
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(AubioObjectMarshaler))] CVec cVec
);
#endregion
}
}