Subversion Repositories eduke32

Rev

Rev 8754 | Rev 8775 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8754 Rev 8770
Line 995... Line 995...
995
                numSamples -= blockSamples;
995
                numSamples -= blockSamples;
996
996
997
                if (dynamicLowpass)
997
                if (dynamicLowpass)
998
                {
998
                {
999
                        float fres = tmpInitialFilterFc + v->modlfo.level * tmpModLfoToFilterFc + v->modenv.level * tmpModEnvToFilterFc;
999
                        float fres = tmpInitialFilterFc + v->modlfo.level * tmpModLfoToFilterFc + v->modenv.level * tmpModEnvToFilterFc;
-
 
1000
                        float lowpassFc = (fres <= 13500 ? tsf_cents2Hertz(fres) / f->outSampleRate : 1.0f);
1000
                        tmpLowpass.active = (fres <= 13500.0f);
1001
                        tmpLowpass.active = (lowpassFc < 0.499f);
1001
                        if (tmpLowpass.active) tsf_voice_lowpass_setup(&tmpLowpass, tsf_cents2Hertz(fres) / tmpSampleRate);
1002
                        if (tmpLowpass.active) tsf_voice_lowpass_setup(&tmpLowpass, lowpassFc);
1002
                }
1003
                }
1003
1004
1004
                if (dynamicPitchRatio)
1005
                if (dynamicPitchRatio)
1005
                        pitchRatio = tsf_timecents2Secsd(v->pitchInputTimecents + (v->modlfo.level * tmpModLfoToPitch + v->viblfo.level * tmpVibLfoToPitch + v->modenv.level * tmpModEnvToPitch)) * v->pitchOutputFactor;
1006
                        pitchRatio = tsf_timecents2Secsd(v->pitchInputTimecents + (v->modlfo.level * tmpModLfoToPitch + v->viblfo.level * tmpVibLfoToPitch + v->modenv.level * tmpModEnvToPitch)) * v->pitchOutputFactor;
1006
1007
Line 1241... Line 1242...
1241
1242
1242
        // Play all matching regions.
1243
        // Play all matching regions.
1243
        voicePlayIndex = f->voicePlayIndex++;
1244
        voicePlayIndex = f->voicePlayIndex++;
1244
        for (region = f->presets[preset_index].regions, regionEnd = region + f->presets[preset_index].regionNum; region != regionEnd; region++)
1245
        for (region = f->presets[preset_index].regions, regionEnd = region + f->presets[preset_index].regionNum; region != regionEnd; region++)
1245
        {
1246
        {
1246
                struct tsf_voice *voice, *v, *vEnd; TSF_BOOL doLoop; float filterQDB;
1247
                struct tsf_voice *voice, *v, *vEnd; TSF_BOOL doLoop; float lowpassFilterQDB, lowpassFc;
1247
                if (key < region->lokey || key > region->hikey || midiVelocity < region->lovel || midiVelocity > region->hivel) continue;
1248
                if (key < region->lokey || key > region->hikey || midiVelocity < region->lovel || midiVelocity > region->hivel) continue;
1248
1249
1249
                voice = TSF_NULL, v = f->voices, vEnd = v + f->voiceNum;
1250
                voice = TSF_NULL, v = f->voices, vEnd = v + f->voiceNum;
1250
                if (region->group)
1251
                if (region->group)
1251
                {
1252
                {
Line 1292... Line 1293...
1292
                // Setup envelopes.
1293
                // Setup envelopes.
1293
                tsf_voice_envelope_setup(&voice->ampenv, &region->ampenv, key, midiVelocity, TSF_TRUE, f->outSampleRate);
1294
                tsf_voice_envelope_setup(&voice->ampenv, &region->ampenv, key, midiVelocity, TSF_TRUE, f->outSampleRate);
1294
                tsf_voice_envelope_setup(&voice->modenv, &region->modenv, key, midiVelocity, TSF_FALSE, f->outSampleRate);
1295
                tsf_voice_envelope_setup(&voice->modenv, &region->modenv, key, midiVelocity, TSF_FALSE, f->outSampleRate);
1295
1296
1296
                // Setup lowpass filter.
1297
                // Setup lowpass filter.
-
 
1298
                lowpassFc = (region->initialFilterFc <= 13500 ? tsf_cents2Hertz((float)region->initialFilterFc) / f->outSampleRate : 1.0f);
1297
                filterQDB = region->initialFilterQ / 10.0f;
1299
                lowpassFilterQDB = region->initialFilterQ / 10.0f;
1298
                voice->lowpass.QInv = 1.0 / TSF_POW(10.0, (filterQDB / 20.0));
1300
                voice->lowpass.QInv = 1.0 / TSF_POW(10.0, (lowpassFilterQDB / 20.0));
1299
                voice->lowpass.z1 = voice->lowpass.z2 = 0;
1301
                voice->lowpass.z1 = voice->lowpass.z2 = 0;
1300
                voice->lowpass.active = (region->initialFilterFc <= 13500);
1302
                voice->lowpass.active = (lowpassFc < 0.499f);
1301
                if (voice->lowpass.active) tsf_voice_lowpass_setup(&voice->lowpass, tsf_cents2Hertz((float)region->initialFilterFc) / f->outSampleRate);
1303
                if (voice->lowpass.active) tsf_voice_lowpass_setup(&voice->lowpass, lowpassFc);
1302
1304
1303
                // Setup LFO filters.
1305
                // Setup LFO filters.
1304
                tsf_voice_lfo_setup(&voice->modlfo, region->delayModLFO, region->freqModLFO, f->outSampleRate);
1306
                tsf_voice_lfo_setup(&voice->modlfo, region->delayModLFO, region->freqModLFO, f->outSampleRate);
1305
                tsf_voice_lfo_setup(&voice->viblfo, region->delayVibLFO, region->freqVibLFO, f->outSampleRate);
1307
                tsf_voice_lfo_setup(&voice->viblfo, region->delayVibLFO, region->freqVibLFO, f->outSampleRate);
1306
        }
1308
        }