summaryrefslogtreecommitdiff
path: root/libs/ardour/ardour
diff options
context:
space:
mode:
Diffstat (limited to 'libs/ardour/ardour')
-rw-r--r--libs/ardour/ardour/dsp_filter.h51
-rw-r--r--libs/ardour/ardour/lua_api.h12
2 files changed, 63 insertions, 0 deletions
diff --git a/libs/ardour/ardour/dsp_filter.h b/libs/ardour/ardour/dsp_filter.h
index 994d8725ea..6220dddf5a 100644
--- a/libs/ardour/ardour/dsp_filter.h
+++ b/libs/ardour/ardour/dsp_filter.h
@@ -23,6 +23,8 @@
#include <string.h>
#include <assert.h>
#include <glib.h>
+#include <glibmm.h>
+#include <fftw3.h>
#include "ardour/libardour_visibility.h"
namespace ARDOUR { namespace DSP {
@@ -229,6 +231,9 @@ namespace ARDOUR { namespace DSP {
*/
void compute (Type t, double freq, double Q, double gain);
+ /** setup filter, set coefficients directly */
+ void configure (double a1, double a2, double b0, double b1, double b2);
+
/** filter transfer function (filter response for spectrum visualization)
* @param freq frequency
* @return gain at given frequency in dB (clamped to -120..+120)
@@ -244,5 +249,51 @@ namespace ARDOUR { namespace DSP {
double _b0, _b1, _b2;
};
+ class LIBARDOUR_API FFTSpectrum {
+ public:
+ FFTSpectrum (uint32_t window_size, double rate);
+ ~FFTSpectrum ();
+
+ /** set data to be analyzed and pre-process with hanning window
+ * n_samples + offset must not be larger than the configured window_size
+ *
+ * @param data raw audio data
+ * @param n_samples number of samples to write to analysis buffer
+ * @param offset destination offset
+ */
+ void set_data_hann (float const * const data, const uint32_t n_samples, const uint32_t offset = 0);
+
+ /** process current data in buffer */
+ void execute ();
+
+ /** query
+ * @param bin the frequency bin 0 .. window_size / 2
+ * @param norm gain factor (set equal to @bin for 1/f normalization)
+ * @return signal power at given bin (in dBFS)
+ */
+ float power_at_bin (const uint32_t bin, const float norm = 1.f) const;
+
+ float freq_at_bin (const uint32_t bin) const {
+ return bin * _fft_freq_per_bin;
+ }
+
+ private:
+ static Glib::Threads::Mutex fft_planner_lock;
+ float* hann_window;
+
+ void init (uint32_t window_size, double rate);
+ void reset ();
+
+ uint32_t _fft_window_size;
+ uint32_t _fft_data_size;
+ double _fft_freq_per_bin;
+
+ float* _fft_data_in;
+ float* _fft_data_out;
+ float* _fft_power;
+
+ fftwf_plan _fftplan;
+ };
+
} } /* namespace */
#endif
diff --git a/libs/ardour/ardour/lua_api.h b/libs/ardour/ardour/lua_api.h
index e3cf7bb30f..9ae6bf2ff6 100644
--- a/libs/ardour/ardour/lua_api.h
+++ b/libs/ardour/ardour/lua_api.h
@@ -118,6 +118,18 @@ namespace ARDOUR { namespace LuaAPI {
* @returns 3 parameters: AutomationList, ControlList, ParamaterDescriptor
*/
int plugin_automation (lua_State *lua);
+
+ /**
+ * A convenience function for colorspace HSL to RGB conversion.
+ * All ranges are 0..1
+ *
+ * Example:
+ * @code
+ * local r, g, b, a = ARDOUR.LuaAPI.hsla_to_rgba (hue, saturation, luminosity, alpha)
+ * @endcode
+ * @returns 4 parameters: red, green, blue, alpha (in range 0..1)
+ */
+ int hsla_to_rgba (lua_State *lua);
} } /* namespace */
namespace ARDOUR { namespace LuaOSC {