//--------------------------------------------------- void calcDrumVoiceSyncBlock(const uint8_t voiceNr, int16_t* buf, const uint8_t size) { int16_t modBuf[size]; //calc vol EG #ifdef USE_AMP_FILTER calcOnePoleBlockFixedInput(&voiceArray[voiceNr].ampFilter, voiceArray[voiceNr].ampFilterInput,voiceArray[voiceNr].volEgValueBlock, size); #endif //calc next mod osc sampleBlock calcNextOscSampleBlock(&voiceArray[voiceNr].modOsc,modBuf,size,voiceArray[voiceNr].fmModAmount); if(voiceArray[voiceNr].mixOscs) { //calc main osc buffer calcNextOscSampleBlock(&voiceArray[voiceNr].osc,buf,size, (1.f-voiceArray[voiceNr].fmModAmount)); //add mod buffer to main osc buffer bufferTool_addBuffersSaturating(buf,modBuf,size); } else { calcNextOscSampleFmBlock(&voiceArray[voiceNr].osc,modBuf,buf,size,1.0f); } //calc transient sample transient_calcBlock(&voiceArray[voiceNr].transGen,modBuf,size); //Mix with transient buffer bufferTool_addBuffersSaturating(buf,modBuf,size); //calc filter block SVF_calcBlockZDF(&voiceArray[voiceNr].filter,voiceArray[voiceNr].filterType,buf,size); //attentuate main OSCs by amp EG #ifdef USE_AMP_FILTER bufferTool_multiplyWithFloatBufferDithered(&voiceArray[voiceNr].dither, buf,voiceArray[voiceNr].volEgValueBlock,size); #else bufferTool_addGainInterpolated(buf,voiceArray[voiceNr].ampFilterInput, voiceArray[voiceNr].lastGain, size); #endif //MIDI velocity if(voiceArray[voiceNr].volumeMod) { bufferTool_addGain(buf,voiceArray[voiceNr].velo,size); } //distortion #if (USE_FILTER_DRIVE == 0) calcDistBlock(&voiceArray[voiceNr].distortion,buf,size); #endif //channel volume bufferTool_addGain(buf,voiceArray[voiceNr].vol,size); }
//--------------------------------------------------- void HiHat_calcSyncBlock(int16_t* buf, const uint8_t size) { //2 buffers for the mod oscs int16_t mod1[size],mod2[size]; //calc next mod osc samples, scaled with mod amount calcNextOscSampleBlock(&hatVoice.modOsc,mod1,size, hatVoice.fmModAmount1); calcNextOscSampleBlock(&hatVoice.modOsc2,mod2,size, hatVoice.fmModAmount2); //combine both mod oscs to 1 modulation signal bufferTool_addBuffersSaturating(mod1,mod2,size); calcNextOscSampleFmBlock(&hatVoice.osc,mod1,buf,size,0.5f) ; SVF_calcBlockZDF(&hatVoice.filter,hatVoice.filterType,buf,size); //calc transient sample transient_calcBlock(&hatVoice.transGen,mod1,size); uint8_t j; if(hatVoice.volumeMod) { for(j=0;j<size;j++) { //add filter to buffer buf[j] = __QADD16(buf[j],mod1[j]); buf[j] *= hatVoice.velo * hatVoice.vol * hatVoice.egValueOscVol; } } else { for(j=0;j<size;j++) { //add filter to buffer buf[j] = __QADD16(buf[j],mod1[j]); buf[j] *= hatVoice.vol * hatVoice.egValueOscVol; } } calcDistBlock(&hatVoice.distortion,buf,size); }
//--------------------------------------------------- void Snare_calcSyncBlock(int16_t* buf, const uint8_t size) { int16_t transBuf[size]; calcNoiseBlock(&snareVoice.noiseOsc,buf,size,0.9f); SVF_calcBlockZDF(&snareVoice.filter,snareVoice.filterType,buf,size); //calc transient sample transient_calcBlock(&snareVoice.transGen,transBuf,size); bufferTool_addBuffersSaturating(buf,transBuf,size); //calc next osc sample calcNextOscSampleBlock(&snareVoice.osc,transBuf,size,(1.f-snareVoice.mix)); uint8_t j; if(snareVoice.volumeMod) { for(j=0;j<size;j++) { //add filter to buffer buf[j] *= snareVoice.mix; buf[j] = (__QADD16(buf[j],transBuf[j])); buf[j] *= snareVoice.velo * snareVoice.vol * snareVoice.egValueOscVol; } } else { for(j=0;j<size;j++) { //add filter to buffer buf[j] *= snareVoice.mix; buf[j] = (__QADD16(buf[j],transBuf[j])); buf[j] *= snareVoice.vol * snareVoice.egValueOscVol; } } calcDistBlock(&snareVoice.distortion,buf,size); }
//--------------------------------------------------- void Cymbal_calcSyncBlock(int16_t* buf, const uint8_t size) { int16_t mod[size]; int16_t mod2[size]; //calc next mod osc sample calcNextOscSampleBlock(&cymbalVoice.modOsc,mod,size,cymbalVoice.fmModAmount1); calcNextOscSampleBlock(&cymbalVoice.modOsc2,mod2,size,cymbalVoice.fmModAmount2); //combine both mod oscs to 1 modulation signal bufferTool_addBuffersSaturating(mod,mod2,size); calcNextOscSampleFmBlock(&cymbalVoice.osc,mod,buf,size,1.f) ; SVF_calcBlockZDF(&cymbalVoice.filter,cymbalVoice.filterType,buf,size); //calc transient sample transient_calcBlock(&cymbalVoice.transGen,mod,size); uint8_t j; if(cymbalVoice.volumeMod) { for(j=0;j<size;j++) { //add filter to buffer buf[j] = (__QADD16(buf[j],mod[j])) ; buf[j] *= cymbalVoice.velo * cymbalVoice.vol * cymbalVoice.egValueOscVol; } } else { for(j=0;j<size;j++) { //add filter to buffer buf[j] = (__QADD16(buf[j],mod[j])) ; buf[j] *= cymbalVoice.vol * cymbalVoice.egValueOscVol; } } calcDistBlock(&cymbalVoice.distortion,buf,size); }