git subrepo pull --force deps/lightrec
[pcsx_rearmed.git] / deps / libretro-common / include / audio / conversion / dual_mono.h
1 /* Copyright  (C) 2010-2023 The RetroArch team
2  *
3  * ---------------------------------------------------------------------------------------
4  * The following license statement only applies to this file (s16_to_float.h).
5  * ---------------------------------------------------------------------------------------
6  *
7  * Permission is hereby granted, free of charge,
8  * to any person obtaining a copy of this software and associated documentation files (the "Software"),
9  * to deal in the Software without restriction, including without limitation the rights to
10  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
11  * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  */
22 #ifndef __LIBRETRO_SDK_CONVERSION_DUAL_MONO__
23 #define __LIBRETRO_SDK_CONVERSION_DUAL_MONO__
24
25 #include <stdint.h>
26 #include <stddef.h>
27
28 #include <retro_common_api.h>
29
30 RETRO_BEGIN_DECLS
31
32 /**
33  * Duplicates 1-channel (mono) frames into 2-channel (stereo) frames.
34  * The resulting array is suitable for use in the resampler,
35  * or for any use case that demands stereo input.
36  * This version operates on 32-bit floating-point samples.
37  *
38  * May use SIMD intrinsics on supported platforms,
39  * but will work without them.
40  *
41  * Will do nothing if \c out or \c in are \c NULL.
42  *
43  * @param[out] out The location in which the converted frames will be stored.
44  * Must have enough room for twice the value of \c frames.
45  * @param[in] in The location of the frames to convert.
46  * @param[in] frames The number of frames to convert.
47  */
48 void convert_to_dual_mono_float(float *out, const float *in, size_t frames);
49
50 /**
51  * Downmixes 2-channel (stereo) frames into 1-channel (mono) frames.
52  * This is intended for dual-mono audio (i.e. where both channels are identical),
53  * but it will work if both channels are different.
54  *
55  * This version operates on 32-bit floating-point samples.
56  * It preserves the left channel and ignores the right channel.
57  *
58  * Will do nothing if \c out or \c in are \c NULL.
59  *
60  * @param[out] out The location in which the converted frames will be stored.
61  * Must have enough room for half the value of <code>frames * sizeof(float)</code>.
62  * @param[in] in The location of the frames to convert.
63  * @param[in] frames The number of frames to convert.
64  */
65 void convert_to_mono_float_left(float *out, const float *in, size_t frames);
66
67 RETRO_END_DECLS
68
69 #endif