[c5c04b]: plugins / delay / libkwave-module.cpp Maximize Restore History

Download this file

libkwave-module.cpp    64 lines (40 with data), 1.2 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "kwave/Interpolation.h"
#include "kwave/TimeOperation.h"
#include "kwave/Parser.h"
#define PROGRESS_SIZE 2*2*3*3*5*5
const char *version = "1.0";
const char *author = "Martin Wilz";
const char *name = "delay";
//**********************************************************
int operation (TimeOperation *operation) {
int *sample = operation->getSample();
int len = operation->getLength();
bool fir = true;
int delay = 0;
int ampl = 100;
if (fir) {
int j;
for (int i = delay; i < len; ) {
if (i < len - PROGRESS_SIZE) j = i + PROGRESS_SIZE;
else j = len;
for (; i < j; i++)
sample[i] = (sample[i] + (sample[i - delay] * ampl / 100)) / 2;
operation->setCounter(i);
}
} else {
int j;
for (int i = len - 1; i >= 0; ) {
if (i > PROGRESS_SIZE) j = i - PROGRESS_SIZE;
else j = 0;
for (; i >= j; i--)
sample[i] = (sample[i] + (sample[i - delay] * ampl / 100)) / 2;
operation->setCounter(len - i);
}
}
operation->done();
return 0;
}
//**********************************************************