21 #ifdef HAVE_EMSCRIPTEN 22 #include <emscripten/bind.h> 28 #define _USE_MATH_DEFINES 33 double round(
double number) {
34 return number < 0.0 ? ceil(number - 0.5) : floor(number + 0.5);
40 #define WSOLA_MOD2_ERROR -10+WSOLA_ERROR_OFFSET 41 #define WSOLA_NFRAMES_JACK_ERROR -11+WSOLA_ERROR_OFFSET 42 #define WSOLA_ROWS_ERROR -12+WSOLA_ERROR_OFFSET 43 #define WSOLA_COLS_ERROR -13+WSOLA_ERROR_OFFSET 55 errors[
WSOLA_ROWS_ERROR]=std::string(
"Row request error : You are trying to access beyond the end of the array. ");
56 errors[
WSOLA_COLS_ERROR]=std::string(
"Col request error : You are trying to access beyond the end of the array. ");
64 #include <Eigen/Dense> 65 using namespace Eigen;
69 #define FS_DEFAULT 48000. 72 #define DEFAULT_CH_CNT 1 104 template<
typename Derived>
105 int findSimilarityInBuffer(
const DenseBase<Derived> &buffer);
111 template<
typename Derived>
115 return rms(nextOutput-simComp);
123 template<
typename Derived>
124 FP_TYPE
rms(
const ArrayBase<Derived> &s) {
128 return s.matrix().norm();
156 #ifdef HAVE_EMSCRIPTEN 157 int processOurInput(FP_TYPE timeScale) {
158 return process(timeScale, input);
168 template<
typename Derived>
169 int process(FP_TYPE timeScale,
const DenseBase<Derived> &input) {
175 int chCnt=buffer.rows();
176 buffer.block(0,0,chCnt,buffer.cols()-inputSamplesRequired)=buffer.block(0,inputSamplesRequired,chCnt,buffer.cols()-inputSamplesRequired);
180 buffer.block(0,buffer.cols()-inputSamplesRequired,chCnt,inputSamplesRequired)=input.block(0,0,chCnt,inputSamplesRequired);
188 double shiftOn=timeScale*NO2+rem;
190 inputSamplesRequired=
static_cast<int>(
round(shiftOn));
192 rem=shiftOn-(double)inputSamplesRequired;
194 return inputSamplesRequired;
200 void processInner(
void);
215 return inputSamplesRequired;
227 void reset(
int chCnt);
234 return inputSamplesRequired-=NO2;
244 int loadInput(
int n,
int m, FP_TYPE val);
252 FP_TYPE unloadOutput(
int n,
int m);
257 void setFS(
float fsIn);
int inputSamplesRequired
The number of audio samples required for the next call to process.
int NO2
Half the window size.
int N
The size of the window.
#define WSOLA_COLS_ERROR
Occurs when trying to access a col > the input or output Array cols.
Array< FP_TYPE, Dynamic, Dynamic > nextOutput
The output vector to search for, each channel per row.
double rem
The remainder fraction of a sample to remember for next time (can't move on by fractions of a sample)...
int m
The current row index into the buffer.
std::map< int, std::string > errors
This will contain a map between error numbers and descriptive std::strings for the errors...
Array< FP_TYPE, Dynamic, Dynamic > simComp
Temporary vector used for computation.
FP_TYPE rms(const ArrayBase< Derived > &s)
#define WSOLA_ROWS_ERROR
Occurs when trying to access a row > the input or output Array rows.
Array< FP_TYPE, Dynamic, Dynamic > wnd
The overlap add window.
FP_TYPE findSimilarity(const ArrayBase< Derived > &outputIn)
int getSamplesRequired(void)
float FP_TYPE
The floating point type to use if not previously declared.
Array< FP_TYPE, Dynamic, Dynamic > input
The input vector, each row is a channel.
Array< FP_TYPE, Dynamic, Dynamic > output
The output vector, each row is a channel.
double precision function round(x)
#define WSOLA_MOD2_ERROR
< Provided by GTKIOStream on sf.net
#define WSOLA_NFRAMES_JACK_ERROR
Occurs when jack wants to process nframes which is not divisible by N/2.
int process(FP_TYPE timeScale, const DenseBase< Derived > &input)
virtual ~WSOLADebug()
Destructor.
int getMaxInputSamplesRequired(void)
int M
The number of windows in the search buffer.
float fs
The sample rate in Hz.
Array< FP_TYPE, Dynamic, Dynamic > buffer
The buffer of audio, each channel on its own row.