mirror of
https://github.com/thestk/stk
synced 2026-05-03 04:18:12 +00:00
Compare commits
19 Commits
4.5.1
...
arielelkin
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
889328c3c1 | ||
|
|
62416d7e3f | ||
|
|
9627701d04 | ||
|
|
9966f06757 | ||
|
|
56bcdc32ed | ||
|
|
2ddc79e3bd | ||
|
|
96b1a72186 | ||
|
|
2a6ada02a7 | ||
|
|
488301223a | ||
|
|
08f71c8fa9 | ||
|
|
e03aa486dd | ||
|
|
5dd605ecfd | ||
|
|
77a5cfa4aa | ||
|
|
77bdb45575 | ||
|
|
ff52b9f0b0 | ||
|
|
fe0f5d7f96 | ||
|
|
e1aa259517 | ||
|
|
95fcd14213 | ||
|
|
a5bef56e76 |
@@ -167,7 +167,7 @@ if test $realtime = yes; then
|
||||
api="$api -D__MACOSX_CORE__"
|
||||
AC_MSG_RESULT(using CoreAudio)
|
||||
AC_CHECK_HEADER(CoreAudio/CoreAudio.h, [], [AC_MSG_ERROR(CoreAudio header files not found!)] )
|
||||
LIBS="$LIBS -framework CoreAudio -framework CoreFoundation -framework CoreMidi" ], )
|
||||
LIBS="$LIBS -framework CoreAudio -framework CoreFoundation -framework CoreMIDI" ], )
|
||||
|
||||
# If no audio api flags specified, use CoreAudio
|
||||
if [test "$api" == ""; ] then
|
||||
@@ -176,7 +176,7 @@ if test $realtime = yes; then
|
||||
AC_CHECK_HEADER(CoreAudio/CoreAudio.h,
|
||||
[],
|
||||
[AC_MSG_ERROR(CoreAudio header files not found!)] )
|
||||
AC_SUBST( LIBS, ["-framework CoreAudio -framework CoreFoundation -framework CoreMidi"] )
|
||||
AC_SUBST( LIBS, ["-framework CoreAudio -framework CoreFoundation -framework CoreMIDI"] )
|
||||
fi
|
||||
|
||||
AC_CHECK_LIB(pthread, pthread_create, , AC_MSG_ERROR(RtAudio requires the pthread library!))
|
||||
|
||||
@@ -56,7 +56,7 @@ STK compiles with realtime support on the following flavors of the Unix operatin
|
||||
<TD>Macintosh OS X</TD>
|
||||
<TD>CoreAudio</TD>
|
||||
<TD>__MACOSX_CORE__</TD>
|
||||
<TD><TT>pthread, CoreAudio, CoreMidi, CoreFoundation</TT></TD>
|
||||
<TD><TT>pthread, CoreAudio, CoreMIDI, CoreFoundation</TT></TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
</CENTER>
|
||||
|
||||
@@ -31,7 +31,8 @@ class FileLoop : protected FileWvIn
|
||||
|
||||
//! Class constructor that opens a specified file.
|
||||
FileLoop( std::string fileName, bool raw = false, bool doNormalize = true,
|
||||
unsigned long chunkThreshold = 1000000, unsigned long chunkSize = 1024 );
|
||||
unsigned long chunkThreshold = 1000000, unsigned long chunkSize = 1024,
|
||||
bool doInt2FloatScaling = true );
|
||||
|
||||
//! Class destructor.
|
||||
~FileLoop( void );
|
||||
@@ -40,13 +41,14 @@ class FileLoop : protected FileWvIn
|
||||
/*!
|
||||
Data from a previously opened file will be overwritten by this
|
||||
function. An StkError will be thrown if the file is not found,
|
||||
its format is unknown, or a read error occurs. If the file data
|
||||
is to be loaded incrementally from disk and normalization is
|
||||
specified, a scaling will be applied with respect to fixed-point
|
||||
limits. If the data format is floating-point, no scaling is
|
||||
performed.
|
||||
its format is unknown, or a read error occurs. If the file length
|
||||
is less than the chunkThreshold limit and \e doNormalize is true,
|
||||
the file data will be normalized with respect to the maximum absolute
|
||||
value of the data. If the \e doInt2FloatScaling flag is true and the
|
||||
input data is fixed-point, a scaling will be applied with respect to
|
||||
the fixed-point limits.
|
||||
*/
|
||||
void openFile( std::string fileName, bool raw = false, bool doNormalize = true );
|
||||
void openFile( std::string fileName, bool raw = false, bool doNormalize = true, bool doInt2FloatScaling = true );
|
||||
|
||||
//! Close a file if one is open.
|
||||
void closeFile( void ) { FileWvIn::closeFile(); };
|
||||
|
||||
@@ -29,6 +29,16 @@ namespace stk {
|
||||
chunkThreshold (in sample frames) will be read incrementally in
|
||||
chunks of \e chunkSize each (also in sample frames).
|
||||
|
||||
For file data read completely into local memory, the \e doNormalize
|
||||
flag can be used to normalize all values with respect to the maximum
|
||||
absolute value of the data.
|
||||
|
||||
If the file data format is fixed point, the flag \e doInt2FloatScaling
|
||||
can be used to control whether the values are scaled with respect to
|
||||
the corresponding fixed-point maximum. For example, if reading 16-bit
|
||||
signed integers, the input values will be scaled by 1 / 32768.0. This
|
||||
scaling will not happen for floating-point file data formats.
|
||||
|
||||
When the file end is reached, subsequent calls to the tick()
|
||||
functions return zeros and isFinished() returns \e true.
|
||||
|
||||
@@ -51,7 +61,8 @@ public:
|
||||
unknown, or a read error occurs.
|
||||
*/
|
||||
FileWvIn( std::string fileName, bool raw = false, bool doNormalize = true,
|
||||
unsigned long chunkThreshold = 1000000, unsigned long chunkSize = 1024 );
|
||||
unsigned long chunkThreshold = 1000000, unsigned long chunkSize = 1024,
|
||||
bool doInt2FloatScaling = true );
|
||||
|
||||
//! Class destructor.
|
||||
~FileWvIn( void );
|
||||
@@ -60,13 +71,14 @@ public:
|
||||
/*!
|
||||
Data from a previously opened file will be overwritten by this
|
||||
function. An StkError will be thrown if the file is not found,
|
||||
its format is unknown, or a read error occurs. If the file data
|
||||
is to be loaded incrementally from disk and normalization is
|
||||
specified, a scaling will be applied with respect to fixed-point
|
||||
limits. If the data format is floating-point, no scaling is
|
||||
performed.
|
||||
its format is unknown, or a read error occurs. If the file length
|
||||
is less than the chunkThreshold limit and \e doNormalize is true,
|
||||
the file data will be normalized with respect to the maximum absolute
|
||||
value of the data. If the \e doInt2FloatScaling flag is true and the
|
||||
input data is fixed-point, a scaling will be applied with respect to
|
||||
the fixed-point limits.
|
||||
*/
|
||||
virtual void openFile( std::string fileName, bool raw = false, bool doNormalize = true );
|
||||
virtual void openFile( std::string fileName, bool raw = false, bool doNormalize = true, bool doInt2FloatScaling = true );
|
||||
|
||||
//! Close a file if one is open.
|
||||
virtual void closeFile( void );
|
||||
@@ -167,7 +179,7 @@ protected:
|
||||
FileRead file_;
|
||||
bool finished_;
|
||||
bool interpolate_;
|
||||
bool normalizing_;
|
||||
bool int2floatscaling_;
|
||||
bool chunking_;
|
||||
StkFloat time_;
|
||||
StkFloat rate_;
|
||||
|
||||
@@ -1 +1 @@
|
||||
wish < tcl/Banded.tcl | stk-demo BandedWG -or -ip
|
||||
wish < tcl/Banded.tcl | ./stk-demo BandedWG -or -ip
|
||||
|
||||
@@ -1 +1 @@
|
||||
wish < tcl/Drums.tcl | stk-demo Drummer -or -ip
|
||||
wish < tcl/Drums.tcl | ./stk-demo Drummer -or -ip
|
||||
|
||||
@@ -1 +1 @@
|
||||
wish < tcl/Modal.tcl | stk-demo ModalBar -or -ip
|
||||
wish < tcl/Modal.tcl | ./stk-demo ModalBar -or -ip
|
||||
|
||||
@@ -1 +1 @@
|
||||
wish < tcl/Physical.tcl | stk-demo Clarinet -or -ip
|
||||
wish < tcl/Physical.tcl | ./stk-demo Clarinet -or -ip
|
||||
|
||||
@@ -1 +1 @@
|
||||
wish < tcl/Shakers.tcl | stk-demo Shakers -or -ip
|
||||
wish < tcl/Shakers.tcl | ./stk-demo Shakers -or -ip
|
||||
|
||||
@@ -1 +1 @@
|
||||
wish < tcl/Demo.tcl | stk-demo Clarinet -or -ip
|
||||
wish < tcl/Demo.tcl | ./stk-demo Clarinet -or -ip
|
||||
|
||||
@@ -1 +1 @@
|
||||
wish < tcl/Voice.tcl | stk-demo FMVoices -or -ip
|
||||
wish < tcl/Voice.tcl | ./stk-demo FMVoices -or -ip
|
||||
|
||||
@@ -104,6 +104,7 @@ int main(int argc, char *argv[])
|
||||
RtAudio::StreamOptions options;
|
||||
//options.flags |= RTAUDIO_NONINTERLEAVED;
|
||||
|
||||
bufferBytes = bufferFrames * channels * sizeof( MY_TYPE );
|
||||
try {
|
||||
adac.openStream( &oParams, &iParams, FORMAT, fs, &bufferFrames, &inout, (void *)&bufferBytes, &options );
|
||||
}
|
||||
@@ -112,8 +113,6 @@ int main(int argc, char *argv[])
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
bufferBytes = bufferFrames * channels * sizeof( MY_TYPE );
|
||||
|
||||
// Test RtAudio functionality for reporting latency.
|
||||
std::cout << "\nStream latency = " << adac.getStreamLatency() << " frames" << std::endl;
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
using namespace stk;
|
||||
|
||||
// Eewww ... global variables! :-)
|
||||
bool done;
|
||||
bool done = false;
|
||||
StkFrames frames;
|
||||
static void finish(int ignore){ done = true; }
|
||||
|
||||
@@ -45,9 +45,10 @@ int tick( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
|
||||
double streamTime, RtAudioStreamStatus status, void *userData )
|
||||
{
|
||||
FileWvIn *input = (FileWvIn *) userData;
|
||||
register StkFloat *samples = (StkFloat *) outputBuffer;
|
||||
StkFloat *samples = (StkFloat *) outputBuffer;
|
||||
|
||||
input->tick( frames );
|
||||
|
||||
for ( unsigned int i=0; i<frames.size(); i++ ) {
|
||||
*samples++ = frames[i];
|
||||
if ( input->channelsOut() == 1 ) *samples++ = frames[i]; // play mono files in stereo
|
||||
|
||||
@@ -42,7 +42,7 @@ Delay :: ~Delay()
|
||||
void Delay :: setMaximumDelay( unsigned long delay )
|
||||
{
|
||||
if ( delay < inputs_.size() ) return;
|
||||
inputs_.resize( delay + 1 );
|
||||
inputs_.resize( delay + 1, 1, 0.0 );
|
||||
}
|
||||
|
||||
void Delay :: setDelay( unsigned long delay )
|
||||
|
||||
@@ -98,10 +98,11 @@ void FMVoices :: setFrequency( StkFloat frequency )
|
||||
i = currentVowel_ - 64;
|
||||
temp2 = 1.1;
|
||||
}
|
||||
else if (currentVowel_ <= 128) {
|
||||
else if (currentVowel_ < 128) {
|
||||
i = currentVowel_ - 96;
|
||||
temp2 = 1.2;
|
||||
}
|
||||
else return;
|
||||
|
||||
baseFrequency_ = frequency;
|
||||
temp = (temp2 * Phonemes::formantFrequency(i, 0) / baseFrequency_) + 0.5;
|
||||
@@ -140,7 +141,7 @@ void FMVoices :: controlChange( int number, StkFloat value )
|
||||
if (number == __SK_Breath_) // 2
|
||||
gains_[3] = fmGains_[(int) ( normalizedValue * 99.9 )];
|
||||
else if (number == __SK_FootControl_) { // 4
|
||||
currentVowel_ = (int) (normalizedValue * 128.0);
|
||||
currentVowel_ = (int) (normalizedValue * 127.0);
|
||||
this->setFrequency(baseFrequency_);
|
||||
}
|
||||
else if (number == __SK_ModFrequency_) // 11
|
||||
|
||||
@@ -28,10 +28,11 @@ FileLoop :: FileLoop( unsigned long chunkThreshold, unsigned long chunkSize )
|
||||
}
|
||||
|
||||
FileLoop :: FileLoop( std::string fileName, bool raw, bool doNormalize,
|
||||
unsigned long chunkThreshold, unsigned long chunkSize )
|
||||
unsigned long chunkThreshold, unsigned long chunkSize,
|
||||
bool doInt2FloatScaling )
|
||||
: FileWvIn( chunkThreshold, chunkSize ), phaseOffset_(0.0)
|
||||
{
|
||||
this->openFile( fileName, raw, doNormalize );
|
||||
this->openFile( fileName, raw, doNormalize, doInt2FloatScaling );
|
||||
Stk::addSampleRateAlert( this );
|
||||
}
|
||||
|
||||
@@ -40,7 +41,7 @@ FileLoop :: ~FileLoop( void )
|
||||
Stk::removeSampleRateAlert( this );
|
||||
}
|
||||
|
||||
void FileLoop :: openFile( std::string fileName, bool raw, bool doNormalize )
|
||||
void FileLoop :: openFile( std::string fileName, bool raw, bool doNormalize, bool doInt2FloatScaling )
|
||||
{
|
||||
// Call close() in case another file is already open.
|
||||
this->closeFile();
|
||||
@@ -53,16 +54,19 @@ void FileLoop :: openFile( std::string fileName, bool raw, bool doNormalize )
|
||||
chunking_ = true;
|
||||
chunkPointer_ = 0;
|
||||
data_.resize( chunkSize_ + 1, file_.channels() );
|
||||
if ( doNormalize ) normalizing_ = true;
|
||||
else normalizing_ = false;
|
||||
}
|
||||
else {
|
||||
chunking_ = false;
|
||||
data_.resize( file_.fileSize() + 1, file_.channels() );
|
||||
}
|
||||
|
||||
if ( doInt2FloatScaling )
|
||||
int2floatscaling_ = true;
|
||||
else
|
||||
int2floatscaling_ = false;
|
||||
|
||||
// Load all or part of the data.
|
||||
file_.read( data_, 0, doNormalize );
|
||||
file_.read( data_, 0, int2floatscaling_ );
|
||||
|
||||
if ( chunking_ ) { // If chunking, save the first sample frame for later.
|
||||
firstFrame_.resize( 1, data_.channels() );
|
||||
@@ -134,6 +138,8 @@ StkFloat FileLoop :: tick( unsigned int channel )
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( finished_ ) return 0.0;
|
||||
|
||||
// Check limits of time address ... if necessary, recalculate modulo
|
||||
// fileSize.
|
||||
while ( time_ < 0.0 )
|
||||
@@ -171,7 +177,7 @@ StkFloat FileLoop :: tick( unsigned int channel )
|
||||
}
|
||||
|
||||
// Load more data.
|
||||
file_.read( data_, chunkPointer_, normalizing_ );
|
||||
file_.read( data_, chunkPointer_, int2floatscaling_ );
|
||||
}
|
||||
|
||||
// Adjust index for the current buffer.
|
||||
@@ -195,7 +201,7 @@ StkFloat FileLoop :: tick( unsigned int channel )
|
||||
|
||||
StkFrames& FileLoop :: tick( StkFrames& frames, unsigned int channel)
|
||||
{
|
||||
if ( !file_.isOpen() ) {
|
||||
if ( finished_ ) {
|
||||
#if defined(_STK_DEBUG_)
|
||||
oStream_ << "FileLoop::tick(): no file data is loaded!";
|
||||
handleError( StkError::DEBUG_PRINT );
|
||||
|
||||
@@ -688,8 +688,9 @@ void FileWrite :: closeMatFile( void )
|
||||
|
||||
SINT32 headsize, temp;
|
||||
fseek(fd_, 196, SEEK_SET); // jump to header size
|
||||
if (fread(&headsize, 4, 1, fd_) < 4) {
|
||||
if (fread(&headsize, 4, 1, fd_) != 1) {
|
||||
oStream_ << "FileWrite: could not read MAT-file header size.";
|
||||
handleError( StkError::WARNING );
|
||||
goto close_file;
|
||||
}
|
||||
|
||||
@@ -699,7 +700,7 @@ void FileWrite :: closeMatFile( void )
|
||||
// Write file size (minus some header info)
|
||||
fwrite(&headsize, 4, 1, fd_);
|
||||
|
||||
fseek(fd_, temp+196, SEEK_SET); // jumpt to data size (in bytes)
|
||||
fseek(fd_, temp+196, SEEK_SET); // jump to data size (in bytes)
|
||||
temp = (SINT32) (frameCounter_ * 8 * channels_);
|
||||
fwrite(&temp, 4, 1, fd_);
|
||||
|
||||
|
||||
@@ -44,11 +44,12 @@ FileWvIn :: FileWvIn( unsigned long chunkThreshold, unsigned long chunkSize )
|
||||
}
|
||||
|
||||
FileWvIn :: FileWvIn( std::string fileName, bool raw, bool doNormalize,
|
||||
unsigned long chunkThreshold, unsigned long chunkSize )
|
||||
unsigned long chunkThreshold, unsigned long chunkSize,
|
||||
bool doInt2FloatScaling )
|
||||
: finished_(true), interpolate_(false), time_(0.0), rate_(0.0),
|
||||
chunkThreshold_(chunkThreshold), chunkSize_(chunkSize)
|
||||
{
|
||||
openFile( fileName, raw, doNormalize );
|
||||
openFile( fileName, raw, doNormalize, doInt2FloatScaling );
|
||||
Stk::addSampleRateAlert( this );
|
||||
}
|
||||
|
||||
@@ -71,7 +72,7 @@ void FileWvIn :: closeFile( void )
|
||||
lastFrame_.resize( 0, 0 );
|
||||
}
|
||||
|
||||
void FileWvIn :: openFile( std::string fileName, bool raw, bool doNormalize )
|
||||
void FileWvIn :: openFile( std::string fileName, bool raw, bool doNormalize, bool doInt2FloatScaling )
|
||||
{
|
||||
// Call close() in case another file is already open.
|
||||
this->closeFile();
|
||||
@@ -84,16 +85,19 @@ void FileWvIn :: openFile( std::string fileName, bool raw, bool doNormalize )
|
||||
chunking_ = true;
|
||||
chunkPointer_ = 0;
|
||||
data_.resize( chunkSize_, file_.channels() );
|
||||
if ( doNormalize ) normalizing_ = true;
|
||||
else normalizing_ = false;
|
||||
}
|
||||
else {
|
||||
chunking_ = false;
|
||||
data_.resize( (size_t) file_.fileSize(), file_.channels() );
|
||||
}
|
||||
|
||||
if ( doInt2FloatScaling )
|
||||
int2floatscaling_ = true;
|
||||
else
|
||||
int2floatscaling_ = false;
|
||||
|
||||
// Load all or part of the data.
|
||||
file_.read( data_, 0, doNormalize );
|
||||
file_.read( data_, 0, int2floatscaling_ );
|
||||
|
||||
// Resize our lastFrame container.
|
||||
lastFrame_.resize( 1, file_.channels() );
|
||||
@@ -204,7 +208,7 @@ StkFloat FileWvIn :: tick( unsigned int channel )
|
||||
}
|
||||
|
||||
// Load more data.
|
||||
file_.read( data_, chunkPointer_, normalizing_ );
|
||||
file_.read( data_, chunkPointer_, int2floatscaling_ );
|
||||
}
|
||||
|
||||
// Adjust index for the current buffer.
|
||||
@@ -228,9 +232,9 @@ StkFloat FileWvIn :: tick( unsigned int channel )
|
||||
|
||||
StkFrames& FileWvIn :: tick( StkFrames& frames, unsigned int channel)
|
||||
{
|
||||
if ( !file_.isOpen() ) {
|
||||
if ( finished_ ) {
|
||||
#if defined(_STK_DEBUG_)
|
||||
oStream_ << "FileWvIn::tick(): no file data is loaded!";
|
||||
oStream_ << "FileWvIn::tick(): end of file or no open file!";
|
||||
handleError( StkError::DEBUG_PRINT );
|
||||
#endif
|
||||
return frames;
|
||||
@@ -258,7 +262,6 @@ StkFrames& FileWvIn :: tick( StkFrames& frames, unsigned int channel)
|
||||
}
|
||||
}
|
||||
return frames;
|
||||
|
||||
}
|
||||
|
||||
} // stk namespace
|
||||
|
||||
@@ -117,7 +117,7 @@ void Guitar :: setBodyFile( std::string bodyfile )
|
||||
void Guitar :: setPluckPosition( StkFloat position, int string )
|
||||
{
|
||||
if ( position < 0.0 || position > 1.0 ) {
|
||||
std::cerr << "Guitar::setPluckPosition: position parameter out of range!";
|
||||
oStream_ << "Guitar::setPluckPosition: position parameter out of range!";
|
||||
handleError( StkError::WARNING ); return;
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ void Guitar :: setPluckPosition( StkFloat position, int string )
|
||||
void Guitar :: setLoopGain( StkFloat gain, int string )
|
||||
{
|
||||
if ( gain < 0.0 || gain > 1.0 ) {
|
||||
std::cerr << "Guitar::setLoopGain: gain parameter out of range!";
|
||||
oStream_ << "Guitar::setLoopGain: gain parameter out of range!";
|
||||
handleError( StkError::WARNING ); return;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ void Mandolin :: clear( void )
|
||||
void Mandolin :: setPluckPosition( StkFloat position )
|
||||
{
|
||||
if ( position < 0.0 || position > 1.0 ) {
|
||||
std::cerr << "Mandolin::setPluckPosition: position parameter out of range!";
|
||||
oStream_ << "Mandolin::setPluckPosition: position parameter out of range!";
|
||||
handleError( StkError::WARNING ); return;
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +79,8 @@ MidiFileIn :: MidiFileIn( std::string fileName )
|
||||
usingTimeCode_ = false;
|
||||
if ( *data & 0x8000 ) {
|
||||
// Determine ticks per second from time-code formats.
|
||||
tickrate = (double) -(*data & 0x7F00);
|
||||
signed char tmp = -(*data & 0xFF00)>>8;
|
||||
tickrate = (double) tmp;
|
||||
// If frames per second value is 29, it really should be 29.97.
|
||||
if ( tickrate == 29.0 ) tickrate = 29.97;
|
||||
tickrate *= (*data & 0x00FF);
|
||||
|
||||
@@ -56,7 +56,7 @@ void Resonate :: setResonance( StkFloat frequency, StkFloat radius )
|
||||
}
|
||||
|
||||
if ( radius < 0.0 || radius >= 1.0 ) {
|
||||
std::cerr << "Resonate::setResonance: radius parameter is out of range!";
|
||||
oStream_ << "Resonate::setResonance: radius parameter is out of range!";
|
||||
handleError( StkError::WARNING ); return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1010,7 +1010,7 @@ void MidiOutCore :: openVirtualPort( std::string portName )
|
||||
void MidiOutCore :: sendMessage( std::vector<unsigned char> *message )
|
||||
{
|
||||
// We use the MIDISendSysex() function to asynchronously send sysex
|
||||
// messages. Otherwise, we use a single CoreMidi MIDIPacket.
|
||||
// messages. Otherwise, we use a single CoreMIDI MIDIPacket.
|
||||
unsigned int nBytes = message->size();
|
||||
if ( nBytes == 0 ) {
|
||||
errorString_ = "MidiOutCore::sendMessage: no data in message argument!";
|
||||
|
||||
@@ -153,10 +153,13 @@ long Skini :: parseString( std::string& line, Message& message )
|
||||
|
||||
// Parse the remaining fields (maximum of 2 more).
|
||||
int iValue = 0;
|
||||
unsigned int iToken = iValue + 3; //rgh: MIDI extension argument counts are different from regular MIDI
|
||||
long dataType = skini_msgs[iSkini].data2;
|
||||
while ( dataType != NOPE ) {
|
||||
|
||||
if ( tokens.size() <= (unsigned int) (iValue+3) ) {
|
||||
// if ( tokens.size() <= (unsigned int) (iValue+3) ) { //rgh: test iToken rather than always testing iValue+3
|
||||
// if (tokens.size() <= iToken) { //rgh: iToken only tests it more tokens are to be consumed (SK_INT, SK_DBL, SK_STR)
|
||||
if ((tokens.size() <= iToken) && (dataType < 0)) { //Don't fail if remaining iValues come from skini_msgs[] rather than tokens[].
|
||||
oStream_ << "Skini::parseString: inconsistency between type table and parsed line:\n " << line;
|
||||
handleError( StkError::WARNING );
|
||||
return message.type = 0;
|
||||
@@ -165,23 +168,25 @@ long Skini :: parseString( std::string& line, Message& message )
|
||||
switch ( dataType ) {
|
||||
|
||||
case SK_INT:
|
||||
message.intValues[iValue] = atoi( tokens[iValue+3].c_str() );
|
||||
message.intValues[iValue] = atoi( tokens[iToken].c_str() ); //rgh: use new index
|
||||
message.floatValues[iValue] = (StkFloat) message.intValues[iValue];
|
||||
++iToken; //rgh: increment token index and value index (below)
|
||||
break;
|
||||
|
||||
case SK_DBL:
|
||||
message.floatValues[iValue] = atof( tokens[iValue+3].c_str() );
|
||||
message.floatValues[iValue] = atof( tokens[iToken].c_str() ); //rgh: use new index
|
||||
message.intValues[iValue] = (long) message.floatValues[iValue];
|
||||
++iToken; //rgh: increment token index and value index (below)
|
||||
break;
|
||||
|
||||
case SK_STR: // Must be the last field.
|
||||
message.remainder = tokens[iValue+3];
|
||||
message.remainder = tokens[iToken]; //rgh: use new index
|
||||
return message.type;
|
||||
|
||||
default: // MIDI extension message
|
||||
message.intValues[iValue] = dataType;
|
||||
message.floatValues[iValue] = (StkFloat) message.intValues[iValue];
|
||||
iValue--;
|
||||
//iValue--; //rgh: iValue must increment even when iToken does not; resetting iValue only works sometimes
|
||||
}
|
||||
|
||||
if ( ++iValue == 1 )
|
||||
|
||||
Reference in New Issue
Block a user