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

Download this file

libkwave-module.cpp    58 lines (41 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
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "kwave/TimeOperation.h"
#include "kwave/Parser.h"
const char *version = "1.0";
const char *author = "Martin Wilz";
const char *name = "fadein";
//**********************************************************
int operation (TimeOperation *operation) {
int *sample = operation->getSample();
int len = operation->getLength();
Parser parser(operation->getCommand());
double curve = parser.toDouble();
if (curve) curve *= 10;
int i = 0;
if (curve == 0)
for (; i < len; i++) {
sample[i] =
(int)(((long long) (sample[i])) * i / len);
operation->setCounter (i);
}
else if (curve < 0)
for (; i < len; i++) {
sample[i] =
(int)((double)sample[i] *
log10(1 + ( -curve * ((double)i) / len)) / log10(1 - curve));
operation->setCounter (i);
}
else {
for (; i < len; i++)
sample[i] =
(int)((double)sample[i] *
(1 - log10(1 + (curve * ((double)len - i) / len)) / log10(1 + curve)));
operation->setCounter (i);
}
operation->done();
return 0;
}
//**********************************************************