Skip to content

Commit 9727851

Browse files
committed
Use C# language version 12
1 parent cd93953 commit 9727851

72 files changed

Lines changed: 15312 additions & 15423 deletions

Some content is hidden

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

.editorconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ dotnet_style_prefer_conditional_expression_over_return = false:suggestion
125125
dotnet_style_coalesce_expression = true:warning
126126
dotnet_style_null_propagation = true:warning
127127

128+
# Use primary constructor
129+
# https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0290
130+
dotnet_style_prefer_primary_constructors = false
131+
dotnet_diagnostic.IDE0290.severity = silent
132+
128133
# C# Code Style Settings
129134
[*.{cs,csx,cake}]
130135

SFML.Module.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
<Import Project="SFML.CodeStyle.props" />
77

88
<PropertyGroup>
9+
<LangVersion>12</LangVersion>
10+
911
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
1012
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1113

src/SFML.Audio/Cone.cs

Lines changed: 50 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,63 @@
11
using System.Runtime.InteropServices;
22
using SFML.System;
33

4-
namespace SFML.Audio
4+
namespace SFML.Audio;
5+
6+
////////////////////////////////////////////////////////////
7+
/// <summary>
8+
/// Structure defining the properties of a directional cone
9+
/// <para/>
10+
/// When set on the listener, sounds will play at gain 1 when
11+
/// they are positioned within the inner angle of the cone.
12+
/// Sounds will play at outerGain when they are positioned
13+
/// outside the outer angle of the cone.
14+
/// The gain declines linearly from 1 to outerGain as the
15+
/// sound moves from the inner angle to the outer angle.
16+
/// <para/>
17+
/// When set on sound sources, they will play at gain 1 when the
18+
/// listener is positioned within the inner angle of the cone.
19+
/// Sounds will play at `outerGain` when the listener is
20+
/// positioned outside the outer angle of the cone.
21+
/// The gain declines linearly from 1 to outerGain as the
22+
/// listener moves from the inner angle to the outer angle.
23+
/// </summary>
24+
////////////////////////////////////////////////////////////
25+
public struct Cone
526
{
6-
////////////////////////////////////////////////////////////
7-
/// <summary>
8-
/// Structure defining the properties of a directional cone
9-
/// <para/>
10-
/// When set on the listener, sounds will play at gain 1 when
11-
/// they are positioned within the inner angle of the cone.
12-
/// Sounds will play at outerGain when they are positioned
13-
/// outside the outer angle of the cone.
14-
/// The gain declines linearly from 1 to outerGain as the
15-
/// sound moves from the inner angle to the outer angle.
16-
/// <para/>
17-
/// When set on sound sources, they will play at gain 1 when the
18-
/// listener is positioned within the inner angle of the cone.
19-
/// Sounds will play at `outerGain` when the listener is
20-
/// positioned outside the outer angle of the cone.
21-
/// The gain declines linearly from 1 to outerGain as the
22-
/// listener moves from the inner angle to the outer angle.
23-
/// </summary>
24-
////////////////////////////////////////////////////////////
25-
public struct Cone
26-
{
27-
/// <summary>Inner angle</summary>
28-
public Angle InnerAngle;
27+
/// <summary>Inner angle</summary>
28+
public Angle InnerAngle;
2929

30-
/// <summary>Outer angle</summary>
31-
public Angle OuterAngle;
30+
/// <summary>Outer angle</summary>
31+
public Angle OuterAngle;
3232

33-
/// <summary>Outer angle</summary>
34-
public float OuterGain;
33+
/// <summary>Outer angle</summary>
34+
public float OuterGain;
3535

36-
[StructLayout(LayoutKind.Sequential)]
37-
internal struct MarshalData
38-
{
39-
public float InnerAngleDegrees;
40-
public float OuterAngleDegrees;
41-
public float OuterGain;
42-
}
36+
[StructLayout(LayoutKind.Sequential)]
37+
internal struct MarshalData
38+
{
39+
public float InnerAngleDegrees;
40+
public float OuterAngleDegrees;
41+
public float OuterGain;
42+
}
4343

44-
internal Cone(MarshalData data)
45-
{
46-
InnerAngle = Angle.FromDegrees(data.InnerAngleDegrees);
47-
OuterAngle = Angle.FromDegrees(data.OuterAngleDegrees);
48-
OuterGain = data.OuterGain;
49-
}
44+
internal Cone(MarshalData data)
45+
{
46+
InnerAngle = Angle.FromDegrees(data.InnerAngleDegrees);
47+
OuterAngle = Angle.FromDegrees(data.OuterAngleDegrees);
48+
OuterGain = data.OuterGain;
49+
}
5050

51-
// Return a marshalled version of the instance, that can directly be passed to the C API
52-
internal MarshalData Marshal()
51+
// Return a marshalled version of the instance, that can directly be passed to the C API
52+
internal MarshalData Marshal()
53+
{
54+
var data = new MarshalData
5355
{
54-
var data = new MarshalData
55-
{
56-
InnerAngleDegrees = InnerAngle.Degrees,
57-
OuterAngleDegrees = OuterAngle.Degrees,
58-
OuterGain = OuterGain
59-
};
56+
InnerAngleDegrees = InnerAngle.Degrees,
57+
OuterAngleDegrees = OuterAngle.Degrees,
58+
OuterGain = OuterGain
59+
};
6060

61-
return data;
62-
}
61+
return data;
6362
}
6463
}

