8dc645b1a527d5d0da50937f4b56eb96f50d6fce
3 Copyright (C) 2011 Grame
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 Grame Research Laboratory, 9 rue du Garet, 69001 Lyon - France
31 #include "MessageDriven.h"
37 typedef class SMARTP
<FaustNode
> SFaustNode
;
40 * map (rescale) input values to output values
50 mapping(float imin
, float imax
, float omin
, float omax
) : fMinIn(imin
), fMaxIn(imax
),
51 fMinOut(omin
), fMaxOut(omax
),
52 fScale( (fMaxOut
-fMinOut
)/(fMaxIn
-fMinIn
) ) {}
53 float scale (float x
) { float z
= (x
< fMinIn
) ? fMinIn
: (x
> fMaxIn
) ? fMaxIn
: x
; return fMinOut
+ (z
- fMinIn
) * fScale
; }
57 //--------------------------------------------------------------------------
59 \brief a faust node is a terminal node and represents a faust parameter controler
61 class FaustNode
: public MessageDriven
63 float * fZone
; // the parameter memory zone
66 bool store (float val
);
69 FaustNode(const char *name
, float* zone
, float init
, float min
, float max
, const char* prefix
)
70 : MessageDriven (name
, prefix
), fZone(zone
), fMapping(min
, max
, min
, max
)
73 FaustNode(const char *name
, float* zone
, float imin
, float imax
, float init
, float min
, float max
, const char* prefix
)
74 : MessageDriven (name
, prefix
), fZone(zone
), fMapping(imin
, imax
, min
, max
)
76 virtual ~FaustNode() {}
79 static SFaustNode
create (const char* name
, float* zone
, float init
, float min
, float max
, const char* prefix
)
80 { return new FaustNode(name
, zone
, init
, min
, max
, prefix
); }
81 static SFaustNode
create (const char* name
, float* zone
, float imin
, float imax
, float init
, float min
, float max
, const char* prefix
)
82 { return new FaustNode(name
, zone
, imin
, imax
, init
, min
, max
, prefix
); }
85 virtual bool accept( const Message
* msg
); ///< handler for the 'accept' message
86 virtual void get (unsigned long ipdest
) const; ///< handler for the 'get' message