|
From: Johnny P. <ele...@us...> - 2004-10-01 04:07:17
|
Update of /cvsroot/xpanda/Panda/Framework-Library/MACOSX/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8297/MACOSX/Core Modified Files: PandaModule.cpp PandaModule.h moduleloader.cpp moduleloader.hpp Log Message: update Index: PandaModule.h =================================================================== RCS file: /cvsroot/xpanda/Panda/Framework-Library/MACOSX/Core/PandaModule.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PandaModule.h 23 Apr 2004 14:28:32 -0000 1.7 --- PandaModule.h 1 Oct 2004 04:06:58 -0000 1.8 *************** *** 77,80 **** --- 77,90 ---- void deleteAudioEngine(); + void Sleep_SetBPM(double bpm); + + double Sleep_GetBPM(); + + void Sleep_SetResolution(int res); + + int Sleep_GetResolution(); + + void Sleep_ForTicks(long ticks); + void HELP(int ID); Index: moduleloader.cpp =================================================================== RCS file: /cvsroot/xpanda/Panda/Framework-Library/MACOSX/Core/moduleloader.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** moduleloader.cpp 23 Apr 2004 14:28:32 -0000 1.11 --- moduleloader.cpp 1 Oct 2004 04:06:58 -0000 1.12 *************** *** 45,52 **** #endif - #ifndef MAXPATHLEN - #define MAXPATHLEN 1024 - #endif - list<ModuleLoader*> ModuleLoader::Audio_StartPoints; list<ModuleLoader*> ModuleLoader::Audio_ADCs; --- 45,48 ---- *************** *** 64,67 **** --- 60,64 ---- isStartPoint = false; isADC = false; + needsStartPoint = false; int nameLen = strlen(name); char modName2Arr[nameLen+10]; *************** *** 81,91 **** loadBundle(ID,argc,argv); Connection::addModule(ID,this); ! if(strcmp(name,"Audio/StartPoint")==0 || strcmp(name,"audio/startpoint")==0) { ! ModuleLoader::Audio_StartPoints.push_back(this); ! isStartPoint = true; } ! if(strcmp(name,"Audio/ADC")==0 || strcmp(name,"audio/adc")==0) { ! ModuleLoader::Audio_ADCs.push_back(this); ! isADC = true; } modName = (char*)calloc(strlen(name)+2,sizeof(char)); --- 78,88 ---- loadBundle(ID,argc,argv); Connection::addModule(ID,this); ! if(functs.GetParameterListPtr(data).subType=='PSPO') { ! ModuleLoader::Audio_StartPoints.push_back(this); ! isStartPoint = true; } ! if(functs.GetParameterListPtr(data).subType=='PADC') { ! ModuleLoader::Audio_ADCs.push_back(this); ! isADC = true; } modName = (char*)calloc(strlen(name)+2,sizeof(char)); *************** *** 114,118 **** if(ModuleLoader::s_modules_extension) strcat(modName2,ModuleLoader::s_modules_extension); ! else strcat(modName2,".panda"); char *bundleName = modName2; --- 111,115 ---- if(ModuleLoader::s_modules_extension) strcat(modName2,ModuleLoader::s_modules_extension); ! else strcat(modName2,".panda"); char *bundleName = modName2; *************** *** 305,312 **** audio_outlets = functs.GetParameterListPtr(data).audio_outlets; audio_inlets = functs.GetParameterListPtr(data).audio_inlets; if(audio_inlets>0) { functs.AllocInletsPtr = (float** (*)(MyData*,long int,int*)) dlsym(module,"AllocInlets"); inletsBufferList.buffers = functs.AllocInletsPtr(data,GetPandaBufferSize(),&inletsBufferList.manyBuffers); ! } else printf("cannot call AllocInlets\n"); break; case ONLY_PARAMETERS: --- 302,310 ---- audio_outlets = functs.GetParameterListPtr(data).audio_outlets; audio_inlets = functs.GetParameterListPtr(data).audio_inlets; + needsStartPoint = c_bool(functs.GetParameterListPtr(data).audio_startpoint); if(audio_inlets>0) { functs.AllocInletsPtr = (float** (*)(MyData*,long int,int*)) dlsym(module,"AllocInlets"); inletsBufferList.buffers = functs.AllocInletsPtr(data,GetPandaBufferSize(),&inletsBufferList.manyBuffers); ! } break; case ONLY_PARAMETERS: *************** *** 415,422 **** audio_outlets = functs.GetParameterListPtr(data).audio_outlets; audio_inlets = functs.GetParameterListPtr(data).audio_inlets; if(audio_inlets>0) { functs.AllocInletsPtr = (float** (*)(MyData*,long int,int*)) loadlib_func(module,"AllocInlets"); inletsBufferList.buffers = functs.AllocInletsPtr(data,GetPandaBufferSize(),&inletsBufferList.manyBuffers); ! } else printf("cannot call AllocInlets\n"); break; case ONLY_PARAMETERS: --- 413,421 ---- audio_outlets = functs.GetParameterListPtr(data).audio_outlets; audio_inlets = functs.GetParameterListPtr(data).audio_inlets; + needsStartPoint = c_bool(functs.GetParameterListPtr(data).audio_startpoint); if(audio_inlets>0) { functs.AllocInletsPtr = (float** (*)(MyData*,long int,int*)) loadlib_func(module,"AllocInlets"); inletsBufferList.buffers = functs.AllocInletsPtr(data,GetPandaBufferSize(),&inletsBufferList.manyBuffers); ! } break; case ONLY_PARAMETERS: *************** *** 448,452 **** *theBundle = CFBundleCreate(kCFAllocatorDefault,bundleURL); CFRelease(bundleURL); ! } if(!bundleURL || *theBundle==NULL) { CFRelease(stringa); --- 447,452 ---- *theBundle = CFBundleCreate(kCFAllocatorDefault,bundleURL); CFRelease(bundleURL); ! } ! if(ModuleLoader::s_modules_directory) return noErr; if(!bundleURL || *theBundle==NULL) { CFRelease(stringa); *************** *** 506,510 **** if(!bundleURL || *theBundle==NULL) return -55; ! return noErr; --- 506,518 ---- if(!bundleURL || *theBundle==NULL) return -55; ! CFURLRef resURL = CFBundleCopyResourcesDirectoryURL(*theBundle); ! if(resURL) { ! memset(&resourcePath[0],0x0,sizeof(char)*1024); ! UInt8 *buf = (UInt8*)&resourcePath[0]; ! CFURLGetFileSystemRepresentation(resURL,true,buf,1024); ! CFRelease(resURL); ! strcat(&resourcePath[0],"/"); ! } ! return noErr; *************** *** 541,548 **** audio_outlets = functs.GetParameterListPtr(data).audio_outlets; audio_inlets = functs.GetParameterListPtr(data).audio_inlets; if(audio_inlets>0) { functs.AllocInletsPtr = (float** (*)(MyData*,long int,int*)) CFBundleGetFunctionPointerForName(module, CFSTR("AllocInlets")); inletsBufferList.buffers = functs.AllocInletsPtr(data,GetPandaBufferSize(),&inletsBufferList.manyBuffers); ! } else printf("cannot call AllocInlets\n"); break; case ONLY_PARAMETERS: --- 549,557 ---- audio_outlets = functs.GetParameterListPtr(data).audio_outlets; audio_inlets = functs.GetParameterListPtr(data).audio_inlets; + needsStartPoint = c_bool(functs.GetParameterListPtr(data).audio_startpoint); if(audio_inlets>0) { functs.AllocInletsPtr = (float** (*)(MyData*,long int,int*)) CFBundleGetFunctionPointerForName(module, CFSTR("AllocInlets")); inletsBufferList.buffers = functs.AllocInletsPtr(data,GetPandaBufferSize(),&inletsBufferList.manyBuffers); ! } break; case ONLY_PARAMETERS: *************** *** 647,845 **** #endif - //EXTERN "C" - - char * GetModuleResourcesPath(int ID) { - ModuleLoader *module = Connection::moduleFromID(ID); - return &module->resourcePath[0]; - } - - #if defined (__LINUX__) || (__WIN32__) - void * GetModuleBundleFromID(int ID) { - return ModuleLoader::GetModuleBundle(ID); - } - #else - CFBundleRef GetModuleBundleFromID(int ID) { - return ModuleLoader::GetModuleBundle(ID); - } - #endif - - void * GetModuleVoidPtr(int ID) { - return (void*)Connection::moduleFromID(ID); - } - - int GetManyModules() { - return Connection::modules.size(); - } - - list<S_SharedPtr> keysList; - - int setSharedPointer(char *key,void *ptr) { - S_SharedPtr newItem; - strcpy(&newItem.key[0],key); - newItem.ptr = ptr; - - keysList.push_back(newItem); - - return TRUE; - } - - void *sharedPointer(char *key) { - list<S_SharedPtr>::iterator i; - for(i=keysList.begin(); i!=keysList.end();++i) { - S_SharedPtr item = *i; - if(strcmp(&item.key[0],key)==0) { - return item.ptr; - } - } - - return NULL; - } - - void removeSharedPointer(char *key) { - list<S_SharedPtr>::iterator i; - for(i=keysList.begin(); i!=keysList.end();++i) { - S_SharedPtr item = *i; - if(strcmp(&item.key[0],key)==0) { - keysList.erase(i); - return; - } - } - } - - void PandaLog(char *fmt,...) { - va_list ap; - va_start(ap, fmt); - fprintf(stderr,"PandaLog: "); - vfprintf(stderr, fmt, ap); - va_end(ap); - } - - void outletCall(int ID, int outletNumber, void * values) { - Var *variables = (Var*)values; - Connection::executeConnected(ID,outletNumber,variables); - } - - int audio_StartPointCall(int ID, int outletNumber,long bufferSize) { - return Connection::audio_executeConnected(ID,outletNumber,bufferSize); - } - - int audio_DoRenderAtModule(int ID,long bufferSize) { - ModuleLoader *module = Connection::moduleFromID(ID); - if(module) return module->audio_executeMethod(bufferSize); - return 0; - } - - InletsBuffers2 GetOutletBuffers(int ID, int outletNumber) { - InletsBuffers2 buffersList; - Connection::getBuffersConnected(ID,outletNumber,&buffersList); - return buffersList; - } - - float **GetADCBuffers(int *channels) { - *channels = AudioRender::gInputChannels; - return AudioRender::getADC(); - } - - float **GetDACBuffers(int *channels) { - *channels = AudioRender::gOutputChannels; - return AudioRender::getDAC(); - } - - void setADC(float **buffers) { - AudioRender::setADC(buffers); - } - - void setDAC(float **buffers) { - AudioRender::setDAC(buffers); - } - - long GetBufferSize() { - return GetPandaBufferSize(); - } - - long GetPandaBufferSize() { - return glBufferSize; - } - - void SetPandaBufferSize(long nframes) { // useful for multiple buffer size zones. this must be set with the more higher value of the zones. - if(nframes>glBufferSize) { - glBufferSize = nframes; - } - } - - void SetPandaSampleRate(float newSR) { - AudioRender::gSampleRate = newSR; - } - - void SetPandaInChannels(int inChannels) { - AudioRender::gInputChannels = inChannels; - } - - void SetPandaOutChannels(int outChannels) { - AudioRender::gOutputChannels = outChannels; - } - - float GetSampleRate() { - float res = AudioRender::gSampleRate; - return res; - } - int GetDeviceInputChannels() { - int res = AudioRender::gInputChannels; - return res; - } - int GetDeviceOutputChannels() { - int res = AudioRender::gOutputChannels; - return res; - } - - float **GetPluginADCBuffers(char *istanceName) { - return P_AudioUnitRender::getADC(istanceName); - } - - float **GetPluginDACBuffers(char *istanceName) { - return P_AudioUnitRender::getDAC(istanceName); - } - - P_BOOL GetPluginAudioConfiguration(char *istanceName,float *outSR,long *outBSize,int *outInCh,int *outOutCh) { - return P_AudioUnitRender::getAudioConfiguration(istanceName,outSR,outBSize,outInCh,outOutCh); - } - - int c_bool(P_BOOL the_p_bool) { - if(the_p_bool==B_YES) return TRUE; - return FALSE; - } - - P_BOOL p_bool(int c_cond) { - if(c_cond) return B_YES; - return B_NO; - } - - int addThread(void *callerData,ThreadFunctionPtr ThreadFunction) { - return Thread::newThread(callerData,ThreadFunction); - } - - void removeThread(int ThreadReference) { - Thread::deleteThread(ThreadReference); - } - - int changeThreadPriority(int ThreadReference,int priority) { - return Thread::changePriority(ThreadReference,priority); - } - - void doPandaRender(long nframes) { - list<ModuleLoader*>::iterator i; - for(i=ModuleLoader::Audio_StartPoints.begin(); i!=ModuleLoader::Audio_StartPoints.end();++i) { - ModuleLoader *theConn = *i; - theConn->audio_executeMethod(nframes); - } - - for(i=ModuleLoader::Audio_ADCs.begin(); i!=ModuleLoader::Audio_ADCs.end();++i) { - ModuleLoader *theConn = *i; - theConn->audio_executeMethod(nframes); - } - } - - //END EXTERN "C" - //class connection --- 656,659 ---- *************** *** 856,860 **** bool Connection::connect(int fromID,int fromOutlet,int toID,int toInlet) { ModuleLoader *module = Connection::moduleFromID(fromID); ! if(!module) return false; list<Connection*>::iterator i; for(i=module->connections.begin(); i!=module->connections.end();++i) { --- 670,677 ---- bool Connection::connect(int fromID,int fromOutlet,int toID,int toInlet) { ModuleLoader *module = Connection::moduleFromID(fromID); ! ModuleLoader *toModule = Connection::moduleFromID(toID); ! if(!module || !toModule) return false; ! if(fromOutlet>=module->outlets) return false; ! if(toInlet>=toModule->inlets) return false; list<Connection*>::iterator i; for(i=module->connections.begin(); i!=module->connections.end();++i) { *************** *** 884,888 **** bool Connection::audio_connect(int fromID,int fromOutlet,int toID,int toInlet) { ModuleLoader *module = Connection::moduleFromID(fromID); ! if(!module) return false; list<Connection*>::iterator i; for(i=module->audio_connections.begin(); i!=module->audio_connections.end();++i) { --- 701,712 ---- bool Connection::audio_connect(int fromID,int fromOutlet,int toID,int toInlet) { ModuleLoader *module = Connection::moduleFromID(fromID); ! ModuleLoader *toModule = Connection::moduleFromID(toID); ! if(!module || !toModule) return false; ! if(fromOutlet>=module->audio_outlets) return false; ! if(toInlet>=toModule->audio_inlets) { ! if(!(toInlet==0 && toModule->needsStartPoint)) { ! return false; ! } ! } list<Connection*>::iterator i; for(i=module->audio_connections.begin(); i!=module->audio_connections.end();++i) { *************** *** 946,950 **** } ! bool isDone(int toID,int *array, int many) { int i; for(i=0;i<many;i++) { --- 770,774 ---- } ! bool Connection::isDone(int toID,int *array, int many) { int i; for(i=0;i<many;i++) { *************** *** 1699,1702 **** --- 1523,1565 ---- #endif + // PandaSleep CLASS + + double PandaSleep::bpm = 60.0; + int PandaSleep::res = PandaSleep::res1_4; + + void PandaSleep::WaitForTicks(long ticks) { + // unit us (microseconds) + double ms_meas_time = (60.0/PandaSleep::bpm)*1000000.0; + double tick_time = 0.0; + switch(PandaSleep::res) { + case PandaSleep::res1_4: + tick_time = ms_meas_time; + break; + case PandaSleep::res1_8: + tick_time = ms_meas_time/4.0; + break; + case PandaSleep::res1_16: + tick_time = ms_meas_time/8.0; + break; + case PandaSleep::res1_32: + tick_time = ms_meas_time/16.0; + break; + case PandaSleep::res1_64: + tick_time = ms_meas_time/32.0; + break; + case PandaSleep::res1_128: + tick_time = ms_meas_time/64.0; + break; + default: + return; + } + long time_to_sleep = ticks * (long)floor(tick_time); + #ifndef __WIN32__ + usleep(time_to_sleep); + #else + Sleep(time_to_sleep/1000); //I'm not a win32 developer, so I don't know an usleep like function..... + #endif + } + //Audio render CLASS *************** *** 1726,1730 **** #endif ! if(!driver_bundle) { PandaLog("driver NULL\n"); status = false; return; } #if defined (__LINUX__) || (__WIN32__) --- 1589,1593 ---- #endif ! if(!driver_bundle) { PandaLog("Cannot find or load requested Panda audio driver.\n"); status = false; return; } #if defined (__LINUX__) || (__WIN32__) *************** *** 1807,1810 **** --- 1670,1679 ---- } + if(!driver_bundle && ModuleLoader::s_modules_directory) { + strcpy(&loadPathArr[0],ModuleLoader::s_modules_directory); + strcat(&loadPathArr[0],moduleExcPath); + driver_bundle = dlopen (&loadPathArr[0], RTLD_NOW|RTLD_GLOBAL); + } + return driver_bundle ? TRUE : FALSE; } *************** *** 1890,1893 **** --- 1759,1768 ---- } + if(!driver_bundle && ModuleLoader::s_modules_directory) { + strcpy(&loadPathArr[0],ModuleLoader::s_modules_directory); + strcat(&loadPathArr[0],moduleExcPath); + driver_bundle = dlopen (&loadPathArr[0], RTLD_NOW|RTLD_GLOBAL); + } + return driver_bundle ? TRUE : FALSE; } *************** *** 1941,1945 **** *theBundle = CFBundleCreate(kCFAllocatorDefault,bundleURL); CFRelease(bundleURL); ! } else return -22; } --- 1816,1833 ---- *theBundle = CFBundleCreate(kCFAllocatorDefault,bundleURL); CFRelease(bundleURL); ! } else { ! CFRelease(stringa); ! strcpy(&homeName[0],ModuleLoader::s_modules_directory); ! strcat(&homeName[0],bundleName); ! ! stringa = CFStringCreateWithCString(kCFAllocatorDefault,&homeName[0],NULL); ! ! bundleURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault,stringa,kCFURLPOSIXPathStyle,true); ! ! if(bundleURL) { ! *theBundle = CFBundleCreate(kCFAllocatorDefault,bundleURL); ! CFRelease(bundleURL); ! } else { CFRelease(stringa); return -22; } ! } } *************** *** 2031,2035 **** } ! float **AudioRender::getDAC() { if(AudioRender::theRender==NULL) return NULL; return AudioRender::theRender->outBuffers; --- 1919,1923 ---- } ! float **AudioRender::getDAC() { if(AudioRender::theRender==NULL) return NULL; return AudioRender::theRender->outBuffers; *************** *** 2052,2058 **** strcpy(&name[0],istanceName); theAu = theAU; if(vInChannels>0) inBuffers = (float**)malloc(sizeof(float*)*vInChannels); else inBuffers = NULL; ! if(vChannels>0) outBuffers = (float**)malloc(sizeof(float*)*vChannels); else outBuffers = NULL; --- 1940,1948 ---- strcpy(&name[0],istanceName); theAu = theAU; + if(vInChannels>0) inBuffers = (float**)malloc(sizeof(float*)*vInChannels); else inBuffers = NULL; ! ! if(vChannels>0) outBuffers = (float**)malloc(sizeof(float*)*vChannels); else outBuffers = NULL; *************** *** 2082,2086 **** free(inBuffers[i]); } ! free(inBuffers); } --- 1972,1976 ---- free(inBuffers[i]); } ! if(inBuffers) free(inBuffers); } *************** *** 2089,2093 **** free(outBuffers[i]); } ! free(outBuffers); } --- 1979,1983 ---- free(outBuffers[i]); } ! if(outBuffers) free(outBuffers); } *************** *** 2120,2127 **** if(i->second) { P_AudioUnitRender *au = i->second; ! *outSR = au->vSampleRate; ! *outBSize = au->vBufferSize; ! *outInCh = au->vInChannels; ! *outOutCh = au->vChannels; return B_YES; } --- 2010,2017 ---- if(i->second) { P_AudioUnitRender *au = i->second; ! if(outSR) *outSR = au->vSampleRate; ! if(outBSize) *outBSize = au->vBufferSize; ! if(outInCh) *outInCh = au->vInChannels; ! if(outOutCh) *outOutCh = au->vChannels; return B_YES; } *************** *** 2134,2137 **** --- 2024,2039 ---- if(i->second) { P_AudioUnitRender *au = i->second; + ModuleLoader *mod = Connection::moduleFromID(moduleID); + switch(mod->functs.GetParameterListPtr(mod->data).subType) { + case 'PSPO': + au->addStartPoint(instance,mod); + break; + case 'PLAD': + au->addADC(instance,mod); + break; + case 'PADC': + case 'PDAC': + return; + } au->modulesInThis.push_back(moduleID); } *************** *** 2147,2151 **** int ID = *it; if(ID!=-1) { - printf("trying to release module: %d\n",ID); ModuleLoader *theModule = Connection::moduleFromID(ID); if(theModule!=NULL) delete theModule; --- 2049,2052 ---- *************** *** 2169,2173 **** theConn->audio_executeMethod(nframes); } - for(i=au->p_ADC.begin(); i!=au->p_ADC.end();++i) { ModuleLoader *theConn = *i; --- 2070,2073 ---- *************** *** 2197,2199 **** --- 2097,2294 ---- } + //EXTERN "C" + + char * GetModuleResourcesPath(int ID) { + ModuleLoader *module = Connection::moduleFromID(ID); + return &module->resourcePath[0]; + } + + #if defined (__LINUX__) || (__WIN32__) + void * GetModuleBundleFromID(int ID) { + return ModuleLoader::GetModuleBundle(ID); + } + #else + CFBundleRef GetModuleBundleFromID(int ID) { + return ModuleLoader::GetModuleBundle(ID); + } + #endif + + void * GetModuleVoidPtr(int ID) { + return (void*)Connection::moduleFromID(ID); + } + + int GetManyModules() { + return Connection::modules.size(); + } + + list<S_SharedPtr> keysList; + + int setSharedPointer(char *key,void *ptr) { + S_SharedPtr newItem; + strcpy(&newItem.key[0],key); + newItem.ptr = ptr; + + keysList.push_back(newItem); + + return TRUE; + } + + void *sharedPointer(char *key) { + list<S_SharedPtr>::iterator i; + for(i=keysList.begin(); i!=keysList.end();++i) { + S_SharedPtr item = *i; + if(strcmp(&item.key[0],key)==0) { + return item.ptr; + } + } + + return NULL; + } + + void removeSharedPointer(char *key) { + list<S_SharedPtr>::iterator i; + for(i=keysList.begin(); i!=keysList.end();++i) { + S_SharedPtr item = *i; + if(strcmp(&item.key[0],key)==0) { + keysList.erase(i); + return; + } + } + } + + void PandaLog(char *fmt,...) { + va_list ap; + va_start(ap, fmt); + fprintf(stderr,"PandaLog: "); + vfprintf(stderr, fmt, ap); + va_end(ap); + } + + void outletCall(int ID, int outletNumber, void * values) { + Var *variables = (Var*)values; + Connection::executeConnected(ID,outletNumber,variables); + } + + int audio_StartPointCall(int ID, int outletNumber,long bufferSize) { + return Connection::audio_executeConnected(ID,outletNumber,bufferSize); + } + + int audio_DoRenderAtModule(int ID,long bufferSize) { + ModuleLoader *module = Connection::moduleFromID(ID); + if(module) return module->audio_executeMethod(bufferSize); + return 0; + } + + InletsBuffers2 GetOutletBuffers(int ID, int outletNumber) { + InletsBuffers2 buffersList; + Connection::getBuffersConnected(ID,outletNumber,&buffersList); + return buffersList; + } + + float **GetADCBuffers(int *channels) { + *channels = AudioRender::gInputChannels; + return AudioRender::getADC(); + } + + float **GetDACBuffers(int *channels) { + *channels = AudioRender::gOutputChannels; + return AudioRender::getDAC(); + } + + void setADC(float **buffers) { + AudioRender::setADC(buffers); + } + + void setDAC(float **buffers) { + AudioRender::setDAC(buffers); + } + + long GetBufferSize() { + return GetPandaBufferSize(); + } + + long GetPandaBufferSize() { + return glBufferSize; + } + + void SetPandaBufferSize(long nframes) { // useful for multiple buffer size zones. this must be set with the more higher value of the zones. + if(nframes>glBufferSize) { + glBufferSize = nframes; + } + } + + void SetPandaSampleRate(float newSR) { + AudioRender::gSampleRate = newSR; + } + + void SetPandaInChannels(int inChannels) { + AudioRender::gInputChannels = inChannels; + } + + void SetPandaOutChannels(int outChannels) { + AudioRender::gOutputChannels = outChannels; + } + + float GetSampleRate() { + float res = AudioRender::gSampleRate; + return res; + } + int GetDeviceInputChannels() { + int res = AudioRender::gInputChannels; + return res; + } + int GetDeviceOutputChannels() { + int res = AudioRender::gOutputChannels; + return res; + } + + float **GetPluginADCBuffers(char *istanceName) { + return P_AudioUnitRender::getADC(istanceName); + } + + float **GetPluginDACBuffers(char *istanceName) { + return P_AudioUnitRender::getDAC(istanceName); + } + + P_BOOL GetPluginAudioConfiguration(char *istanceName,float *outSR,long *outBSize,int *outInCh,int *outOutCh) { + return P_AudioUnitRender::getAudioConfiguration(istanceName,outSR,outBSize,outInCh,outOutCh); + } + + int c_bool(P_BOOL the_p_bool) { + if(the_p_bool==B_YES) return TRUE; + return FALSE; + } + + P_BOOL p_bool(int c_cond) { + if(c_cond) return B_YES; + return B_NO; + } + + int addThread(void *callerData,ThreadFunctionPtr ThreadFunction) { + return Thread::newThread(callerData,ThreadFunction); + } + + void removeThread(int ThreadReference) { + Thread::deleteThread(ThreadReference); + } + + int changeThreadPriority(int ThreadReference,int priority) { + return Thread::changePriority(ThreadReference,priority); + } + + void doPandaRender(long nframes) { + list<ModuleLoader*>::iterator i; + for(i=ModuleLoader::Audio_StartPoints.begin(); i!=ModuleLoader::Audio_StartPoints.end();++i) { + ModuleLoader *theConn = *i; + theConn->audio_executeMethod(nframes); + } + + for(i=ModuleLoader::Audio_ADCs.begin(); i!=ModuleLoader::Audio_ADCs.end();++i) { + ModuleLoader *theConn = *i; + theConn->audio_executeMethod(nframes); + } + } + + //END EXTERN "C" + Index: PandaModule.cpp =================================================================== RCS file: /cvsroot/xpanda/Panda/Framework-Library/MACOSX/Core/PandaModule.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PandaModule.cpp 23 Apr 2004 14:28:32 -0000 1.6 --- PandaModule.cpp 1 Oct 2004 04:06:58 -0000 1.7 *************** *** 81,84 **** --- 81,85 ---- if(fromID==-1 || toID==-1)return FALSE; bool res = Connection::connect(fromID,fromOutlet,toID,toInlet); + if(!res) PandaLog("Cannot: Connect(%d,%d,%d,%d)\n",fromID,fromOutlet,toID,toInlet); if(res) return TRUE; else return FALSE; *************** *** 95,98 **** --- 96,100 ---- if(fromID==-1 || toID==-1)return FALSE; bool res = Connection::audio_connect(fromID,fromOutlet,toID,toInlet); + if(!res) PandaLog("Cannot: Audio_Connect(%d,%d,%d,%d)\n",fromID,fromOutlet,toID,toInlet); if(res) return TRUE; else return FALSE; *************** *** 209,212 **** --- 211,236 ---- } + //------ + + void Sleep_SetBPM(double bpm) { + PandaSleep::SetBpm(bpm); + } + + double Sleep_GetBPM() { + return PandaSleep::GetBpm(); + } + + void Sleep_SetResolution(int res) { + PandaSleep::SetResolution(res); + } + + int Sleep_GetResolution() { + return PandaSleep::GetResolution(); + } + + void Sleep_ForTicks(long ticks) { + PandaSleep::WaitForTicks(ticks); + } + //------- *************** *** 263,270 **** void changeModulesSearchDirectory(char *newDirectory) { ! if(!newDirectory && ModuleLoader::s_modules_directory) { ! free(ModuleLoader::s_modules_directory); ModuleLoader::s_modules_directory = NULL; ! } else if(newDirectory && !ModuleLoader::s_modules_directory) { long len = strlen(newDirectory); ModuleLoader::s_modules_directory = (char*)calloc(len+2,sizeof(char)); --- 287,295 ---- void changeModulesSearchDirectory(char *newDirectory) { ! if(newDirectory==NULL) { ! if(ModuleLoader::s_modules_directory) free(ModuleLoader::s_modules_directory); ModuleLoader::s_modules_directory = NULL; ! } else { ! if(ModuleLoader::s_modules_directory) free(ModuleLoader::s_modules_directory); long len = strlen(newDirectory); ModuleLoader::s_modules_directory = (char*)calloc(len+2,sizeof(char)); *************** *** 274,281 **** void changeModulesBundleExtension(char *newExtension) { ! if(!newExtension && ModuleLoader::s_modules_extension) { ! free(ModuleLoader::s_modules_extension); ModuleLoader::s_modules_extension = NULL; ! } else if(newExtension && !ModuleLoader::s_modules_extension) { long len = strlen(newExtension); ModuleLoader::s_modules_extension = (char*)calloc(len+2,sizeof(char)); --- 299,307 ---- void changeModulesBundleExtension(char *newExtension) { ! if(newExtension==NULL) { ! if(ModuleLoader::s_modules_extension) free(ModuleLoader::s_modules_extension); ModuleLoader::s_modules_extension = NULL; ! } else { ! if(ModuleLoader::s_modules_extension) free(ModuleLoader::s_modules_extension); long len = strlen(newExtension); ModuleLoader::s_modules_extension = (char*)calloc(len+2,sizeof(char)); Index: moduleloader.hpp =================================================================== RCS file: /cvsroot/xpanda/Panda/Framework-Library/MACOSX/Core/moduleloader.hpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** moduleloader.hpp 23 Apr 2004 14:28:32 -0000 1.9 --- moduleloader.hpp 1 Oct 2004 04:06:58 -0000 1.10 *************** *** 37,47 **** #ifndef __WIN32__ #include <pthread.h> - #else - #endif #include "loadlib.h" ! #define TEST PandaLog("TEST\n") using namespace std; --- 37,47 ---- #ifndef __WIN32__ #include <pthread.h> #endif #include "loadlib.h" ! #ifndef MAXPATHLEN ! #define MAXPATHLEN 1024 ! #endif using namespace std; *************** *** 90,94 **** list<Connection*> connections; list<Connection*> audio_connections; ! char resourcePath[256]; private: bool isStartPoint; --- 90,96 ---- list<Connection*> connections; list<Connection*> audio_connections; ! char resourcePath[MAXPATHLEN]; ! int outlets,inlets,audio_outlets,audio_inlets; ! bool needsStartPoint; private: bool isStartPoint; *************** *** 105,109 **** int status; int ID; - int outlets,inlets,audio_outlets,audio_inlets; }; --- 107,110 ---- *************** *** 133,136 **** --- 134,138 ---- static list<Connection*> audio_connections; static map<int,ModuleLoader*>::iterator pos; + static bool isDone(int toID,int *array, int many); }; *************** *** 157,160 **** --- 159,175 ---- }; + class PandaSleep { + public: + enum { res1_4,res1_8,res1_16,res1_32,res1_64,res1_128 }; + static void SetBpm(double newBpmValue) { bpm = newBpmValue; } + static void SetResolution(int resolution) { res = resolution; } + static double GetBpm() { return bpm; } + static int GetResolution() { return res; } + static void WaitForTicks(long ticks); + private: + static double bpm; + static int res; + }; + class AudioRender { public: |