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
stk::StkFrames
An STK class to handle vectorized audio data.
Definition Stk.h:279
stk::Stk
STK base class.
Definition Stk.h:136
stk::Stk::sampleRate
static StkFloat sampleRate(void)
Static method that returns the current STK sample rate.
Definition Stk.h:148
stk::WvOut
STK audio output abstract base class.
Definition WvOut.h:23
stk::WvOut::getTime
StkFloat getTime(void) const
Return the number of seconds of data output.
Definition WvOut.h:33
stk::WvOut::WvOut
WvOut(void)
Default constructor.
Definition WvOut.h:27
stk::WvOut::resetClipStatus
void resetClipStatus(void)
Reset the clipping status to false.
Definition WvOut.h:39
stk::WvOut::tick
virtual void tick(const StkFrames &frames)=0
Output the StkFrames data.
stk::WvOut::tick
virtual void tick(const StkFloat sample)=0
Output a single sample to all channels in a sample frame.
stk::WvOut::clipStatus
bool clipStatus(void)
Returns true if clipping has been detected during output since instantiation or the last reset.
Definition WvOut.h:36
stk::WvOut::getFrameCount
unsigned long getFrameCount(void) const
Return the number of sample frames output.
Definition WvOut.h:30
stk
The STK namespace.
Definition ADSR.h:6

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