Skip to content

Commit

Permalink
Add support for new filter range parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
drfiemost committed Jan 13, 2024
1 parent d5dc92a commit 3aa4aba
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 5 deletions.
6 changes: 6 additions & 0 deletions doc/en/sidplayfp.ini.pod
Original file line number Diff line number Diff line change
Expand Up @@ -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<FilterRange6581>=I<< <number> >>

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<FilterCurve8580>=I<< <number> >>

Controls the filter curve for the 8580 model in the ReSIDfp
Expand Down
6 changes: 6 additions & 0 deletions src/IniConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/IniConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
102 changes: 98 additions & 4 deletions src/player.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -113,14 +113,73 @@ 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.
//
// This works under the assumption that the authors used the
// 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 },
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
Expand Down
3 changes: 3 additions & 0 deletions src/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 5 additions & 1 deletion src/sidlib_features.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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

0 comments on commit 3aa4aba

Please sign in to comment.