Added new versions of RtAudio and RtMidi, updated RtWvIn and RtWvOut for new API, updated demo project for new API.

This commit is contained in:
garyscavone
2023-08-04 09:44:26 -04:00
parent 2af2f1c816
commit 8b29e0ea6d
15 changed files with 4225 additions and 2579 deletions

View File

@@ -172,8 +172,8 @@ void BlowHole :: startBlowing( StkFloat amplitude, StkFloat rate )
void BlowHole :: stopBlowing( StkFloat rate )
{
if ( rate <= 0.0 ) {
oStream_ << "BlowHole::stopBlowing: argument is less than or equal to zero!";
if ( rate < 0.0 ) {
oStream_ << "BlowHole::stopBlowing: argument is less than zero!";
handleError( StkError::WARNING ); return;
}

View File

@@ -105,8 +105,8 @@ void Brass :: startBlowing( StkFloat amplitude, StkFloat rate )
void Brass :: stopBlowing( StkFloat rate )
{
if ( rate <= 0.0 ) {
oStream_ << "Brass::stopBlowing: argument is less than or equal to zero!";
if ( rate < 0.0 ) {
oStream_ << "Brass::stopBlowing: argument is less than zero!";
handleError( StkError::WARNING ); return;
}

View File

@@ -86,8 +86,8 @@ void Clarinet :: startBlowing( StkFloat amplitude, StkFloat rate )
void Clarinet :: stopBlowing( StkFloat rate )
{
if ( rate <= 0.0 ) {
oStream_ << "Clarinet::stopBlowing: argument is less than or equal to zero!";
if ( rate < 0.0 ) {
oStream_ << "Clarinet::stopBlowing: argument is less than zero!";
handleError( StkError::WARNING ); return;
}

View File

@@ -110,8 +110,8 @@ void Flute :: startBlowing( StkFloat amplitude, StkFloat rate )
void Flute :: stopBlowing( StkFloat rate )
{
if ( rate <= 0.0 ) {
oStream_ << "Flute::stopBlowing: argument is less than or equal to zero!";
if ( rate < 0.0 ) {
oStream_ << "Flute::stopBlowing: argument is less than zero!";
handleError( StkError::WARNING ); return;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -70,24 +70,28 @@ void RtWvIn :: fillBuffer( void *buffer, unsigned int nFrames )
}
}
RtWvIn :: RtWvIn( unsigned int nChannels, StkFloat sampleRate, int device, int bufferFrames, int nBuffers )
RtWvIn :: RtWvIn( unsigned int nChannels, StkFloat sampleRate, int deviceIndex, int bufferFrames, int nBuffers )
: stopped_( true ), readIndex_( 0 ), writeIndex_( 0 ), framesFilled_( 0 )
{
std::vector<unsigned int> deviceIds = adc_.getDeviceIds();
if ( deviceIds.size() < 1 )
handleError( "RtWvIn: No audio devices found!", StkError::AUDIO_SYSTEM );
// We'll let RtAudio deal with channel and sample rate limitations.
RtAudio::StreamParameters parameters;
if ( device == 0 )
if ( deviceIndex == 0 )
parameters.deviceId = adc_.getDefaultInputDevice();
else
parameters.deviceId = device - 1;
else {
if ( deviceIndex >= deviceIds.size() )
handleError( "RtWvIn: Device index is invalid.", StkError::AUDIO_SYSTEM );
parameters.deviceId = deviceIds[deviceIndex-1];
}
parameters.nChannels = nChannels;
unsigned int size = bufferFrames;
RtAudioFormat format = ( sizeof(StkFloat) == 8 ) ? RTAUDIO_FLOAT64 : RTAUDIO_FLOAT32;
try {
adc_.openStream( NULL, &parameters, format, (unsigned int)Stk::sampleRate(), &size, &read, (void *)this );
}
catch ( RtAudioError &error ) {
handleError( error.what(), StkError::AUDIO_SYSTEM );
if ( adc_.openStream( NULL, &parameters, format, (unsigned int)Stk::sampleRate(), &size, &read, (void *)this ) ) {
handleError( adc_.getErrorText(), StkError::AUDIO_SYSTEM );
}
data_.resize( size * nBuffers, nChannels );

View File

@@ -90,25 +90,29 @@ int RtWvOut :: readBuffer( void *buffer, unsigned int frameCount )
}
RtWvOut :: RtWvOut( unsigned int nChannels, StkFloat sampleRate, int device, int bufferFrames, int nBuffers )
RtWvOut :: RtWvOut( unsigned int nChannels, StkFloat sampleRate, int deviceIndex, int bufferFrames, int nBuffers )
: stopped_( true ), readIndex_( 0 ), writeIndex_( 0 ), framesFilled_( 0 ), status_(0)
{
std::vector<unsigned int> deviceIds = dac_.getDeviceIds();
if ( deviceIds.size() < 1 )
handleError( "RtWvOut: No audio devices found!", StkError::AUDIO_SYSTEM );
// We'll let RtAudio deal with channel and sample rate limitations.
RtAudio::StreamParameters parameters;
if ( device == 0 )
if ( deviceIndex == 0 )
parameters.deviceId = dac_.getDefaultOutputDevice();
else
parameters.deviceId = device - 1;
else {
if ( deviceIndex >= deviceIds.size() )
handleError( "RtWvOut: Device index is invalid.", StkError::AUDIO_SYSTEM );
parameters.deviceId = deviceIds[deviceIndex-1];
}
parameters.nChannels = nChannels;
unsigned int size = bufferFrames;
RtAudioFormat format = ( sizeof(StkFloat) == 8 ) ? RTAUDIO_FLOAT64 : RTAUDIO_FLOAT32;
// Open a stream and set the callback function.
try {
dac_.openStream( &parameters, NULL, format, (unsigned int)Stk::sampleRate(), &size, &write, (void *)this );
}
catch ( RtAudioError &error ) {
handleError( error.what(), StkError::AUDIO_SYSTEM );
if ( dac_.openStream( &parameters, NULL, format, (unsigned int)Stk::sampleRate(), &size, &write, (void *)this ) ) {
handleError( dac_.getErrorText(), StkError::AUDIO_SYSTEM );
}
data_.resize( size * nBuffers, nChannels );

View File

@@ -121,8 +121,8 @@ void Saxofony :: startBlowing( StkFloat amplitude, StkFloat rate )
void Saxofony :: stopBlowing( StkFloat rate )
{
if ( rate <= 0.0 ) {
oStream_ << "Saxofony::stopBlowing: argument is less than or equal to zero!";
if ( rate < 0.0 ) {
oStream_ << "Saxofony::stopBlowing: argument is less than zero!";
handleError( StkError::WARNING ); return;
}