Plugin newPluginMock(void) { Plugin plugin = _newPlugin(PLUGIN_TYPE_INTERNAL, PLUGIN_TYPE_INSTRUMENT); charStringCopyCString(plugin->pluginName, "Mock"); charStringCopyCString(plugin->pluginLocation, "Internal"); plugin->openPlugin = _pluginMockOpen; plugin->displayInfo = _pluginMockEmpty; plugin->getSetting = _pluginMockGetSetting; plugin->prepareForProcessing = _pluginMockPrepareForProcessing; plugin->processAudio = _pluginMockProcessAudio; plugin->processMidiEvents = _pluginMockProcessMidiEvents; plugin->setParameter = _pluginMockSetParameter; plugin->closePlugin = _pluginMockClose; plugin->freePluginData = _pluginMockEmpty; PluginMockData extraData = (PluginMockData)malloc(sizeof(PluginMockDataMembers)); extraData->isOpen = false; extraData->isPrepared = false; extraData->processAudioCalled = false; extraData->processMidiCalled = false; plugin->extraData = extraData; return plugin; }
static void _remapFileToErrorReportRelativePath(void* item, void* userData) { char* itemName = (char*)item; CharString tempPath = newCharString(); ErrorReporter errorReporter = (ErrorReporter)userData; charStringCopyCString(tempPath, itemName); snprintf(tempPath->data, tempPath->length, "%s/%s", errorReporter->reportName->data, itemName); strncpy(itemName, tempPath->data, tempPath->length); }
static int _testGetFileDirname(void) { CharString filename = newCharStringWithCString(ABSOLUTE_TEST_FILENAME); CharString expected = newCharString(); CharString result = newCharString(); #if UNIX charStringCopyCString(expected, "/tmp"); #elif WINDOWS charStringCopyCString(expected, "C:\\Temp"); #endif getFileDirname(filename, result); assertCharStringEquals(result, expected->data); freeCharString(filename); freeCharString(expected); freeCharString(result); return 0; }
static int _testAppendItemToList(void) { LinkedList l = newLinkedList(); CharString c = newCharString(); charStringCopyCString(c, TEST_ITEM_STRING); linkedListAppend(l, c); assertNotNull(l->item); assertCharStringEquals(((CharString)l->item), TEST_ITEM_STRING); assertIsNull(l->nextItem); freeLinkedListAndItems(l, (LinkedListFreeItemFunc)freeCharString); return 0; }
void errorReporterRemapPath(ErrorReporter self, CharString path) { CharString basename = newCharString(); CharString outString = newCharStringWithCapacity(path->capacity); charStringCopyCString(basename, getFileBasename(path->data)); buildAbsolutePath(self->reportDirPath, basename, NULL, outString); charStringCopy(path, outString); freeCharString(basename); freeCharString(outString); }
static boolByte openSampleSourcePcm(void* sampleSourcePtr, const SampleSourceOpenAs openAs) { SampleSource sampleSource = (SampleSource)sampleSourcePtr; SampleSourcePcmData extraData = (SampleSourcePcmData)(sampleSource->extraData); extraData->dataBufferNumItems = 0; if(openAs == SAMPLE_SOURCE_OPEN_READ) { if(charStringIsEqualToCString(sampleSource->sourceName, "-", false)) { extraData->fileHandle = stdin; charStringCopyCString(sampleSource->sourceName, "stdin"); extraData->isStream = true; } else { extraData->fileHandle = fopen(sampleSource->sourceName->data, "rb"); } } else if(openAs == SAMPLE_SOURCE_OPEN_WRITE) { if(charStringIsEqualToCString(sampleSource->sourceName, "-", false)) { extraData->fileHandle = stdout; charStringCopyCString(sampleSource->sourceName, "stdout"); extraData->isStream = true; } else { extraData->fileHandle = fopen(sampleSource->sourceName->data, "wb"); } } else { logInternalError("Invalid type for openAs in PCM file"); return false; } if(extraData->fileHandle == NULL) { logError("PCM File '%s' could not be opened for %s", sampleSource->sourceName->data, openAs == SAMPLE_SOURCE_OPEN_READ ? "reading" : "writing"); return false; } sampleSource->openedAs = openAs; return true; }
static int _testNumItemsInList(void) { CharString c; int i; LinkedList l = newLinkedList(); for(i = 0; i < 100; i++) { c = newCharString(); charStringCopyCString(c, TEST_ITEM_STRING); linkedListAppend(l, c); } assertIntEquals(linkedListLength(l), 100); freeLinkedListAndItems(l, (LinkedListFreeItemFunc)freeCharString); return 0; }
static int _testAppendMultipleItemsToList(void) { LinkedListIterator i; LinkedList l = newLinkedList(); CharString c = newCharString(); CharString c2 = newCharString(); charStringCopyCString(c, TEST_ITEM_STRING); charStringCopyCString(c2, OTHER_TEST_ITEM_STRING); linkedListAppend(l, c); linkedListAppend(l, c2); assertNotNull(l->item); assertCharStringEquals(((CharString)l->item), TEST_ITEM_STRING); assertNotNull(l->nextItem); i = l->nextItem; assertNotNull(i->item); assertCharStringEquals(((CharString)i->item), OTHER_TEST_ITEM_STRING); assertIsNull(i->nextItem); assertIntEquals(linkedListLength(l), 2); freeLinkedListAndItems(l, (LinkedListFreeItemFunc)freeCharString); return 0; }
static int _testForeachOverUserData(void) { LinkedList l = newLinkedList(); CharString c = newCharString(); charStringCopyCString(c, TEST_ITEM_STRING); linkedListAppend(l, c); linkedListForeach(l, _linkedListUserDataCallback, c); assertIntEquals(_gNumForeachCallbacksMade, 1); assert(_gForeachCallbackOk); freeLinkedListAndItems(l, (LinkedListFreeItemFunc)freeCharString); return 0; }
char* stringForLastError(int errorNumber) { EventLogger eventLogger = _getEventLoggerInstance(); if(eventLogger->systemErrorMessage == NULL) { eventLogger->systemErrorMessage = newCharString(); } #if UNIX return strerror(errorNumber); #elif WINDOWS FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, 0, errorNumber, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), eventLogger->systemErrorMessage->data, eventLogger->systemErrorMessage->length - 1, NULL); #else charStringCopyCString(eventLogger->systemErrorMessage, "Unknown error"); #endif return eventLogger->systemErrorMessage->data; }
SampleSource _newSampleSourceSilence(void) { SampleSource sampleSource = (SampleSource)malloc(sizeof(SampleSourceMembers)); sampleSource->sampleSourceType = SAMPLE_SOURCE_TYPE_SILENCE; sampleSource->openedAs = SAMPLE_SOURCE_OPEN_NOT_OPENED; sampleSource->sourceName = newCharString(); charStringCopyCString(sampleSource->sourceName, "(silence)"); sampleSource->numSamplesProcessed = 0; sampleSource->openSampleSource = _openSampleSourceSilence; sampleSource->closeSampleSource = _closeSampleSourceSilence; sampleSource->readSampleBlock = _readBlockFromSilence; sampleSource->writeSampleBlock = _writeBlockToSilence; sampleSource->freeSampleSourceData = _freeInputSourceDataSilence; return sampleSource; }
Plugin newPluginPassthru(const CharString pluginName) { Plugin plugin = _newPlugin(PLUGIN_TYPE_INTERNAL, PLUGIN_TYPE_EFFECT); charStringCopy(plugin->pluginName, pluginName); charStringCopyCString(plugin->pluginLocation, "Internal"); plugin->openPlugin = _pluginPassthruOpen; plugin->displayInfo = _pluginPassthruDisplayInfo; plugin->getSetting = _pluginPassthruGetSetting; plugin->prepareForProcessing = _pluginPassthruEmpty; plugin->processAudio = _pluginPassthruProcessAudio; plugin->processMidiEvents = _pluginPassthruProcessMidiEvents; plugin->setParameter = _pluginPassthruSetParameter; plugin->closePlugin = _pluginPassthruEmpty; plugin->freePluginData = _pluginPassthruEmpty; plugin->extraData = NULL; return plugin; }
void errorReporterCreateLauncher(ErrorReporter self, int argc, char* argv[]) { CharString outScriptName = newCharString(); FILE *scriptFilePointer; int i; charStringCopyCString(outScriptName, "run.sh"); errorReporterRemapPath(self, outScriptName); scriptFilePointer = fopen(outScriptName->data, "w"); fprintf(scriptFilePointer, "#!/bin/sh\n"); fprintf(scriptFilePointer, "mrswatson"); for(i = 1; i < argc; i++) { // Don't run with the error report option again if(strcmp(argv[i], "--error-report")) { fprintf(scriptFilePointer, " %s", argv[i]); } } fprintf(scriptFilePointer, "\n"); fclose(scriptFilePointer); }
Plugin newPluginSilence(const CharString pluginName) { Plugin plugin = _newPlugin(PLUGIN_TYPE_INTERNAL, PLUGIN_TYPE_INSTRUMENT); charStringCopy(plugin->pluginName, pluginName); charStringCopyCString(plugin->pluginLocation, "Internal"); plugin->openPlugin = _pluginSilenceOpen; plugin->displayInfo = _pluginSilenceDisplayInfo; plugin->getSetting = _pluginSilenceGetSetting; plugin->prepareForProcessing = _pluginSilenceEmpty; plugin->showEditor = _pluginSilenceEmpty; plugin->processAudio = _pluginSilenceProcessAudio; plugin->processMidiEvents = _pluginSilenceProcessMidiEvents; plugin->setParameter = _pluginSilenceSetParameter; plugin->closePlugin = _pluginSilenceEmpty; plugin->freePluginData = _pluginSilenceEmpty; plugin->extraData = NULL; return plugin; }
Plugin newPluginGain(const CharString pluginName) { Plugin plugin = _newPlugin(PLUGIN_TYPE_INTERNAL, PLUGIN_TYPE_EFFECT); PluginGainSettings settings = (PluginGainSettings)malloc(sizeof(PluginGainSettingsMembers)); charStringCopy(plugin->pluginName, pluginName); charStringCopyCString(plugin->pluginLocation, "Internal"); plugin->openPlugin = _pluginGainOpen; plugin->displayInfo = _pluginGainDisplayInfo; plugin->getSetting = _pluginGainGetSetting; plugin->prepareForProcessing = _pluginGainEmpty; plugin->showEditor = _pluginGainEmpty; plugin->processAudio = _pluginGainProcessAudio; plugin->processMidiEvents = _pluginGainProcessMidiEvents; plugin->setParameter = _pluginGainSetParameter; plugin->closePlugin = _pluginGainEmpty; plugin->freePluginData = _pluginGainEmpty; settings->gain = 1.0f; plugin->extraData = settings; return plugin; }