From 3aa4aba559f5d83ee919ee606a474b4a8aebf3d9 Mon Sep 17 00:00:00 2001 From: Leandro Nini Date: Sat, 13 Jan 2024 19:01:05 +0100 Subject: [PATCH] Add support for new filter range parameter --- doc/en/sidplayfp.ini.pod | 6 +++ src/IniConfig.cpp | 6 +++ src/IniConfig.h | 3 ++ src/player.cpp | 102 +++++++++++++++++++++++++++++++++++++-- src/player.h | 3 ++ src/sidlib_features.h | 6 ++- 6 files changed, 121 insertions(+), 5 deletions(-) diff --git a/doc/en/sidplayfp.ini.pod b/doc/en/sidplayfp.ini.pod index 6229d5c..7343540 100644 --- a/doc/en/sidplayfp.ini.pod +++ b/doc/en/sidplayfp.ini.pod @@ -216,6 +216,12 @@ Controls the filter curve for the 6581 model in the ReSIDfp emulation. Ranges from 0.0 (light) to 1.0 (dark), the default value is 0.5. +=item B=I<< >> + +Controls the filter uCox parameter for the 6581 model in the ReSIDfp +emulation. Ranges from 0.0 (dark) to 1.0 (bright), the default +value is 0.5. + =item B=I<< >> Controls the filter curve for the 8580 model in the ReSIDfp diff --git a/src/IniConfig.cpp b/src/IniConfig.cpp index ef7d858..d274f5e 100644 --- a/src/IniConfig.cpp +++ b/src/IniConfig.cpp @@ -119,6 +119,9 @@ void IniConfig::clear() emulation_s.bias = 0.5; emulation_s.filterCurve6581 = 0.5; +#ifdef FEAT_FILTER_RANGE + emulation_s.filterRange6581 = 0.5; +#endif emulation_s.filterCurve8580 = 0.5; emulation_s.powerOnDelay = -1; emulation_s.samplingMethod = SidConfig::RESAMPLE_INTERPOLATE; @@ -426,6 +429,9 @@ void IniConfig::readEmulation(iniHandler &ini) readDouble(ini, TEXT("FilterBias"), emulation_s.bias); readDouble(ini, TEXT("FilterCurve6581"), emulation_s.filterCurve6581); +#ifdef FEAT_FILTER_RANGE + readDouble(ini, TEXT("filterRange6581"), emulation_s.filterRange6581); +#endif readDouble(ini, TEXT("FilterCurve8580"), emulation_s.filterCurve8580); readInt(ini, TEXT("PowerOnDelay"), emulation_s.powerOnDelay); diff --git a/src/IniConfig.h b/src/IniConfig.h index e02975e..e0a06ac 100644 --- a/src/IniConfig.h +++ b/src/IniConfig.h @@ -82,6 +82,9 @@ class IniConfig bool filter; double bias; double filterCurve6581; +#ifdef FEAT_FILTER_RANGE + double filterRange6581; +#endif double filterCurve8580; int powerOnDelay; SidConfig::sampling_method_t samplingMethod; diff --git a/src/player.cpp b/src/player.cpp index 7b1c3b6..d23816e 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -1,7 +1,7 @@ /* * This file is part of sidplayfp, a console SID player. * - * Copyright 2011-2023 Leandro Nini + * Copyright 2011-2024 Leandro Nini * Copyright 2000-2001 Simon White * * This program is free software; you can redistribute it and/or modify @@ -113,7 +113,7 @@ uint16_t freqTableNtsc[] }; #endif -// This table contains chip-profiles which allow us to adjust +// This tables contains chip-profiles which allow us to adjust // certain settings that varied wildly between 6581 chips, even // made in the same factory on the same day. // @@ -121,6 +121,65 @@ uint16_t freqTableNtsc[] // same SID chip their entire career. // // based on https://github.com/reFX/libSidplayEZ/blob/modernized/src/chip-profiles.h +#ifdef FEAT_FILTER_RANGE +static const filter_map_t filterRangeMap = +{ + { "Anthony Lees", 0.641 }, + { "Antony Crowther (Ratt)", 0.538 }, + { "Barry Leitch (The Jackal)", 0.000 }, + { "Ben Daglish", 0.282 }, + { "Charles Deenen", 0.077 }, + { "Chris H\xFClsbeck", 0.231 }, + { "David Dunn", 0.051 }, + { "David Dunn & Aidan Bell", 0.051 }, + { "David Whittaker", 0.051 }, + { "Thomas Mogensen (DRAX)", 0.128 }, + { "Edwin van Santen", 0.231 }, + { "Edwin van Santen & Falco Paul", 0.179 }, + { "Edwin van Santen & Venom", 0.179 }, + { "Falco Paul", 0.051 }, + { "Falco Paul & Edwin van Santen", 0.179 }, + { "Figge Wasberger (Fegolhuzz)", 0.103 }, + { "Fred Gray", 0.067 }, + { "Geir Tjelta", 0.231 }, + { "Georg Feil", 0.077 }, + { "Glenn Rune Gallefoss", 0.077 }, + { "Graham Jarvis & Rob Hartshorne", 0.103 }, + { "Jason Page", 0.134 }, + { "Jeroen Tel", 0.134 }, + { "Johannes Bjerregaard", 0.134 }, + { "Jonathan Dunn", 0.103 }, + { "Jouni Ikonen (Mixer)", 0.103 }, + { "Jori Olkkonen", 0.038 }, + { "Jori Olkkonen (Yip)", 0.038 }, + { "Kim Christensen (Future Freak)", 0.154 }, + { "Linus \xC5kesson (lft)", 0.128 }, + { "Mark Cooksey", 0.103 }, + { "Markus M\xFCller (Superbrain)", 0.128 }, + { "Martin Galway", 0.487 }, + { "Martin Walker", 0.051 }, + { "Matt Gray", 0.128 }, + { "Michael Hendriks", 0.103 }, + { "Mitch & Dane", 0.359 }, + { "M. Nilsson-Vonderburgh (Mic)", 0.103 }, + { "M. Nilsson-Vonderburgh (Mitch)", 0.103 }, + { "M. Nilsson-Vonderburgh (Yankee)", 0.103 }, + { "Neil Brennan", 0.103 }, + { "Peter Clarke", 0.077 }, + { "Pex Tufvesson (Mahoney)", 0.154 }, + { "Pex Tufvesson (Zax)", 0.154 }, + { "Renato Brosowski (Zoci-Joe)", 0.128 }, + { "Reyn Ouwehand", 0.103 }, + { "Richard Joseph", 0.128 }, + { "Rob Hubbard", 0.154 }, + { "Russell Lieblich", 0.103 }, + { "Stellan Andersson (Dane)", 0.359 }, + { "Steve Turner", 0.282 }, + { "Tim Follin", 0.231 }, + { "Thomas E. Petersen (Laxity)", 0.128 }, + { "Thomas E. Petersen (TSS)", 0.128 }, +}; +#else static const filter_map_t filterCurveMap = { { "Anthony Lees", 0.450 }, @@ -170,12 +229,21 @@ static const filter_map_t filterCurveMap = { "Thomas E. Petersen (Laxity)", 1.550 }, { "Thomas E. Petersen (TSS)", 1.550 }, }; +#endif +#ifdef FEAT_FILTER_RANGE +double getRecommendedFilterRange(const std::string& author) +{ + filter_map_iter_t it = filterRangeMap.find(author); + return (it != filterRangeMap.end()) ? it->second : -1.; +} +#else double getRecommendedFilterCurve(const std::string& author) { filter_map_iter_t it = filterCurveMap.find(author); - return (it != filterCurveMap.end()) ? it->second : 0.5; + return (it != filterCurveMap.end()) ? it->second : -1.; } +#endif uint8_t* loadRom(const SID_STRING &romPath, const int size) { @@ -300,6 +368,9 @@ ConsolePlayer::ConsolePlayer (const char * const name) : m_filter.enabled = emulation.filter; m_filter.bias = emulation.bias; m_filter.filterCurve6581 = emulation.filterCurve6581; +#ifdef FEAT_FILTER_RANGE + m_filter.filterRange6581 = emulation.filterRange6581; +#endif m_filter.filterCurve8580 = emulation.filterCurve8580; if (emulation.powerOnDelay >= 0) @@ -524,15 +595,38 @@ bool ConsolePlayer::createSidEmu (SIDEMUS emu, const SidTuneInfo *tuneInfo) rs->create ((m_engine.info ()).maxsids()); if (!rs->getStatus()) goto createSidEmu_error; +#ifdef FEAT_FILTER_RANGE + double frange = -1.0; + if (m_autofilter && (tuneInfo->numberOfInfoStrings() == 3)) + { + frange = getRecommendedFilterRange(tuneInfo->infoString(1)); + if (m_verboseLevel > 1) + cerr << "Recommended filter range: " << frange << endl; + } + if (m_filter.filterRange6581 >= 0.0) + { + frange = m_filter.filterRange6581; + } + + if (frange >= 0.0) + { + if (m_verboseLevel) + cerr << "6581 filter range: " << frange << endl; + rs->filter6581Range(frange); + } +#endif + // 6581 double fcurve = -1.0; +#ifndef FEAT_FILTER_RANGE if (m_autofilter && (tuneInfo->numberOfInfoStrings() == 3)) { fcurve = getRecommendedFilterCurve(tuneInfo->infoString(1)); if (m_verboseLevel > 1) cerr << "Recommended filter curve: " << fcurve << endl; } - else if (m_fcurve >= 0.0) +#endif + if (m_fcurve >= 0.0) { fcurve = m_fcurve; } diff --git a/src/player.h b/src/player.h index 084b437..d1e6b44 100644 --- a/src/player.h +++ b/src/player.h @@ -152,6 +152,9 @@ class ConsolePlayer double bias; // Filter parameters for reSIDfp double filterCurve6581; +#ifdef FEAT_FILTER_RANGE + double filterRange6581; +#endif double filterCurve8580; bool enabled; diff --git a/src/sidlib_features.h b/src/sidlib_features.h index 0de654f..62b89ef 100644 --- a/src/sidlib_features.h +++ b/src/sidlib_features.h @@ -1,7 +1,7 @@ /* * This file is part of sidplayfp, a console SID player. * - * Copyright 2021 Leandro Nini + * Copyright 2024 Leandro Nini * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -39,4 +39,8 @@ # define FEAT_DB_WCHAR_OPEN #endif +#if LIBSIDPLAYFP_VERSION_MAJ > 2 || (LIBSIDPLAYFP_VERSION_MAJ == 2 && LIBSIDPLAYFP_VERSION_MIN >= 7) +# define FEAT_FILTER_RANGE +#endif + #endif