22using System . Runtime . InteropServices ;
33using 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