forked from cgestes/multifxvst
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TAFadeInOut.cpp
145 lines (124 loc) · 3.02 KB
/
TAFadeInOut.cpp
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#include "stdafx.h"
#include "tafadeinout.h"
CTAFadeInOut::CTAFadeInOut(void)
{
fade = false;
fadein = false;
//inc = 0.00002f; //50000 block
//inc = 0.001f; //50000 block
inc = 0.0002f;
start = 0.0;
stop = 0.0;
current = 0.0;
}
CTAFadeInOut::~CTAFadeInOut(void)
{
}
void CTAFadeInOut::SetFadeIn(float start ,float stop)//start 1.0, stop = 0.0
{
if(this->fade == true)//on fait deja un fade
{
if(current > stop) //il faut continuer le fade
{
this->stop = stop;
this->start = start;
this->fadein = true;
}else //on fait un fade out
{
this->stop = stop;
this->start = start;
this->fadein = false;
}
}else ///on fait un nouveau fade in
{
this->start = start;
this->stop = stop;
this->fade = true;
this->fadein = true;
this->current = start;
}
}
void CTAFadeInOut::SetSampleRate(double samplerate)//futur use
{
}
void CTAFadeInOut::SetFadeLenght(double lenght_ms) //futur use
{
}
void CTAFadeInOut::SetFadeOut(float start,float stop)//start 0.0, stop = 1.0
{ if(this->fade == true)//on fait deja un fade
{
if(current < stop) //il faut continuer le dade
{
this->stop = stop;
this->start = start;
this->fadein = false;
}else //on fait un fade in
{
this->stop = stop;
this->start = start;
this->fadein = true;
}
}else ///on fait un nouveau fade in
{
this->start = start;
this->stop = stop;
this->fade = true;
this->fadein = false;
this->current = start;
}
}
//addition à coef ! (CTAFMATHEMATIQUE!)
#define OPERATION_SCIENTIFIQUE(x,y,coef) ( (x*(1.0f - coef))+(y*coef) )
//return true si le fondu est atteint completeme
// dest // process //clean
bool CTAFadeInOut::FonduBuffer(float ** dest,float ** source,float ** afondre,long size/*,float start,float inc*/)
{
//float val = current/*start*/;
//float inc = (end - start) / float(size);
for (int i = 0; i< size; i++)
{
/*if(current < 0.0)current = 0.0;
if(current > 1.0)current = 1.0;*/
if(fadein)
{
if(current < stop)
{
current = stop;
}
}
else
{
if(current > stop)
{
current = stop;
}
}
dest[0][i] = OPERATION_SCIENTIFIQUE(source[0][i],afondre[0][i],current);
dest[1][i] = OPERATION_SCIENTIFIQUE(source[1][i],afondre[1][i],current);
if(current != stop)
if(fadein)
current -= inc;
else
current += inc;
}
fade = !(current == stop);
return !fade;
}
//on voit l'algo direct! (vive l'assembleur!)
void CTAFadeInOut::AddBuffer(float ** dest, float ** source,long size)
{
for (int i = 0; i< size; i++)
{
dest[0][i] += source[0][i];
dest[1][i] += source[1][i];
}
}
//on voit l'algo direct! (vive l'assembleur!)
void CTAFadeInOut::CopyBuffer(float ** dest, float ** source,long size)
{
for (int i = 0; i< size; i++)
{
dest[0][i] = source[0][i];
dest[1][i] = source[1][i];
}
}