1 // Licensed GNU LGPL v3 or later: http://www.gnu.org/licenses/lgpl.html
2 
3 #include "smadsrenvelope.hh"
4 #include "smmath.hh"
5 #include "smmain.hh"
6 
7 #include <vector>
8 
9 #include <stdio.h>
10 
11 using namespace SpectMorph;
12 using std::vector;
13 
14 void
run(ADSREnvelope & adsr_envelope,size_t samples)15 run (ADSREnvelope& adsr_envelope, size_t samples)
16 {
17   vector<float> input (samples, 1.0);
18   adsr_envelope.process (input.size(), &input[0]);
19   for (auto v : input)
20     printf ("%f\n", v);
21 }
22 
23 int
main(int argc,char ** argv)24 main (int argc, char **argv)
25 {
26   Main main (&argc, &argv);
27 
28   float rate = 48000;
29 
30   ADSREnvelope adsr_envelope;
31 
32   adsr_envelope.set_config (sm_atof (argv[1]), sm_atof (argv[2]), sm_atof (argv[3]), sm_atof (argv[4]), rate);
33   adsr_envelope.retrigger();
34   run (adsr_envelope, sm_round_positive (rate / 2));
35   adsr_envelope.release();
36   while (!adsr_envelope.done())
37     {
38       run (adsr_envelope, sm_round_positive (rate / 2));
39     }
40 }
41