Home   Information   Classes   Download   Usage   Mail List   Requirements   Links   FAQ   Tutorial


RtWvIn.h
1 #ifndef STK_RTWVIN_H
2 #define STK_RTWVIN_H
3 
4 #include "WvIn.h"
5 #include "RtAudio.h"
6 #include "Mutex.h"
7 
8 namespace stk {
9 
10 /***************************************************/
29 /***************************************************/
30 
31 class RtWvIn : public WvIn
32 {
33 public:
35 
42  RtWvIn( unsigned int nChannels = 1, StkFloat sampleRate = Stk::sampleRate(),
43  int device = 0, int bufferFrames = RT_BUFFER_SIZE, int nBuffers = 20 );
44 
46  ~RtWvIn();
47 
49 
53  void start( void );
54 
56 
60  void stop( void );
61 
63 
72  StkFloat lastOut( unsigned int channel = 0 );
73 
75 
84  StkFloat tick( unsigned int channel = 0 );
85 
87 
95  StkFrames& tick( StkFrames& frames, unsigned int channel = 0 );
96 
97  // This function is not intended for general use but must be
98  // public for access from the audio callback function.
99  void fillBuffer( void *buffer, unsigned int nFrames );
100 
101 protected:
102 
103  RtAudio adc_;
104  Mutex mutex_;
105  bool stopped_;
106  unsigned int readIndex_;
107  unsigned int writeIndex_;
108  unsigned int framesFilled_;
109 
110 };
111 
112 inline StkFloat RtWvIn :: lastOut( unsigned int channel )
113 {
114 #if defined(_STK_DEBUG_)
115  if ( channel >= data_.channels() ) {
116  oStream_ << "RtWvIn::lastOut(): channel argument and audio stream are incompatible!";
117  handleError( StkError::FUNCTION_ARGUMENT );
118  }
119 #endif
120 
121  return lastFrame_[channel];
122 }
123 
124 } // stk namespace
125 
126 #endif
stk::RtWvIn::lastOut
StkFloat lastOut(unsigned int channel=0)
Return the specified channel value of the last computed frame.
Definition: RtWvIn.h:112
stk::RtWvIn::tick
StkFloat tick(unsigned int channel=0)
Compute a sample frame and return the specified channel value.
stk::Stk::sampleRate
static StkFloat sampleRate(void)
Static method that returns the current STK sample rate.
Definition: Stk.h:145
stk::StkFrames
An STK class to handle vectorized audio data.
Definition: Stk.h:275
stk::StkFrames::channels
unsigned int channels(void) const
Return the number of channels represented by the data.
Definition: Stk.h:404
stk::Mutex
STK mutex class.
Definition: Mutex.h:36
stk::Stk::handleError
static void handleError(const char *message, StkError::Type type)
Static function for error reporting and handling using c-strings.
stk::RtWvIn::RtWvIn
RtWvIn(unsigned int nChannels=1, StkFloat sampleRate=Stk::sampleRate(), int device=0, int bufferFrames=RT_BUFFER_SIZE, int nBuffers=20)
Default constructor.
stk::RtWvIn
STK realtime audio (blocking) input class.
Definition: RtWvIn.h:31
stk
The STK namespace.
Definition: ADSR.h:6
stk::WvIn
STK audio input abstract base class.
Definition: WvIn.h:19
stk::RtWvIn::stop
void stop(void)
Stop the audio input stream.
stk::RtWvIn::start
void start(void)
Start the audio input stream.
stk::RtWvIn::~RtWvIn
~RtWvIn()
Class destructor.

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