src/SFML.Audio/EffectProcessor.cs

Lines changed: 85 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -2,90 +2,89 @@
22
using System.Runtime.InteropServices;
33
using System;
44

5-
namespace SFML.Audio
6-
{
7-
////////////////////////////////////////////////////////////
8-
/// <summary>
9-
/// Callable that is provided with sound data for processing
10-
/// <para/>
11-
/// When the audio engine sources sound data from sound
12-
/// sources it will pass the data through an effects
13-
/// processor if one is set. The sound data will already be
14-
/// converted to the internal floating point format.
15-
/// <para/>
16-
/// Sound data that is processed this way is provided in
17-
/// frames. Each frame contains 1 floating point sample per
18-
/// channel. If e.g. the data source provides stereo data,
19-
/// each frame will contain 2 floats.
20-
/// <para/>
21-
/// The effects processor function takes 4 parameters:
22-
/// - The input data frames, channels interleaved
23-
/// - The number of input data frames available
24-
/// - The buffer to write output data frames to, channels interleaved
25-
/// - The number of output data frames that the output buffer can hold
26-
/// - The channel count
27-
/// <para/>
28-
/// The input and output frame counts are in/out parameters.
29-
/// <para/>
30-
/// When this function is called, the input count will
31-
/// contain the number of frames available in the input
32-
/// buffer. The output count will contain the size of the
33-
/// output buffer i.e. the maximum number of frames that
34-
/// can be written to the output buffer.
35-
/// <para/>
36-
/// Attempting to read more frames than the input frame
37-
/// count or write more frames than the output frame count
38-
/// will result in undefined behaviour.
39-
/// <para/>
40-
/// Attempting to read more frames than the input frame
41-
/// count or write more frames than the output frame count
42-
/// will result in undefined behaviour.
43-
/// <para/>
44-
/// It is important to note that the channel count of the
45-
/// audio engine currently sourcing data from this sound
46-
/// will always be provided in `frameChannelCount`. This can
47-
/// be different from the channel count of the sound source
48-
/// so make sure to size necessary processing buffers
49-
/// according to the engine channel count and not the sound
50-
/// source channel count.
51-
/// <para/>
52-
/// When done processing the frames, the input and output
53-
/// frame counts must be updated to reflect the actual
54-
/// number of frames that were read from the input and
55-
/// written to the output.
56-
/// <para/>
57-
/// The processing function should always try to process as
58-
/// much sound data as possible i.e. always try to fill the
59-
/// output buffer to the maximum. In certain situations for
60-
/// specific effects it can be possible that the input frame
61-
/// count and output frame count aren't equal. As long as
62-
/// the frame counts are updated accordingly this is
63-
/// perfectly valid.
64-
/// <para/>
65-
/// If the audio engine determines that no audio data is
66-
/// available from the data source, the input data frames
67-
/// pointer is set to `nullptr` and the input frame count is
68-
/// set to 0. In this case it is up to the function to
69-
/// decide how to handle the situation. For specific effects
70-
/// e.g. Echo/Delay buffered data might still be able to be
71-
/// written to the output buffer even if there is no longer
72-
/// any input data.
73-
/// <para/>
74-
/// An important thing to remember is that this function is
75-
/// directly called by the audio engine. Because the audio
76-
/// engine runs on an internal thread of its own, make sure
77-
/// access to shared data is synchronized appropriately.
78-
/// <para/>
79-
/// Because this function is stored by the `SoundSource`
80-
/// object it will be able to be called as long as the
81-
/// `SoundSource` object hasn't yet been destroyed. Make sure
82-
/// that any data this function references outlives the
83-
/// SoundSource object otherwise use-after-free errors will
84-
/// occur.
85-
/// </summary>
86-
////////////////////////////////////////////////////////////
87-
public delegate long EffectProcessor(float[] inputFrames, float[] outputFrames, uint frameChannelCount);
5+
namespace SFML.Audio;
886

89-
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
90-
internal delegate long EffectProcessorInternal(IntPtr inputFrames, uint inputFrameCount, IntPtr outputFrames, uint outputFrameCount, uint frameChannelCount);
91-
}
7+
////////////////////////////////////////////////////////////
8+
/// <summary>
9+
/// Callable that is provided with sound data for processing
10+
/// <para/>
11+
/// When the audio engine sources sound data from sound
12+
/// sources it will pass the data through an effects
13+
/// processor if one is set. The sound data will already be
14+
/// converted to the internal floating point format.
15+
/// <para/>
16+
/// Sound data that is processed this way is provided in
17+
/// frames. Each frame contains 1 floating point sample per
18+
/// channel. If e.g. the data source provides stereo data,
19+
/// each frame will contain 2 floats.
20+
/// <para/>
21+
/// The effects processor function takes 4 parameters:
22+
/// - The input data frames, channels interleaved
23+
/// - The number of input data frames available
24+
/// - The buffer to write output data frames to, channels interleaved
25+
/// - The number of output data frames that the output buffer can hold
26+
/// - The channel count
27+
/// <para/>
28+
/// The input and output frame counts are in/out parameters.
29+
/// <para/>
30+
/// When this function is called, the input count will
31+
/// contain the number of frames available in the input
32+
/// buffer. The output count will contain the size of the
33+
/// output buffer i.e. the maximum number of frames that
34+
/// can be written to the output buffer.
35+
/// <para/>
36+
/// Attempting to read more frames than the input frame
37+
/// count or write more frames than the output frame count
38+
/// will result in undefined behaviour.
39+
/// <para/>
40+
/// Attempting to read more frames than the input frame
41+
/// count or write more frames than the output frame count
42+
/// will result in undefined behaviour.
43+
/// <para/>
44+
/// It is important to note that the channel count of the
45+
/// audio engine currently sourcing data from this sound
46+
/// will always be provided in `frameChannelCount`. This can
47+
/// be different from the channel count of the sound source
48+
/// so make sure to size necessary processing buffers
49+
/// according to the engine channel count and not the sound
50+
/// source channel count.
51+
/// <para/>
52+
/// When done processing the frames, the input and output
53+
/// frame counts must be updated to reflect the actual
54+
/// number of frames that were read from the input and
55+
/// written to the output.
56+
/// <para/>
57+
/// The processing function should always try to process as
58+
/// much sound data as possible i.e. always try to fill the
59+
/// output buffer to the maximum. In certain situations for
60+
/// specific effects it can be possible that the input frame
61+
/// count and output frame count aren't equal. As long as
62+
/// the frame counts are updated accordingly this is
63+
/// perfectly valid.
64+
/// <para/>
65+
/// If the audio engine determines that no audio data is
66+
/// available from the data source, the input data frames
67+
/// pointer is set to `nullptr` and the input frame count is
68+
/// set to 0. In this case it is up to the function to
69+
/// decide how to handle the situation. For specific effects
70+
/// e.g. Echo/Delay buffered data might still be able to be
71+
/// written to the output buffer even if there is no longer
72+
/// any input data.
73+
/// <para/>
74+
/// An important thing to remember is that this function is
75+
/// directly called by the audio engine. Because the audio
76+
/// engine runs on an internal thread of its own, make sure
77+
/// access to shared data is synchronized appropriately.
78+
/// <para/>
79+
/// Because this function is stored by the `SoundSource`
80+
/// object it will be able to be called as long as the
81+
/// `SoundSource` object hasn't yet been destroyed. Make sure
82+
/// that any data this function references outlives the
83+
/// SoundSource object otherwise use-after-free errors will
84+
/// occur.
85+
/// </summary>
86+
////////////////////////////////////////////////////////////
87+
public delegate long EffectProcessor(float[] inputFrames, float[] outputFrames, uint frameChannelCount);
88+
89+
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
90+
internal delegate long EffectProcessorInternal(IntPtr inputFrames, uint inputFrameCount, IntPtr outputFrames, uint outputFrameCount, uint frameChannelCount);

0 commit comments

Comments
 (0)