/* FFTPlugin>>#loadFFTFrom: */ static sqInt loadFFTFrom(sqInt fftOop) { sqInt oop; success((slotSizeOf(fftOop)) >= 6); if (failed()) { return 0; } nu = fetchIntegerofObject(0, fftOop); fftSize = fetchIntegerofObject(1, fftOop); oop = fetchPointerofObject(2, fftOop); sinTableSize = stSizeOf(oop); /* begin checkedFloatPtrOf: */ success(isWords(oop)); if (failed()) { sinTable = 0; goto l1; } sinTable = ((float *) (firstIndexableField(oop))); l1: /* end checkedFloatPtrOf: */; oop = fetchPointerofObject(3, fftOop); permTableSize = stSizeOf(oop); /* begin checkedWordPtrOf: */ success(isWords(oop)); permTable = ((unsigned int *) (firstIndexableField(oop))); oop = fetchPointerofObject(4, fftOop); realDataSize = stSizeOf(oop); /* begin checkedFloatPtrOf: */ success(isWords(oop)); if (failed()) { realData = 0; goto l3; } realData = ((float *) (firstIndexableField(oop))); l3: /* end checkedFloatPtrOf: */; oop = fetchPointerofObject(5, fftOop); imagDataSize = stSizeOf(oop); /* begin checkedFloatPtrOf: */ success(isWords(oop)); if (failed()) { imagData = 0; goto l4; } imagData = ((float *) (firstIndexableField(oop))); l4: /* end checkedFloatPtrOf: */; success((((((1L << nu) == fftSize) && (((fftSize / 4) + 1) == sinTableSize)) && (fftSize == realDataSize)) && (fftSize == imagDataSize)) && (realDataSize == imagDataSize)); return (failed()) == 0; }
primPCREExec(void) { sqInt extraObj; sqInt length; int *matchSpacePtr; sqInt matchSpaceSize; sqInt result; char *searchBuffer; sqInt searchObject; /* Load Parameters */ searchObject = stackObjectValue(0); searchBuffer = arrayValueOf(searchObject); length = byteSizeOf(searchObject); /* begin loadRcvrFromStackAt: */ rcvr = stackObjectValue(1); pcrePtr = ((sqInt) (fetchArrayofObject(2, rcvr))); /* begin rcvrExtraPtr */ extraObj = fetchPointerofObject(3, rcvr); extraPtr = ((sqInt) ((!(extraObj == (nilObject())) ? arrayValueOf(extraObj) : 0))); matchFlags = fetchIntegerofObject(6, rcvr); matchSpacePtr = ((int *) (fetchArrayofObject(7, rcvr))); matchSpaceSize = (byteSizeOf(fetchPointerofObject(7, rcvr))) / 4; if (failed()) { return null; } result = pcre_exec((pcre *)pcrePtr, (pcre_extra *)extraPtr, searchBuffer, length, 0, matchFlags, matchSpacePtr, matchSpaceSize); pop(2); pushInteger(result); return 0; }
primitiveTextureUpload(void) { // B3DAcceleratorPlugin>>#primitiveTextureUpload sqInt bits; void*bitsPtr; sqInt d; sqInt form; sqInt h; sqInt handle; sqInt ppw; sqInt renderer; sqInt result; sqInt w; if (!((methodArgumentCount()) == 3)) { return primitiveFail(); } form = stackValue(0); if (!((isPointers(form)) && ((slotSizeOf(form)) >= 4))) { return primitiveFail(); } bits = fetchPointerofObject(0, form); w = fetchIntegerofObject(1, form); h = fetchIntegerofObject(2, form); d = fetchIntegerofObject(3, form); ppw = 32 / d; if (!(isWords(bits))) { return primitiveFail(); } if (!((slotSizeOf(bits)) == ((((w + ppw) - 1) / ppw) * h))) { return primitiveFail(); } bitsPtr = firstIndexableField(bits); handle = stackIntegerValue(1); renderer = stackIntegerValue(2); if (failed()) { return null; } result = b3dxUploadTexture(renderer, handle, w, h, d, bitsPtr); if (!result) { return primitiveFail(); } return pop(3); }
/* High-priority and synchronous ticker function support. */ void addHighPriorityTickee(void (*ticker)(void), unsigned periodms); void addSynchronousTickee(void (*ticker)(void), unsigned periodms, unsigned roundms); #if SPURVM /* For now these are here; perhaps they're better in the VM. */ static sqInt interceptFetchIntegerofObject(sqInt fieldIndex, sqInt objectPointer) { if (fieldIndex == 0 && isCharacterObject(objectPointer)) return characterValueOf(objectPointer); return fetchIntegerofObject(fieldIndex, objectPointer); }
primPCREExecfromto(void) { sqInt extraObj; sqInt fromInteger; sqInt length; int *matchSpacePtr; sqInt matchSpaceSize; sqInt result; char *searchBuffer; sqInt searchObject; sqInt toInteger; /* Load Parameters */ toInteger = stackIntegerValue(0); fromInteger = stackIntegerValue(1); searchObject = stackObjectValue(2); searchBuffer = arrayValueOf(searchObject); length = byteSizeOf(searchObject); /* begin loadRcvrFromStackAt: */ rcvr = stackObjectValue(3); success(1 <= fromInteger); success(toInteger <= length); /* Smalltalk offsets are 1-based */ fromInteger -= 1; success(fromInteger <= toInteger); length = toInteger - fromInteger; /* Load Instance Variables */ searchBuffer += fromInteger; pcrePtr = ((sqInt) (fetchArrayofObject(2, rcvr))); /* begin rcvrExtraPtr */ extraObj = fetchPointerofObject(3, rcvr); extraPtr = ((sqInt) ((!(extraObj == (nilObject())) ? arrayValueOf(extraObj) : 0))); matchFlags = fetchIntegerofObject(6, rcvr); matchSpacePtr = ((int *) (fetchArrayofObject(7, rcvr))); matchSpaceSize = (byteSizeOf(fetchPointerofObject(7, rcvr))) / 4; if (failed()) { return null; } result = pcre_exec((pcre *)pcrePtr, (pcre_extra *)extraPtr, searchBuffer, length, 0, matchFlags, matchSpacePtr, matchSpaceSize); pop(4); pushInteger(result); return 0; }
primPCRECompile(void) { /* begin loadRcvrFromStackAt: */ rcvr = stackObjectValue(0); patternStrPtr = ((char *) (fetchArrayofObject(0, rcvr))); compileFlags = fetchIntegerofObject(1, rcvr); if (failed()) { return null; } pcrePtr = (sqInt) pcre_compile(patternStrPtr, compileFlags, &errorStrBuffer, &errorOffset, NULL); if (pcrePtr) { allocateByteArrayAndSetRcvrPCREPtrFromPCRE(pcrePtr); extraPtr = (sqInt) pcre_study((pcre *)pcrePtr, compileFlags, &errorStrBuffer); allocateByteArrayAndSetRcvrExtraPtrFrom(extraPtr); /* begin rePluginFree: */ numFrees += 1; if ((((void *)pcrePtr)) != null) { free(((void *)pcrePtr)); } if (extraPtr) { /* begin rePluginFree: */ numFrees += 1; if ((((void *)extraPtr)) != null) { free(((void *)extraPtr)); } } if (failed()) { return null; } popthenPush(1, nilObject()); } else { errorStr = allocateStringAndSetRcvrErrorStrFromCStr(errorStrBuffer); /* begin rcvrErrorOffsetFrom: */ storeIntegerofObjectwithValue(5, rcvr, errorOffset); if (failed()) { return null; } popthenPush(1, errorStr); } return 0; }
int primWaveTableSoundmixSampleCountintostartingAtpan(void) { int rcvr; int n; short int *aSoundBuffer; int startIndex; int pan; int lastIndex; int channelIndex; int i; int mySample; int sample; short int *waveTable; int waveTableSize; int count; int amplitude; int increment; int index; rcvr = stackValue(4); n = checkedIntegerValueOf(stackValue(3)); aSoundBuffer = arrayValueOf(stackValue(2)); startIndex = checkedIntegerValueOf(stackValue(1)); pan = checkedIntegerValueOf(stackValue(0)); waveTable = fetchArrayofObject(1, rcvr); waveTableSize = fetchIntegerofObject(2, rcvr); count = fetchIntegerofObject(4, rcvr); amplitude = fetchIntegerofObject(6, rcvr); increment = fetchIntegerofObject(8, rcvr); index = fetchIntegerofObject(9, rcvr); if (!(successFlag)) { return null; } lastIndex = (startIndex + n) - 1; for (i = startIndex; i <= lastIndex; i += 1) { mySample = (amplitude * (waveTable[index - 1])) / 1000; if (pan > 0) { channelIndex = 2 * i; sample = (aSoundBuffer[channelIndex - 1]) + ((mySample * pan) / 1000); if (sample > 32767) { sample = 32767; } if (sample < -32767) { sample = -32767; } aSoundBuffer[channelIndex - 1] = sample; } if (pan < 1000) { channelIndex = (2 * i) - 1; sample = (aSoundBuffer[channelIndex - 1]) + ((mySample * (1000 - pan)) / 1000); if (sample > 32767) { sample = 32767; } if (sample < -32767) { sample = -32767; } aSoundBuffer[channelIndex - 1] = sample; } index += increment; if (index > waveTableSize) { index -= waveTableSize; } } count -= n; storeIntegerofObjectwithValue(4, rcvr, count); storeIntegerofObjectwithValue(9, rcvr, index); pop(4); }
int primSampledSoundmixSampleCountintostartingAtpan(void) { int rcvr; int n; short int *aSoundBuffer; int startIndex; int pan; int lastIndex; int i; int channelIndex; int sample; int sampleIndex; int thisSample; short int *samples; int samplesSize; int incrementTimes1000; int count; int indexTimes1000; rcvr = stackValue(4); n = checkedIntegerValueOf(stackValue(3)); aSoundBuffer = arrayValueOf(stackValue(2)); startIndex = checkedIntegerValueOf(stackValue(1)); pan = checkedIntegerValueOf(stackValue(0)); samples = fetchArrayofObject(1, rcvr); samplesSize = fetchIntegerofObject(2, rcvr); incrementTimes1000 = fetchIntegerofObject(3, rcvr); count = fetchIntegerofObject(5, rcvr); indexTimes1000 = fetchIntegerofObject(6, rcvr); if (!(successFlag)) { return null; } lastIndex = (startIndex + n) - 1; i = startIndex; sampleIndex = indexTimes1000 / 1000; while ((sampleIndex <= samplesSize) && (i <= lastIndex)) { thisSample = samples[sampleIndex - 1]; if (pan > 0) { channelIndex = 2 * i; sample = (aSoundBuffer[channelIndex - 1]) + ((thisSample * pan) / 1000); if (sample > 32767) { sample = 32767; } if (sample < -32767) { sample = -32767; } aSoundBuffer[channelIndex - 1] = sample; } if (pan < 1000) { channelIndex = (2 * i) - 1; sample = (aSoundBuffer[channelIndex - 1]) + ((thisSample * (1000 - pan)) / 1000); if (sample > 32767) { sample = 32767; } if (sample < -32767) { sample = -32767; } aSoundBuffer[channelIndex - 1] = sample; } indexTimes1000 += incrementTimes1000; sampleIndex = indexTimes1000 / 1000; i += 1; } count -= n; storeIntegerofObjectwithValue(5, rcvr, count); storeIntegerofObjectwithValue(6, rcvr, indexTimes1000); pop(4); }
int primPluckedSoundmixSampleCountintostartingAtpan(void) { int rcvr; int n; short int *aSoundBuffer; int startIndex; int pan; int lastIndex; int channelIndex; int i; int sample; int mySample; int thisIndex; int nextIndex; int count; short int *ring; int ringSize; int ringIndx; rcvr = stackValue(4); n = checkedIntegerValueOf(stackValue(3)); aSoundBuffer = arrayValueOf(stackValue(2)); startIndex = checkedIntegerValueOf(stackValue(1)); pan = checkedIntegerValueOf(stackValue(0)); count = fetchIntegerofObject(2, rcvr); ring = fetchArrayofObject(4, rcvr); ringSize = fetchIntegerofObject(5, rcvr); ringIndx = fetchIntegerofObject(6, rcvr); if (!(successFlag)) { return null; } lastIndex = (startIndex + n) - 1; thisIndex = ringIndx; for (i = startIndex; i <= lastIndex; i += 1) { nextIndex = (thisIndex % ringSize) + 1; mySample = ((ring[thisIndex - 1]) + (ring[nextIndex - 1])) / 2; ring[thisIndex - 1] = mySample; thisIndex = nextIndex; if (pan > 0) { channelIndex = 2 * i; sample = (aSoundBuffer[channelIndex - 1]) + ((mySample * pan) / 1000); if (sample > 32767) { sample = 32767; } if (sample < -32767) { sample = -32767; } aSoundBuffer[channelIndex - 1] = sample; } if (pan < 1000) { channelIndex = (2 * i) - 1; sample = (aSoundBuffer[channelIndex - 1]) + ((mySample * (1000 - pan)) / 1000); if (sample > 32767) { sample = 32767; } if (sample < -32767) { sample = -32767; } aSoundBuffer[channelIndex - 1] = sample; } } ringIndx = nextIndex; count -= n; storeIntegerofObjectwithValue(2, rcvr, count); storeIntegerofObjectwithValue(6, rcvr, ringIndx); pop(4); }
/* RePlugin>>#rcvrMatchFlags */ static sqInt rcvrMatchFlags(void) { return fetchIntegerofObject(6, rcvr); }
/* RePlugin>>#rcvrCompileFlags */ static sqInt rcvrCompileFlags(void) { return fetchIntegerofObject(1, rcvr); }