-
Notifications
You must be signed in to change notification settings - Fork 22
/
VoiceBody.hpp
51 lines (32 loc) · 1.1 KB
/
VoiceBody.hpp
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
/*****************************************************************************
VoiceBody.hpp
Copyright (c) 2020 Raphael DINGE
*Tab=3***********************************************************************/
#pragma once
/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
#include <cmath>
/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
/*
==============================================================================
Name : process
==============================================================================
*/
template <typename T>
float VoiceBody::process (const T & sample)
{
if (!_active_flag) return 0.f;
float integral;
float mix = std::modf (_pos, &integral);
size_t pos = size_t (_pos);
float ret_1 = sample.samples [pos];
float ret_2 = sample.samples [pos + 1];
float ret = ret_1 + (ret_2 - ret_1) * mix;
float r = _ramp.process ();
ret *= (3.f - 2.f * r) * r * r;
_pos += _step_spl;
if (_pos + 2.f >= float (sample.samples.size ()))
{
_active_flag = false;
}
return ret;
}