set raw wave path dynamically if needed

This commit is contained in:
Ariel Elkin
2014-03-12 04:49:11 +01:00
parent 042dea6ff7
commit 8055f1d040
2 changed files with 39 additions and 0 deletions

View File

@@ -71,12 +71,39 @@ std::ostringstream Stk :: oStream_;
Stk :: Stk( void )
: ignoreSampleRateChange_(false)
{
setRawwavePathForDynamicallyLoadedRawwaves();
}
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 )
{
if ( rate > 0.0 && rate != srate_ ) {