mirror of
https://github.com/thestk/stk
synced 2026-05-02 03:58:38 +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__"
|
api="$api -D__MACOSX_CORE__"
|
||||||
AC_MSG_RESULT(using CoreAudio)
|
AC_MSG_RESULT(using CoreAudio)
|
||||||
AC_CHECK_HEADER(CoreAudio/CoreAudio.h, [], [AC_MSG_ERROR(CoreAudio header files not found!)] )
|
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 no audio api flags specified, use CoreAudio
|
||||||
if [test "$api" == ""; ] then
|
if [test "$api" == ""; ] then
|
||||||
@@ -176,7 +176,7 @@ if test $realtime = yes; then
|
|||||||
AC_CHECK_HEADER(CoreAudio/CoreAudio.h,
|
AC_CHECK_HEADER(CoreAudio/CoreAudio.h,
|
||||||
[],
|
[],
|
||||||
[AC_MSG_ERROR(CoreAudio header files not found!)] )
|
[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
|
fi
|
||||||
|
|
||||||
AC_CHECK_LIB(pthread, pthread_create, , AC_MSG_ERROR(RtAudio requires the pthread library!))
|
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>Macintosh OS X</TD>
|
||||||
<TD>CoreAudio</TD>
|
<TD>CoreAudio</TD>
|
||||||
<TD>__MACOSX_CORE__</TD>
|
<TD>__MACOSX_CORE__</TD>
|
||||||
<TD><TT>pthread, CoreAudio, CoreMidi, CoreFoundation</TT></TD>
|
<TD><TT>pthread, CoreAudio, CoreMIDI, CoreFoundation</TT></TD>
|
||||||
</TR>
|
</TR>
|
||||||
</TABLE>
|
</TABLE>
|
||||||
</CENTER>
|
</CENTER>
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
This file contains instructions for integrating the STK in Xcode projects and solutions to common integration issues.
|
This file contains instructions for integrating the STK in Xcode projects and solutions to common integration issues.
|
||||||
|
|
||||||
##Setup
|
## Setup
|
||||||
|
|
||||||
###If you have [Cocoapods](http://cocoapods.org/)
|
### If you have [Cocoapods](http://cocoapods.org/)
|
||||||
|
|
||||||
1. Add `pod 'STK', '~> 4.5'` to your Podfile.
|
1. Add `pod 'STK', '~> 4.5'` to your Podfile.
|
||||||
|
|
||||||
1. Run `pod install`
|
1. Run `pod install`
|
||||||
|
|
||||||
###If you don't have Cocoapods
|
### If you don't have Cocoapods
|
||||||
|
|
||||||
1. Clone or [download][download_link] the STK into your project's directory.
|
1. Clone or [download][download_link] the STK into your project's directory.
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ This file contains instructions for integrating the STK in Xcode projects and so
|
|||||||
![][header_search_paths_screenshot]
|
![][header_search_paths_screenshot]
|
||||||
|
|
||||||
|
|
||||||
##Usage
|
## Usage
|
||||||
|
|
||||||
1. Import the STK classes in the source files you require.
|
1. Import the STK classes in the source files you require.
|
||||||
* E.g. `#import "SineWave.h"`
|
* E.g. `#import "SineWave.h"`
|
||||||
@@ -32,9 +32,9 @@ This file contains instructions for integrating the STK in Xcode projects and so
|
|||||||
You can also look at the [iOS Demo project](..projects/demo/iOS%20Demo) for a sample usage.
|
You can also look at the [iOS Demo project](..projects/demo/iOS%20Demo) for a sample usage.
|
||||||
|
|
||||||
|
|
||||||
##Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
###'FileName.h' file not found
|
### 'FileName.h' file not found
|
||||||
|
|
||||||
If you get this error when `#import`ing an STK header, you have added the wrong header search path for the STK in your project's settings (see Step 4 in Setup)
|
If you get this error when `#import`ing an STK header, you have added the wrong header search path for the STK in your project's settings (see Step 4 in Setup)
|
||||||
|
|
||||||
@@ -49,19 +49,19 @@ If this problem doesn't go away:
|
|||||||
If that doesn't solve it:
|
If that doesn't solve it:
|
||||||
Install Cocoapods and use it to install the STK. It takes one minute and will make your life easier. Visit the [Cocoapods website](http://cocoapods.org/) for installation instructions.
|
Install Cocoapods and use it to install the STK. It takes one minute and will make your life easier. Visit the [Cocoapods website](http://cocoapods.org/) for installation instructions.
|
||||||
|
|
||||||
###FileRead::open: could not open or find file (../../rawwaves/filename.raw)!
|
### FileRead::open: could not open or find file (../../rawwaves/filename.raw)!
|
||||||
|
|
||||||
If you use a class that makes use of raw waves (such as `Mandolin`, `Wurley`, or `Rhodey`) you need to make sure that the STK's raw wave files are copied into your bundle and that the STK knows where they are. You'll know you need to if you get this runtime error:
|
If you use a class that makes use of raw waves (such as `Mandolin`, `Wurley`, or `Rhodey`) you need to make sure that the STK's raw wave files are copied into your bundle and that the STK knows where they are. You'll know you need to if you get this runtime error:
|
||||||
`FileRead::open: could not open or find file (../../rawwaves/filename.raw)!`
|
`FileRead::open: could not open or find file (../../rawwaves/filename.raw)!`
|
||||||
|
|
||||||
####If you're using Cocoapods
|
#### If you're using Cocoapods
|
||||||
|
|
||||||
Add this code before using a class that needs the raw waves:
|
Add this code before using a class that needs the raw waves:
|
||||||
```objective-c
|
```objective-c
|
||||||
stk::Stk::setRawwavePath([[[NSBundle mainBundle] pathForResource:@"rawwaves" ofType:@"bundle"] UTF8String]);
|
stk::Stk::setRawwavePath([[[NSBundle mainBundle] pathForResource:@"rawwaves" ofType:@"bundle"] UTF8String]);
|
||||||
```
|
```
|
||||||
|
|
||||||
####If you're not using Cocoapods
|
#### If you're not using Cocoapods
|
||||||
|
|
||||||
1. Open your project's settings, open the *Build Phases* tab.
|
1. Open your project's settings, open the *Build Phases* tab.
|
||||||
1. In the *Copy Bundle Resources*, drag and drop **rawwaves.bundle** (it's located in **STK.xcodeproj**'s **Helpers** folder).
|
1. In the *Copy Bundle Resources*, drag and drop **rawwaves.bundle** (it's located in **STK.xcodeproj**'s **Helpers** folder).
|
||||||
@@ -73,7 +73,7 @@ stk::Stk::setRawwavePath([[rawwaveBundle resourcePath] UTF8String]);
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
###rawwaves.bundle: No such file or directory
|
### rawwaves.bundle: No such file or directory
|
||||||
|
|
||||||
This means that **rawwaves.bundle** hasn't been copied to the build folder, so you'll need to do it manually:
|
This means that **rawwaves.bundle** hasn't been copied to the build folder, so you'll need to do it manually:
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ Select the rawwaves scheme:
|
|||||||
|
|
||||||
Build it (⌘+B) then build your project's main scheme.
|
Build it (⌘+B) then build your project's main scheme.
|
||||||
|
|
||||||
###Apple Mach-O Linker Error
|
### Apple Mach-O Linker Error
|
||||||
|
|
||||||
This means that **STKLib.a** isn't being linked to your binary. Follow step 2 above in [Setup](#setup).
|
This means that **STKLib.a** isn't being linked to your binary. Follow step 2 above in [Setup](#setup).
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ class FileLoop : protected FileWvIn
|
|||||||
|
|
||||||
//! Class constructor that opens a specified file.
|
//! Class constructor that opens a specified file.
|
||||||
FileLoop( std::string fileName, bool raw = false, bool doNormalize = true,
|
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.
|
//! Class destructor.
|
||||||
~FileLoop( void );
|
~FileLoop( void );
|
||||||
@@ -40,13 +41,14 @@ class FileLoop : protected FileWvIn
|
|||||||
/*!
|
/*!
|
||||||
Data from a previously opened file will be overwritten by this
|
Data from a previously opened file will be overwritten by this
|
||||||
function. An StkError will be thrown if the file is not found,
|
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
|
its format is unknown, or a read error occurs. If the file length
|
||||||
is to be loaded incrementally from disk and normalization is
|
is less than the chunkThreshold limit and \e doNormalize is true,
|
||||||
specified, a scaling will be applied with respect to fixed-point
|
the file data will be normalized with respect to the maximum absolute
|
||||||
limits. If the data format is floating-point, no scaling is
|
value of the data. If the \e doInt2FloatScaling flag is true and the
|
||||||
performed.
|
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.
|
//! Close a file if one is open.
|
||||||
void closeFile( void ) { FileWvIn::closeFile(); };
|
void closeFile( void ) { FileWvIn::closeFile(); };
|
||||||
|
|||||||
@@ -29,6 +29,16 @@ namespace stk {
|
|||||||
chunkThreshold (in sample frames) will be read incrementally in
|
chunkThreshold (in sample frames) will be read incrementally in
|
||||||
chunks of \e chunkSize each (also in sample frames).
|
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()
|
When the file end is reached, subsequent calls to the tick()
|
||||||
functions return zeros and isFinished() returns \e true.
|
functions return zeros and isFinished() returns \e true.
|
||||||
|
|
||||||
@@ -51,7 +61,8 @@ public:
|
|||||||
unknown, or a read error occurs.
|
unknown, or a read error occurs.
|
||||||
*/
|
*/
|
||||||
FileWvIn( std::string fileName, bool raw = false, bool doNormalize = true,
|
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.
|
//! Class destructor.
|
||||||
~FileWvIn( void );
|
~FileWvIn( void );
|
||||||
@@ -60,13 +71,14 @@ public:
|
|||||||
/*!
|
/*!
|
||||||
Data from a previously opened file will be overwritten by this
|
Data from a previously opened file will be overwritten by this
|
||||||
function. An StkError will be thrown if the file is not found,
|
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
|
its format is unknown, or a read error occurs. If the file length
|
||||||
is to be loaded incrementally from disk and normalization is
|
is less than the chunkThreshold limit and \e doNormalize is true,
|
||||||
specified, a scaling will be applied with respect to fixed-point
|
the file data will be normalized with respect to the maximum absolute
|
||||||
limits. If the data format is floating-point, no scaling is
|
value of the data. If the \e doInt2FloatScaling flag is true and the
|
||||||
performed.
|
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.
|
//! Close a file if one is open.
|
||||||
virtual void closeFile( void );
|
virtual void closeFile( void );
|
||||||
@@ -158,7 +170,7 @@ public:
|
|||||||
performed if _STK_DEBUG_ is defined during compilation, in which
|
performed if _STK_DEBUG_ is defined during compilation, in which
|
||||||
case an out-of-range value will trigger an StkError exception.
|
case an out-of-range value will trigger an StkError exception.
|
||||||
*/
|
*/
|
||||||
virtual StkFrames& tick( StkFrames& frames,unsigned int channel = 0 );
|
virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 0 );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@@ -167,7 +179,7 @@ protected:
|
|||||||
FileRead file_;
|
FileRead file_;
|
||||||
bool finished_;
|
bool finished_;
|
||||||
bool interpolate_;
|
bool interpolate_;
|
||||||
bool normalizing_;
|
bool int2floatscaling_;
|
||||||
bool chunking_;
|
bool chunking_;
|
||||||
StkFloat time_;
|
StkFloat time_;
|
||||||
StkFloat rate_;
|
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;
|
RtAudio::StreamOptions options;
|
||||||
//options.flags |= RTAUDIO_NONINTERLEAVED;
|
//options.flags |= RTAUDIO_NONINTERLEAVED;
|
||||||
|
|
||||||
|
bufferBytes = bufferFrames * channels * sizeof( MY_TYPE );
|
||||||
try {
|
try {
|
||||||
adac.openStream( &oParams, &iParams, FORMAT, fs, &bufferFrames, &inout, (void *)&bufferBytes, &options );
|
adac.openStream( &oParams, &iParams, FORMAT, fs, &bufferFrames, &inout, (void *)&bufferBytes, &options );
|
||||||
}
|
}
|
||||||
@@ -112,8 +113,6 @@ int main(int argc, char *argv[])
|
|||||||
exit( 1 );
|
exit( 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
bufferBytes = bufferFrames * channels * sizeof( MY_TYPE );
|
|
||||||
|
|
||||||
// Test RtAudio functionality for reporting latency.
|
// Test RtAudio functionality for reporting latency.
|
||||||
std::cout << "\nStream latency = " << adac.getStreamLatency() << " frames" << std::endl;
|
std::cout << "\nStream latency = " << adac.getStreamLatency() << " frames" << std::endl;
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
using namespace stk;
|
using namespace stk;
|
||||||
|
|
||||||
// Eewww ... global variables! :-)
|
// Eewww ... global variables! :-)
|
||||||
bool done;
|
bool done = false;
|
||||||
StkFrames frames;
|
StkFrames frames;
|
||||||
static void finish(int ignore){ done = true; }
|
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 )
|
double streamTime, RtAudioStreamStatus status, void *userData )
|
||||||
{
|
{
|
||||||
FileWvIn *input = (FileWvIn *) userData;
|
FileWvIn *input = (FileWvIn *) userData;
|
||||||
register StkFloat *samples = (StkFloat *) outputBuffer;
|
StkFloat *samples = (StkFloat *) outputBuffer;
|
||||||
|
|
||||||
input->tick( frames );
|
input->tick( frames );
|
||||||
|
|
||||||
for ( unsigned int i=0; i<frames.size(); i++ ) {
|
for ( unsigned int i=0; i<frames.size(); i++ ) {
|
||||||
*samples++ = frames[i];
|
*samples++ = frames[i];
|
||||||
if ( input->channelsOut() == 1 ) *samples++ = frames[i]; // play mono files in stereo
|
if ( input->channelsOut() == 1 ) *samples++ = frames[i]; // play mono files in stereo
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ Delay :: ~Delay()
|
|||||||
void Delay :: setMaximumDelay( unsigned long delay )
|
void Delay :: setMaximumDelay( unsigned long delay )
|
||||||
{
|
{
|
||||||
if ( delay < inputs_.size() ) return;
|
if ( delay < inputs_.size() ) return;
|
||||||
inputs_.resize( delay + 1 );
|
inputs_.resize( delay + 1, 1, 0.0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Delay :: setDelay( unsigned long delay )
|
void Delay :: setDelay( unsigned long delay )
|
||||||
|
|||||||
@@ -98,10 +98,11 @@ void FMVoices :: setFrequency( StkFloat frequency )
|
|||||||
i = currentVowel_ - 64;
|
i = currentVowel_ - 64;
|
||||||
temp2 = 1.1;
|
temp2 = 1.1;
|
||||||
}
|
}
|
||||||
else if (currentVowel_ <= 128) {
|
else if (currentVowel_ < 128) {
|
||||||
i = currentVowel_ - 96;
|
i = currentVowel_ - 96;
|
||||||
temp2 = 1.2;
|
temp2 = 1.2;
|
||||||
}
|
}
|
||||||
|
else return;
|
||||||
|
|
||||||
baseFrequency_ = frequency;
|
baseFrequency_ = frequency;
|
||||||
temp = (temp2 * Phonemes::formantFrequency(i, 0) / baseFrequency_) + 0.5;
|
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
|
if (number == __SK_Breath_) // 2
|
||||||
gains_[3] = fmGains_[(int) ( normalizedValue * 99.9 )];
|
gains_[3] = fmGains_[(int) ( normalizedValue * 99.9 )];
|
||||||
else if (number == __SK_FootControl_) { // 4
|
else if (number == __SK_FootControl_) { // 4
|
||||||
currentVowel_ = (int) (normalizedValue * 128.0);
|
currentVowel_ = (int) (normalizedValue * 127.0);
|
||||||
this->setFrequency(baseFrequency_);
|
this->setFrequency(baseFrequency_);
|
||||||
}
|
}
|
||||||
else if (number == __SK_ModFrequency_) // 11
|
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,
|
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)
|
: FileWvIn( chunkThreshold, chunkSize ), phaseOffset_(0.0)
|
||||||
{
|
{
|
||||||
this->openFile( fileName, raw, doNormalize );
|
this->openFile( fileName, raw, doNormalize, doInt2FloatScaling );
|
||||||
Stk::addSampleRateAlert( this );
|
Stk::addSampleRateAlert( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,7 +41,7 @@ FileLoop :: ~FileLoop( void )
|
|||||||
Stk::removeSampleRateAlert( this );
|
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.
|
// Call close() in case another file is already open.
|
||||||
this->closeFile();
|
this->closeFile();
|
||||||
@@ -53,16 +54,19 @@ void FileLoop :: openFile( std::string fileName, bool raw, bool doNormalize )
|
|||||||
chunking_ = true;
|
chunking_ = true;
|
||||||
chunkPointer_ = 0;
|
chunkPointer_ = 0;
|
||||||
data_.resize( chunkSize_ + 1, file_.channels() );
|
data_.resize( chunkSize_ + 1, file_.channels() );
|
||||||
if ( doNormalize ) normalizing_ = true;
|
|
||||||
else normalizing_ = false;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
chunking_ = false;
|
chunking_ = false;
|
||||||
data_.resize( file_.fileSize() + 1, file_.channels() );
|
data_.resize( file_.fileSize() + 1, file_.channels() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( doInt2FloatScaling )
|
||||||
|
int2floatscaling_ = true;
|
||||||
|
else
|
||||||
|
int2floatscaling_ = false;
|
||||||
|
|
||||||
// Load all or part of the data.
|
// 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.
|
if ( chunking_ ) { // If chunking, save the first sample frame for later.
|
||||||
firstFrame_.resize( 1, data_.channels() );
|
firstFrame_.resize( 1, data_.channels() );
|
||||||
@@ -134,6 +138,8 @@ StkFloat FileLoop :: tick( unsigned int channel )
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if ( finished_ ) return 0.0;
|
||||||
|
|
||||||
// Check limits of time address ... if necessary, recalculate modulo
|
// Check limits of time address ... if necessary, recalculate modulo
|
||||||
// fileSize.
|
// fileSize.
|
||||||
while ( time_ < 0.0 )
|
while ( time_ < 0.0 )
|
||||||
@@ -171,7 +177,7 @@ StkFloat FileLoop :: tick( unsigned int channel )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load more data.
|
// Load more data.
|
||||||
file_.read( data_, chunkPointer_, normalizing_ );
|
file_.read( data_, chunkPointer_, int2floatscaling_ );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adjust index for the current buffer.
|
// Adjust index for the current buffer.
|
||||||
@@ -195,7 +201,7 @@ StkFloat FileLoop :: tick( unsigned int channel )
|
|||||||
|
|
||||||
StkFrames& FileLoop :: tick( StkFrames& frames, unsigned int channel)
|
StkFrames& FileLoop :: tick( StkFrames& frames, unsigned int channel)
|
||||||
{
|
{
|
||||||
if ( !file_.isOpen() ) {
|
if ( finished_ ) {
|
||||||
#if defined(_STK_DEBUG_)
|
#if defined(_STK_DEBUG_)
|
||||||
oStream_ << "FileLoop::tick(): no file data is loaded!";
|
oStream_ << "FileLoop::tick(): no file data is loaded!";
|
||||||
handleError( StkError::DEBUG_PRINT );
|
handleError( StkError::DEBUG_PRINT );
|
||||||
|
|||||||
@@ -688,8 +688,9 @@ void FileWrite :: closeMatFile( void )
|
|||||||
|
|
||||||
SINT32 headsize, temp;
|
SINT32 headsize, temp;
|
||||||
fseek(fd_, 196, SEEK_SET); // jump to header size
|
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.";
|
oStream_ << "FileWrite: could not read MAT-file header size.";
|
||||||
|
handleError( StkError::WARNING );
|
||||||
goto close_file;
|
goto close_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -699,7 +700,7 @@ void FileWrite :: closeMatFile( void )
|
|||||||
// Write file size (minus some header info)
|
// Write file size (minus some header info)
|
||||||
fwrite(&headsize, 4, 1, fd_);
|
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_);
|
temp = (SINT32) (frameCounter_ * 8 * channels_);
|
||||||
fwrite(&temp, 4, 1, fd_);
|
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,
|
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),
|
: finished_(true), interpolate_(false), time_(0.0), rate_(0.0),
|
||||||
chunkThreshold_(chunkThreshold), chunkSize_(chunkSize)
|
chunkThreshold_(chunkThreshold), chunkSize_(chunkSize)
|
||||||
{
|
{
|
||||||
openFile( fileName, raw, doNormalize );
|
openFile( fileName, raw, doNormalize, doInt2FloatScaling );
|
||||||
Stk::addSampleRateAlert( this );
|
Stk::addSampleRateAlert( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,7 +72,7 @@ void FileWvIn :: closeFile( void )
|
|||||||
lastFrame_.resize( 0, 0 );
|
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.
|
// Call close() in case another file is already open.
|
||||||
this->closeFile();
|
this->closeFile();
|
||||||
@@ -84,16 +85,19 @@ void FileWvIn :: openFile( std::string fileName, bool raw, bool doNormalize )
|
|||||||
chunking_ = true;
|
chunking_ = true;
|
||||||
chunkPointer_ = 0;
|
chunkPointer_ = 0;
|
||||||
data_.resize( chunkSize_, file_.channels() );
|
data_.resize( chunkSize_, file_.channels() );
|
||||||
if ( doNormalize ) normalizing_ = true;
|
|
||||||
else normalizing_ = false;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
chunking_ = false;
|
chunking_ = false;
|
||||||
data_.resize( (size_t) file_.fileSize(), file_.channels() );
|
data_.resize( (size_t) file_.fileSize(), file_.channels() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( doInt2FloatScaling )
|
||||||
|
int2floatscaling_ = true;
|
||||||
|
else
|
||||||
|
int2floatscaling_ = false;
|
||||||
|
|
||||||
// Load all or part of the data.
|
// Load all or part of the data.
|
||||||
file_.read( data_, 0, doNormalize );
|
file_.read( data_, 0, int2floatscaling_ );
|
||||||
|
|
||||||
// Resize our lastFrame container.
|
// Resize our lastFrame container.
|
||||||
lastFrame_.resize( 1, file_.channels() );
|
lastFrame_.resize( 1, file_.channels() );
|
||||||
@@ -204,7 +208,7 @@ StkFloat FileWvIn :: tick( unsigned int channel )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load more data.
|
// Load more data.
|
||||||
file_.read( data_, chunkPointer_, normalizing_ );
|
file_.read( data_, chunkPointer_, int2floatscaling_ );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adjust index for the current buffer.
|
// Adjust index for the current buffer.
|
||||||
@@ -228,9 +232,9 @@ StkFloat FileWvIn :: tick( unsigned int channel )
|
|||||||
|
|
||||||
StkFrames& FileWvIn :: tick( StkFrames& frames, unsigned int channel)
|
StkFrames& FileWvIn :: tick( StkFrames& frames, unsigned int channel)
|
||||||
{
|
{
|
||||||
if ( !file_.isOpen() ) {
|
if ( finished_ ) {
|
||||||
#if defined(_STK_DEBUG_)
|
#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 );
|
handleError( StkError::DEBUG_PRINT );
|
||||||
#endif
|
#endif
|
||||||
return frames;
|
return frames;
|
||||||
@@ -258,7 +262,6 @@ StkFrames& FileWvIn :: tick( StkFrames& frames, unsigned int channel)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return frames;
|
return frames;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // stk namespace
|
} // stk namespace
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ void Guitar :: setBodyFile( std::string bodyfile )
|
|||||||
void Guitar :: setPluckPosition( StkFloat position, int string )
|
void Guitar :: setPluckPosition( StkFloat position, int string )
|
||||||
{
|
{
|
||||||
if ( position < 0.0 || position > 1.0 ) {
|
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;
|
handleError( StkError::WARNING ); return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,7 +136,7 @@ void Guitar :: setPluckPosition( StkFloat position, int string )
|
|||||||
void Guitar :: setLoopGain( StkFloat gain, int string )
|
void Guitar :: setLoopGain( StkFloat gain, int string )
|
||||||
{
|
{
|
||||||
if ( gain < 0.0 || gain > 1.0 ) {
|
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;
|
handleError( StkError::WARNING ); return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ void Mandolin :: clear( void )
|
|||||||
void Mandolin :: setPluckPosition( StkFloat position )
|
void Mandolin :: setPluckPosition( StkFloat position )
|
||||||
{
|
{
|
||||||
if ( position < 0.0 || position > 1.0 ) {
|
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;
|
handleError( StkError::WARNING ); return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,7 +79,8 @@ MidiFileIn :: MidiFileIn( std::string fileName )
|
|||||||
usingTimeCode_ = false;
|
usingTimeCode_ = false;
|
||||||
if ( *data & 0x8000 ) {
|
if ( *data & 0x8000 ) {
|
||||||
// Determine ticks per second from time-code formats.
|
// 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 frames per second value is 29, it really should be 29.97.
|
||||||
if ( tickrate == 29.0 ) tickrate = 29.97;
|
if ( tickrate == 29.0 ) tickrate = 29.97;
|
||||||
tickrate *= (*data & 0x00FF);
|
tickrate *= (*data & 0x00FF);
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ void Resonate :: setResonance( StkFloat frequency, StkFloat radius )
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( radius < 0.0 || radius >= 1.0 ) {
|
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;
|
handleError( StkError::WARNING ); return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1010,7 +1010,7 @@ void MidiOutCore :: openVirtualPort( std::string portName )
|
|||||||
void MidiOutCore :: sendMessage( std::vector<unsigned char> *message )
|
void MidiOutCore :: sendMessage( std::vector<unsigned char> *message )
|
||||||
{
|
{
|
||||||
// We use the MIDISendSysex() function to asynchronously send sysex
|
// 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();
|
unsigned int nBytes = message->size();
|
||||||
if ( nBytes == 0 ) {
|
if ( nBytes == 0 ) {
|
||||||
errorString_ = "MidiOutCore::sendMessage: no data in message argument!";
|
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).
|
// Parse the remaining fields (maximum of 2 more).
|
||||||
int iValue = 0;
|
int iValue = 0;
|
||||||
|
unsigned int iToken = iValue + 3; //rgh: MIDI extension argument counts are different from regular MIDI
|
||||||
long dataType = skini_msgs[iSkini].data2;
|
long dataType = skini_msgs[iSkini].data2;
|
||||||
while ( dataType != NOPE ) {
|
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;
|
oStream_ << "Skini::parseString: inconsistency between type table and parsed line:\n " << line;
|
||||||
handleError( StkError::WARNING );
|
handleError( StkError::WARNING );
|
||||||
return message.type = 0;
|
return message.type = 0;
|
||||||
@@ -165,23 +168,25 @@ long Skini :: parseString( std::string& line, Message& message )
|
|||||||
switch ( dataType ) {
|
switch ( dataType ) {
|
||||||
|
|
||||||
case SK_INT:
|
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];
|
message.floatValues[iValue] = (StkFloat) message.intValues[iValue];
|
||||||
|
++iToken; //rgh: increment token index and value index (below)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SK_DBL:
|
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];
|
message.intValues[iValue] = (long) message.floatValues[iValue];
|
||||||
|
++iToken; //rgh: increment token index and value index (below)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SK_STR: // Must be the last field.
|
case SK_STR: // Must be the last field.
|
||||||
message.remainder = tokens[iValue+3];
|
message.remainder = tokens[iToken]; //rgh: use new index
|
||||||
return message.type;
|
return message.type;
|
||||||
|
|
||||||
default: // MIDI extension message
|
default: // MIDI extension message
|
||||||
message.intValues[iValue] = dataType;
|
message.intValues[iValue] = dataType;
|
||||||
message.floatValues[iValue] = (StkFloat) message.intValues[iValue];
|
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 )
|
if ( ++iValue == 1 )
|
||||||
|
|||||||
Reference in New Issue
Block a user