Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial
STK realtime audio (blocking) input class. More...
#include <RtWvIn.h>
Public Member Functions | |
RtWvIn (unsigned int nChannels=1, StkFloat sampleRate=Stk::sampleRate(), int deviceIndex=0, int bufferFrames=RT_BUFFER_SIZE, int nBuffers=20) | |
Default constructor. | |
~RtWvIn () | |
Class destructor. | |
void | start (void) |
Start the audio input stream. | |
void | stop (void) |
Stop the audio input stream. | |
StkFloat | lastOut (unsigned int channel=0) |
Return the specified channel value of the last computed frame. | |
StkFloat | tick (unsigned int channel=0) |
Compute a sample frame and return the specified channel value. | |
StkFrames & | tick (StkFrames &frames, unsigned int channel=0) |
Fill the StkFrames object with computed sample frames, starting at the specified channel and return the same reference. | |
Public Member Functions inherited from stk::WvIn | |
unsigned int | channelsOut (void) const |
Return the number of audio channels in the data or stream. | |
const StkFrames & | lastFrame (void) const |
Return an StkFrames reference to the last computed sample frame. | |
virtual StkFloat | tick (unsigned int channel=0)=0 |
Compute one sample frame and return the specified channel value. | |
virtual StkFrames & | tick (StkFrames &frames, unsigned int channel=0)=0 |
Fill the StkFrames object with computed sample frames, starting at the specified channel and return the same reference. | |
Public Member Functions inherited from stk::Stk | |
void | ignoreSampleRateChange (bool ignore=true) |
A function to enable/disable the automatic updating of class data when the STK sample rate changes. | |
Additional Inherited Members | |
Static Public Member Functions inherited from stk::Stk | |
static StkFloat | sampleRate (void) |
Static method that returns the current STK sample rate. | |
static void | setSampleRate (StkFloat rate) |
Static method that sets the STK sample rate. | |
static void | clear_alertList () |
Static method that frees memory from alertList_. | |
static std::string | rawwavePath (void) |
Static method that returns the current rawwave path. | |
static void | setRawwavePath (std::string path) |
Static method that sets the STK rawwave path. | |
static void | swap16 (unsigned char *ptr) |
Static method that byte-swaps a 16-bit data type. | |
static void | swap32 (unsigned char *ptr) |
Static method that byte-swaps a 32-bit data type. | |
static void | swap64 (unsigned char *ptr) |
Static method that byte-swaps a 64-bit data type. | |
static void | sleep (unsigned long milliseconds) |
Static cross-platform method to sleep for a number of milliseconds. | |
static bool | inRange (StkFloat value, StkFloat min, StkFloat max) |
Static method to check whether a value is within a specified range. | |
static void | handleError (const char *message, StkError::Type type) |
Static function for error reporting and handling using c-strings. | |
static void | handleError (std::string message, StkError::Type type) |
Static function for error reporting and handling using c++ strings. | |
static void | showWarnings (bool status) |
Toggle display of WARNING and STATUS messages. | |
static void | printErrors (bool status) |
Toggle display of error messages before throwing exceptions. | |
Static Public Attributes inherited from stk::Stk | |
static const StkFormat | STK_SINT8 |
static const StkFormat | STK_SINT16 |
static const StkFormat | STK_SINT24 |
static const StkFormat | STK_SINT32 |
static const StkFormat | STK_FLOAT32 |
static const StkFormat | STK_FLOAT64 |
Protected Member Functions inherited from stk::Stk | |
Stk (void) | |
Default constructor. | |
virtual | ~Stk (void) |
Class destructor. | |
virtual void | sampleRateChanged (StkFloat newRate, StkFloat oldRate) |
This function should be implemented in subclasses that depend on the sample rate. | |
void | addSampleRateAlert (Stk *ptr) |
Add class pointer to list for sample rate change notification. | |
void | removeSampleRateAlert (Stk *ptr) |
Remove class pointer from list for sample rate change notification. | |
void | handleError (StkError::Type type) const |
Internal function for error reporting that assumes message in oStream_ variable. | |
STK realtime audio (blocking) input class.
This class provides a simplified interface to RtAudio for realtime audio input. It is a subclass of WvIn. This class makes use of RtAudio's callback functionality by creating a large ring-buffer from which data is read. This class should not be used when low-latency is desired.
RtWvIn supports multi-channel data in both interleaved and non-interleaved formats. It is important to distinguish the tick() method that computes a single frame (and returns only the specified sample of a multi-channel frame) from the overloaded one that takes an StkFrames object for multi-channel and/or multi-frame data.
by Perry R. Cook and Gary P. Scavone, 1995–2023.
stk::RtWvIn::RtWvIn | ( | unsigned int | nChannels = 1 , |
StkFloat | sampleRate = Stk::sampleRate() , |
||
int | deviceIndex = 0 , |
||
int | bufferFrames = RT_BUFFER_SIZE , |
||
int | nBuffers = 20 |
||
) |
Default constructor.
The default deviceIndex argument value (zero) will select the default input device on your system. The first device enumerated by the underlying audio API is specified with a value of one. The default buffer size of RT_BUFFER_SIZE is defined in Stk.h. An StkError will be thrown if an error occurs duing instantiation.
void stk::RtWvIn::start | ( | void | ) |
Start the audio input stream.
The stream is started automatically, if necessary, when a tick() or tickFrame() method is called.
void stk::RtWvIn::stop | ( | void | ) |
Stop the audio input stream.
It may be necessary to use this method to avoid audio underflow problems if you wish to temporarily stop audio input.
|
inline |
Return the specified channel value of the last computed frame.
For multi-channel files, use the lastFrame() function to get all values from the last computed frame. If the device is stopped, the returned value is 0.0. The channel
argument must be less than the number of channels in the audio stream (the first channel is specified by 0). However, range checking is only performed if STK_DEBUG is defined during compilation, in which case an out-of-range value will trigger an StkError exception.
|
virtual |
Compute a sample frame and return the specified channel
value.
For multi-channel files, use the lastFrame() function to get all values from the computed frame. If the device is "stopped", it is "started". The channel
argument must be less than the number of channels in the audio stream (the first channel is specified by 0). However, range checking is only performed if STK_DEBUG is defined during compilation, in which case an out-of-range value will trigger an StkError exception.
Implements stk::WvIn.
Fill the StkFrames object with computed sample frames, starting at the specified channel and return the same reference.
If the device is "stopped", it is "started". The channel
argument plus the number of input channels must be less than the number of channels in the StkFrames argument (the first channel is specified by 0). However, range checking is only performed if STK_DEBUG is defined during compilation, in which case an out-of-range value will trigger an StkError exception.
Implements stk::WvIn.
The Synthesis ToolKit in C++ (STK) |
©1995--2023 Perry R. Cook and Gary P. Scavone. All Rights Reserved. |