mirror of
https://github.com/thestk/stk
synced 2026-01-19 07:31:52 +00:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
4574
src/RtAudio.cpp
4574
src/RtAudio.cpp
File diff suppressed because it is too large
Load Diff
1376
src/RtMidi.cpp
1376
src/RtMidi.cpp
File diff suppressed because it is too large
Load Diff
@@ -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, ¶meters, format, (unsigned int)Stk::sampleRate(), &size, &read, (void *)this );
|
||||
}
|
||||
catch ( RtAudioError &error ) {
|
||||
handleError( error.what(), StkError::AUDIO_SYSTEM );
|
||||
if ( adc_.openStream( NULL, ¶meters, format, (unsigned int)Stk::sampleRate(), &size, &read, (void *)this ) ) {
|
||||
handleError( adc_.getErrorText(), StkError::AUDIO_SYSTEM );
|
||||
}
|
||||
|
||||
data_.resize( size * nBuffers, nChannels );
|
||||
|
||||
@@ -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( ¶meters, NULL, format, (unsigned int)Stk::sampleRate(), &size, &write, (void *)this );
|
||||
}
|
||||
catch ( RtAudioError &error ) {
|
||||
handleError( error.what(), StkError::AUDIO_SYSTEM );
|
||||
if ( dac_.openStream( ¶meters, NULL, format, (unsigned int)Stk::sampleRate(), &size, &write, (void *)this ) ) {
|
||||
handleError( dac_.getErrorText(), StkError::AUDIO_SYSTEM );
|
||||
}
|
||||
|
||||
data_.resize( size * nBuffers, nChannels );
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user