#include <iostream>
#include <cstdlib>
#include <cstring>
int inout( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
{
if ( status ) std::cout << "Stream over/underflow detected." << std::endl;
unsigned int *bytes = (unsigned int *) data;
memcpy( outputBuffer, inputBuffer, *bytes );
return 0;
}
int main()
{
if ( deviceIds.size() < 1 ) {
std::cout << "\nNo audio devices found!\n";
exit( 0 );
}
unsigned int bufferBytes, bufferFrames = 512;
if ( adac.
openStream( &oParams, &iParams, RTAUDIO_SINT32, 44100,
&bufferFrames, &inout, (void *)&bufferBytes ) ) {
std::cout <<
'\n' << adac.
getErrorText() <<
'\n' << std::endl;
exit( 0 );
}
bufferBytes = bufferFrames * 2 * 4;
goto cleanup;
}
char input;
std::cout << "\nRunning ... press <enter> to quit.\n";
std::cin.get(input);
cleanup:
return 0;
}
unsigned int RtAudioStreamStatus
RtAudio stream status (over- or underflow) flags.
Definition RtAudio.h:178
Realtime audio i/o C++ classes.
Definition RtAudio.h:268
bool isStreamRunning(void) const
Returns true if the stream is running and false if it is stopped or not open.
Definition RtAudio.h:922
RtAudioErrorType stopStream(void)
Stop a stream, allowing any samples remaining in the output queue to be played.
Definition RtAudio.h:918
const std::string getErrorText(void)
Retrieve the error message corresponding to the last error or warning condition.
Definition RtAudio.h:920
unsigned int nChannels
Definition RtAudio.h:305
void closeStream(void)
A function that closes a stream and frees any associated stream memory.
Definition RtAudio.h:916
RtAudioErrorType openStream(RtAudio::StreamParameters *outputParameters, RtAudio::StreamParameters *inputParameters, RtAudioFormat format, unsigned int sampleRate, unsigned int *bufferFrames, RtAudioCallback callback, void *userData=NULL, RtAudio::StreamOptions *options=NULL)
A public function for opening a stream with the specified parameters.
RtAudioErrorType startStream(void)
A function that starts a stream.
Definition RtAudio.h:917
bool isStreamOpen(void) const
Returns true if a stream is open and false if not.
Definition RtAudio.h:921
std::vector< unsigned int > getDeviceIds(void)
A public function that returns a vector of audio device IDs.
Definition RtAudio.h:912
unsigned int deviceId
Definition RtAudio.h:304
The structure for specifying input or output stream parameters.
Definition RtAudio.h:302
In this example, audio recorded by the stream input will be played out during the next round of audio processing.
Note that a duplex stream can (and often must) make use of two different devices (except when using the Linux Jack and Windows ASIO APIs). However, if the two devices do not share a common internal or external "sync", there may be timing problems due to possible device clock variations.