void process(AUAudioFrameCount frameCount, AUAudioFrameCount bufferOffset) override { for (int frameIndex = 0; frameIndex < frameCount; ++frameIndex) { int frameOffset = int(frameIndex + bufferOffset); baseFrequency = double(baseFrequencyRamper.getAndStep()); carrierMultiplier = double(carrierMultiplierRamper.getAndStep()); modulatingMultiplier = double(modulatingMultiplierRamper.getAndStep()); modulationIndex = double(modulationIndexRamper.getAndStep()); amplitude = double(amplitudeRamper.getAndStep()); fosc->freq = baseFrequency; fosc->car = carrierMultiplier; fosc->mod = modulatingMultiplier; fosc->indx = modulationIndex; fosc->amp = amplitude; float temp = 0; for (int channel = 0; channel < channels; ++channel) { float *out = (float *)outBufferListPtr->mBuffers[channel].mData + frameOffset; if (started) { if (channel == 0) { sp_fosc_compute(sp, fosc, nil, &temp); } *out = temp; } else { *out = 0.0; } } } }
uint32_t compute_buffer(int16_t *pbuf, int bufsize) { int i, o; SPFLOAT fm = 0, lfo = 0; SPFLOAT tmp = 0; SPFLOAT r0, r1; for(i = 0; i < bufsize / 2; i+=2) { sp_osc_compute(sp, osc, NULL, &lfo); fm = 0; for(o = 0; o < NOSCS; o++) { tmp = 0; fosc[o]->indx = ((1.0 + lfo) * 0.5) * 6; sp_fosc_compute(sp, fosc[o], NULL, &tmp); fm += tmp; } sp_revsc_compute(sp, revsc, &fm, &fm, &r0, &r1); pbuf[i] = (fm * 0.8 + r0 * 0.1) * 32767; pbuf[i + 1] = (fm * 0.8 + r1 * 0.1) * 32767; } return 0; }