/[svn]/linuxsampler/trunk/src/engines/common/SignalUnitRack.h
ViewVC logotype

Contents of /linuxsampler/trunk/src/engines/common/SignalUnitRack.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2205 - (show annotations) (download) (as text)
Mon Jul 11 17:52:01 2011 UTC (12 years, 9 months ago) by iliev
File MIME type: text/x-c++hdr
File size: 4980 byte(s)
* Introduced Signal Units and Signal Unit Racks, which hopefully will meet
  the demands of the new engines for flexible signal processing.
* sf2: Initial implementation of vibrato LFO, fixes in modulation EG and
  and volume EG (work in progress)

1 /***************************************************************************
2 * *
3 * LinuxSampler - modular, streaming capable sampler *
4 * *
5 * Copyright (C) 2011 Grigor Iliev *
6 * *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the Free Software *
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
20 * MA 02111-1307 USA *
21 ***************************************************************************/
22
23 #ifndef __LS_SIGNALUNITRACK_H__
24 #define __LS_SIGNALUNITRACK_H__
25
26 #include "Event.h"
27 #include "SignalUnit.h"
28 #include "../../common/Pool.h"
29
30
31 namespace LinuxSampler {
32 class SignalUnitRack {
33 protected:
34 uint CurrentStep; // The current time step
35
36 public:
37 SignalUnitRack(): CurrentStep(0) { }
38 uint GetCurrentStep() { return CurrentStep; }
39
40 /**
41 * Will be called to increment the time with one sample point.
42 * Each unit should recalculate its current level on every call of this function.
43 */
44 virtual void Increment() = 0;
45
46 virtual void ProcessCCEvent(RTList<Event>::Iterator& itEvent) = 0;
47
48 /** Initializes and triggers the rack. */
49 virtual void Trigger() = 0;
50
51 /**
52 * When the rack belongs to a voice, this method is
53 * called when the voice enter the release stage.
54 */
55 virtual void EnterReleaseStage() = 0;
56
57 /**
58 * When the rack belongs to a voice, this method is
59 * called when the voice is of type which ignore note off.
60 */
61 virtual void CancelRelease() = 0;
62
63 virtual EndpointSignalUnit* GetEndpointUnit() = 0;
64 };
65
66 template <class O /* The signal unit rack's owner */>
67 class SignalUnitRackBase: public SignalUnitRack {
68 protected:
69 O* pOwner; // The owner to which this rack belongs.
70
71 public:
72 ArrayList<SignalUnitBase<O>*> Units; // A list of all signal units in this rack
73
74 SignalUnitRackBase(O* Owner) {
75 pOwner = Owner;
76 }
77
78 /**
79 * Will be called to increment the time with one sample point.
80 * Each unit should recalculate its current level on every call of this function.
81 */
82 virtual void Increment() {
83 CurrentStep++;
84
85 for (int i = 0; i < Units.size(); i++) {
86 Units[i]->Increment();
87 }
88 }
89
90 virtual void ProcessCCEvent(RTList<Event>::Iterator& itEvent) {
91 if ( !(itEvent->Type == Event::type_control_change && itEvent->Param.CC.Controller) ) return;
92 for (int i = 0; i < Units.size(); i++) {
93 Units[i]->ProcessCCEvent(itEvent->Param.CC.Controller, itEvent->Param.CC.Value);
94 }
95 }
96
97 /** Initializes and triggers the rack. */
98 virtual void Trigger() {
99 CurrentStep = 0;
100 for (int i = 0; i < Units.size(); i++) {
101 Units[i]->SetOwner(pOwner);
102 Units[i]->Trigger();
103 }
104 }
105
106 virtual void EnterReleaseStage() {
107 for (int i = 0; i < Units.size(); i++) {
108 Units[i]->EnterReleaseStage();
109 }
110 }
111
112 virtual void CancelRelease() {
113 for (int i = 0; i < Units.size(); i++) {
114 Units[i]->CancelRelease();
115 }
116 }
117 };
118 } // namespace LinuxSampler
119
120 #endif /* __LS_SIGNALUNITRACK_H__ */

  ViewVC Help
Powered by ViewVC