Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial

WvOut.h
1 #ifndef STK_WVOUT_H
2 #define STK_WVOUT_H
3
4 #include "Stk.h"
5
6 namespace stk {
7
8 /***************************************************/
20 /***************************************************/
21
22 class WvOut : public Stk
23 {
24 public:
25
27 WvOut( void ) : frameCounter_(0), clipping_(false) {};
28
30 unsigned long getFrameCount( void ) const { return frameCounter_; };
31
33 StkFloat getTime( void ) const { return (StkFloat) frameCounter_ / Stk::sampleRate(); };
34
36 bool clipStatus( void ) { return clipping_; };
37
39 void resetClipStatus( void ) { clipping_ = false; };
40
42
45 virtual void tick( const StkFloat sample ) = 0;
46
48 virtual void tick( const StkFrames& frames ) = 0;
49
50 protected:
51
52 // Check for sample clipping and clamp.
53 StkFloat& clipTest( StkFloat& sample );
54
55 StkFrames data_;
56 unsigned long frameCounter_;
57 bool clipping_;
58
59 };
60
61 inline StkFloat& WvOut :: clipTest( StkFloat& sample )
62 {
63 bool clip = false;
64 if ( sample > 1.0 ) {
65 sample = 1.0;
66 clip = true;
67 }
68 else if ( sample < -1.0 ) {
69 sample = -1.0;
70 clip = true;
71 }
72
73 if ( clip == true && clipping_ == false ) {
74 // First occurrence of clipping since instantiation or reset.
75 clipping_ = true;
76 oStream_ << "WvOut: data value(s) outside +-1.0 detected ... clamping at outer bound!";
77 handleError( StkError::WARNING );
78 }
79
80 return sample;
81 }
82
83 } // stk namespace
84
85 #endif

The Synthesis ToolKit in C++ (STK)
©1995--2017 Perry R. Cook and Gary P. Scavone. All Rights Reserved.