Skip to content

Commit dc4fce9

Browse files
committed
Add public documentation
1 parent 51bfc1a commit dc4fce9

File tree

86 files changed

+1715
-76
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+1715
-76
lines changed

src/NPlug.CodeGen/CodeGenerator.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,13 @@ public void Generate(string destinationFolder)
121121

122122
// Prepare for the C# generated file
123123
var csFile = new CSharpGeneratedFile("/LibVst.generated.cs");
124-
csFile.Members.Add(new CSharpFreeMember() { Text = "#pragma warning disable CS0649" });
124+
csFile.Members.Add(new CSharpFreeMember() { Text = @"#pragma warning disable CS0649
125+
#pragma warning disable CS1658
126+
#pragma warning disable CS1570
127+
#pragma warning disable CS1573
128+
#pragma warning disable CS1574
129+
#pragma warning disable CS1584
130+
" });
125131
csFile.Members.Add(new CSharpNamespace("NPlug.Interop") { IsFileScoped = true });
126132
csFile.Members.Add(new CSharpUsingDeclaration("System.Collections.Generic"));
127133
csFile.Members.Add(new CSharpUsingDeclaration("System.Diagnostics.CodeAnalysis"));

src/NPlug/AudioAttributeList.cs

+139
Original file line numberDiff line numberDiff line change
@@ -8,135 +8,274 @@
88

99
namespace NPlug;
1010

11+
/// <summary>
12+
/// A list of attribute used to communicate with the host (e.g via message).
13+
/// </summary>
1114
public readonly ref struct AudioAttributeList
1215
{
1316
private readonly IAudioAttributeListBackend? _backend;
1417
internal readonly IntPtr NativeContext;
18+
19+
/// <summary>
20+
/// Creates a new instance.
21+
/// </summary>
1522
public AudioAttributeList(IAudioAttributeListBackend? backend, IntPtr nativeContext)
1623
{
1724
_backend = backend;
1825
NativeContext = nativeContext;
1926
}
2027

28+
/// <summary>
29+
/// Tries to set a value for the specified attribute.
30+
/// </summary>
31+
/// <param name="attributeId">The name of the attribute.</param>
32+
/// <param name="value">The value to set.</param>
33+
/// <returns><c>true</c> if the value was successfully set; <c>false</c> otherwise</returns>
2134
public bool TrySetBool(string attributeId, bool value)
2235
{
2336
return TrySetInt64(attributeId, value ? 1 : 0);
2437
}
2538

39+
/// <summary>
40+
/// Tries to get a value for the specified attribute.
41+
/// </summary>
42+
/// <param name="attributeId">The name of the attribute.</param>
43+
/// <param name="value">The value to get.</param>
44+
/// <returns><c>true</c> if the value was successfully get; <c>false</c> otherwise</returns>
2645
public bool TryGetBool(string attributeId, out bool value)
2746
{
2847
var result = TryGetInt64(attributeId, out var intValue);
2948
value = intValue != 0;
3049
return result;
3150
}
3251

52+
/// <summary>
53+
/// Tries to set a value for the specified attribute.
54+
/// </summary>
55+
/// <param name="attributeId">The name of the attribute.</param>
56+
/// <param name="value">The value to set.</param>
57+
/// <returns><c>true</c> if the value was successfully set; <c>false</c> otherwise</returns>
3358
public bool TrySetByte(string attributeId, byte value)
3459
{
3560
return TrySetInt64(attributeId, value);
3661
}
3762

63+
/// <summary>
64+
/// Tries to get a value for the specified attribute.
65+
/// </summary>
66+
/// <param name="attributeId">The name of the attribute.</param>
67+
/// <param name="value">The value to get.</param>
68+
/// <returns><c>true</c> if the value was successfully get; <c>false</c> otherwise</returns>
3869
public bool TryGetByte(string attributeId, out byte value)
3970
{
4071
var result = TryGetInt64(attributeId, out var intValue);
4172
value = (byte)intValue;
4273
return result;
4374
}
4475

76+
/// <summary>
77+
/// Tries to set a value for the specified attribute.
78+
/// </summary>
79+
/// <param name="attributeId">The name of the attribute.</param>
80+
/// <param name="value">The value to set.</param>
81+
/// <returns><c>true</c> if the value was successfully set; <c>false</c> otherwise</returns>
4582
public bool TrySetInt16(string attributeId, short value)
4683
{
4784
return TrySetInt64(attributeId, value);
4885
}
4986

87+
/// <summary>
88+
/// Tries to get a value for the specified attribute.
89+
/// </summary>
90+
/// <param name="attributeId">The name of the attribute.</param>
91+
/// <param name="value">The value to get.</param>
92+
/// <returns><c>true</c> if the value was successfully get; <c>false</c> otherwise</returns>
5093
public bool TryGetInt16(string attributeId, out short value)
5194
{
5295
var result = TryGetInt64(attributeId, out var intValue);
5396
value = (short)intValue;
5497
return result;
5598
}
5699

100+
/// <summary>
101+
/// Tries to set a value for the specified attribute.
102+
/// </summary>
103+
/// <param name="attributeId">The name of the attribute.</param>
104+
/// <param name="value">The value to set.</param>
105+
/// <returns><c>true</c> if the value was successfully set; <c>false</c> otherwise</returns>
57106
public bool TrySetUInt16(string attributeId, ushort value)
58107
{
59108
return TrySetInt64(attributeId, value);
60109
}
61110

111+
/// <summary>
112+
/// Tries to get a value for the specified attribute.
113+
/// </summary>
114+
/// <param name="attributeId">The name of the attribute.</param>
115+
/// <param name="value">The value to get.</param>
116+
/// <returns><c>true</c> if the value was successfully get; <c>false</c> otherwise</returns>
62117
public bool TryGetUInt16(string attributeId, out ushort value)
63118
{
64119
var result = TryGetInt64(attributeId, out var intValue);
65120
value = (ushort)intValue;
66121
return result;
67122
}
68123

124+
/// <summary>
125+
/// Tries to set a value for the specified attribute.
126+
/// </summary>
127+
/// <param name="attributeId">The name of the attribute.</param>
128+
/// <param name="value">The value to set.</param>
129+
/// <returns><c>true</c> if the value was successfully set; <c>false</c> otherwise</returns>
69130
public bool TrySetUInt32(string attributeId, uint value)
70131
{
71132
return TrySetInt64(attributeId, value);
72133
}
73134

135+
/// <summary>
136+
/// Tries to get a value for the specified attribute.
137+
/// </summary>
138+
/// <param name="attributeId">The name of the attribute.</param>
139+
/// <param name="value">The value to get.</param>
140+
/// <returns><c>true</c> if the value was successfully get; <c>false</c> otherwise</returns>
74141
public bool TryGetUInt32(string attributeId, out uint value)
75142
{
76143
var result = TryGetInt64(attributeId, out var intValue);
77144
value = unchecked((uint)intValue);
78145
return result;
79146
}
80147

148+
/// <summary>
149+
/// Tries to set a value for the specified attribute.
150+
/// </summary>
151+
/// <param name="attributeId">The name of the attribute.</param>
152+
/// <param name="value">The value to set.</param>
153+
/// <returns><c>true</c> if the value was successfully set; <c>false</c> otherwise</returns>
81154
public bool TrySetInt32(string attributeId, int value)
82155
{
83156
return TrySetInt64(attributeId, value);
84157
}
85158

159+
/// <summary>
160+
/// Tries to get a value for the specified attribute.
161+
/// </summary>
162+
/// <param name="attributeId">The name of the attribute.</param>
163+
/// <param name="value">The value to get.</param>
164+
/// <returns><c>true</c> if the value was successfully get; <c>false</c> otherwise</returns>
86165
public bool TryGetInt32(string attributeId, out int value)
87166
{
88167
var result = TryGetInt64(attributeId, out var intValue);
89168
value = unchecked((int)intValue);
90169
return result;
91170
}
92171

172+
/// <summary>
173+
/// Tries to set a value for the specified attribute.
174+
/// </summary>
175+
/// <param name="attributeId">The name of the attribute.</param>
176+
/// <param name="value">The value to set.</param>
177+
/// <returns><c>true</c> if the value was successfully set; <c>false</c> otherwise</returns>
93178
public bool TrySetFloat32(string attributeId, float value)
94179
{
95180
return TrySetFloat64(attributeId, value);
96181
}
97182

183+
/// <summary>
184+
/// Tries to get a value for the specified attribute.
185+
/// </summary>
186+
/// <param name="attributeId">The name of the attribute.</param>
187+
/// <param name="value">The value to get.</param>
188+
/// <returns><c>true</c> if the value was successfully get; <c>false</c> otherwise</returns>
98189
public bool TryGetFloat32(string attributeId, out float value)
99190
{
100191
var result = TryGetFloat64(attributeId, out var doubleValue);
101192
value = (float)doubleValue;
102193
return result;
103194
}
104195

196+
/// <summary>
197+
/// Tries to set a value for the specified attribute.
198+
/// </summary>
199+
/// <param name="attributeId">The name of the attribute.</param>
200+
/// <param name="value">The value to set.</param>
201+
/// <returns><c>true</c> if the value was successfully set; <c>false</c> otherwise</returns>
105202
public bool TrySetInt64(string attributeId, long value)
106203
{
107204
return GetSafeBackend().TrySetInt64(this, attributeId, value);
108205
}
109206

207+
/// <summary>
208+
/// Tries to get a value for the specified attribute.
209+
/// </summary>
210+
/// <param name="attributeId">The name of the attribute.</param>
211+
/// <param name="value">The value to get.</param>
212+
/// <returns><c>true</c> if the value was successfully get; <c>false</c> otherwise</returns>
110213
public bool TryGetInt64(string attributeId, out long value)
111214
{
112215
return GetSafeBackend().TryGetInt64(this, attributeId, out value);
113216
}
114217

218+
/// <summary>
219+
/// Tries to set a value for the specified attribute.
220+
/// </summary>
221+
/// <param name="attributeId">The name of the attribute.</param>
222+
/// <param name="value">The value to set.</param>
223+
/// <returns><c>true</c> if the value was successfully set; <c>false</c> otherwise</returns>
115224
public bool TrySetFloat64(string attributeId, double value)
116225
{
117226
return GetSafeBackend().TrySetFloat64(this, attributeId, value);
118227
}
119228

229+
/// <summary>
230+
/// Tries to get a value for the specified attribute.
231+
/// </summary>
232+
/// <param name="attributeId">The name of the attribute.</param>
233+
/// <param name="value">The value to get.</param>
234+
/// <returns><c>true</c> if the value was successfully get; <c>false</c> otherwise</returns>
120235
public bool TryGetFloat64(string attributeId, out double value)
121236
{
122237
return GetSafeBackend().TryGetFloat64(this, attributeId, out value);
123238
}
124239

240+
/// <summary>
241+
/// Tries to set a value for the specified attribute.
242+
/// </summary>
243+
/// <param name="attributeId">The name of the attribute.</param>
244+
/// <param name="value">The value to set.</param>
245+
/// <returns><c>true</c> if the value was successfully set; <c>false</c> otherwise</returns>
125246
public bool TrySetString(string attributeId, string value)
126247
{
127248
return GetSafeBackend().TrySetString(this, attributeId, value);
128249
}
129250

251+
/// <summary>
252+
/// Tries to get a value for the specified attribute.
253+
/// </summary>
254+
/// <param name="attributeId">The name of the attribute.</param>
255+
/// <param name="value">The value to get.</param>
256+
/// <returns><c>true</c> if the value was successfully get; <c>false</c> otherwise</returns>
130257
public bool TryGetString(string attributeId, out string value)
131258
{
132259
return GetSafeBackend().TryGetString(this, attributeId, out value);
133260
}
134261

262+
/// <summary>
263+
/// Tries to set a value for the specified attribute.
264+
/// </summary>
265+
/// <param name="attributeId">The name of the attribute.</param>
266+
/// <param name="value">The value to set.</param>
267+
/// <returns><c>true</c> if the value was successfully set; <c>false</c> otherwise</returns>
135268
public bool TrySetBinary(string attributeId, ReadOnlySpan<byte> value)
136269
{
137270
return GetSafeBackend().TrySetBinary(this, attributeId, value);
138271
}
139272

273+
/// <summary>
274+
/// Tries to get a value for the specified attribute.
275+
/// </summary>
276+
/// <param name="attributeId">The name of the attribute.</param>
277+
/// <param name="value">The value to get.</param>
278+
/// <returns><c>true</c> if the value was successfully get; <c>false</c> otherwise</returns>
140279
[UnscopedRef]
141280
public bool TryGetBinary(string attributeId, out ReadOnlySpan<byte> value)
142281
{

src/NPlug/AudioBoolParameter.cs

+12
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,29 @@
44

55
namespace NPlug;
66

7+
/// <summary>
8+
/// A boolean <see cref="AudioParameter"/> that maps <c>true</c> to 1.0 and false to 0.0.
9+
/// </summary>
710
public class AudioBoolParameter : AudioParameter
811
{
12+
/// <summary>
13+
/// Creates a new instance of this parameter.
14+
/// </summary>
915
public AudioBoolParameter(AudioParameterInfo info) : base(info)
1016
{
1117
StepCount = 1;
1218
}
1319

20+
/// <summary>
21+
/// Creates a new instance of this parameter.
22+
/// </summary>
1423
public AudioBoolParameter(string title, int id = 0, string? units = null, string? shortTitle = null, bool defaultValue = false, AudioParameterFlags flags = AudioParameterFlags.CanAutomate) : base(title, units, id, shortTitle, 1, defaultValue ? 1.0 : 0.0, flags)
1524
{
1625
}
1726

27+
/// <summary>
28+
/// Gets or sets the value of this parameter.
29+
/// </summary>
1830
public bool Value
1931
{
2032
get

src/NPlug/AudioBusBuffers.cs

+39-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
namespace NPlug;
99

10+
/// <summary>
11+
/// The buffers for a specific bus, used in <see cref="AudioBusData"/> while processing audio via <see cref="IAudioProcessor.Process"/>.
12+
/// </summary>
1013
public unsafe ref struct AudioBusBuffers
1114
{
1215
/// <summary>
@@ -19,9 +22,14 @@ public unsafe ref struct AudioBusBuffers
1922
/// </summary>
2023
public ulong SilenceFlags;
2124

25+
// internal pointer to buffers. Use GetChannelSpanAsBytes / GetChannelSpanAsFloat32 / GetChannelSpanAsFloat64 methods.
2226
private readonly void** _channelBuffers;
23-
24-
27+
28+
/// <summary>
29+
/// Mark a specific channel as silence or not.
30+
/// </summary>
31+
/// <param name="channelIndex">The index of the channel.</param>
32+
/// <param name="silence"><c>true</c> to mark the channel as silence.</param>
2533
public void SetChannelSilence(int channelIndex, bool silence)
2634
{
2735
if (silence)
@@ -34,22 +42,51 @@ public void SetChannelSilence(int channelIndex, bool silence)
3442
}
3543
}
3644

45+
/// <summary>
46+
/// Checks whether the specified channel is silenced.
47+
/// </summary>
48+
/// <param name="channelIndex">The index of the channel.</param>
49+
/// <returns><c>true</c> if the channel is silenced.</returns>
3750
public bool IsChannelSilence(int channelIndex) => (SilenceFlags & (1UL << channelIndex)) != 0;
3851

52+
/// <summary>
53+
/// Safely gets the buffer associated with the current sampling rate and sample size.
54+
/// </summary>
55+
/// <param name="setupData">The processing setup data initialized by <see cref="IAudioProcessor.SetupProcessing"/>.</param>
56+
/// <param name="processData">The processing data provided during <see cref="IAudioProcessor.Process"/>.</param>
57+
/// <param name="channelIndex">The index of the channel.</param>
58+
/// <returns>A span of the audio buffer.</returns>
59+
/// <exception cref="ArgumentException">If the index is out of range.</exception>
3960
public Span<byte> GetChannelSpanAsBytes(in AudioProcessSetupData setupData, in AudioProcessData processData, int channelIndex)
4061
{
4162
if ((uint)channelIndex >= (uint)ChannelCount) throw new ArgumentException($"Invalid Channel Index {channelIndex}", nameof(channelIndex));
4263
var size = setupData.SampleSize == AudioSampleSize.Float32 ? 4 : 8;
4364
return new Span<byte>((byte*)_channelBuffers[channelIndex], size * processData.SampleCount);
4465
}
4566

67+
/// <summary>
68+
/// Safely gets the buffer associated with the current sampling rate and sample size.
69+
/// </summary>
70+
/// <param name="setupData">The processing setup data initialized by <see cref="IAudioProcessor.SetupProcessing"/>.</param>
71+
/// <param name="processData">The processing data provided during <see cref="IAudioProcessor.Process"/>.</param>
72+
/// <param name="channelIndex">The index of the channel.</param>
73+
/// <returns>A span of the audio buffer.</returns>
74+
/// <exception cref="ArgumentException">If the index is out of range or the sample size is not Float32.</exception>
4675
public Span<float> GetChannelSpanAsFloat32(in AudioProcessSetupData setupData, in AudioProcessData processData, int channelIndex)
4776
{
4877
if (setupData.SampleSize != AudioSampleSize.Float32) throw new InvalidOperationException($"Expecting 32-bit samples but getting {setupData.SampleSize}");
4978
if ((uint)channelIndex >= (uint)ChannelCount) throw new ArgumentException($"Invalid Channel Index {channelIndex}", nameof(channelIndex));
5079
return new Span<float>((float*)_channelBuffers[channelIndex], processData.SampleCount);
5180
}
5281

82+
/// <summary>
83+
/// Safely gets the buffer associated with the current sampling rate and sample size.
84+
/// </summary>
85+
/// <param name="setupData">The processing setup data initialized by <see cref="IAudioProcessor.SetupProcessing"/>.</param>
86+
/// <param name="processData">The processing data provided during <see cref="IAudioProcessor.Process"/>.</param>
87+
/// <param name="channelIndex">The index of the channel.</param>
88+
/// <returns>A span of the audio buffer.</returns>
89+
/// <exception cref="ArgumentException">If the index is out of range or the sample size is not Float64.</exception>
5390
public Span<double> GetChannelSpanAsFloat64(in AudioProcessSetupData setupData, in AudioProcessData processData, int channelIndex)
5491
{
5592
if (setupData.SampleSize != AudioSampleSize.Float64) throw new InvalidOperationException($"Expecting 64-bit samples but getting {setupData.SampleSize}");

0 commit comments

Comments
 (0)