Ardour  9.0-pre0-582-g084a23a80d
ardour/ardour/mix.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2011 David Robillard <d@drobilla.net>
3  * Copyright (C) 2007-2015 Paul Davis <paul@linuxaudiosystems.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 #pragma once
20 
22 #include "ardour/types.h"
23 #include "ardour/utils.h"
24 
25 #if defined (ARCH_X86) && defined (BUILD_SSE_OPTIMIZATIONS)
26 
27 extern "C" {
28 /* SSE functions */
29  LIBARDOUR_API float x86_sse_compute_peak (float const* buf, uint32_t nsamples, float current);
30  LIBARDOUR_API void x86_sse_apply_gain_to_buffer (float* buf, uint32_t nframes, float gain);
31  LIBARDOUR_API void x86_sse_mix_buffers_with_gain(float* dst, float const* src, uint32_t nframes, float gain);
32  LIBARDOUR_API void x86_sse_mix_buffers_no_gain (float* dst, float const* src, uint32_t nframes);
33 }
34 
35 LIBARDOUR_API void x86_sse_find_peaks (float const* buf, uint32_t nsamples, float* min, float* max);
36 
37 extern "C" {
38 /* AVX functions */
39  LIBARDOUR_API float x86_sse_avx_compute_peak (float const* buf, uint32_t nsamples, float current);
40  LIBARDOUR_API void x86_sse_avx_apply_gain_to_buffer (float* buf, uint32_t nframes, float gain);
41  LIBARDOUR_API void x86_sse_avx_mix_buffers_with_gain (float* dst, float const* src, uint32_t nframes, float gain);
42  LIBARDOUR_API void x86_sse_avx_mix_buffers_no_gain (float* dst, float const* src, uint32_t nframes);
43  LIBARDOUR_API void x86_sse_avx_copy_vector (float* dst, float const* src, uint32_t nframes);
44 #ifndef PLATFORM_WINDOWS
45  LIBARDOUR_API void x86_sse_avx_find_peaks (float const* buf, uint32_t nsamples, float* min, float* max);
46 #endif
47 }
48 #ifdef PLATFORM_WINDOWS
49 LIBARDOUR_API void x86_sse_avx_find_peaks (float const* buf, uint32_t nsamples, float* min, float* max);
50 #endif
51 
52 /* FMA functions */
53 #ifdef FPU_AVX_FMA_SUPPORT
54 LIBARDOUR_API void x86_fma_mix_buffers_with_gain (float* dst, float const* src, uint32_t nframes, float gain);
55 #endif
56 
57 /* AVX512F functions */
58 #ifdef FPU_AVX512F_SUPPORT
59 LIBARDOUR_API float x86_avx512f_compute_peak (float const* buf, uint32_t nsamples, float current);
60 LIBARDOUR_API void x86_avx512f_apply_gain_to_buffer (float* buf, uint32_t nframes, float gain);
61 LIBARDOUR_API void x86_avx512f_mix_buffers_with_gain (float* dst, float const* src, uint32_t nframes, float gain);
62 LIBARDOUR_API void x86_avx512f_mix_buffers_no_gain (float* dst, float const* src, uint32_t nframes);
63 LIBARDOUR_API void x86_avx512f_copy_vector (float* dst, float const* src, uint32_t nframes);
64 LIBARDOUR_API void x86_avx512f_find_peaks (float const* buf, uint32_t nsamples, float* min, float* max);
65 #endif
66 
67 /* debug wrappers for SSE functions */
68 
69 LIBARDOUR_API float debug_compute_peak (ARDOUR::Sample const* buf, ARDOUR::pframes_t nsamples, float current);
70 LIBARDOUR_API void debug_apply_gain_to_buffer (ARDOUR::Sample* buf, ARDOUR::pframes_t nframes, float gain);
71 LIBARDOUR_API void debug_mix_buffers_with_gain (ARDOUR::Sample* dst, ARDOUR::Sample const* src, ARDOUR::pframes_t nframes, float gain);
72 LIBARDOUR_API void debug_mix_buffers_no_gain (ARDOUR::Sample* dst, ARDOUR::Sample const* src, ARDOUR::pframes_t nframes);
73 LIBARDOUR_API void debug_copy_vector (ARDOUR::Sample* dst, ARDOUR::Sample const* src, ARDOUR::pframes_t nframes);
74 
75 #endif
76 
77 #if defined (__APPLE__)
78 
79 LIBARDOUR_API float veclib_compute_peak (ARDOUR::Sample const* buf, ARDOUR::pframes_t nsamples, float current);
80 LIBARDOUR_API void veclib_apply_gain_to_buffer (ARDOUR::Sample* buf, ARDOUR::pframes_t nframes, float gain);
81 LIBARDOUR_API void veclib_mix_buffers_with_gain (ARDOUR::Sample* dst, ARDOUR::Sample const* src, ARDOUR::pframes_t nframes, float gain);
82 LIBARDOUR_API void veclib_mix_buffers_no_gain (ARDOUR::Sample* dst, ARDOUR::Sample const* src, ARDOUR::pframes_t nframes);
83 LIBARDOUR_API void veclib_find_peaks (ARDOUR::Sample const* buf, ARDOUR::pframes_t nsamples, float* min, float* max);
84 
85 #endif
86 
87 #if defined ARM_NEON_SUPPORT
88 /* Optimized NEON functions */
89 extern "C" {
90  LIBARDOUR_API float arm_neon_compute_peak (float const* buf, uint32_t nsamples, float current);
91  LIBARDOUR_API void arm_neon_apply_gain_to_buffer (float* buf, uint32_t nframes, float gain);
92  LIBARDOUR_API void arm_neon_copy_vector (float* dst, float const* src, uint32_t nframes);
93  LIBARDOUR_API void arm_neon_find_peaks (float const* src, uint32_t nframes, float* minf, float* maxf);
94  LIBARDOUR_API void arm_neon_mix_buffers_no_gain (float* dst, float const* src, uint32_t nframes);
95  LIBARDOUR_API void arm_neon_mix_buffers_with_gain (float* dst, float const* src, uint32_t nframes, float gain);
96 }
97 #endif
98 
99 /* non-optimized functions */
100 
101 LIBARDOUR_API float default_compute_peak (ARDOUR::Sample const* buf, ARDOUR::pframes_t nsamples, float current);
102 LIBARDOUR_API void default_find_peaks (ARDOUR::Sample const* buf, ARDOUR::pframes_t nsamples, float* min, float* max);
107 
void default_find_peaks(ARDOUR::Sample const *buf, ARDOUR::pframes_t nsamples, float *min, float *max)
void default_apply_gain_to_buffer(ARDOUR::Sample *buf, ARDOUR::pframes_t nframes, float gain)
float default_compute_peak(ARDOUR::Sample const *buf, ARDOUR::pframes_t nsamples, float current)
void default_copy_vector(ARDOUR::Sample *dst, ARDOUR::Sample const *src, ARDOUR::pframes_t nframes)
void default_mix_buffers_no_gain(ARDOUR::Sample *dst, ARDOUR::Sample const *src, ARDOUR::pframes_t nframes)
void default_mix_buffers_with_gain(ARDOUR::Sample *dst, ARDOUR::Sample const *src, ARDOUR::pframes_t nframes, float gain)
#define LIBARDOUR_API
PBD::PropertyDescriptor< gain_t > gain
uint32_t pframes_t