Skip to content

Commit

Permalink
Add support for muting samples (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
drfiemost committed Sep 15, 2024
1 parent 42ea9d0 commit 491a1a1
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 2 deletions.
18 changes: 17 additions & 1 deletion src/args.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,20 @@ int ConsolePlayer::args(int argc, const char *argv[])
}
}

#ifdef FEAT_SAMPLE_MUTE
// Sample muting
else if (argv[i][1] == 'g')
{
if (argv[i][2] == '\0')
err = true;
else
{
const int chip = atoi(&argv[i][2]);
if (chip > 0 && chip <= m_mute_samples.size())
m_mute_samples[chip-1] = true;
}
}
#endif
else if (argv[i][1] == 'p')
{ // User forgot precision
if (argv[i][2] == '\0')
Expand Down Expand Up @@ -634,7 +648,9 @@ void ConsolePlayer::displayArgs (const char *arg)
#endif

<< " -u<num> mute voice <num> (e.g. -u1 -u2)" << endl

#ifdef FEAT_SAMPLE_MUTE
<< " -g<num> mute samples <num> (e.g. -g1 -g2)" << endl
#endif
<< " -nf no SID filter emulation" << endl

<< " -o<l|s>[num] looping and/or single track" << endl
Expand Down
5 changes: 5 additions & 0 deletions src/keyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ static char keytable[] =
'7',0, A_TOGGLE_VOICE7,
'8',0, A_TOGGLE_VOICE8,
'9',0, A_TOGGLE_VOICE9,
#ifdef FEAT_SAMPLE_MUTE
'q',0, A_TOGGLE_SAMPLE1,
'w',0, A_TOGGLE_SAMPLE2,
'e',0, A_TOGGLE_SAMPLE3,
#endif
'f',0, A_TOGGLE_FILTER,

// General Keys
Expand Down
7 changes: 7 additions & 0 deletions src/keyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#include "sidlib_features.h"

#ifdef _WIN32
# include <conio.h>
#else
Expand Down Expand Up @@ -55,6 +57,11 @@ enum
A_TOGGLE_VOICE7,
A_TOGGLE_VOICE8,
A_TOGGLE_VOICE9,
#ifdef FEAT_SAMPLE_MUTE
A_TOGGLE_SAMPLE1,
A_TOGGLE_SAMPLE2,
A_TOGGLE_SAMPLE3,
#endif
A_TOGGLE_FILTER
};

Expand Down
20 changes: 19 additions & 1 deletion src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,11 @@ bool ConsolePlayer::open (void)
m_engine.mute(2, 0, m_mute_channel[6]);
m_engine.mute(2, 1, m_mute_channel[7]);
m_engine.mute(2, 2, m_mute_channel[8]);
#ifdef FEAT_SAMPLE_MUTE
m_engine.mute(0, 3, m_mute_samples[0]);
m_engine.mute(1, 3, m_mute_samples[1]);
m_engine.mute(2, 3, m_mute_samples[2]);
#endif

// As yet we don't have a required songlength
// so try the songlength database or keep the default
Expand Down Expand Up @@ -1192,7 +1197,20 @@ void ConsolePlayer::decodeKeys ()
m_mute_channel.flip(8);
m_engine.mute(2, 2, m_mute_channel[8]);
break;

#ifdef FEAT_SAMPLE_MUTE
case A_TOGGLE_SAMPLE1:
m_mute_samples.flip(0);
m_engine.mute(0, 3, m_mute_samples[0]);
break;
case A_TOGGLE_SAMPLE2:
m_mute_samples.flip(1);
m_engine.mute(1, 3, m_mute_samples[1]);
break;
case A_TOGGLE_SAMPLE3:
m_mute_samples.flip(2);
m_engine.mute(2, 3, m_mute_samples[2]);
break;
#endif
case A_TOGGLE_FILTER:
m_filter.enabled = !m_filter.enabled;
m_engCfg.sidEmulation->filter(m_filter.enabled);
Expand Down
3 changes: 3 additions & 0 deletions src/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ class ConsolePlayer
bool m_autofilter;

std::bitset<9> m_mute_channel;
#ifdef FEAT_SAMPLE_MUTE
std::bitset<3> m_mute_samples;
#endif

int m_channels;
int m_precision;
Expand Down
4 changes: 4 additions & 0 deletions src/sidlib_features.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,8 @@
# define FEAT_CW_STRENGTH
#endif

#if LIBSIDPLAYFP_VERSION_MAJ > 2 || (LIBSIDPLAYFP_VERSION_MAJ == 2 && LIBSIDPLAYFP_VERSION_MIN >= 10)
# define FEAT_SAMPLE_MUTE
#endif

#endif

0 comments on commit 491a1a1

Please # to comment.