// ---------------------------------------------------------------------------- void PlayerLibSidplay::setFilterSettingsFromPlaybackSettings(sid_filter_t& filterSettings, PlaybackSettings* settings) // ---------------------------------------------------------------------------- { filterSettings.distortion_enable = settings->mEnableFilterDistortion; filterSettings.rate = settings->mDistortionRate; filterSettings.headroom = settings->mDistortionHeadroom; if (settings->mFilterType == SID_FILTER_8580) { filterSettings.opmin = -99999; filterSettings.opmax = 99999; filterSettings.points = sDefault8580PointCount; memcpy(filterSettings.cutoff, sDefault8580, sizeof(sDefault8580)); } else { filterSettings.opmin = -20000; filterSettings.opmax = 20000; filterSettings.points = 0x800; for (int i = 0; i < 0x800; i++) { float i_kinked = approximate_dac(i, settings->mFilterKinkiness); float freq = settings->mFilterBaseLevel + powf(2.0f, (i_kinked - settings->mFilterOffset) / settings->mFilterSteepness); // Better expression for this required. // As it stands, it's kinda embarrassing. for (float j = 1000.f; j < 18500.f; j += 500.f) { if (freq > j) freq -= (freq - j) / settings->mFilterRolloff; } if (freq > 18500) freq = 18500; filterSettings.cutoff[i][0] = i; filterSettings.cutoff[i][1] = freq; } } }
// ---------------------------------------------------------------------------- void PlayerLibSidplay::setupSIDInfo() // ---------------------------------------------------------------------------- { if (mSidTune == NULL) return; mSidTune->getInfo(mTuneInfo); mCurrentSubtune = mTuneInfo.currentSong; mSubtuneCount = mTuneInfo.songs; mDefaultSubtune = mTuneInfo.startSong; if (getCurrentChipModel() == sChipModel8580) { printf("8580\n"); mFilterSettings.distortion_enable = true; mFilterSettings.rate = 3200; mFilterSettings.headroom = 235; mFilterSettings.opmin = -99999; mFilterSettings.opmax = 99999; mFilterSettings.points = sDefault8580PointCount; memcpy(mFilterSettings.cutoff, sDefault8580, sizeof(sDefault8580)); mBuilder->set_filter((sid_filter_t*)NULL, mPlaybackSettings.mOverrideCutoffCurve); } else { printf("6581\n"); mFilterSettings.distortion_enable = true; mFilterSettings.rate = 1500; mFilterSettings.headroom = 300; mFilterSettings.opmin = -20000; mFilterSettings.opmax = 20000; float filterKinkiness = 0.17f; float filterBaseLevel = 210.0f; float filterOffset = -375.0f; float filterSteepness = 120.0f; float filterRolloff = 5.5f; mFilterSettings.points = 0x800; for (int i = 0; i < 0x800; i++) { float i_kinked = approximate_dac(i, filterKinkiness); float freq = filterBaseLevel + powf(2.0f, (i_kinked - filterOffset) / filterSteepness); // Better expression for this required. // As it stands, it's kinda embarrassing. for (float j = 1000.f; j < 18500.f; j += 500.f) { if (freq > j) freq -= (freq - j) / filterRolloff; } if (freq > 18500) freq = 18500; mFilterSettings.cutoff[i][0] = i; mFilterSettings.cutoff[i][1] = freq; } mBuilder->set_filter(&mFilterSettings, mPlaybackSettings.mOverrideCutoffCurve); } }