//--------------------------------------------------- void Drum_trigger(const uint8_t voiceNr, const uint8_t vol, const uint8_t note) { lfo_retrigger(voiceNr); //update velocity modulation modNode_updateValue(&velocityModulators[voiceNr],vol/127.f); //only reset phase if envelope is closed #ifdef USE_AMP_FILTER if((voiceArray[voiceNr].volEgValueBlock[15]<=0.01f) || (voiceArray[voiceNr].transGen.waveform==1)) #else // if((voiceArray[voiceNr].ampFilterInput<=0.01f) || (voiceArray[voiceNr].transGen.waveform==1)) #endif { float offset = 1; if(voiceArray[voiceNr].transGen.waveform==1) //offset mode { offset -= voiceArray[voiceNr].transGen.volume; #ifdef USE_AMP_FILTER setOnePoleCoef(&voiceArray[voiceNr].ampFilter,1.0f); //turn off amp filter for super snappy attack } else { setOnePoleCoef(&voiceArray[voiceNr].ampFilter,ampSmoothValue); #endif } if(voiceArray[voiceNr].osc.waveform == SINE) voiceArray[voiceNr].osc.phase = 1024 + ( (0x3ff<<20) - 1024)*offset;//voiceArray[voiceNr].osc.startPhase ; else if(voiceArray[voiceNr].osc.waveform > SINE && voiceArray[voiceNr].osc.waveform <= REC) voiceArray[voiceNr].osc.phase = (0xff<<20)*offset; else voiceArray[voiceNr].osc.phase = 0; } osc_setBaseNote(&voiceArray[voiceNr].osc,note); osc_setBaseNote(&voiceArray[voiceNr].modOsc,note); DecayEg_trigger(&voiceArray[voiceNr].oscPitchEg); slopeEg2_trigger(&voiceArray[voiceNr].oscVolEg); voiceArray[voiceNr].velo = vol/127.f; transient_trigger(&voiceArray[voiceNr].transGen); SnapEg_trigger(&voiceArray[voiceNr].snapEg); }
//--------------------------------------------------- void initDrumVoice() { ampSmoothValue = 0.1f; int i; for(i=0;i<NUM_VOICES;i++) { SnapEg_init(&voiceArray[i].snapEg); setPan(i,0.f); voiceArray[i].vol = 0.8f; //voiceArray[i].panModifier = 1.f; voiceArray[i].fmModAmount = 0.5f; transient_init(&voiceArray[i].transGen); #if ENABLE_DRUM_SVF SVF_init(&voiceArray[i].filter); voiceArray[i].filterType = 0x01; #endif lfo_init(&voiceArray[i].lfo); voiceArray[i].modOsc.freq = 440; voiceArray[i].modOsc.waveform = 1; voiceArray[i].modOsc.fmMod = 0; voiceArray[i].modOsc.midiFreq = 70<<8; voiceArray[i].modOsc.pitchMod = 1.0f; voiceArray[i].modOsc.modNodeValue = 1; voiceArray[i].volumeMod = 1; voiceArray[i].osc.freq = 440; voiceArray[i].osc.modNodeValue = 1; voiceArray[i].osc.waveform = TRI+i; //for testing init to tri,saw,rec voiceArray[i].osc.fmMod = 0; voiceArray[i].osc.midiFreq = 70<<8; DecayEg_init(&voiceArray[i].oscPitchEg); voiceArray[i].egPitchModAmount = 0.5f; slopeEg2_init(&voiceArray[i].oscVolEg); setDistortionShape(&voiceArray[i].distortion, 2.f); #ifdef USE_AMP_FILTER initOnePole(&voiceArray[i].ampFilter); setOnePoleCoef(&voiceArray[i].ampFilter,ampSmoothValue); #endif #if ENABLE_MIX_OSC voiceArray[i].mixOscs = true; #endif voiceArray[i].decimationCnt = 0; voiceArray[i].decimationRate = 1; } }