Files

42 lines
1.5 KiB
C
Raw Permalink Normal View History

2026-03-04 15:34:46 +01:00
//
// Created by david on 04.03.2026.
//
#ifndef PASADASUPERPROJECT_SIGNAL_H
#define PASADASUPERPROJECT_SIGNAL_H
#include <vector>
#include <deque>
2026-03-04 15:34:46 +01:00
namespace pd_signal {
2026-03-04 16:27:00 +01:00
/** `num` evenly spaced numbers over interval [start,stop] */
void linspace(std::vector<double>& data, double start, double stop, int num);
/** `num` evenly spaced numbers over interval [start,stop] with endpoint=true or [start,stop) with endpoint=false */
void linspace(std::vector<double>& data, double start, double stop, int num, bool endpoint);
2026-03-04 15:34:46 +01:00
/**
* Evaluate at points x the function given by the samples fp[xp[n]].
* Returned in y.
*/
2026-03-04 16:27:00 +01:00
void interp(std::vector<double>& y, std::vector<double>& x, std::vector<double>& xp, std::vector<double>& fp);
/** resample to BEAT_LEN */
2026-03-09 18:38:21 +01:00
void resample(std::vector<double> &out, std::vector<double> &x, int beat_len);
/**
* normalized cross-correlation of the two signals of same length.
* normalization factor is <c>1 / sqrt(\sum_i x_i^2 * \sum_i y_i^2)</c>
*/
double crossCorr(std::vector<double> &x, std::vector<double> &y);
/** clip 'val' to between 'a_min' and 'a_max'. */
double clip(double val, double a_min, double a_max);
/** two-dimensional mean of a collection of signals */
void mean(std::vector<double> &out, std::vector<std::vector<double> >& m);
/** two-dimensional mean of a collection of signals */
void mean(std::vector<double> &out, std::deque<std::vector<double> >& m);
2026-03-04 16:27:00 +01:00
2026-03-04 15:34:46 +01:00
}
#endif //PASADASUPERPROJECT_SIGNAL_H