1 //-----------------------------------------------------------------------------
4 // Category : SDK Core Interfaces
5 // Filename : pluginterfaces/base/futils.h
6 // Created by : Steinberg, 01/2004
7 // Description : Basic utilities
9 //-----------------------------------------------------------------------------
10 // This file is part of a Steinberg SDK. It is subject to the license terms
11 // in the LICENSE file found in the top-level directory of this distribution
12 // and at www.steinberg.net/sdklicenses.
13 // No part of the SDK, including this file, may be copied, modified, propagated,
14 // or distributed except according to the terms contained in the LICENSE file.
15 //-----------------------------------------------------------------------------
19 #include "pluginterfaces/base/ftypes.h"
22 //----------------------------------------------------------------------------
23 // min/max/etc. template functions
25 inline const T
& Min (const T
& a
, const T
& b
)
31 inline const T
& Max (const T
& a
, const T
& b
)
37 inline T
Abs (const T
& value
)
39 return (value
>= (T
)0) ? value
: -value
;
43 inline T
Sign (const T
& value
)
45 return (value
== (T
)0) ? 0 : ((value
>= (T
)0) ? 1 : -1);
49 inline T
Bound (T minval
, T maxval
, T x
)
59 void Swap (T
& t1
, T
& t2
)
67 bool IsApproximateEqual (T t1
, T t2
, T epsilon
)
80 inline T
ToNormalized (const T
& value
, const int32 numSteps
)
82 return value
/ T (numSteps
);
86 inline int32
FromNormalized (const T
& norm
, const int32 numSteps
)
88 return Min
<int32
> (numSteps
, int32 (norm
* (numSteps
+ 1)));
91 // Four character constant
93 #define CCONST(a, b, c, d) \
94 ((((int32) (a)) << 24) | (((int32) (b)) << 16) | (((int32) (c)) << 8) | (((int32) (d)) << 0))
97 //------------------------------------------------------------------------
98 } // namespace Steinberg