1 // Copyright 2016 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 // Windowed sine segments.
28 
29 #ifndef PLAITS_DSP_ENGINE_GRAIN_ENGINE_H_
30 #define PLAITS_DSP_ENGINE_GRAIN_ENGINE_H_
31 
32 #include "stmlib/dsp/filter.h"
33 
34 #include "plaits/dsp/engine/engine.h"
35 #include "plaits/dsp/oscillator/grainlet_oscillator.h"
36 #include "plaits/dsp/oscillator/vosim_oscillator.h"
37 #include "plaits/dsp/oscillator/z_oscillator.h"
38 
39 namespace plaits {
40 
41 class GrainEngine : public Engine {
42  public:
GrainEngine()43   GrainEngine() { }
~GrainEngine()44   ~GrainEngine() { }
45 
46   virtual void Init(stmlib::BufferAllocator* allocator);
47   virtual void Reset();
48   virtual void Render(const EngineParameters& parameters,
49       float* out,
50       float* aux,
51       size_t size,
52       bool* already_enveloped);
53 
54  private:
55   GrainletOscillator grainlet_[2];
56   // VOSIMOscillator vosim_oscillator_;
57   ZOscillator z_oscillator_;
58   stmlib::OnePole dc_blocker_[2];
59 
60   float grain_balance_;
61 
62   DISALLOW_COPY_AND_ASSIGN(GrainEngine);
63 };
64 
65 }  // namespace plaits
66 
67 #endif  // PLAITS_DSP_ENGINE_GRAIN_ENGINE_H_