1 // Copyright 2013 Emilie Gillet.
2 //
3 // Author: Emilie Gillet (emilie.o.gillet@gmail.com)
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 // THE SOFTWARE.
22 //
23 // See http://creativecommons.org/licenses/MIT/ for more information.
24 //
25 // -----------------------------------------------------------------------------
26 //
27 // LFO.
28
29 #include "peaks/processors.h"
30
31 #include <algorithm>
32
33 namespace peaks {
34
35 using namespace stmlib;
36 using namespace std;
37
38 #define REGISTER_PROCESSOR(ClassName) \
39 { &Processors::ClassName ## Init, \
40 &Processors::ClassName ## Process, \
41 &Processors::ClassName ## Configure },
42
43 /* static */
44 const Processors::ProcessorCallbacks
45 Processors::callbacks_table_[PROCESSOR_FUNCTION_LAST] = {
46 REGISTER_PROCESSOR(MultistageEnvelope)
47 REGISTER_PROCESSOR(Lfo)
48 REGISTER_PROCESSOR(Lfo)
49 REGISTER_PROCESSOR(BassDrum)
50 REGISTER_PROCESSOR(SnareDrum)
51 REGISTER_PROCESSOR(HighHat)
52 REGISTER_PROCESSOR(FmDrum)
53 REGISTER_PROCESSOR(PulseShaper)
54 REGISTER_PROCESSOR(PulseRandomizer)
55 REGISTER_PROCESSOR(BouncingBall)
56 REGISTER_PROCESSOR(MiniSequencer)
57 REGISTER_PROCESSOR(NumberStation)
58 };
59
Init(uint8_t index)60 void Processors::Init(uint8_t index) {
61 for (uint16_t i = 0; i < PROCESSOR_FUNCTION_LAST; ++i) {
62 (this->*callbacks_table_[i].init_fn)();
63 }
64
65 bass_drum_.Init();
66 snare_drum_.Init();
67 fm_drum_.Init();
68 fm_drum_.set_sd_range(index == 1);
69 high_hat_.Init();
70 bouncing_ball_.Init();
71 lfo_.Init();
72 envelope_.Init();
73 pulse_shaper_.Init();
74 pulse_randomizer_.Init();
75 mini_sequencer_.Init();
76 number_station_.Init();
77 number_station_.set_voice(index == 1);
78
79 control_mode_ = CONTROL_MODE_FULL;
80 set_function(PROCESSOR_FUNCTION_ENVELOPE);
81 std::fill(¶meter_[0], ¶meter_[4], 32768);
82 }
83
84 /* extern */
85 Processors processors[2];
86
87 } // namespace peaks
88