mirror of
https://github.com/thestk/stk
synced 2026-02-07 09:46:16 +00:00
set raw wave path dynamically if needed
This commit is contained in:
@@ -174,6 +174,9 @@ public:
|
|||||||
//! Static method that returns the current rawwave path.
|
//! Static method that returns the current rawwave path.
|
||||||
static std::string rawwavePath(void) { return rawwavepath_; }
|
static std::string rawwavePath(void) { return rawwavepath_; }
|
||||||
|
|
||||||
|
//! Static method to set the rawwave path on platforms where library resources are loaded dynamically.
|
||||||
|
static void setRawwavePathForDynamicallyLoadedRawwaves ( void );
|
||||||
|
|
||||||
//! Static method that sets the STK rawwave path.
|
//! Static method that sets the STK rawwave path.
|
||||||
static void setRawwavePath( std::string path );
|
static void setRawwavePath( std::string path );
|
||||||
|
|
||||||
@@ -519,6 +522,9 @@ const unsigned int RT_BUFFER_SIZE = 512;
|
|||||||
// the various STK core classes (ex. Clarinet.cpp). If you wish to
|
// the various STK core classes (ex. Clarinet.cpp). If you wish to
|
||||||
// move the rawwaves directory to a different location in your file
|
// move the rawwaves directory to a different location in your file
|
||||||
// system, you will need to set this path definition appropriately.
|
// system, you will need to set this path definition appropriately.
|
||||||
|
// Platforms that load resources dynamically will call
|
||||||
|
// Stk::setRawwavePathForDynamicallyLoadedRawwaves() and set the raw
|
||||||
|
//wave path accordingly.
|
||||||
#if !defined(RAWWAVE_PATH)
|
#if !defined(RAWWAVE_PATH)
|
||||||
#define RAWWAVE_PATH "../../rawwaves/"
|
#define RAWWAVE_PATH "../../rawwaves/"
|
||||||
#endif
|
#endif
|
||||||
@@ -527,6 +533,10 @@ const StkFloat PI = 3.14159265358979;
|
|||||||
const StkFloat TWO_PI = 2 * PI;
|
const StkFloat TWO_PI = 2 * PI;
|
||||||
const StkFloat ONE_OVER_128 = 0.0078125;
|
const StkFloat ONE_OVER_128 = 0.0078125;
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#include "TargetConditionals.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__WINDOWS_DS__) || defined(__WINDOWS_ASIO__) || defined(__WINDOWS_MM__)
|
#if defined(__WINDOWS_DS__) || defined(__WINDOWS_ASIO__) || defined(__WINDOWS_MM__)
|
||||||
#define __OS_WINDOWS__
|
#define __OS_WINDOWS__
|
||||||
#define __STK_REALTIME__
|
#define __STK_REALTIME__
|
||||||
@@ -535,6 +545,8 @@ const StkFloat ONE_OVER_128 = 0.0078125;
|
|||||||
#define __STK_REALTIME__
|
#define __STK_REALTIME__
|
||||||
#elif defined(__IRIX_AL__)
|
#elif defined(__IRIX_AL__)
|
||||||
#define __OS_IRIX__
|
#define __OS_IRIX__
|
||||||
|
#elif defined TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
|
||||||
|
#define __OS_IOS__
|
||||||
#elif defined(__MACOSX_CORE__) || defined(__UNIX_JACK__)
|
#elif defined(__MACOSX_CORE__) || defined(__UNIX_JACK__)
|
||||||
#define __OS_MACOSX__
|
#define __OS_MACOSX__
|
||||||
#define __STK_REALTIME__
|
#define __STK_REALTIME__
|
||||||
|
|||||||
27
src/Stk.cpp
27
src/Stk.cpp
@@ -71,12 +71,39 @@ std::ostringstream Stk :: oStream_;
|
|||||||
Stk :: Stk( void )
|
Stk :: Stk( void )
|
||||||
: ignoreSampleRateChange_(false)
|
: ignoreSampleRateChange_(false)
|
||||||
{
|
{
|
||||||
|
setRawwavePathForDynamicallyLoadedRawwaves();
|
||||||
}
|
}
|
||||||
|
|
||||||
Stk :: ~Stk( void )
|
Stk :: ~Stk( void )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __OS_IOS__
|
||||||
|
#include <CoreFoundation/CoreFoundation.h>
|
||||||
|
#endif
|
||||||
|
void Stk :: setRawwavePathForDynamicallyLoadedRawwaves ( void )
|
||||||
|
{
|
||||||
|
static bool rawwavesPathSet;
|
||||||
|
if (!rawwavesPathSet)
|
||||||
|
{
|
||||||
|
#ifdef __OS_IOS__
|
||||||
|
CFBundleRef mainBundle = CFBundleGetMainBundle();
|
||||||
|
CFURLRef url = CFBundleCopyResourceURL(mainBundle, CFSTR("rawwaves"), CFSTR("bundle"), NULL);
|
||||||
|
CFStringRef rawwavesPathCFString = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);
|
||||||
|
CFIndex length = CFStringGetLength(rawwavesPathCFString);
|
||||||
|
CFIndex maxSize = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8);
|
||||||
|
char *rawwavesPathCString = (char *)malloc(maxSize);
|
||||||
|
CFStringGetCString(rawwavesPathCFString, rawwavesPathCString, maxSize, kCFStringEncodingUTF8);
|
||||||
|
std::string str(rawwavesPathCString);
|
||||||
|
setRawwavePath(rawwavesPathCString);
|
||||||
|
|
||||||
|
CFRelease(url);
|
||||||
|
CFRelease(rawwavesPathCFString);
|
||||||
|
#endif
|
||||||
|
rawwavesPathSet = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Stk :: setSampleRate( StkFloat rate )
|
void Stk :: setSampleRate( StkFloat rate )
|
||||||
{
|
{
|
||||||
if ( rate > 0.0 && rate != srate_ ) {
|
if ( rate > 0.0 && rate != srate_ ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user