1
/* Automatically generated from Squeak on (4 January 1998 3:05:25 am ) */
6
/* Memory Access Macros */
7
#define byteAt(i) (*((unsigned char *) (i)))
8
#define byteAtput(i, val) (*((unsigned char *) (i)) = val)
9
#define longAt(i) (*((int *) (i)))
10
#define longAtput(i, val) (*((int *) (i)) = val)
12
/*** Imported Functions/Variables ***/
13
extern int stackValue(int);
14
extern int successFlag;
18
/*** Function Prototypes ***/
19
int primFMSoundmixSampleCountintostartingAtpan(void);
20
int primPluckedSoundmixSampleCountintostartingAtpan(void);
21
int primSampledSoundmixSampleCountintostartingAtpan(void);
22
int primWaveTableSoundmixSampleCountintostartingAtpan(void);
23
int oldprimSampledSoundmixSampleCountintostartingAtleftVolrightVol(void);
25
int primFMSoundmixSampleCountintostartingAtpan(void) {
28
short int *aSoundBuffer;
47
n = checkedIntegerValueOf(stackValue(3));
48
aSoundBuffer = arrayValueOf(stackValue(2));
49
startIndex = checkedIntegerValueOf(stackValue(1));
50
pan = checkedIntegerValueOf(stackValue(0));
51
waveTable = fetchArrayofObject(1, rcvr);
52
waveTableSize = fetchIntegerofObject(2, rcvr);
53
count = fetchIntegerofObject(4, rcvr);
54
amplitude = fetchIntegerofObject(6, rcvr);
55
increment = fetchIntegerofObject(8, rcvr);
56
index = fetchIntegerofObject(9, rcvr);
57
modulation = fetchIntegerofObject(11, rcvr);
58
offsetIncrement = fetchIntegerofObject(14, rcvr);
59
offsetIndex = fetchIntegerofObject(15, rcvr);
63
lastIndex = (startIndex + n) - 1;
64
for (i = startIndex; i <= lastIndex; i += 1) {
65
mySample = (amplitude * (waveTable[index - 1])) / 1000;
68
sample = (aSoundBuffer[channelIndex - 1]) + ((mySample * pan) / 1000);
72
if (sample < -32767) {
75
aSoundBuffer[channelIndex - 1] = sample;
78
channelIndex = (2 * i) - 1;
79
sample = (aSoundBuffer[channelIndex - 1]) + ((mySample * (1000 - pan)) / 1000);
83
if (sample < -32767) {
86
aSoundBuffer[channelIndex - 1] = sample;
88
index = (index + increment) + ((modulation * (waveTable[offsetIndex - 1])) / 1000000);
89
if (index > waveTableSize) {
90
index -= waveTableSize;
93
index += waveTableSize;
95
offsetIndex += offsetIncrement;
96
if (offsetIndex > waveTableSize) {
97
offsetIndex -= waveTableSize;
101
storeIntegerofObjectwithValue(4, rcvr, count);
102
storeIntegerofObjectwithValue(9, rcvr, index);
103
storeIntegerofObjectwithValue(15, rcvr, offsetIndex);
107
int primPluckedSoundmixSampleCountintostartingAtpan(void) {
110
short int *aSoundBuffer;
125
rcvr = stackValue(4);
126
n = checkedIntegerValueOf(stackValue(3));
127
aSoundBuffer = arrayValueOf(stackValue(2));
128
startIndex = checkedIntegerValueOf(stackValue(1));
129
pan = checkedIntegerValueOf(stackValue(0));
130
count = fetchIntegerofObject(2, rcvr);
131
ring = fetchArrayofObject(4, rcvr);
132
ringSize = fetchIntegerofObject(5, rcvr);
133
ringIndx = fetchIntegerofObject(6, rcvr);
134
if (!(successFlag)) {
137
lastIndex = (startIndex + n) - 1;
138
thisIndex = ringIndx;
139
for (i = startIndex; i <= lastIndex; i += 1) {
140
nextIndex = (thisIndex % ringSize) + 1;
141
mySample = ((ring[thisIndex - 1]) + (ring[nextIndex - 1])) / 2;
142
ring[thisIndex - 1] = mySample;
143
thisIndex = nextIndex;
145
channelIndex = 2 * i;
146
sample = (aSoundBuffer[channelIndex - 1]) + ((mySample * pan) / 1000);
147
if (sample > 32767) {
150
if (sample < -32767) {
153
aSoundBuffer[channelIndex - 1] = sample;
156
channelIndex = (2 * i) - 1;
157
sample = (aSoundBuffer[channelIndex - 1]) + ((mySample * (1000 - pan)) / 1000);
158
if (sample > 32767) {
161
if (sample < -32767) {
164
aSoundBuffer[channelIndex - 1] = sample;
167
ringIndx = nextIndex;
169
storeIntegerofObjectwithValue(2, rcvr, count);
170
storeIntegerofObjectwithValue(6, rcvr, ringIndx);
174
int primSampledSoundmixSampleCountintostartingAtpan(void) {
177
short int *aSoundBuffer;
188
int incrementTimes1000;
192
rcvr = stackValue(4);
193
n = checkedIntegerValueOf(stackValue(3));
194
aSoundBuffer = arrayValueOf(stackValue(2));
195
startIndex = checkedIntegerValueOf(stackValue(1));
196
pan = checkedIntegerValueOf(stackValue(0));
197
samples = fetchArrayofObject(1, rcvr);
198
samplesSize = fetchIntegerofObject(2, rcvr);
199
incrementTimes1000 = fetchIntegerofObject(3, rcvr);
200
count = fetchIntegerofObject(5, rcvr);
201
indexTimes1000 = fetchIntegerofObject(6, rcvr);
202
if (!(successFlag)) {
205
lastIndex = (startIndex + n) - 1;
207
sampleIndex = indexTimes1000 / 1000;
208
while ((sampleIndex <= samplesSize) && (i <= lastIndex)) {
209
thisSample = samples[sampleIndex - 1];
211
channelIndex = 2 * i;
212
sample = (aSoundBuffer[channelIndex - 1]) + ((thisSample * pan) / 1000);
213
if (sample > 32767) {
216
if (sample < -32767) {
219
aSoundBuffer[channelIndex - 1] = sample;
222
channelIndex = (2 * i) - 1;
223
sample = (aSoundBuffer[channelIndex - 1]) + ((thisSample * (1000 - pan)) / 1000);
224
if (sample > 32767) {
227
if (sample < -32767) {
230
aSoundBuffer[channelIndex - 1] = sample;
232
indexTimes1000 += incrementTimes1000;
233
sampleIndex = indexTimes1000 / 1000;
237
storeIntegerofObjectwithValue(5, rcvr, count);
238
storeIntegerofObjectwithValue(6, rcvr, indexTimes1000);
242
int primWaveTableSoundmixSampleCountintostartingAtpan(void) {
245
short int *aSoundBuffer;
253
short int *waveTable;
260
rcvr = stackValue(4);
261
n = checkedIntegerValueOf(stackValue(3));
262
aSoundBuffer = arrayValueOf(stackValue(2));
263
startIndex = checkedIntegerValueOf(stackValue(1));
264
pan = checkedIntegerValueOf(stackValue(0));
265
waveTable = fetchArrayofObject(1, rcvr);
266
waveTableSize = fetchIntegerofObject(2, rcvr);
267
count = fetchIntegerofObject(4, rcvr);
268
amplitude = fetchIntegerofObject(6, rcvr);
269
increment = fetchIntegerofObject(8, rcvr);
270
index = fetchIntegerofObject(9, rcvr);
271
if (!(successFlag)) {
274
lastIndex = (startIndex + n) - 1;
275
for (i = startIndex; i <= lastIndex; i += 1) {
276
mySample = (amplitude * (waveTable[index - 1])) / 1000;
278
channelIndex = 2 * i;
279
sample = (aSoundBuffer[channelIndex - 1]) + ((mySample * pan) / 1000);
280
if (sample > 32767) {
283
if (sample < -32767) {
286
aSoundBuffer[channelIndex - 1] = sample;
289
channelIndex = (2 * i) - 1;
290
sample = (aSoundBuffer[channelIndex - 1]) + ((mySample * (1000 - pan)) / 1000);
291
if (sample > 32767) {
294
if (sample < -32767) {
297
aSoundBuffer[channelIndex - 1] = sample;
300
if (index > waveTableSize) {
301
index -= waveTableSize;
305
storeIntegerofObjectwithValue(4, rcvr, count);
306
storeIntegerofObjectwithValue(9, rcvr, index);
310
int oldprimSampledSoundmixSampleCountintostartingAtleftVolrightVol(void) {
313
short int *aSoundBuffer;
329
int incrementTimes1000;
332
rcvr = stackValue(5);
333
n = checkedIntegerValueOf(stackValue(4));
334
aSoundBuffer = arrayValueOf(stackValue(3));
336
startIndex = checkedIntegerValueOf(stackValue(2));
337
leftVol = checkedIntegerValueOf(stackValue(1));
338
rightVol = checkedIntegerValueOf(stackValue(0));
339
scaledVol = fetchIntegerofObject(3, rcvr);
340
scaledVolIncr = fetchIntegerofObject(4, rcvr);
341
scaledVolLimit = fetchIntegerofObject(5, rcvr);
342
count = fetchIntegerofObject(7, rcvr);
343
samples = fetchArrayofObject(8, rcvr);
345
samplesSize = fetchIntegerofObject(10, rcvr);
346
incrementTimes1000 = fetchIntegerofObject(11, rcvr);
347
indexTimes1000 = fetchIntegerofObject(12, rcvr);
348
if (!(successFlag)) {
351
lastIndex = (startIndex + n) - 1;
352
sliceIndex = startIndex;
353
sampleIndex = indexTimes1000 / 1000;
354
while ((sampleIndex <= samplesSize) && (sliceIndex <= lastIndex)) {
355
sample = ((int) ((samples[sampleIndex]) * scaledVol) >> 15);
357
i = (2 * sliceIndex) - 1;
358
s = (aSoundBuffer[i]) + (((int) (sample * leftVol) >> 15));
369
s = (aSoundBuffer[i]) + (((int) (sample * rightVol) >> 15));
378
if (scaledVolIncr != 0) {
379
scaledVol += scaledVolIncr;
380
if (((scaledVolIncr > 0) && (scaledVol >= scaledVolLimit)) || ((scaledVolIncr < 0) && (scaledVol <= scaledVolLimit))) {
381
scaledVol = scaledVolLimit;
385
indexTimes1000 += incrementTimes1000;
386
sampleIndex = indexTimes1000 / 1000;
390
if (!(successFlag)) {
393
storeIntegerofObjectwithValue(3, rcvr, scaledVol);
394
storeIntegerofObjectwithValue(4, rcvr, scaledVolIncr);
395
storeIntegerofObjectwithValue(7, rcvr, count);
396
storeIntegerofObjectwithValue(12, rcvr, indexTimes1000);